Home | History | Annotate | Download | only in extensions
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ERROR_HANDLER_H_
      6 #define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ERROR_HANDLER_H_
      7 
      8 #include <string>
      9 
     10 #include "base/basictypes.h"
     11 #include "base/compiler_specific.h"
     12 #include "base/memory/weak_ptr.h"
     13 #include "content/public/browser/web_ui_message_handler.h"
     14 
     15 namespace base {
     16 class DictionaryValue;
     17 class ListValue;
     18 }
     19 
     20 namespace content {
     21 class WebUIDataSource;
     22 }
     23 
     24 class Profile;
     25 
     26 namespace extensions {
     27 
     28 class Extension;
     29 
     30 // The handler page for the Extension Commands UI overlay.
     31 class ExtensionErrorHandler : public content::WebUIMessageHandler {
     32  public:
     33   explicit ExtensionErrorHandler(Profile* profile);
     34   virtual ~ExtensionErrorHandler();
     35 
     36   // Fetches the localized values for the page and deposits them into |source|.
     37   void GetLocalizedValues(content::WebUIDataSource* source);
     38 
     39   // WebUIMessageHandler implementation.
     40   virtual void RegisterMessages() OVERRIDE;
     41 
     42  private:
     43   friend class ManifestHighlightUnitTest;
     44 
     45   // Handle the "requestFileSource" call.
     46   void HandleRequestFileSource(const base::ListValue* args);
     47 
     48   // Called when |error_ui_util::HandleRequestFileSource| finishes.
     49   void OnFileSourceHandled(const base::DictionaryValue& source);
     50 
     51   // Handle the "openDevTools" call.
     52   void HandleOpenDevTools(const base::ListValue* args);
     53 
     54   // Populate the results for a manifest file's content in response to the
     55   // "requestFileSource" call. Highlight the part of the manifest which
     56   // corresponds to the given |key| and |specific| locations. Caller owns
     57   // |dict|.
     58   void GetManifestFileCallback(base::DictionaryValue* dict,
     59                                const std::string& key,
     60                                const std::string& specific,
     61                                const std::string& contents);
     62 
     63   // Populate the results for a source file's content in response to the
     64   // "requestFileSource" call. Highlight the part of the source which
     65   // corresponds to the given |line_number|.
     66   void GetSourceFileCallback(base::DictionaryValue* results,
     67                              int line_number,
     68                              const std::string& contents);
     69 
     70   // The profile with which this Handler is associated.
     71   Profile* profile_;
     72 
     73   // Weak pointer factory for posting background tasks.
     74   base::WeakPtrFactory<ExtensionErrorHandler> weak_ptr_factory_;
     75 
     76   DISALLOW_COPY_AND_ASSIGN(ExtensionErrorHandler);
     77 };
     78 
     79 }  // namespace extensions
     80 
     81 #endif  // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ERROR_HANDLER_H_
     82