OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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_LOADER_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_LOADER_HANDLER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/compiler_specific.h" |
| 11 #include "base/files/file_path.h" |
| 12 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" |
| 15 #include "content/public/browser/web_ui_message_handler.h" |
| 16 |
| 17 namespace base { |
| 18 class ListValue; |
| 19 } |
| 20 |
| 21 namespace content { |
| 22 class WebUIDataSource; |
| 23 } |
| 24 |
| 25 class ExtensionService; |
| 26 class Profile; |
| 27 |
| 28 namespace extensions { |
| 29 |
| 30 class Extension; |
| 31 |
| 32 // The handler page for the Extension Commands UI overlay. |
| 33 class ExtensionLoaderHandler : public content::WebUIMessageHandler { |
| 34 public: |
| 35 explicit ExtensionLoaderHandler(Profile* profile); |
| 36 virtual ~ExtensionLoaderHandler(); |
| 37 |
| 38 // Fetches the localized values for the page and deposits them into |source|. |
| 39 void GetLocalizedValues(content::WebUIDataSource* source); |
| 40 |
| 41 // WebUIMessageHandler implementation. |
| 42 virtual void RegisterMessages() OVERRIDE; |
| 43 |
| 44 private: |
| 45 class FileHelper; |
| 46 |
| 47 // Handle the 'extensionLoaderLoadUnpacked' message. |
| 48 void HandleLoadUnpacked(const base::ListValue* args); |
| 49 |
| 50 // Handle the 'extensionLoaderRetry' message. |
| 51 void HandleRetry(const base::ListValue* args); |
| 52 |
| 53 // Try to load an unpacked extension from the given |file_path|. |
| 54 void LoadUnpackedExtensionImpl(const base::FilePath& file_path); |
| 55 |
| 56 // Called when an unpacked extension fails to load. |
| 57 void OnLoadFailure(const base::FilePath& file_path, const std::string& error); |
| 58 |
| 59 // Notify the frontend of the failure. If it was a manifest error, |manifest| |
| 60 // will hold the manifest contents, and |line_number| will point to the line |
| 61 // at which the error was found. |
| 62 void NotifyFrontendOfFailure(const base::FilePath& file_path, |
| 63 const std::string& error, |
| 64 size_t line_number, |
| 65 const std::string& manifest); |
| 66 |
| 67 // The profile with which this Handler is associated. |
| 68 Profile* profile_; |
| 69 |
| 70 // A helper to manage file picking. |
| 71 scoped_ptr<FileHelper> file_helper_; |
| 72 |
| 73 // The file path to the extension that failed to load, or empty. This is |
| 74 // loaded when the user selects "retry". |
| 75 base::FilePath failed_path_; |
| 76 |
| 77 // Weak pointer factory for posting background tasks. |
| 78 base::WeakPtrFactory<ExtensionLoaderHandler> weak_ptr_factory_; |
| 79 |
| 80 DISALLOW_COPY_AND_ASSIGN(ExtensionLoaderHandler); |
| 81 }; |
| 82 |
| 83 } // namespace extensions |
| 84 |
| 85 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_LOADER_HANDLER_H_ |
OLD | NEW |