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 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 20 matching lines...) Expand all Loading... | |
31 #include "chrome/browser/extensions/menu_manager.h" | 31 #include "chrome/browser/extensions/menu_manager.h" |
32 #include "chrome/browser/extensions/pending_extension_manager.h" | 32 #include "chrome/browser/extensions/pending_extension_manager.h" |
33 #include "chrome/browser/extensions/process_map.h" | 33 #include "chrome/browser/extensions/process_map.h" |
34 #include "chrome/browser/extensions/update_observer.h" | 34 #include "chrome/browser/extensions/update_observer.h" |
35 #include "chrome/common/extensions/extension.h" | 35 #include "chrome/common/extensions/extension.h" |
36 #include "chrome/common/extensions/extension_constants.h" | 36 #include "chrome/common/extensions/extension_constants.h" |
37 #include "chrome/common/extensions/extension_set.h" | 37 #include "chrome/common/extensions/extension_set.h" |
38 #include "chrome/common/extensions/manifest.h" | 38 #include "chrome/common/extensions/manifest.h" |
39 #include "content/public/browser/notification_observer.h" | 39 #include "content/public/browser/notification_observer.h" |
40 #include "content/public/browser/notification_registrar.h" | 40 #include "content/public/browser/notification_registrar.h" |
41 #include "ipc/ipc_listener.h" | |
41 #include "sync/api/string_ordinal.h" | 42 #include "sync/api/string_ordinal.h" |
42 #include "sync/api/sync_change.h" | 43 #include "sync/api/sync_change.h" |
43 #include "sync/api/syncable_service.h" | 44 #include "sync/api/syncable_service.h" |
44 | 45 |
45 class CommandLine; | 46 class CommandLine; |
46 class ExtensionErrorUI; | 47 class ExtensionErrorUI; |
47 class ExtensionSyncData; | 48 class ExtensionSyncData; |
48 class ExtensionToolbarModel; | 49 class ExtensionToolbarModel; |
49 class GURL; | 50 class GURL; |
50 class Profile; | 51 class Profile; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 | 131 |
131 // Returns task runner for crx installation file I/O operations. | 132 // Returns task runner for crx installation file I/O operations. |
132 virtual base::SequencedTaskRunner* GetFileTaskRunner() = 0; | 133 virtual base::SequencedTaskRunner* GetFileTaskRunner() = 0; |
133 }; | 134 }; |
134 | 135 |
135 // Manages installed and running Chromium extensions. | 136 // Manages installed and running Chromium extensions. |
136 class ExtensionService | 137 class ExtensionService |
137 : public ExtensionServiceInterface, | 138 : public ExtensionServiceInterface, |
138 public extensions::ExternalProviderInterface::VisitorInterface, | 139 public extensions::ExternalProviderInterface::VisitorInterface, |
139 public content::NotificationObserver, | 140 public content::NotificationObserver, |
140 public extensions::Blacklist::Observer { | 141 public extensions::Blacklist::Observer, |
142 public IPC::Listener { | |
asargent_no_longer_on_chrome
2013/08/14 18:05:12
Since ExtensionService already does a lot of stuff
sergeygs
2013/08/18 11:40:24
It looks to me now that this attempt wasn't viable
| |
141 public: | 143 public: |
142 // The name of the directory inside the profile where extensions are | 144 // The name of the directory inside the profile where extensions are |
143 // installed to. | 145 // installed to. |
144 static const char kInstallDirectoryName[]; | 146 static const char kInstallDirectoryName[]; |
145 | 147 |
146 // If auto-updates are turned on, default to running every 5 hours. | 148 // If auto-updates are turned on, default to running every 5 hours. |
147 static const int kDefaultUpdateFrequencySeconds = 60 * 60 * 5; | 149 static const int kDefaultUpdateFrequencySeconds = 60 * 60 * 5; |
148 | 150 |
149 // The name of the directory inside the profile where per-app local settings | 151 // The name of the directory inside the profile where per-app local settings |
150 // are stored. | 152 // are stored. |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 | 403 |
402 // Returns true if |url| should get extension api bindings and be permitted | 404 // Returns true if |url| should get extension api bindings and be permitted |
403 // to make api calls. Note that this is independent of what extension | 405 // to make api calls. Note that this is independent of what extension |
404 // permissions the given extension has been granted. | 406 // permissions the given extension has been granted. |
405 bool ExtensionBindingsAllowed(const GURL& url); | 407 bool ExtensionBindingsAllowed(const GURL& url); |
406 | 408 |
407 // Returns true if a normal browser window should avoid showing |url| in a | 409 // Returns true if a normal browser window should avoid showing |url| in a |
408 // tab. In this case, |url| is also rewritten to an error URL. | 410 // tab. In this case, |url| is also rewritten to an error URL. |
409 bool ShouldBlockUrlInBrowserTab(GURL* url); | 411 bool ShouldBlockUrlInBrowserTab(GURL* url); |
410 | 412 |
413 // Looks if there is a platform app that's registered itself for handling | |
414 // a URL pattern(s) that matches |url|. If there is, launches the app, using | |
415 // the onLaunched event with |url|, |referrerUrl| and the just found | |
416 // handler ID as launch parameters, and returns true. | |
417 // Otherwise, returns false. | |
418 // This direct way of redirecting URLs to apps is for use in browser- | |
419 // initiated that happen in the browser process (compare to | |
420 // OnRedirectUrlToApp). | |
421 bool MaybeRedirectUrlToApp(const GURL& url, const GURL& referrer_url); | |
422 | |
411 // Called when the initial extensions load has completed. | 423 // Called when the initial extensions load has completed. |
412 virtual void OnLoadedInstalledExtensions(); | 424 virtual void OnLoadedInstalledExtensions(); |
413 | 425 |
414 // Adds |extension| to this ExtensionService and notifies observers that the | 426 // Adds |extension| to this ExtensionService and notifies observers that the |
415 // extensions have been loaded. | 427 // extensions have been loaded. |
416 virtual void AddExtension(const extensions::Extension* extension) OVERRIDE; | 428 virtual void AddExtension(const extensions::Extension* extension) OVERRIDE; |
417 | 429 |
418 // Check if we have preferences for the component extension and, if not or if | 430 // Check if we have preferences for the component extension and, if not or if |
419 // the stored version differs, install the extension (without requirements | 431 // the stored version differs, install the extension (without requirements |
420 // checking) before calling AddExtension. | 432 // checking) before calling AddExtension. |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
673 // until the extension is idle. Tests might not like this behavior, so you can | 685 // until the extension is idle. Tests might not like this behavior, so you can |
674 // disable it with this method. | 686 // disable it with this method. |
675 void set_install_updates_when_idle_for_test(bool value) { | 687 void set_install_updates_when_idle_for_test(bool value) { |
676 install_updates_when_idle_ = value; | 688 install_updates_when_idle_ = value; |
677 } | 689 } |
678 | 690 |
679 // Adds/Removes update observers. | 691 // Adds/Removes update observers. |
680 void AddUpdateObserver(extensions::UpdateObserver* observer); | 692 void AddUpdateObserver(extensions::UpdateObserver* observer); |
681 void RemoveUpdateObserver(extensions::UpdateObserver* observer); | 693 void RemoveUpdateObserver(extensions::UpdateObserver* observer); |
682 | 694 |
695 // IPC::Listener implementation. | |
696 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
697 | |
683 private: | 698 private: |
684 // Contains Extension data that can change during the life of the process, | 699 // Contains Extension data that can change during the life of the process, |
685 // but does not persist across restarts. | 700 // but does not persist across restarts. |
686 struct ExtensionRuntimeData { | 701 struct ExtensionRuntimeData { |
687 // True if the background page is ready. | 702 // True if the background page is ready. |
688 bool background_page_ready; | 703 bool background_page_ready; |
689 | 704 |
690 // True while the extension is being upgraded. | 705 // True while the extension is being upgraded. |
691 bool being_upgraded; | 706 bool being_upgraded; |
692 | 707 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
820 void OnNeedsToGarbageCollectIsolatedStorage(); | 835 void OnNeedsToGarbageCollectIsolatedStorage(); |
821 | 836 |
822 // extensions::Blacklist::Observer implementation. | 837 // extensions::Blacklist::Observer implementation. |
823 virtual void OnBlacklistUpdated() OVERRIDE; | 838 virtual void OnBlacklistUpdated() OVERRIDE; |
824 | 839 |
825 // Manages the blacklisted extensions, intended as callback from | 840 // Manages the blacklisted extensions, intended as callback from |
826 // Blacklist::GetBlacklistedIDs. | 841 // Blacklist::GetBlacklistedIDs. |
827 void ManageBlacklist(const std::set<std::string>& old_blacklisted_ids, | 842 void ManageBlacklist(const std::set<std::string>& old_blacklisted_ids, |
828 const std::set<std::string>& new_blacklisted_ids); | 843 const std::set<std::string>& new_blacklisted_ids); |
829 | 844 |
845 // Launches an app that has |app_id|, using the onLaunched event with | |
846 // |handler_id|, |url| and |referrerUrl| as launch parameters. | |
847 // This is registered to listen to the respective IPC control message | |
848 // from renderer processes to provide a way of redirecting URLs to apps | |
849 // to them (compare to MaybeRedirectUrlToApp). | |
850 void OnRedirectUrlToApp(const std::string& app_id, | |
851 const std::string& handler_id, | |
852 const GURL& url, | |
853 const GURL& referrer_url); | |
854 | |
830 // Controls if installs are delayed. See comment for |installs_delayed_|. | 855 // Controls if installs are delayed. See comment for |installs_delayed_|. |
831 void set_installs_delayed(bool value) { installs_delayed_ = value; } | 856 void set_installs_delayed(bool value) { installs_delayed_ = value; } |
832 bool installs_delayed() const { return installs_delayed_; } | 857 bool installs_delayed() const { return installs_delayed_; } |
833 | 858 |
834 // The normal profile associated with this ExtensionService. | 859 // The normal profile associated with this ExtensionService. |
835 Profile* profile_; | 860 Profile* profile_; |
836 | 861 |
837 // The ExtensionSystem for the profile above. | 862 // The ExtensionSystem for the profile above. |
838 extensions::ExtensionSystem* system_; | 863 extensions::ExtensionSystem* system_; |
839 | 864 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
988 ObserverList<extensions::UpdateObserver, true> update_observers_; | 1013 ObserverList<extensions::UpdateObserver, true> update_observers_; |
989 | 1014 |
990 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 1015 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
991 InstallAppsWithUnlimtedStorage); | 1016 InstallAppsWithUnlimtedStorage); |
992 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 1017 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
993 InstallAppsAndCheckStorageProtection); | 1018 InstallAppsAndCheckStorageProtection); |
994 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 1019 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
995 }; | 1020 }; |
996 | 1021 |
997 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 1022 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
OLD | NEW |