| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSIONS_UI_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSIONS_UI_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSIONS_UI_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSIONS_UI_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" | 11 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
| 12 #include "chrome/browser/dom_ui/dom_ui.h" | 12 #include "chrome/browser/dom_ui/dom_ui.h" |
| 13 #include "chrome/browser/extensions/pack_extension_job.h" |
| 13 #include "chrome/browser/shell_dialogs.h" | 14 #include "chrome/browser/shell_dialogs.h" |
| 14 #include "chrome/common/notification_observer.h" | 15 #include "chrome/common/notification_observer.h" |
| 15 #include "chrome/common/notification_registrar.h" | 16 #include "chrome/common/notification_registrar.h" |
| 16 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 17 | 18 |
| 18 class DictionaryValue; | 19 class DictionaryValue; |
| 19 class Extension; | 20 class Extension; |
| 20 class ExtensionsService; | 21 class ExtensionsService; |
| 21 class FilePath; | 22 class FilePath; |
| 22 class UserScript; | 23 class UserScript; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 45 } | 46 } |
| 46 | 47 |
| 47 private: | 48 private: |
| 48 DISALLOW_COPY_AND_ASSIGN(ExtensionsUIHTMLSource); | 49 DISALLOW_COPY_AND_ASSIGN(ExtensionsUIHTMLSource); |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 // The handler for Javascript messages related to the "extensions" view. | 52 // The handler for Javascript messages related to the "extensions" view. |
| 52 class ExtensionsDOMHandler | 53 class ExtensionsDOMHandler |
| 53 : public DOMMessageHandler, | 54 : public DOMMessageHandler, |
| 54 public NotificationObserver, | 55 public NotificationObserver, |
| 56 public PackExtensionJob::Client, |
| 55 public SelectFileDialog::Listener { | 57 public SelectFileDialog::Listener { |
| 56 public: | 58 public: |
| 57 explicit ExtensionsDOMHandler(ExtensionsService* extension_service); | 59 explicit ExtensionsDOMHandler(ExtensionsService* extension_service); |
| 58 virtual ~ExtensionsDOMHandler(); | 60 virtual ~ExtensionsDOMHandler(); |
| 59 | 61 |
| 60 // DOMMessageHandler implementation. | 62 // DOMMessageHandler implementation. |
| 61 virtual void RegisterMessages(); | 63 virtual void RegisterMessages(); |
| 62 | 64 |
| 63 // Extension Detail JSON Struct for page. (static for ease of testing). | 65 // Extension Detail JSON Struct for page. (static for ease of testing). |
| 64 static DictionaryValue* CreateExtensionDetailValue( | 66 static DictionaryValue* CreateExtensionDetailValue( |
| 65 const Extension *extension, | 67 const Extension *extension, |
| 66 const std::vector<ExtensionPage>&, | 68 const std::vector<ExtensionPage>&, |
| 67 bool enabled); | 69 bool enabled); |
| 68 | 70 |
| 69 // ContentScript JSON Struct for page. (static for ease of testing). | 71 // ContentScript JSON Struct for page. (static for ease of testing). |
| 70 static DictionaryValue* CreateContentScriptDetailValue( | 72 static DictionaryValue* CreateContentScriptDetailValue( |
| 71 const UserScript& script, | 73 const UserScript& script, |
| 72 const FilePath& extension_path); | 74 const FilePath& extension_path); |
| 73 | 75 |
| 76 // ExtensionPackJob::Client |
| 77 virtual void OnPackSuccess(const FilePath& crx_file, |
| 78 const FilePath& key_file); |
| 79 |
| 80 virtual void OnPackFailure(const std::wstring& message); |
| 81 |
| 74 private: | 82 private: |
| 75 #if defined(OS_WIN) | |
| 76 // The implementation of this method is platform-specific and defined | |
| 77 // elsewhere. | |
| 78 static void ShowPackDialog(); | |
| 79 #endif | |
| 80 | |
| 81 // Callback for "requestExtensionsData" message. | 83 // Callback for "requestExtensionsData" message. |
| 82 void HandleRequestExtensionsData(const Value* value); | 84 void HandleRequestExtensionsData(const Value* value); |
| 83 | 85 |
| 84 // Callback for "inspect" message. | 86 // Callback for "inspect" message. |
| 85 void HandleInspectMessage(const Value* value); | 87 void HandleInspectMessage(const Value* value); |
| 86 | 88 |
| 87 // Callback for "reload" message. | 89 // Callback for "reload" message. |
| 88 void HandleReloadMessage(const Value* value); | 90 void HandleReloadMessage(const Value* value); |
| 89 | 91 |
| 90 // Callback for "enable" message. | 92 // Callback for "enable" message. |
| 91 void HandleEnableMessage(const Value* value); | 93 void HandleEnableMessage(const Value* value); |
| 92 | 94 |
| 93 // Callback for "uninstall" message. | 95 // Callback for "uninstall" message. |
| 94 void HandleUninstallMessage(const Value* value); | 96 void HandleUninstallMessage(const Value* value); |
| 95 | 97 |
| 96 // Callback for "load" message. | 98 // Callback for "load" message. |
| 97 void HandleLoadMessage(const Value* value); | 99 void HandleLoadMessage(const Value* value); |
| 98 | 100 |
| 99 // Callback for "pack" message. | 101 // Callback for "pack" message. |
| 100 void HandlePackMessage(const Value* value); | 102 void HandlePackMessage(const Value* value); |
| 101 | 103 |
| 102 // Callback for "autoupdate" message. | 104 // Callback for "autoupdate" message. |
| 103 void HandleAutoUpdateMessage(const Value* value); | 105 void HandleAutoUpdateMessage(const Value* value); |
| 104 | 106 |
| 107 // Utility for calling javascript window.alert in the page. |
| 108 void ShowAlert(const std::string& message); |
| 109 |
| 110 // Callback for "selectFilePath" message. |
| 111 void HandleSelectFilePathMessage(const Value* value); |
| 112 |
| 105 // SelectFileDialog::Listener | 113 // SelectFileDialog::Listener |
| 106 virtual void FileSelected(const FilePath& path, | 114 virtual void FileSelected(const FilePath& path, |
| 107 int index, void* params); | 115 int index, void* params); |
| 108 virtual void MultiFilesSelected( | 116 virtual void MultiFilesSelected( |
| 109 const std::vector<FilePath>& files, void* params) { | 117 const std::vector<FilePath>& files, void* params) { |
| 110 NOTREACHED(); | 118 NOTREACHED(); |
| 111 } | 119 } |
| 112 virtual void FileSelectionCanceled(void* params) {} | 120 virtual void FileSelectionCanceled(void* params) {} |
| 113 | 121 |
| 114 // NotificationObserver | 122 // NotificationObserver |
| 115 virtual void Observe(NotificationType type, | 123 virtual void Observe(NotificationType type, |
| 116 const NotificationSource& source, | 124 const NotificationSource& source, |
| 117 const NotificationDetails& details); | 125 const NotificationDetails& details); |
| 118 | 126 |
| 119 // Helper that lists the current active html pages for an extension. | 127 // Helper that lists the current active html pages for an extension. |
| 120 std::vector<ExtensionPage> GetActivePagesForExtension( | 128 std::vector<ExtensionPage> GetActivePagesForExtension( |
| 121 const std::string& extension_id); | 129 const std::string& extension_id); |
| 122 | 130 |
| 123 // Our model. | 131 // Our model. |
| 124 scoped_refptr<ExtensionsService> extensions_service_; | 132 scoped_refptr<ExtensionsService> extensions_service_; |
| 125 | 133 |
| 126 // Used to pick the directory when loading an extension. | 134 // Used to pick the directory when loading an extension. |
| 127 scoped_refptr<SelectFileDialog> load_extension_dialog_; | 135 scoped_refptr<SelectFileDialog> load_extension_dialog_; |
| 128 | 136 |
| 137 // Used to package the extension. |
| 138 scoped_refptr<PackExtensionJob> pack_job_; |
| 139 |
| 129 // We monitor changes to the extension system so that we can reload when | 140 // We monitor changes to the extension system so that we can reload when |
| 130 // necessary. | 141 // necessary. |
| 131 NotificationRegistrar registrar_; | 142 NotificationRegistrar registrar_; |
| 132 | 143 |
| 133 DISALLOW_COPY_AND_ASSIGN(ExtensionsDOMHandler); | 144 DISALLOW_COPY_AND_ASSIGN(ExtensionsDOMHandler); |
| 134 }; | 145 }; |
| 135 | 146 |
| 136 class ExtensionsUI : public DOMUI { | 147 class ExtensionsUI : public DOMUI { |
| 137 public: | 148 public: |
| 138 explicit ExtensionsUI(TabContents* contents); | 149 explicit ExtensionsUI(TabContents* contents); |
| 139 | 150 |
| 140 private: | 151 private: |
| 141 DISALLOW_COPY_AND_ASSIGN(ExtensionsUI); | 152 DISALLOW_COPY_AND_ASSIGN(ExtensionsUI); |
| 142 }; | 153 }; |
| 143 | 154 |
| 144 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_UI_H_ | 155 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_UI_H_ |
| OLD | NEW |