OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 virtual void UpdateExtensionBlacklist( | 108 virtual void UpdateExtensionBlacklist( |
109 const std::vector<std::string>& blacklist) = 0; | 109 const std::vector<std::string>& blacklist) = 0; |
110 virtual void CheckAdminBlacklist() = 0; | 110 virtual void CheckAdminBlacklist() = 0; |
111 | 111 |
112 // Safe to call multiple times in a row. | 112 // Safe to call multiple times in a row. |
113 // | 113 // |
114 // TODO(akalin): Remove this method (and others) once we refactor | 114 // TODO(akalin): Remove this method (and others) once we refactor |
115 // themes sync to not use it directly. | 115 // themes sync to not use it directly. |
116 virtual void CheckForUpdatesSoon() = 0; | 116 virtual void CheckForUpdatesSoon() = 0; |
| 117 |
| 118 virtual void AddExtension(const Extension* extension) = 0; |
| 119 |
| 120 virtual void UnloadExtension( |
| 121 const std::string& extension_id, |
| 122 extension_misc::UnloadedExtensionReason reason) = 0; |
| 123 |
| 124 virtual bool is_ready() = 0; |
117 }; | 125 }; |
118 | 126 |
119 // Manages installed and running Chromium extensions. | 127 // Manages installed and running Chromium extensions. |
120 class ExtensionService | 128 class ExtensionService |
121 : public ExtensionServiceInterface, | 129 : public ExtensionServiceInterface, |
122 public ExternalExtensionProviderInterface::VisitorInterface, | 130 public ExternalExtensionProviderInterface::VisitorInterface, |
123 public base::SupportsWeakPtr<ExtensionService>, | 131 public base::SupportsWeakPtr<ExtensionService>, |
124 public content::NotificationObserver { | 132 public content::NotificationObserver { |
125 public: | 133 public: |
126 using base::SupportsWeakPtr<ExtensionService>::AsWeakPtr; | 134 using base::SupportsWeakPtr<ExtensionService>::AsWeakPtr; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 void GrantPermissionsAndEnableExtension(const Extension* extension); | 313 void GrantPermissionsAndEnableExtension(const Extension* extension); |
306 | 314 |
307 // Sets the |extension|'s active permissions to |permissions|. | 315 // Sets the |extension|'s active permissions to |permissions|. |
308 void UpdateActivePermissions(const Extension* extension, | 316 void UpdateActivePermissions(const Extension* extension, |
309 const ExtensionPermissionSet* permissions); | 317 const ExtensionPermissionSet* permissions); |
310 | 318 |
311 // Check for updates (or potentially new extensions from external providers) | 319 // Check for updates (or potentially new extensions from external providers) |
312 void CheckForExternalUpdates(); | 320 void CheckForExternalUpdates(); |
313 | 321 |
314 // Unload the specified extension. | 322 // Unload the specified extension. |
315 void UnloadExtension(const std::string& extension_id, | 323 virtual void UnloadExtension( |
316 extension_misc::UnloadedExtensionReason reason); | 324 const std::string& extension_id, |
| 325 extension_misc::UnloadedExtensionReason reason); |
317 | 326 |
318 // Unload all extensions. This is currently only called on shutdown, and | 327 // Unload all extensions. This is currently only called on shutdown, and |
319 // does not send notifications. | 328 // does not send notifications. |
320 void UnloadAllExtensions(); | 329 void UnloadAllExtensions(); |
321 | 330 |
322 // Called only by testing. | 331 // Called only by testing. |
323 void ReloadExtensions(); | 332 void ReloadExtensions(); |
324 | 333 |
325 // Scan the extension directory and clean up the cruft. | 334 // Scan the extension directory and clean up the cruft. |
326 void GarbageCollectExtensions(); | 335 void GarbageCollectExtensions(); |
(...skipping 26 matching lines...) Expand all Loading... |
353 // Returns the icon to display in the omnibox popup window for the given | 362 // Returns the icon to display in the omnibox popup window for the given |
354 // extension. | 363 // extension. |
355 const SkBitmap& GetOmniboxPopupIcon(const std::string& extension_id); | 364 const SkBitmap& GetOmniboxPopupIcon(const std::string& extension_id); |
356 | 365 |
357 // Called when the initial extensions load has completed. | 366 // Called when the initial extensions load has completed. |
358 virtual void OnLoadedInstalledExtensions(); | 367 virtual void OnLoadedInstalledExtensions(); |
359 | 368 |
360 // Adds |extension| to this ExtensionService and notifies observers than an | 369 // Adds |extension| to this ExtensionService and notifies observers than an |
361 // extension has been loaded. Called by the backend after an extension has | 370 // extension has been loaded. Called by the backend after an extension has |
362 // been loaded from a file and installed. | 371 // been loaded from a file and installed. |
363 void AddExtension(const Extension* extension); | 372 virtual void AddExtension(const Extension* extension); |
364 | 373 |
365 // Called by the backend when an extension has been installed. | 374 // Called by the backend when an extension has been installed. |
366 void OnExtensionInstalled( | 375 void OnExtensionInstalled( |
367 const Extension* extension, bool from_webstore, int page_index); | 376 const Extension* extension, bool from_webstore, int page_index); |
368 | 377 |
369 // Initializes the |extension|'s active permission set and disables the | 378 // Initializes the |extension|'s active permission set and disables the |
370 // extension if the privilege level has increased (e.g., due to an upgrade). | 379 // extension if the privilege level has increased (e.g., due to an upgrade). |
371 void InitializePermissions(const Extension* extension); | 380 void InitializePermissions(const Extension* extension); |
372 | 381 |
373 // Go through each extensions in pref, unload blacklisted extensions | 382 // Go through each extensions in pref, unload blacklisted extensions |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 | 417 |
409 // TODO(skerner): Change to const ExtensionPrefs& extension_prefs() const, | 418 // TODO(skerner): Change to const ExtensionPrefs& extension_prefs() const, |
410 // ExtensionPrefs* mutable_extension_prefs(). | 419 // ExtensionPrefs* mutable_extension_prefs(). |
411 ExtensionPrefs* extension_prefs(); | 420 ExtensionPrefs* extension_prefs(); |
412 | 421 |
413 extensions::SettingsFrontend* settings_frontend(); | 422 extensions::SettingsFrontend* settings_frontend(); |
414 | 423 |
415 ExtensionContentSettingsStore* GetExtensionContentSettingsStore(); | 424 ExtensionContentSettingsStore* GetExtensionContentSettingsStore(); |
416 | 425 |
417 // Whether the extension service is ready. | 426 // Whether the extension service is ready. |
418 bool is_ready() { return ready_; } | 427 virtual bool is_ready() OVERRIDE; |
419 | 428 |
420 extensions::ComponentLoader* component_loader() { | 429 extensions::ComponentLoader* component_loader() { |
421 return component_loader_.get(); | 430 return component_loader_.get(); |
422 } | 431 } |
423 | 432 |
424 // Note that this may return NULL if autoupdate is not turned on. | 433 // Note that this may return NULL if autoupdate is not turned on. |
425 ExtensionUpdater* updater(); | 434 ExtensionUpdater* updater(); |
426 | 435 |
427 ExtensionToolbarModel* toolbar_model() { return &toolbar_model_; } | 436 ExtensionToolbarModel* toolbar_model() { return &toolbar_model_; } |
428 | 437 |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 extensions::ProcessMap process_map_; | 803 extensions::ProcessMap process_map_; |
795 | 804 |
796 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 805 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
797 InstallAppsWithUnlimtedStorage); | 806 InstallAppsWithUnlimtedStorage); |
798 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 807 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
799 InstallAppsAndCheckStorageProtection); | 808 InstallAppsAndCheckStorageProtection); |
800 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 809 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
801 }; | 810 }; |
802 | 811 |
803 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 812 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
OLD | NEW |