| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| 11 #include "chrome/browser/extensions/api/developer_private/entry_picker.h" | 11 #include "chrome/browser/extensions/api/developer_private/entry_picker.h" |
| 12 #include "chrome/browser/extensions/api/file_system/file_system_api.h" | 12 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
| 13 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
| 13 #include "chrome/browser/extensions/chrome_extension_function.h" | 14 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 14 #include "chrome/browser/extensions/error_console/error_console.h" | 15 #include "chrome/browser/extensions/error_console/error_console.h" |
| 15 #include "chrome/browser/extensions/extension_install_prompt.h" | 16 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 16 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 17 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
| 17 #include "chrome/browser/extensions/pack_extension_job.h" | 18 #include "chrome/browser/extensions/pack_extension_job.h" |
| 18 #include "chrome/browser/extensions/requirements_checker.h" | 19 #include "chrome/browser/extensions/requirements_checker.h" |
| 19 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | |
| 20 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
| 21 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
| 22 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
| 23 #include "extensions/browser/event_router.h" | 23 #include "extensions/browser/event_router.h" |
| 24 #include "ui/shell_dialogs/select_file_dialog.h" | 24 #include "ui/shell_dialogs/select_file_dialog.h" |
| 25 #include "webkit/browser/fileapi/file_system_context.h" | 25 #include "webkit/browser/fileapi/file_system_context.h" |
| 26 #include "webkit/browser/fileapi/file_system_operation.h" | 26 #include "webkit/browser/fileapi/file_system_operation.h" |
| 27 | 27 |
| 28 class ExtensionService; | 28 class ExtensionService; |
| 29 | 29 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // the Apps Developer Tool (which replaces the chrome://extensions page), we | 83 // the Apps Developer Tool (which replaces the chrome://extensions page), we |
| 84 // don't want to send information about the subscribing extension in an | 84 // don't want to send information about the subscribing extension in an |
| 85 // update. In particular, we want to avoid entering a loop, which could happen | 85 // update. In particular, we want to avoid entering a loop, which could happen |
| 86 // when, e.g., the Apps Developer Tool throws an error. | 86 // when, e.g., the Apps Developer Tool throws an error. |
| 87 std::set<std::string> extension_ids_; | 87 std::set<std::string> extension_ids_; |
| 88 | 88 |
| 89 DISALLOW_COPY_AND_ASSIGN(DeveloperPrivateEventRouter); | 89 DISALLOW_COPY_AND_ASSIGN(DeveloperPrivateEventRouter); |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 // The profile-keyed service that manages the DeveloperPrivate API. | 92 // The profile-keyed service that manages the DeveloperPrivate API. |
| 93 class DeveloperPrivateAPI : public BrowserContextKeyedService, | 93 class DeveloperPrivateAPI : public ProfileKeyedAPI, |
| 94 public EventRouter::Observer { | 94 public EventRouter::Observer { |
| 95 public: | 95 public: |
| 96 static ProfileKeyedAPIFactory<DeveloperPrivateAPI>* GetFactoryInstance(); |
| 97 |
| 96 // Convenience method to get the DeveloperPrivateAPI for a profile. | 98 // Convenience method to get the DeveloperPrivateAPI for a profile. |
| 97 static DeveloperPrivateAPI* Get(Profile* profile); | 99 static DeveloperPrivateAPI* Get(Profile* profile); |
| 98 | 100 |
| 99 explicit DeveloperPrivateAPI(Profile* profile); | 101 explicit DeveloperPrivateAPI(Profile* profile); |
| 100 virtual ~DeveloperPrivateAPI(); | 102 virtual ~DeveloperPrivateAPI(); |
| 101 | 103 |
| 102 void SetLastUnpackedDirectory(const base::FilePath& path); | 104 void SetLastUnpackedDirectory(const base::FilePath& path); |
| 103 | 105 |
| 104 base::FilePath& GetLastUnpackedDirectory() { | 106 base::FilePath& GetLastUnpackedDirectory() { |
| 105 return last_unpacked_directory_; | 107 return last_unpacked_directory_; |
| 106 } | 108 } |
| 107 | 109 |
| 108 // BrowserContextKeyedService implementation | 110 // BrowserContextKeyedService implementation |
| 109 virtual void Shutdown() OVERRIDE; | 111 virtual void Shutdown() OVERRIDE; |
| 110 | 112 |
| 111 // EventRouter::Observer implementation. | 113 // EventRouter::Observer implementation. |
| 112 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; | 114 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; |
| 113 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; | 115 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; |
| 114 | 116 |
| 115 private: | 117 private: |
| 118 friend class ProfileKeyedAPIFactory<DeveloperPrivateAPI>; |
| 119 |
| 120 // ProfileKeyedAPI implementation. |
| 121 static const char* service_name() { return "DeveloperPrivateAPI"; } |
| 122 static const bool kServiceRedirectedInIncognito = true; |
| 123 static const bool kServiceIsNULLWhileTesting = true; |
| 124 |
| 116 void RegisterNotifications(); | 125 void RegisterNotifications(); |
| 117 | 126 |
| 118 Profile* profile_; | 127 Profile* profile_; |
| 119 | 128 |
| 120 // Used to start the load |load_extension_dialog_| in the last directory that | 129 // Used to start the load |load_extension_dialog_| in the last directory that |
| 121 // was loaded. | 130 // was loaded. |
| 122 base::FilePath last_unpacked_directory_; | 131 base::FilePath last_unpacked_directory_; |
| 123 | 132 |
| 124 // Created lazily upon OnListenerAdded. | 133 // Created lazily upon OnListenerAdded. |
| 125 scoped_ptr<DeveloperPrivateEventRouter> developer_private_event_router_; | 134 scoped_ptr<DeveloperPrivateEventRouter> developer_private_event_router_; |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 | 461 |
| 453 // ExtensionFunction: | 462 // ExtensionFunction: |
| 454 virtual bool RunImpl() OVERRIDE; | 463 virtual bool RunImpl() OVERRIDE; |
| 455 }; | 464 }; |
| 456 | 465 |
| 457 } // namespace api | 466 } // namespace api |
| 458 | 467 |
| 459 } // namespace extensions | 468 } // namespace extensions |
| 460 | 469 |
| 461 #endif // CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API
_H_ | 470 #endif // CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API
_H_ |
| OLD | NEW |