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_EXTENSION_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // themes sync to not use it directly. | 118 // themes sync to not use it directly. |
119 virtual void CheckForUpdatesSoon() = 0; | 119 virtual void CheckForUpdatesSoon() = 0; |
120 | 120 |
121 // Returns true if the extension was successfully added. | 121 // Returns true if the extension was successfully added. |
122 virtual bool AddExtension(const Extension* extension) = 0; | 122 virtual bool AddExtension(const Extension* extension) = 0; |
123 | 123 |
124 virtual void UnloadExtension( | 124 virtual void UnloadExtension( |
125 const std::string& extension_id, | 125 const std::string& extension_id, |
126 extension_misc::UnloadedExtensionReason reason) = 0; | 126 extension_misc::UnloadedExtensionReason reason) = 0; |
127 | 127 |
| 128 virtual void SyncExtensionChangeIfNeeded(const Extension& extension) = 0; |
| 129 |
128 virtual bool is_ready() = 0; | 130 virtual bool is_ready() = 0; |
129 }; | 131 }; |
130 | 132 |
131 // Manages installed and running Chromium extensions. | 133 // Manages installed and running Chromium extensions. |
132 class ExtensionService | 134 class ExtensionService |
133 : public ExtensionServiceInterface, | 135 : public ExtensionServiceInterface, |
134 public ExternalExtensionProviderInterface::VisitorInterface, | 136 public ExternalExtensionProviderInterface::VisitorInterface, |
135 public base::SupportsWeakPtr<ExtensionService>, | 137 public base::SupportsWeakPtr<ExtensionService>, |
136 public content::NotificationObserver { | 138 public content::NotificationObserver { |
137 public: | 139 public: |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 222 |
221 // When app notification setup is done, we call this to save the developer's | 223 // When app notification setup is done, we call this to save the developer's |
222 // oauth client id which we'll need at uninstall time to revoke the oauth | 224 // oauth client id which we'll need at uninstall time to revoke the oauth |
223 // permission grant for sending notifications. | 225 // permission grant for sending notifications. |
224 virtual void SetAppNotificationSetupDone(const std::string& extension_id, | 226 virtual void SetAppNotificationSetupDone(const std::string& extension_id, |
225 const std::string& oauth_client_id); | 227 const std::string& oauth_client_id); |
226 | 228 |
227 virtual void SetAppNotificationDisabled(const std::string& extension_id, | 229 virtual void SetAppNotificationDisabled(const std::string& extension_id, |
228 bool value); | 230 bool value); |
229 | 231 |
230 // Getters and setters for the position of Apps in the NTP. The setters | |
231 // will trigger a sync if needed. | |
232 // The getters return invalid StringOridinals for non-app extensions and | |
233 // setting ordinals for non-apps is an error. | |
234 StringOrdinal GetAppLaunchOrdinal(const std::string& extension_id) const; | |
235 void SetAppLaunchOrdinal(const std::string& extension_id, | |
236 const StringOrdinal& app_launch_ordinal); | |
237 StringOrdinal GetPageOrdinal(const std::string& extension_id) const; | |
238 void SetPageOrdinal(const std::string& extension_id, | |
239 const StringOrdinal& page_ordinal); | |
240 | |
241 // Updates the app launcher value for the moved extension so that it is now | 232 // Updates the app launcher value for the moved extension so that it is now |
242 // located after the given predecessor and before the successor. This will | 233 // located after the given predecessor and before the successor. This will |
243 // trigger a sync if needed. Empty strings are used to indicate no successor | 234 // trigger a sync if needed. Empty strings are used to indicate no successor |
244 // or predecessor. | 235 // or predecessor. |
245 void OnExtensionMoved(const std::string& moved_extension_id, | 236 void OnExtensionMoved(const std::string& moved_extension_id, |
246 const std::string& predecessor_extension_id, | 237 const std::string& predecessor_extension_id, |
247 const std::string& successor_extension_id); | 238 const std::string& successor_extension_id); |
248 | 239 |
249 // Returns true if the given extension can see events and data from another | 240 // Returns true if the given extension can see events and data from another |
250 // sub-profile (incognito to original profile, or vice versa). | 241 // sub-profile (incognito to original profile, or vice versa). |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 // Unload all extensions. This is currently only called on shutdown, and | 359 // Unload all extensions. This is currently only called on shutdown, and |
369 // does not send notifications. | 360 // does not send notifications. |
370 void UnloadAllExtensions(); | 361 void UnloadAllExtensions(); |
371 | 362 |
372 // Called only by testing. | 363 // Called only by testing. |
373 void ReloadExtensions(); | 364 void ReloadExtensions(); |
374 | 365 |
375 // Scan the extension directory and clean up the cruft. | 366 // Scan the extension directory and clean up the cruft. |
376 void GarbageCollectExtensions(); | 367 void GarbageCollectExtensions(); |
377 | 368 |
| 369 // Notifies Sync (if needed) of a newly-installed extension or a change to |
| 370 // an existing extension. |
| 371 virtual void SyncExtensionChangeIfNeeded(const Extension& extension) OVERRIDE; |
| 372 |
378 // The App that represents the web store. | 373 // The App that represents the web store. |
379 const Extension* GetWebStoreApp(); | 374 const Extension* GetWebStoreApp(); |
380 | 375 |
381 // Returns true if |url| should get extension api bindings and be permitted | 376 // Returns true if |url| should get extension api bindings and be permitted |
382 // to make api calls. Note that this is independent of what extension | 377 // to make api calls. Note that this is independent of what extension |
383 // permissions the given extension has been granted. | 378 // permissions the given extension has been granted. |
384 bool ExtensionBindingsAllowed(const GURL& url); | 379 bool ExtensionBindingsAllowed(const GURL& url); |
385 | 380 |
386 // Returns the icon to display in the omnibox for the given extension. | 381 // Returns the icon to display in the omnibox for the given extension. |
387 const SkBitmap& GetOmniboxIcon(const std::string& extension_id); | 382 const SkBitmap& GetOmniboxIcon(const std::string& extension_id); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 | 622 |
628 struct NaClModuleInfo { | 623 struct NaClModuleInfo { |
629 NaClModuleInfo(); | 624 NaClModuleInfo(); |
630 ~NaClModuleInfo(); | 625 ~NaClModuleInfo(); |
631 | 626 |
632 GURL url; | 627 GURL url; |
633 std::string mime_type; | 628 std::string mime_type; |
634 }; | 629 }; |
635 typedef std::list<NaClModuleInfo> NaClModuleInfoList; | 630 typedef std::list<NaClModuleInfo> NaClModuleInfoList; |
636 | 631 |
637 // Notifies Sync (if needed) of a newly-installed extension or a change to | |
638 // an existing extension. | |
639 void SyncExtensionChangeIfNeeded(const Extension& extension); | |
640 | |
641 // Get the appropriate SyncBundle, given some representation of Sync data. | 632 // Get the appropriate SyncBundle, given some representation of Sync data. |
642 SyncBundle* GetSyncBundleForExtension(const Extension& extension); | 633 SyncBundle* GetSyncBundleForExtension(const Extension& extension); |
643 SyncBundle* GetSyncBundleForExtensionSyncData( | 634 SyncBundle* GetSyncBundleForExtensionSyncData( |
644 const ExtensionSyncData& extension_sync_data); | 635 const ExtensionSyncData& extension_sync_data); |
645 SyncBundle* GetSyncBundleForModelType(syncable::ModelType type); | 636 SyncBundle* GetSyncBundleForModelType(syncable::ModelType type); |
646 const SyncBundle* GetSyncBundleForModelTypeConst(syncable::ModelType type) | 637 const SyncBundle* GetSyncBundleForModelTypeConst(syncable::ModelType type) |
647 const; | 638 const; |
648 | 639 |
649 // Gets the ExtensionSyncData for all extensions. | 640 // Gets the ExtensionSyncData for all extensions. |
650 std::vector<ExtensionSyncData> GetSyncDataList( | 641 std::vector<ExtensionSyncData> GetSyncDataList( |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 scoped_ptr<ExtensionGlobalError> extension_global_error_; | 841 scoped_ptr<ExtensionGlobalError> extension_global_error_; |
851 | 842 |
852 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 843 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
853 InstallAppsWithUnlimtedStorage); | 844 InstallAppsWithUnlimtedStorage); |
854 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 845 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
855 InstallAppsAndCheckStorageProtection); | 846 InstallAppsAndCheckStorageProtection); |
856 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 847 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
857 }; | 848 }; |
858 | 849 |
859 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 850 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
OLD | NEW |