15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 88bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include <list> 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <map> 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <set> 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string> 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector> 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/compiler_specific.h" 152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/files/file_path.h" 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/gtest_prod_util.h" 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/ref_counted.h" 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/weak_ptr.h" 192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/prefs/pref_change_registrar.h" 20868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/string16.h" 212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/extensions/blacklist.h" 222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/extensions/extension_function_histogram_value.h" 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/extensions/extension_prefs.h" 241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "chrome/browser/extensions/extension_sync_service.h" 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/extensions/extension_constants.h" 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/extensions/extension_set.h" 277dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "content/public/browser/devtools_agent_host.h" 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_observer.h" 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_registrar.h" 30f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "extensions/browser/external_provider_interface.h" 31f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "extensions/browser/management_policy.h" 32f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "extensions/browser/pending_extension_manager.h" 33f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "extensions/browser/process_manager.h" 34f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "extensions/browser/process_map.h" 35f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "extensions/browser/quota_service.h" 36f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "extensions/common/extension.h" 373551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "extensions/common/manifest.h" 38f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "extensions/common/manifest_handlers/shared_module_info.h" 3990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "extensions/common/one_shot_event.h" 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CommandLine; 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ExtensionErrorUI; 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ExtensionToolbarModel; 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class GURL; 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Profile; 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace base { 482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class SequencedTaskRunner; 49c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class Version; 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace extensions { 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class BrowserEventRouter; 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ComponentLoader; 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ContentSettingsStore; 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CrxInstaller; 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ExtensionActionStorageManager; 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ExtensionSystem; 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ExtensionUpdater; 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class PendingExtensionManager; 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class SettingsFrontend; 62a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class UpdateObserver; 63eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch} // namespace extensions 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace syncer { 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class SyncErrorFactory; 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This is an interface class to encapsulate the dependencies that 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// various classes have on ExtensionService. This allows easy mocking. 711e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class ExtensionServiceInterface 721e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) : public base::SupportsWeakPtr<ExtensionServiceInterface> { 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~ExtensionServiceInterface() {} 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual const ExtensionSet* extensions() const = 0; 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual const ExtensionSet* disabled_extensions() const = 0; 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual extensions::PendingExtensionManager* pending_extension_manager() = 0; 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Install an update. Return true if the install can be started. 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Set out_crx_installer to the installer if one was started. 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool UpdateExtension( 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& id, 832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const base::FilePath& path, 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const GURL& download_url, 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) extensions::CrxInstaller** out_crx_installer) = 0; 862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual const extensions::Extension* GetExtensionById( 872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const std::string& id, 882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool include_disabled) const = 0; 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual const extensions::Extension* GetInstalledExtension( 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& id) const = 0; 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual const extensions::Extension* GetPendingExtensionUpdate( 932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const std::string& extension_id) const = 0; 942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void FinishDelayedInstallation(const std::string& extension_id) = 0; 952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsExtensionEnabled(const std::string& extension_id) const = 0; 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsExternalExtensionUninstalled( 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& extension_id) const = 0; 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void CheckManagementPolicy() = 0; 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Safe to call multiple times in a row. 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(akalin): Remove this method (and others) once we refactor 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // themes sync to not use it directly. 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void CheckForUpdatesSoon() = 0; 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void AddExtension(const extensions::Extension* extension) = 0; 1092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void AddComponentExtension( 1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const extensions::Extension* extension) = 0; 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void UnloadExtension( 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& extension_id, 1141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) extensions::UnloadedExtensionInfo::Reason reason) = 0; 11558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) virtual void RemoveComponentExtension(const std::string& extension_id) = 0; 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool is_ready() = 0; 1182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Returns task runner for crx installation file I/O operations. 1202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual base::SequencedTaskRunner* GetFileTaskRunner() = 0; 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Manages installed and running Chromium extensions. 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ExtensionService 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) : public ExtensionServiceInterface, 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public extensions::ExternalProviderInterface::VisitorInterface, 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public content::NotificationObserver, 1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public extensions::Blacklist::Observer { 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 130f60fc993c7b081abf77ce2ffc7fcca1142c8cb01Torne (Richard Coles) // Returns the Extension for a given url or NULL if the url doesn't belong to 131f60fc993c7b081abf77ce2ffc7fcca1142c8cb01Torne (Richard Coles) // an installed extension. This may be a hosted app extent or a 132f60fc993c7b081abf77ce2ffc7fcca1142c8cb01Torne (Richard Coles) // chrome-extension:// url. 133d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles) const extensions::Extension* GetInstalledExtensionByUrl( 134d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles) const GURL& url) const; 135d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles) 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the Extension of hosted or packaged apps, NULL otherwise. 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const extensions::Extension* GetInstalledApp(const GURL& url) const; 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns whether the URL is from either a hosted or packaged app. 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool IsInstalledApp(const GURL& url) const; 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Attempts to uninstall an extension from a given ExtensionService. Returns 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // true iff the target extension exists. 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool UninstallExtensionHelper(ExtensionService* extensions_service, 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& extension_id); 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Constructor stores pointers to |profile| and |extension_prefs| but 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // ownership remains at caller. 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ExtensionService(Profile* profile, 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const CommandLine* command_line, 1512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const base::FilePath& install_directory, 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) extensions::ExtensionPrefs* extension_prefs, 1532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) extensions::Blacklist* blacklist, 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool autoupdate_enabled, 15590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool extensions_enabled, 15690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) extensions::OneShotEvent* ready); 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~ExtensionService(); 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Gets the list of currently installed extensions. 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual const ExtensionSet* extensions() const OVERRIDE; 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual const ExtensionSet* disabled_extensions() const OVERRIDE; 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const ExtensionSet* terminated_extensions() const; 1642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const ExtensionSet* blacklisted_extensions() const; 165a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) const ExtensionSet* delayed_installs() const; 1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Returns a set of all installed, disabled, blacklisted, and terminated 1682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // extensions. 169f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) scoped_ptr<ExtensionSet> GenerateInstalledExtensionsSet() const; 1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Gets the object managing the set of pending extensions. 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual extensions::PendingExtensionManager* 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) pending_extension_manager() OVERRIDE; 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const base::FilePath& install_directory() const { return install_directory_; } 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) extensions::ProcessMap* process_map() { return &process_map_; } 1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Updates the app launcher value for the moved extension so that it is now 1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // located after the given predecessor and before the successor. This will 1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // trigger a sync if needed. Empty strings are used to indicate no successor 1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // or predecessor. 1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void OnExtensionMoved(const std::string& moved_extension_id, 1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& predecessor_extension_id, 1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& successor_extension_id); 1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether the persistent background page, if any, is ready. We don't load 1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // other components until then. If there is no background page, or if it is 1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // non-persistent (lazy), we consider it to be ready. 1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool IsBackgroundPageReady(const extensions::Extension* extension) const; 1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetBackgroundPageReady(const extensions::Extension* extension); 1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Getter and setter for the flag that specifies whether the extension is 1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // being upgraded. 1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool IsBeingUpgraded(const extensions::Extension* extension) const; 1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetBeingUpgraded(const extensions::Extension* extension, bool value); 1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 198eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Getter and setter for the flag that specifies whether the extension is 199eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // being reloaded. 20068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) bool IsBeingReloaded(const std::string& extension_id) const; 201eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch void SetBeingReloaded(const std::string& extension_id, bool value); 202eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Getter and setter for the flag that specifies if the extension has used 2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the webrequest API. 2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(mpcomplete): remove. http://crbug.com/100411 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool HasUsedWebRequest(const extensions::Extension* extension) const; 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetHasUsedWebRequest(const extensions::Extension* extension, bool value); 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Initialize and start all installed extensions. 2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void Init(); 2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 21233bff6d6e5e82ca5f2abf842074e33f4944cc250Ben Murdoch // See if we need to bootstrap the install verifier. 21333bff6d6e5e82ca5f2abf842074e33f4944cc250Ben Murdoch void MaybeBootstrapVerifier(); 21433bff6d6e5e82ca5f2abf842074e33f4944cc250Ben Murdoch 215923bd855a3a49144a9f75d8a8200416a52bae775Ben Murdoch // Attempts to verify all extensions using the InstallVerifier. The 216923bd855a3a49144a9f75d8a8200416a52bae775Ben Murdoch // |bootstrap| parameter indicates whether we're doing this because the 217923bd855a3a49144a9f75d8a8200416a52bae775Ben Murdoch // InstallVerifier needed to be bootstrapped (otherwise it's for another 218923bd855a3a49144a9f75d8a8200416a52bae775Ben Murdoch // reason, e.g. extension install/uninstall). 219923bd855a3a49144a9f75d8a8200416a52bae775Ben Murdoch void VerifyAllExtensions(bool bootstrap); 220f60fc993c7b081abf77ce2ffc7fcca1142c8cb01Torne (Richard Coles) 221f60fc993c7b081abf77ce2ffc7fcca1142c8cb01Torne (Richard Coles) // Once the verifier work is finished, we may want to re-check management 222f60fc993c7b081abf77ce2ffc7fcca1142c8cb01Torne (Richard Coles) // policy if |success| indicates the verifier got a new signature back. 223923bd855a3a49144a9f75d8a8200416a52bae775Ben Murdoch void FinishVerifyAllExtensions(bool bootstrap, bool success); 224f60fc993c7b081abf77ce2ffc7fcca1142c8cb01Torne (Richard Coles) 2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called when the associated Profile is going to be destroyed. 2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void Shutdown(); 2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Look up an extension by ID. Does not include terminated 2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // extensions. 2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual const extensions::Extension* GetExtensionById( 2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& id, bool include_disabled) const OVERRIDE; 2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) enum IncludeFlag { 2342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) INCLUDE_NONE = 0, 2352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) INCLUDE_ENABLED = 1 << 0, 2362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) INCLUDE_DISABLED = 1 << 1, 2372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) INCLUDE_TERMINATED = 1 << 2, 2382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) INCLUDE_BLACKLISTED = 1 << 3, 2392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) INCLUDE_EVERYTHING = (1 << 4) - 1, 2402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) }; 2412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Look up an extension by ID, selecting which sets to look in: 2432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // * extensions() --> INCLUDE_ENABLED 2442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // * disabled_extensions() --> INCLUDE_DISABLED 2452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // * terminated_extensions() --> INCLUDE_TERMINATED 2462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // * blacklisted_extensions() --> INCLUDE_BLACKLISTED 2472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const extensions::Extension* GetExtensionById(const std::string& id, 2482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int include_mask) const; 2492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Returns the site of the given |extension_id|. Suitable for use with 2512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // BrowserContext::GetStoragePartitionForSite(). 2522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GURL GetSiteForExtensionId(const std::string& extension_id); 2532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Looks up a terminated (crashed) extension by ID. 2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const extensions::Extension* 2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GetTerminatedExtension(const std::string& id) const; 2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Looks up an extension by ID, regardless of whether it's enabled, 2592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // disabled, blacklisted, or terminated. 2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual const extensions::Extension* GetInstalledExtension( 2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& id) const OVERRIDE; 2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Updates a currently-installed extension with the contents from 2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |extension_path|. 2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(aa): This method can be removed. ExtensionUpdater could use 2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // CrxInstaller directly instead. 2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool UpdateExtension( 2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& id, 2692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const base::FilePath& extension_path, 2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const GURL& download_url, 2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) extensions::CrxInstaller** out_crx_installer) OVERRIDE; 2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Reloads the specified extension, sending the onLaunched() event to it if it 2742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // currently has any window showing. 275eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch void ReloadExtension(const std::string extension_id); 2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Uninstalls the specified extension. Callers should only call this method 2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // with extensions that exist. |external_uninstall| is a magical parameter 2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // that is only used to send information to ExtensionPrefs, which external 2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // callers should never set to true. 2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // We pass the |extension_id| by value to avoid having it deleted from under 2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // us incase someone calls it with Extension::id() or another string that we 2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // are going to delete in this function. 2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(aa): Remove |external_uninstall| -- this information should be passed 2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // to ExtensionPrefs some other way. 2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool UninstallExtension(std::string extension_id, 2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool external_uninstall, 290a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16* error); 2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsExtensionEnabled( 2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& extension_id) const OVERRIDE; 2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsExternalExtensionUninstalled( 2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& extension_id) const OVERRIDE; 2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Enables the extension. If the extension is already enabled, does 2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // nothing. 2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void EnableExtension(const std::string& extension_id); 3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Disables the extension. If the extension is already disabled, or 3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // cannot be disabled, does nothing. 3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void DisableExtension(const std::string& extension_id, 3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) extensions::Extension::DisableReason disable_reason); 3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3063240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch // Disable non-default and non-managed extensions with ids not in 3073240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch // |except_ids|. Default extensions are those from the Web Store with 3083240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch // |was_installed_by_default| flag. 3097dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch void DisableUserExtensions(const std::vector<std::string>& except_ids); 3107d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Updates the |extension|'s granted permissions lists to include all 3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // permissions in the |extension|'s manifest and re-enables the 3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // extension. 3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void GrantPermissionsAndEnableExtension( 3152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const extensions::Extension* extension); 3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Updates the |extension|'s granted permissions lists to include all 3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // permissions in the |extensions|'s manifest. 3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void GrantPermissions( 3202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const extensions::Extension* extension); 3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Check for updates (or potentially new extensions from external providers) 3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void CheckForExternalUpdates(); 3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Unload the specified extension. 3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void UnloadExtension( 3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& extension_id, 3281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; 3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 33058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Remove the specified component extension. 33158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) virtual void RemoveComponentExtension(const std::string& extension_id) 33258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) OVERRIDE; 33358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Unload all extensions. This is currently only called on shutdown, and 3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // does not send notifications. 3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void UnloadAllExtensions(); 3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called only by testing. 3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void ReloadExtensions(); 3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Scan the extension directory and clean up the cruft. 3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void GarbageCollectExtensions(); 3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if |url| should get extension api bindings and be permitted 3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // to make api calls. Note that this is independent of what extension 3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // permissions the given extension has been granted. 3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool ExtensionBindingsAllowed(const GURL& url); 3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if a normal browser window should avoid showing |url| in a 3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // tab. In this case, |url| is also rewritten to an error URL. 3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool ShouldBlockUrlInBrowserTab(GURL* url); 3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called when the initial extensions load has completed. 3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnLoadedInstalledExtensions(); 3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Adds |extension| to this ExtensionService and notifies observers that the 3572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // extensions have been loaded. 3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void AddExtension(const extensions::Extension* extension) OVERRIDE; 3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Check if we have preferences for the component extension and, if not or if 3612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // the stored version differs, install the extension (without requirements 3622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // checking) before calling AddExtension. 3632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void AddComponentExtension(const extensions::Extension* extension) 3642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) OVERRIDE; 3652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 366eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch enum ImportStatus { 367eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch IMPORT_STATUS_OK, 368eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch IMPORT_STATUS_UNSATISFIED, 369eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch IMPORT_STATUS_UNRECOVERABLE 370eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch }; 371eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 3728bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Checks an extension's imports. No installed and outdated imports will be 3738bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // stored in |missing_modules| and |outdated_modules|. 3748bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) ImportStatus CheckImports( 3758bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const extensions::Extension* extension, 3768bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) std::list<extensions::SharedModuleInfo::ImportInfo>* missing_modules, 3778bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) std::list<extensions::SharedModuleInfo::ImportInfo>* outdated_modules); 3788bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 379eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Checks an extension's shared module imports to see if they are satisfied. 380eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // If they are not, this function adds the dependencies to the pending install 381eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // list if |extension| came from the webstore. 382eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch ImportStatus SatisfyImports(const extensions::Extension* extension); 383eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 384eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Returns a set of extensions that import a given extension. 385eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch scoped_ptr<const ExtensionSet> GetDependentExtensions( 386eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch const extensions::Extension* extension); 387eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 388eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Uninstalls shared modules that were only referenced by |extension|. 389eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch void PruneSharedModulesOnUninstall(const extensions::Extension* extension); 390eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 3912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Informs the service that an extension's files are in place for loading. 3922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // 393a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) // |page_ordinal| is the location of the extension in the app launcher. 394a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) // |has_requirement_errors| is true if requirements of the extension weren't 395a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) // met (for example graphics capabilities). 396a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) // |blacklist_state| will be BLACKLISTED if the extension is blacklisted. 397a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) // |wait_for_idle| may be false to install the extension immediately. 3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void OnExtensionInstalled( 3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const extensions::Extension* extension, 4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const syncer::StringOrdinal& page_ordinal, 4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool has_requirement_errors, 402a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) extensions::Blacklist::BlacklistState blacklist_state, 4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool wait_for_idle); 4045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 405eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Checks for delayed installation for all pending installs. 406eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch void MaybeFinishDelayedInstallations(); 407eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 4082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Similar to FinishInstallation, but first checks if there still is an update 4092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // pending for the extension, and makes sure the extension is still idle. 4102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void MaybeFinishDelayedInstallation(const std::string& extension_id); 4112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Finishes installation of an update for an extension with the specified id, 4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // when installation of that extension was previously delayed because the 4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // extension was in use. 4152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void FinishDelayedInstallation( 4162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const std::string& extension_id) OVERRIDE; 4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Returns an update for an extension with the specified id, if installation 4192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // of that update was previously delayed because the extension was in use. If 4202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // no updates are pending for the extension returns NULL. 4212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual const extensions::Extension* GetPendingExtensionUpdate( 4222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const std::string& extension_id) const OVERRIDE; 4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Go through each extension and unload those that are not allowed to run by 4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // management policy providers (ie. network admin and Google-managed 4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // blacklist). 4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void CheckManagementPolicy() OVERRIDE; 4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void CheckForUpdatesSoon() OVERRIDE; 4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void set_extensions_enabled(bool enabled) { extensions_enabled_ = enabled; } 4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool extensions_enabled() { return extensions_enabled_; } 4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void set_show_extensions_prompts(bool enabled) { 4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) show_extensions_prompts_ = enabled; 4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool show_extensions_prompts() { 4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return show_extensions_prompts_; 4405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Profile* profile(); 4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(skerner): Change to const ExtensionPrefs& extension_prefs() const, 4455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // ExtensionPrefs* mutable_extension_prefs(). 4465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) extensions::ExtensionPrefs* extension_prefs(); 4478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const extensions::ExtensionPrefs* extension_prefs() const; 4485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) extensions::SettingsFrontend* settings_frontend(); 4505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4511e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void set_extension_sync_service( 4521e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) ExtensionSyncService* extension_sync_service) { 4531e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) extension_sync_service_ = extension_sync_service; 4541e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) } 4551e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 4565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) extensions::ContentSettingsStore* GetContentSettingsStore(); 4575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether the extension service is ready. 4595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool is_ready() OVERRIDE; 4605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual base::SequencedTaskRunner* GetFileTaskRunner() OVERRIDE; 4622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) extensions::ComponentLoader* component_loader() { 4645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return component_loader_.get(); 4655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Note that this may return NULL if autoupdate is not turned on. 4685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) extensions::ExtensionUpdater* updater(); 4695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 470f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) extensions::QuotaService* quota_service() { return "a_service_; } 4715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 472f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Sets the name, id and icon resource path of the given extension into the 473f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // returned dictionary. Returns an empty dictionary if the given extension id 474f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // is not found. 475f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) scoped_ptr<DictionaryValue> GetExtensionInfo( 476f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) const std::string& extension_id) const; 4775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Notify the frontend that there was an error loading an extension. 4795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This method is public because UnpackedInstaller and InstalledLoader 4805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // can post to here. 4815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(aa): Remove this. It doesn't do enough to be worth the dependency 4825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // of these classes on ExtensionService. 4832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void ReportExtensionLoadError(const base::FilePath& extension_path, 4845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& error, 4855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool be_noisy); 4865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // ExtensionHost of background page calls this method right after its render 4885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // view has been created. 4895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void DidCreateRenderViewForBackgroundPage(extensions::ExtensionHost* host); 4905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // For the extension in |version_path| with |id|, check to see if it's an 4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // externally managed extension. If so, uninstall it. 4935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void CheckExternalUninstall(const std::string& id); 4945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Changes sequenced task runner for crx installation tasks to |task_runner|. 4962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void SetFileTaskRunnerForTesting(base::SequencedTaskRunner* task_runner); 4972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Clear all ExternalProviders. 4995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void ClearProvidersForTesting(); 5005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Adds an ExternalProviderInterface for the service to use during testing. 5025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Takes ownership of |test_provider|. 5035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void AddProviderForTesting( 5045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) extensions::ExternalProviderInterface* test_provider); 5055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // ExternalProvider::Visitor implementation. 5075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool OnExternalExtensionFileFound( 5085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& id, 509c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) const base::Version* version, 5102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const base::FilePath& path, 5112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) extensions::Manifest::Location location, 5125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int creation_flags, 5135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool mark_acknowledged) OVERRIDE; 5145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool OnExternalExtensionUpdateUrlFound( 5165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& id, 5175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const GURL& update_url, 5184e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) extensions::Manifest::Location location, 5194e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) int creation_flags, 5204e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) bool mark_acknowledged) OVERRIDE; 5215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnExternalProviderReady( 5235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const extensions::ExternalProviderInterface* provider) OVERRIDE; 5245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true when all the external extension providers are ready. 5265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool AreAllExternalProvidersReady() const; 5275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void OnAllExternalProvidersReady(); 5295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Once all external providers are done, generates any needed alerts about 5315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // extensions. 5325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void IdentifyAlertableExtensions(); 5335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Given an ExtensionErrorUI alert, populates it with any extensions that 5355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // need alerting. Returns true if the alert should be displayed at all. 5365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 5375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This method takes the extension_error_ui argument rather than using 5385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the member variable to make it easier to test the method in isolation. 5395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool PopulateExtensionErrorUI(ExtensionErrorUI* extension_error_ui); 5405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Checks if there are any new external extensions to notify the user about. 5425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void UpdateExternalExtensionAlert(); 5435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Given a (presumably just-installed) extension id, mark that extension as 5455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // acknowledged. 5465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void AcknowledgeExternalExtension(const std::string& id); 5475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if this extension is an external one that has yet to be 5495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // marked as acknowledged. 5505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool IsUnacknowledgedExternalExtension( 5515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const extensions::Extension* extension); 5525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5534e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // Disable extensions that are known to be disabled yet are currently enabled. 5544e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) void ReconcileKnownDisabled(); 5554e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 5565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Opens the Extensions page because the user wants to get more details 5575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // about the alerts. 5585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void HandleExtensionAlertDetails(); 5595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 560c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Called when the extension alert is closed. Updates prefs and deletes 561c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // the active |extension_error_ui_|. 5625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void HandleExtensionAlertClosed(); 5635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Marks alertable extensions as acknowledged, after the user presses the 5655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // accept button. 5665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void HandleExtensionAlertAccept(); 5675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // content::NotificationObserver 5695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Observe(int type, 5705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::NotificationSource& source, 5715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::NotificationDetails& details) OVERRIDE; 5725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether there are any apps installed. Component apps are not included. 5745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool HasApps() const; 5755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Gets the set of loaded app ids. Component apps are not included. 5775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) extensions::ExtensionIdSet GetAppIds() const; 5785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Record a histogram using the PermissionMessage enum values for each 5805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // permission in |e|. 5815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NOTE: If this is ever called with high frequency, the implementation may 5825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // need to be made more efficient. 5835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static void RecordPermissionMessagesHistogram( 5845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const extensions::Extension* e, const char* histogram); 5855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(UNIT_TEST) 5875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void TrackTerminatedExtensionForTest(const extensions::Extension* extension) { 5885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TrackTerminatedExtension(extension); 5895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 5905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void FinishInstallationForTest(const extensions::Extension* extension) { 5922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) FinishInstallation(extension); 5935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 5942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif 5955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::WeakPtr<ExtensionService> AsWeakPtr() { return base::AsWeakPtr(this); } 5975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool browser_terminating() const { return browser_terminating_; } 5995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // For testing. 6015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void set_browser_terminating_for_test(bool value) { 6025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) browser_terminating_ = value; 6035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 6045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // By default ExtensionService will wait with installing an updated extension 6062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // until the extension is idle. Tests might not like this behavior, so you can 6072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // disable it with this method. 6082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void set_install_updates_when_idle_for_test(bool value) { 6092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) install_updates_when_idle_ = value; 6102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 6112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 612f60fc993c7b081abf77ce2ffc7fcca1142c8cb01Torne (Richard Coles) // Set a callback to be called when all external providers are ready and their 613f60fc993c7b081abf77ce2ffc7fcca1142c8cb01Torne (Richard Coles) // extensions have been installed. 614f60fc993c7b081abf77ce2ffc7fcca1142c8cb01Torne (Richard Coles) void set_external_updates_finished_callback_for_test( 615f60fc993c7b081abf77ce2ffc7fcca1142c8cb01Torne (Richard Coles) const base::Closure& callback) { 616f60fc993c7b081abf77ce2ffc7fcca1142c8cb01Torne (Richard Coles) external_updates_finished_callback_ = callback; 617f60fc993c7b081abf77ce2ffc7fcca1142c8cb01Torne (Richard Coles) } 618f60fc993c7b081abf77ce2ffc7fcca1142c8cb01Torne (Richard Coles) 6192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Adds/Removes update observers. 6202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void AddUpdateObserver(extensions::UpdateObserver* observer); 6212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void RemoveUpdateObserver(extensions::UpdateObserver* observer); 6222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 62358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#if defined(OS_CHROMEOS) 62458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) void disable_garbage_collection() { 62558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) disable_garbage_collection_ = true; 62658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) } 62758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) void enable_garbage_collection() { 62858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) disable_garbage_collection_ = false; 62958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) } 63058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#endif 63158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 6325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 6335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Contains Extension data that can change during the life of the process, 6345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // but does not persist across restarts. 6355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) struct ExtensionRuntimeData { 6365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // True if the background page is ready. 6375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool background_page_ready; 6385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // True while the extension is being upgraded. 6405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool being_upgraded; 6415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // True if the extension has used the webRequest API. 6435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool has_used_webrequest; 6445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ExtensionRuntimeData(); 6465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ~ExtensionRuntimeData(); 6475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 6485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) typedef std::map<std::string, ExtensionRuntimeData> ExtensionRuntimeDataMap; 6495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 65090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Signals *ready_ and sends a notification to the listeners. 651c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void SetReadyAndNotifyListeners(); 652c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 6535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Return true if the sync type of |extension| matches |type|. 6542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void OnExtensionInstallPrefChanged(); 6552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Adds the given extension to the list of terminated extensions if 6575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // it is not already there and unloads it. 6585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void TrackTerminatedExtension(const extensions::Extension* extension); 6595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Removes the extension with the given id from the list of 6615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // terminated extensions if it is there. 6625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void UntrackTerminatedExtension(const std::string& id); 6635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Update preferences for a new or updated extension; notify observers that 6652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // the extension is installed, e.g., to update event handlers on background 6662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // pages; and perform other extension install tasks before calling 6672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // AddExtension. 668a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) void AddNewOrUpdatedExtension( 669a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) const extensions::Extension* extension, 670a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) extensions::Extension::State initial_state, 671a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) extensions::Blacklist::BlacklistState blacklist_state, 672a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) const syncer::StringOrdinal& page_ordinal); 6732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Handles sending notification that |extension| was loaded. 6755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void NotifyExtensionLoaded(const extensions::Extension* extension); 6765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Handles sending notification that |extension| was unloaded. 6781e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void NotifyExtensionUnloaded( 6791e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) const extensions::Extension* extension, 6801e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) extensions::UnloadedExtensionInfo::Reason reason); 6815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Common helper to finish installing the given extension. 6832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void FinishInstallation(const extensions::Extension* extension); 6842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 685c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Updates the |extension|'s active permission set to include only permissions 686c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // currently requested by the extension and all the permissions required by 687c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // the extension. 688c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void UpdateActivePermissions(const extensions::Extension* extension); 689c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 690c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Disables the extension if the privilege level has increased 691c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // (e.g., due to an upgrade). 692c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void CheckPermissionsIncrease(const extensions::Extension* extension, 693ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch bool is_extension_installed); 694c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 6955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Helper that updates the active extension list used for crash reporting. 6965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void UpdateActiveExtensionsInCrashReporter(); 6975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Helper to determine whether we should initially enable an installed 6995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // (or upgraded) extension. 7005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool ShouldEnableOnInstall(const extensions::Extension* extension); 7015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Helper to determine if an extension is idle, and it should be safe 7035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // to update the extension. 7045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool IsExtensionIdle(const std::string& extension_id) const; 7055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Helper to determine if updating an extensions should proceed immediately, 7072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // or if we should delay the update until further notice. 7082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool ShouldDelayExtensionUpdate(const std::string& extension_id, 7092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool wait_for_idle) const; 7102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Helper to search storage directories for extensions with isolated storage 7122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // that have been orphaned by an uninstall. 7132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void GarbageCollectIsolatedStorage(); 7142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void OnGarbageCollectIsolatedStorageFinished(); 7152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void OnNeedsToGarbageCollectIsolatedStorage(); 7162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // extensions::Blacklist::Observer implementation. 7182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void OnBlacklistUpdated() OVERRIDE; 7192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Manages the blacklisted extensions, intended as callback from 7212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Blacklist::GetBlacklistedIDs. 72268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) void ManageBlacklist(const std::set<std::string>& blacklisted_ids); 7232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 724eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Controls if installs are delayed. See comment for 725eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // |installs_delayed_for_gc_|. 726eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch void set_installs_delayed_for_gc(bool value) { 727eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch installs_delayed_for_gc_ = value; 728eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch } 729eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch bool installs_delayed_for_gc() const { return installs_delayed_for_gc_; } 7302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The normal profile associated with this ExtensionService. 7325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Profile* profile_; 7335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The ExtensionSystem for the profile above. 7355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) extensions::ExtensionSystem* system_; 7365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Preferences for the owning profile. 7385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) extensions::ExtensionPrefs* extension_prefs_; 7395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Blacklist for the owning profile. 7412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) extensions::Blacklist* blacklist_; 7422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Settings for the owning profile. 7445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<extensions::SettingsFrontend> settings_frontend_; 7455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // The ExtensionSyncService that is used by this ExtensionService. 7471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) ExtensionSyncService* extension_sync_service_; 7481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 7495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The current list of installed extensions. 7505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ExtensionSet extensions_; 7515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The list of installed extensions that have been disabled. 7535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ExtensionSet disabled_extensions_; 7545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The list of installed extensions that have been terminated. 7565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ExtensionSet terminated_extensions_; 7575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // The list of installed extensions that have been blacklisted. Generally 7592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // these shouldn't be considered as installed by the extension platform: we 7602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // only keep them around so that if extensions are blacklisted by mistake 7612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // they can easily be un-blacklisted. 7622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ExtensionSet blacklisted_extensions_; 7632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 764eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // The list of extension installs delayed for various reasons. The reason 765eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // for delayed install is stored in ExtensionPrefs. 7662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ExtensionSet delayed_installs_; 7675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Hold the set of pending extensions. 7695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) extensions::PendingExtensionManager pending_extension_manager_; 7705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The map of extension IDs to their runtime data. 7725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ExtensionRuntimeDataMap extension_runtime_data_; 7735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The full path to the directory where extensions are installed. 7752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::FilePath install_directory_; 7765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether or not extensions are enabled. 7785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool extensions_enabled_; 7795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether to notify users when they attempt to install an extension. 7815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool show_extensions_prompts_; 7825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Whether to delay installing of extension updates until the extension is 7842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // idle. 7852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool install_updates_when_idle_; 7862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Used by dispatchers to limit API quota for individual extensions. 788f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) extensions::QuotaService quota_service_; 7895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 79090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Signaled when all extensions are loaded. 79190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) extensions::OneShotEvent* const ready_; 7925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Our extension updater, if updates are turned on. 7945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<extensions::ExtensionUpdater> updater_; 7955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Map unloaded extensions' ids to their paths. When a temporarily loaded 7975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // extension is unloaded, we lose the information about it and don't have 7985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // any in the extension preferences file. 7992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) typedef std::map<std::string, base::FilePath> UnloadedExtensionPathMap; 8005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) UnloadedExtensionPathMap unloaded_extension_paths_; 8015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 802c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Store the ids of reloading extensions. 803c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) std::set<std::string> reloading_extensions_; 8045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8057dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch // Map of DevToolsAgentHost instances that are detached, 8067dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch // waiting for an extension to be reloaded. 8077dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch typedef std::map<std::string, scoped_refptr<content::DevToolsAgentHost> > 8087dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch OrphanedDevTools; 8095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) OrphanedDevTools orphaned_dev_tools_; 8105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::NotificationRegistrar registrar_; 8125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PrefChangeRegistrar pref_change_registrar_; 8135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Keeps track of loading and unloading component extensions. 8155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<extensions::ComponentLoader> component_loader_; 8165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // A collection of external extension providers. Each provider reads 8185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // a source of external extension information. Examples include the 8195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // windows registry and external_extensions.json. 8205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) extensions::ProviderCollection external_extension_providers_; 8215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Set to true by OnExternalExtensionUpdateUrlFound() when an external 8235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // extension URL is found, and by CheckForUpdatesSoon() when an update check 8245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // has to wait for the external providers. Used in 8255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // OnAllExternalProvidersReady() to determine if an update check is needed to 8265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // install pending extensions. 8275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool update_once_all_providers_are_ready_; 8285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 829f60fc993c7b081abf77ce2ffc7fcca1142c8cb01Torne (Richard Coles) // A callback to be called when all external providers are ready and their 830f60fc993c7b081abf77ce2ffc7fcca1142c8cb01Torne (Richard Coles) // extensions have been installed. Normally this is a null callback, but 831f60fc993c7b081abf77ce2ffc7fcca1142c8cb01Torne (Richard Coles) // is used in external provider related tests. 832f60fc993c7b081abf77ce2ffc7fcca1142c8cb01Torne (Richard Coles) base::Closure external_updates_finished_callback_; 833f60fc993c7b081abf77ce2ffc7fcca1142c8cb01Torne (Richard Coles) 8345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Set when the browser is terminating. Prevents us from installing or 8355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // updating additional extensions and allows in-progress installations to 8365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // decide to abort. 8375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool browser_terminating_; 8385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 839eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Set to true to delay all new extension installations. Acts as a lock to 840eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // allow background processing of garbage collection of on-disk state without 841eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // needing to worry about race conditions caused by extension installation and 842eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // reinstallation. 843eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch bool installs_delayed_for_gc_; 8442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 845c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Set to true if this is the first time this ExtensionService has run. 846c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Used for specially handling external extensions that are installed the 847c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // first time. 848c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) bool is_first_run_; 8492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 8505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) extensions::ProcessMap process_map_; 8515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 852eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // A set of the extension ids currently being reloaded. We use this to 853eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // avoid showing a "new install" notice for an extension reinstall. 854eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch std::set<std::string> extensions_being_reloaded_; 855eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 8565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<ExtensionErrorUI> extension_error_ui_; 8572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Sequenced task runner for extension related file operations. 8582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_refptr<base::SequencedTaskRunner> file_task_runner_; 8595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(ENABLE_EXTENSIONS) 8615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<extensions::ExtensionActionStorageManager> 8625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) extension_action_storage_manager_; 8635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 8643551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_ptr<extensions::ManagementPolicy::Provider> 8653551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) shared_module_policy_provider_; 8665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ObserverList<extensions::UpdateObserver, true> update_observers_; 8682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 86958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#if defined(OS_CHROMEOS) 87058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // TODO(rkc): HACK alert - this is only in place to allow the 87158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // kiosk_mode_screensaver to prevent its extension from getting garbage 87258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // collected. Remove this once KioskModeScreensaver is removed. 87358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // See crbug.com/280363 87458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) bool disable_garbage_collection_; 87558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#endif 87658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 8775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 8785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) InstallAppsWithUnlimtedStorage); 8795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 8805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) InstallAppsAndCheckStorageProtection); 8815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(ExtensionService); 8825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 8835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ 885