| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 DefaultApps* default_apps() { return &default_apps_; } | 178 DefaultApps* default_apps() { return &default_apps_; } |
| 179 | 179 |
| 180 // Whether this extension can run in an incognito window. | 180 // Whether this extension can run in an incognito window. |
| 181 bool IsIncognitoEnabled(const Extension* extension); | 181 bool IsIncognitoEnabled(const Extension* extension); |
| 182 void SetIsIncognitoEnabled(const Extension* extension, bool enabled); | 182 void SetIsIncognitoEnabled(const Extension* extension, bool enabled); |
| 183 | 183 |
| 184 // Whether this extension can inject scripts into pages with file URLs. | 184 // Whether this extension can inject scripts into pages with file URLs. |
| 185 bool AllowFileAccess(const Extension* extension); | 185 bool AllowFileAccess(const Extension* extension); |
| 186 void SetAllowFileAccess(const Extension* extension, bool allow); | 186 void SetAllowFileAccess(const Extension* extension, bool allow); |
| 187 | 187 |
| 188 // Whether the background page, if any, is ready. We don't load other |
| 189 // components until then. If there is no background page, we consider it to |
| 190 // be ready. |
| 191 bool IsBackgroundPageReady(const Extension* extension); |
| 192 void SetBackgroundPageReady(const Extension* extension); |
| 193 |
| 194 // Getter and setter for the flag that specifies whether the extension is |
| 195 // being upgraded. |
| 196 bool IsBeingUpgraded(const Extension* extension); |
| 197 void SetBeingUpgraded(const Extension* extension, bool value); |
| 198 |
| 188 // Initialize and start all installed extensions. | 199 // Initialize and start all installed extensions. |
| 189 void Init(); | 200 void Init(); |
| 190 | 201 |
| 191 // Start up the extension event routers. | 202 // Start up the extension event routers. |
| 192 void InitEventRouters(); | 203 void InitEventRouters(); |
| 193 | 204 |
| 194 // Look up an extension by ID. | 205 // Look up an extension by ID. |
| 195 const Extension* GetExtensionById(const std::string& id, | 206 const Extension* GetExtensionById(const std::string& id, |
| 196 bool include_disabled) { | 207 bool include_disabled) { |
| 197 return GetExtensionByIdInternal(id, true, include_disabled); | 208 return GetExtensionByIdInternal(id, true, include_disabled); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 const NotificationSource& source, | 408 const NotificationSource& source, |
| 398 const NotificationDetails& details); | 409 const NotificationDetails& details); |
| 399 | 410 |
| 400 // Whether there are any apps installed. Component apps are not included. | 411 // Whether there are any apps installed. Component apps are not included. |
| 401 bool HasApps() const; | 412 bool HasApps() const; |
| 402 | 413 |
| 403 // Gets the set of loaded app ids. Component apps are not included. | 414 // Gets the set of loaded app ids. Component apps are not included. |
| 404 ExtensionIdSet GetAppIds() const; | 415 ExtensionIdSet GetAppIds() const; |
| 405 | 416 |
| 406 private: | 417 private: |
| 407 virtual ~ExtensionsService(); | |
| 408 friend class BrowserThread; | 418 friend class BrowserThread; |
| 409 friend class DeleteTask<ExtensionsService>; | 419 friend class DeleteTask<ExtensionsService>; |
| 410 | 420 |
| 421 // Contains Extension data that can change during the life of the process, |
| 422 // but does not persist across restarts. |
| 423 struct ExtensionRuntimeData { |
| 424 // True if the background page is ready. |
| 425 bool background_page_ready; |
| 426 |
| 427 // True while the extension is being upgraded. |
| 428 bool being_upgraded; |
| 429 |
| 430 ExtensionRuntimeData(); |
| 431 ~ExtensionRuntimeData(); |
| 432 }; |
| 433 typedef std::map<std::string, ExtensionRuntimeData> ExtensionRuntimeDataMap; |
| 434 |
| 435 virtual ~ExtensionsService(); |
| 436 |
| 411 // Clear all persistent data that may have been stored by the extension. | 437 // Clear all persistent data that may have been stored by the extension. |
| 412 void ClearExtensionData(const GURL& extension_url); | 438 void ClearExtensionData(const GURL& extension_url); |
| 413 | 439 |
| 414 // Look up an extension by ID, optionally including either or both of enabled | 440 // Look up an extension by ID, optionally including either or both of enabled |
| 415 // and disabled extensions. | 441 // and disabled extensions. |
| 416 const Extension* GetExtensionByIdInternal(const std::string& id, | 442 const Extension* GetExtensionByIdInternal(const std::string& id, |
| 417 bool include_enabled, | 443 bool include_enabled, |
| 418 bool include_disabled); | 444 bool include_disabled); |
| 419 | 445 |
| 420 // Like AddPendingExtension() but assumes an extension with the same | 446 // Like AddPendingExtension() but assumes an extension with the same |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 | 478 |
| 453 // The current list of installed extensions. | 479 // The current list of installed extensions. |
| 454 ExtensionList extensions_; | 480 ExtensionList extensions_; |
| 455 | 481 |
| 456 // The list of installed extensions that have been disabled. | 482 // The list of installed extensions that have been disabled. |
| 457 ExtensionList disabled_extensions_; | 483 ExtensionList disabled_extensions_; |
| 458 | 484 |
| 459 // The set of pending extensions. | 485 // The set of pending extensions. |
| 460 PendingExtensionMap pending_extensions_; | 486 PendingExtensionMap pending_extensions_; |
| 461 | 487 |
| 488 // The map of extension IDs to their runtime data. |
| 489 ExtensionRuntimeDataMap extension_runtime_data_; |
| 490 |
| 462 // The full path to the directory where extensions are installed. | 491 // The full path to the directory where extensions are installed. |
| 463 FilePath install_directory_; | 492 FilePath install_directory_; |
| 464 | 493 |
| 465 // Whether or not extensions are enabled. | 494 // Whether or not extensions are enabled. |
| 466 bool extensions_enabled_; | 495 bool extensions_enabled_; |
| 467 | 496 |
| 468 // Whether to notify users when they attempt to install an extension. | 497 // Whether to notify users when they attempt to install an extension. |
| 469 bool show_extensions_prompts_; | 498 bool show_extensions_prompts_; |
| 470 | 499 |
| 471 // The backend that will do IO on behalf of this instance. | 500 // The backend that will do IO on behalf of this instance. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 FRIEND_TEST_ALL_PREFIXES(ExtensionsServiceTest, | 565 FRIEND_TEST_ALL_PREFIXES(ExtensionsServiceTest, |
| 537 UpdatePendingExtensionAlreadyInstalled); | 566 UpdatePendingExtensionAlreadyInstalled); |
| 538 FRIEND_TEST_ALL_PREFIXES(ExtensionsServiceTest, | 567 FRIEND_TEST_ALL_PREFIXES(ExtensionsServiceTest, |
| 539 InstallAppsWithUnlimtedStorage); | 568 InstallAppsWithUnlimtedStorage); |
| 540 FRIEND_TEST_ALL_PREFIXES(ExtensionsServiceTest, | 569 FRIEND_TEST_ALL_PREFIXES(ExtensionsServiceTest, |
| 541 InstallAppsAndCheckStorageProtection); | 570 InstallAppsAndCheckStorageProtection); |
| 542 DISALLOW_COPY_AND_ASSIGN(ExtensionsService); | 571 DISALLOW_COPY_AND_ASSIGN(ExtensionsService); |
| 543 }; | 572 }; |
| 544 | 573 |
| 545 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ | 574 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ |
| OLD | NEW |