172a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Use of this source code is governed by a BSD-style license that can be
3c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// found in the LICENSE file.
4c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
521d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
621d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
73345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#pragma once
8c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
9c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <map>
1072a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#include <set>
11c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <string>
12c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <vector>
13c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
14c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "base/command_line.h"
15c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "base/file_path.h"
16c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "base/gtest_prod_util.h"
17ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "base/memory/linked_ptr.h"
18ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "base/memory/ref_counted.h"
19c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "base/task.h"
20c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "base/time.h"
21c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "base/tuple.h"
22ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "base/version.h"
23ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "chrome/browser/extensions/apps_promo.h"
24c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "chrome/browser/extensions/extension_icon_manager.h"
25c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "chrome/browser/extensions/extension_menu_manager.h"
26c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "chrome/browser/extensions/extension_prefs.h"
27c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "chrome/browser/extensions/extension_process_manager.h"
28c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "chrome/browser/extensions/extension_toolbar_model.h"
29c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "chrome/browser/extensions/extensions_quota_service.h"
3072a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#include "chrome/browser/extensions/external_extension_provider_interface.h"
31ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "chrome/browser/extensions/pending_extension_manager.h"
32c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "chrome/browser/extensions/sandboxed_extension_unpacker.h"
333345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#include "chrome/browser/prefs/pref_change_registrar.h"
34c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "chrome/common/extensions/extension.h"
35dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen#include "content/browser/browser_thread.h"
36ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "content/common/notification_observer.h"
37ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "content/common/notification_registrar.h"
38ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "content/common/property_bag.h"
39c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
4072a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsenclass ExtensionBrowserEventRouter;
41ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenclass ExtensionPreferenceEventRouter;
4221d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsenclass ExtensionServiceBackend;
43ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenstruct ExtensionSyncData;
44c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass ExtensionToolbarModel;
45c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass ExtensionUpdater;
46c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass GURL;
47ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenclass PendingExtensionManager;
48c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass Profile;
49c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass Version;
50c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
51c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// This is an interface class to encapsulate the dependencies that
52ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// various classes have on ExtensionService. This allows easy mocking.
53ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenclass ExtensionServiceInterface {
54c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch public:
55ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual ~ExtensionServiceInterface() {}
56c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual const ExtensionList* extensions() const = 0;
57ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual const ExtensionList* disabled_extensions() const = 0;
58ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual PendingExtensionManager* pending_extension_manager() = 0;
59ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual void UpdateExtension(const std::string& id,
60ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                               const FilePath& path,
61c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                               const GURL& download_url) = 0;
62513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  virtual const Extension* GetExtensionById(const std::string& id,
63ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                                            bool include_disabled) const = 0;
64ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
65ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual bool UninstallExtension(const std::string& extension_id,
66ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                                  bool external_uninstall,
67ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                                  std::string* error) = 0;
68ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
69ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual bool IsExtensionEnabled(const std::string& extension_id) const = 0;
70ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual bool IsExternalExtensionUninstalled(
71ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen      const std::string& extension_id) const = 0;
72ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual void EnableExtension(const std::string& extension_id) = 0;
73ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual void DisableExtension(const std::string& extension_id) = 0;
74ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
75c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual void UpdateExtensionBlacklist(
76c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    const std::vector<std::string>& blacklist) = 0;
773345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  virtual void CheckAdminBlacklist() = 0;
78c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
79ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual bool IsIncognitoEnabled(const std::string& extension_id) const = 0;
80ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual void SetIsIncognitoEnabled(const std::string& extension_id,
81ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                                     bool enabled) = 0;
82ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
83ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Safe to call multiple times in a row.
84ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  //
85ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // TODO(akalin): Remove this method (and others) once we refactor
86ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // themes sync to not use it directly.
87ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual void CheckForUpdatesSoon() = 0;
88ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
89ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Take any actions required to make the local state of the
90ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // extension match the state in |extension_sync_data| (including
91ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // installing/uninstalling the extension).
92ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  //
93ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // TODO(akalin): We'll eventually need a separate method for app
94ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // sync.  See http://crbug.com/58077 and http://crbug.com/61447.
95ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual void ProcessSyncData(
96ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen      const ExtensionSyncData& extension_sync_data,
97ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen      PendingExtensionInfo::ShouldAllowInstallPredicate should_allow) = 0;
98ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
99ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // TODO(akalin): Add a method like:
100ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  //
101ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  //   virtual void
102ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  //     GetInitialSyncData(bool (*filter)(Extension),
103ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  //                        map<string, ExtensionSyncData>* out) const;
104ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  //
105ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // which would fill |out| with sync data for the extensions that
106ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // match |filter|.  Sync would use this for the initial syncing
107ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // step.
108c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch};
109c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
110c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Manages installed and running Chromium extensions.
11121d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsenclass ExtensionService
11221d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen    : public base::RefCountedThreadSafe<ExtensionService,
113731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick                                        BrowserThread::DeleteOnUIThread>,
114ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen      public ExtensionServiceInterface,
11572a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen      public ExternalExtensionProviderInterface::VisitorInterface,
116c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      public NotificationObserver {
117c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch public:
118c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Information about a registered component extension.
119c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  struct ComponentExtensionInfo {
120c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    ComponentExtensionInfo(const std::string& manifest,
121c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                           const FilePath& root_directory)
122c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch        : manifest(manifest),
123c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch          root_directory(root_directory) {
124c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    }
125c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
126c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // The extension's manifest. This is required for component extensions so
12721d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen    // that ExtensionService doesn't need to go to disk to load them.
128c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    std::string manifest;
129c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
130c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // Directory where the extension is stored.
131c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    FilePath root_directory;
132c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  };
133c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
134c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // The name of the directory inside the profile where extensions are
135c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // installed to.
136c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  static const char* kInstallDirectoryName;
137c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
138c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // If auto-updates are turned on, default to running every 5 hours.
139c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  static const int kDefaultUpdateFrequencySeconds = 60 * 60 * 5;
140c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
141c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // The name of the file that the current active version number is stored in.
142c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  static const char* kCurrentVersionFileName;
143c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
144c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Determine if a given extension download should be treated as if it came
145731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick  // from the gallery. Note that this is requires *both* that the download_url
146731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick  // match and that the download was referred from a gallery page.
147731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick  bool IsDownloadFromGallery(const GURL& download_url,
148731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick                             const GURL& referrer_url);
149c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
150c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Determine if the downloaded extension came from the theme mini-gallery,
151c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Used to test if we need to show the "Loading" dialog for themes.
152c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  static bool IsDownloadFromMiniGallery(const GURL& download_url);
153c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
154ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Returns the Extension of hosted or packaged apps, NULL otherwise.
155ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  const Extension* GetInstalledApp(const GURL& url);
156ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
15721d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  // Returns whether the URL is from either a hosted or packaged app.
15821d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  bool IsInstalledApp(const GURL& url);
15921d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen
160731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick  // Attempts to uninstall an extension from a given ExtensionService. Returns
161731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick  // true iff the target extension exists.
16221d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  static bool UninstallExtensionHelper(ExtensionService* extensions_service,
163731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick                                       const std::string& extension_id);
164731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick
16521d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  // Constructor stores pointers to |profile| and |extension_prefs| but
16621d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  // ownership remains at caller.
16721d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  ExtensionService(Profile* profile,
16872a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen                   const CommandLine* command_line,
16972a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen                   const FilePath& install_directory,
17072a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen                   ExtensionPrefs* extension_prefs,
171ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                   bool autoupdate_enabled,
172ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                   bool extensions_enabled);
173c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
174c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Gets the list of currently installed extensions.
17521d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  virtual const ExtensionList* extensions() const;
17621d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  virtual const ExtensionList* disabled_extensions() const;
17772a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  virtual const ExtensionList* terminated_extensions() const;
178c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
179ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Gets the object managing the set of pending extensions.
180ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual PendingExtensionManager* pending_extension_manager();
181c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
182c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Registers an extension to be loaded as a component extension.
183c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void register_component_extension(const ComponentExtensionInfo& info) {
184c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    component_extension_manifests_.push_back(info);
185c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  }
186c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
187731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick  const FilePath& install_directory() const { return install_directory_; }
188731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick
189ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  AppsPromo* apps_promo() { return &apps_promo_; }
190731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick
191c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Whether this extension can run in an incognito window.
192ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual bool IsIncognitoEnabled(const std::string& extension_id) const;
193ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual void SetIsIncognitoEnabled(const std::string& extension_id,
194ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                                     bool enabled);
195513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch
196513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  // Returns true if the given extension can see events and data from another
197513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  // sub-profile (incognito to original profile, or vice versa).
198513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  bool CanCrossIncognito(const Extension* extension);
199c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
200c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Whether this extension can inject scripts into pages with file URLs.
201c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool AllowFileAccess(const Extension* extension);
202ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Will reload the extension since this permission is applied at loading time
203ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // only.
204513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  void SetAllowFileAccess(const Extension* extension, bool allow);
205513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch
206201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // Getter and setter for the Browser Action visibility in the toolbar.
207201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  bool GetBrowserActionVisibility(const Extension* extension);
208201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  void SetBrowserActionVisibility(const Extension* extension, bool visible);
209201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch
210513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  // Whether the background page, if any, is ready. We don't load other
211513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  // components until then. If there is no background page, we consider it to
212513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  // be ready.
213513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  bool IsBackgroundPageReady(const Extension* extension);
214513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  void SetBackgroundPageReady(const Extension* extension);
215513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch
216513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  // Getter and setter for the flag that specifies whether the extension is
217513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  // being upgraded.
218513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  bool IsBeingUpgraded(const Extension* extension);
219513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  void SetBeingUpgraded(const Extension* extension, bool value);
220c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
221201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // Getter for the extension's runtime data PropertyBag.
222201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  PropertyBag* GetPropertyBag(const Extension* extension);
223201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch
224c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Initialize and start all installed extensions.
225c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void Init();
226c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
227c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Start up the extension event routers.
228c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void InitEventRouters();
229c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
230c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Look up an extension by ID.
23121d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  virtual const Extension* GetExtensionById(const std::string& id,
232ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                                            bool include_disabled) const;
233c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
234dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen  // Looks up a terminated (crashed) extension by ID. GetExtensionById does
235dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen  // not include terminated extensions.
236dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen  virtual const Extension* GetTerminatedExtension(const std::string& id);
237c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
238c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Updates a currently-installed extension with the contents from
239c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // |extension_path|.
240c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // TODO(aa): This method can be removed. ExtensionUpdater could use
241c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // CrxInstaller directly instead.
242c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual void UpdateExtension(const std::string& id,
243c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                               const FilePath& extension_path,
244c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                               const GURL& download_url);
245c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
246c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Reloads the specified extension.
247c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void ReloadExtension(const std::string& extension_id);
248c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
249c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Uninstalls the specified extension. Callers should only call this method
250c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // with extensions that exist. |external_uninstall| is a magical parameter
251c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // that is only used to send information to ExtensionPrefs, which external
252c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // callers should never set to true.
253c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // TODO(aa): Remove |external_uninstall| -- this information should be passed
254c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // to ExtensionPrefs some other way.
255ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual bool UninstallExtension(const std::string& extension_id,
256ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                                  bool external_uninstall,
257ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                                  std::string* error);
258ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
259ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual bool IsExtensionEnabled(const std::string& extension_id) const;
260ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual bool IsExternalExtensionUninstalled(
261ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen      const std::string& extension_id) const;
262c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
2633345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // Enable or disable an extension. No action if the extension is already
2643345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // enabled/disabled.
265ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual void EnableExtension(const std::string& extension_id);
266ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual void DisableExtension(const std::string& extension_id);
267c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
268201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // Updates the |extension|'s granted permissions lists to include all
269201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // permissions in the |extension|'s manifest.
270201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  void GrantPermissions(const Extension* extension);
271201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch
272201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // Updates the |extension|'s granted permissions lists to include all
273201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // permissions in the |extension|'s manifest and re-enables the
274201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // extension.
275201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  void GrantPermissionsAndEnableExtension(const Extension* extension);
276201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch
277ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Loads the extension from the directory |extension_path|.
278c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void LoadExtension(const FilePath& extension_path);
279c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
280ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Loads any component extensions.
281c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void LoadComponentExtensions();
282c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
283ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Loads particular component extension.
284ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  const Extension* LoadComponentExtension(const ComponentExtensionInfo& info);
285ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
286ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Loads all known extensions (used by startup and testing code).
287c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void LoadAllExtensions();
288c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
289c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Continues loading all know extensions. It can be called from
290c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // LoadAllExtensions or from file thread if we had to relocalize manifest
291c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // (write_to_prefs is true in that case).
292c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void ContinueLoadAllExtensions(ExtensionPrefs::ExtensionsInfo* info,
293c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                                 base::TimeTicks start_time,
294c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                                 bool write_to_prefs);
295c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
296c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Check for updates (or potentially new extensions from external providers)
297c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void CheckForExternalUpdates();
298c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
299c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Unload the specified extension.
30021d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  void UnloadExtension(const std::string& extension_id,
30121d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen                       UnloadedExtensionInfo::Reason reason);
302c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
303c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Unload all extensions. This is currently only called on shutdown, and
304c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // does not send notifications.
305c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void UnloadAllExtensions();
306c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
307c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Called only by testing.
308c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void ReloadExtensions();
309c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
310c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Scan the extension directory and clean up the cruft.
311c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void GarbageCollectExtensions();
312c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
313731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick  // The App that represents the web store.
314513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  const Extension* GetWebStoreApp();
315731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick
316c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Lookup an extension by |url|.
317513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  const Extension* GetExtensionByURL(const GURL& url);
318c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
319c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // If there is an extension for the specified url it is returned. Otherwise
320c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // returns the extension whose web extent contains |url|.
321513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  const Extension* GetExtensionByWebExtent(const GURL& url);
322c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
323c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns an extension that contains any URL that overlaps with the given
324c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // extent, if one exists.
325513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  const Extension* GetExtensionByOverlappingWebExtent(
326513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch      const ExtensionExtent& extent);
327c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
3283345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // Returns true if |url| should get extension api bindings and be permitted
3293345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // to make api calls. Note that this is independent of what extension
3303345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // permissions the given extension has been granted.
3313345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  bool ExtensionBindingsAllowed(const GURL& url);
3323345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick
333c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns the icon to display in the omnibox for the given extension.
334c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  const SkBitmap& GetOmniboxIcon(const std::string& extension_id);
335c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
3363345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // Returns the icon to display in the omnibox popup window for the given
3373345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // extension.
3383345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  const SkBitmap& GetOmniboxPopupIcon(const std::string& extension_id);
3393345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick
340c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Called when the initial extensions load has completed.
341c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual void OnLoadedInstalledExtensions();
342c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
34372a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // Adds |extension| to this ExtensionService and notifies observers than an
34472a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // extension has been loaded.  Called by the backend after an extension has
34572a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // been loaded from a file and installed.
34672a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  void AddExtension(const Extension* extension);
347c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
348c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Called by the backend when an extension has been installed.
349201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  void OnExtensionInstalled(const Extension* extension);
350c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
351201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // Checks if the privileges requested by |extension| have increased, and if
352201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // so, disables the extension and prompts the user to approve the change.
353201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  void DisableIfPrivilegeIncrease(const Extension* extension);
354201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch
355c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Go through each extensions in pref, unload blacklisted extensions
356c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // and update the blacklist state in pref.
357c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual void UpdateExtensionBlacklist(
358c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    const std::vector<std::string>& blacklist);
359c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
3603345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // Go through each extension and unload those that the network admin has
3613345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // put on the blacklist (not to be confused with the Google managed blacklist
3623345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // set of extensions.
3633345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  virtual void CheckAdminBlacklist();
3643345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick
365ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual void CheckForUpdatesSoon();
366ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
367ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual void ProcessSyncData(
368ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen      const ExtensionSyncData& extension_sync_data,
369ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen      PendingExtensionInfo::ShouldAllowInstallPredicate
370ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen          should_allow_install);
371ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
372c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void set_extensions_enabled(bool enabled) { extensions_enabled_ = enabled; }
373c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool extensions_enabled() { return extensions_enabled_; }
374c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
375c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void set_show_extensions_prompts(bool enabled) {
376c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    show_extensions_prompts_ = enabled;
377c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  }
378c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
379c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool show_extensions_prompts() {
380c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    return show_extensions_prompts_;
381c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  }
382c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
383ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  Profile* profile();
384c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
3853345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // Profile calls this when it is being destroyed so that we know not to call
3863345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // it.
3873345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  void DestroyingProfile();
388c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
389ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // TODO(skerner): Change to const ExtensionPrefs& extension_prefs() const,
390ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // ExtensionPrefs* mutable_extension_prefs().
391ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  ExtensionPrefs* extension_prefs();
392c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
393c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Whether the extension service is ready.
394201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // TODO(skerner): Get rid of this method.  crbug.com/63756
395c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool is_ready() { return ready_; }
396c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
397c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Note that this may return NULL if autoupdate is not turned on.
398ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  ExtensionUpdater* updater();
399c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
400c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  ExtensionToolbarModel* toolbar_model() { return &toolbar_model_; }
401c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
402c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  ExtensionsQuotaService* quota_service() { return &quota_service_; }
403c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
404c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  ExtensionMenuManager* menu_manager() { return &menu_manager_; }
405c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
40672a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  ExtensionBrowserEventRouter* browser_event_router() {
40772a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen    return browser_event_router_.get();
40872a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  }
40972a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen
410c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Notify the frontend that there was an error loading an extension.
41121d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  // This method is public because ExtensionServiceBackend can post to here.
412c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void ReportExtensionLoadError(const FilePath& extension_path,
413c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                                const std::string& error,
414c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                                NotificationType type,
415c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                                bool be_noisy);
416c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
4173345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // ExtensionHost of background page calls this method right after its render
4183345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // view has been created.
4193345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  void DidCreateRenderViewForBackgroundPage(ExtensionHost* host);
4203345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick
42172a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // For the extension in |version_path| with |id|, check to see if it's an
42272a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // externally managed extension.  If so, uninstall it.
42372a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  void CheckExternalUninstall(const std::string& id);
42472a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen
42572a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // Clear all ExternalExtensionProviders.
42672a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  void ClearProvidersForTesting();
42772a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen
42872a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // Adds an ExternalExtensionProviderInterface for the service to use during
42972a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // testing. Takes ownership of |test_provider|.
43072a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  void AddProviderForTesting(ExternalExtensionProviderInterface* test_provider);
43172a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen
43272a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // ExternalExtensionProvider::Visitor implementation.
43372a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  virtual void OnExternalExtensionFileFound(const std::string& id,
43472a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen                                            const Version* version,
43572a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen                                            const FilePath& path,
43672a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen                                            Extension::Location location);
43772a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen
43872a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  virtual void OnExternalExtensionUpdateUrlFound(const std::string& id,
43972a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen                                                 const GURL& update_url,
44072a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen                                                 Extension::Location location);
44172a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen
44272a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  virtual void OnExternalProviderReady();
44372a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen
444c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // NotificationObserver
445c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual void Observe(NotificationType type,
446c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                       const NotificationSource& source,
447c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                       const NotificationDetails& details);
448c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
449731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick  // Whether there are any apps installed. Component apps are not included.
450731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick  bool HasApps() const;
451731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick
452731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick  // Gets the set of loaded app ids. Component apps are not included.
453731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick  ExtensionIdSet GetAppIds() const;
454c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
455ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Record a histogram using the PermissionMessage enum values for each
456ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // permission in |e|.
457ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // NOTE: If this is ever called with high frequency, the implementation may
458ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // need to be made more efficient.
459ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  static void RecordPermissionMessagesHistogram(
460ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen      const Extension* e, const char* histogram);
461ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
462c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch private:
463dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen  friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>;
46421d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  friend class DeleteTask<ExtensionService>;
465c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
466513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  // Contains Extension data that can change during the life of the process,
467513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  // but does not persist across restarts.
468513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  struct ExtensionRuntimeData {
469513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch    // True if the background page is ready.
470513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch    bool background_page_ready;
471513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch
472513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch    // True while the extension is being upgraded.
473513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch    bool being_upgraded;
474513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch
475201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch    // Generic bag of runtime data that users can associate with extensions.
476201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch    PropertyBag property_bag;
477201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch
478513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch    ExtensionRuntimeData();
479513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch    ~ExtensionRuntimeData();
480513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  };
481513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  typedef std::map<std::string, ExtensionRuntimeData> ExtensionRuntimeDataMap;
482513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch
483ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  struct NaClModuleInfo {
484ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen    NaClModuleInfo();
485ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen    ~NaClModuleInfo();
486ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
487ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen    GURL url;
488ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen    std::string mime_type;
489ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  };
490ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  typedef std::list<NaClModuleInfo> NaClModuleInfoList;
491ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
49221d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  virtual ~ExtensionService();
493513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch
494c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Clear all persistent data that may have been stored by the extension.
495c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void ClearExtensionData(const GURL& extension_url);
496c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
497c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Look up an extension by ID, optionally including either or both of enabled
498c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // and disabled extensions.
499513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  const Extension* GetExtensionByIdInternal(const std::string& id,
500513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch                                            bool include_enabled,
501ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                                            bool include_disabled) const;
502c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
50372a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen
50472a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // Keep track of terminated extensions.
50572a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  void TrackTerminatedExtension(const Extension* extension);
50672a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  void UntrackTerminatedExtension(const std::string& id);
50772a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen
508c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Handles sending notification that |extension| was loaded.
509513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  void NotifyExtensionLoaded(const Extension* extension);
510c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
511c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Handles sending notification that |extension| was unloaded.
51221d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  void NotifyExtensionUnloaded(const Extension* extension,
51321d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen                               UnloadedExtensionInfo::Reason reason);
514c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
515c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Helper that updates the active extension list used for crash reporting.
516c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void UpdateActiveExtensionsInCrashReporter();
517c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
518c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Helper method. Loads extension from prefs.
5193345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  void LoadInstalledExtension(const ExtensionInfo& info, bool write_to_prefs);
5203345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick
521ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // We implement some Pepper plug-ins using NaCl to take advantage of NaCl's
522ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // strong sandbox. Typically, these NaCl modules are stored in extensions
523ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // and registered here. Not all NaCl modules need to register for a MIME
524ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // type, just the ones that are responsible for rendering a particular MIME
525ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // type, like application/pdf. Note: We only register NaCl modules in the
526ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // browser process.
527ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  void RegisterNaClModule(const GURL& url, const std::string& mime_type);
528ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  void UnregisterNaClModule(const GURL& url);
529ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
530ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Call UpdatePluginListWithNaClModules() after registering or unregistering
531ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // a NaCl module to see those changes reflected in the PluginList.
532ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  void UpdatePluginListWithNaClModules();
533ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
534ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  NaClModuleInfoList::iterator FindNaClModule(const GURL& url);
535ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
53621d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  // The profile this ExtensionService is part of.
537c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  Profile* profile_;
538c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
53921d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  // Preferences for the owning profile (weak reference).
54021d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  ExtensionPrefs* extension_prefs_;
541c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
542c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // The current list of installed extensions.
54372a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // TODO(aa): This should use chrome/common/extensions/extension_set.h.
544c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  ExtensionList extensions_;
545c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
546c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // The list of installed extensions that have been disabled.
547c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  ExtensionList disabled_extensions_;
548c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
54972a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // The list of installed extensions that have been terminated.
55072a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  ExtensionList terminated_extensions_;
55172a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen
55272a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // Used to quickly check if an extension was terminated.
55372a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  std::set<std::string> terminated_extension_ids_;
55472a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen
555ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Hold the set of pending extensions.
556ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  PendingExtensionManager pending_extension_manager_;
557c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
558513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  // The map of extension IDs to their runtime data.
559513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  ExtensionRuntimeDataMap extension_runtime_data_;
560513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch
561c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // The full path to the directory where extensions are installed.
562c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  FilePath install_directory_;
563c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
564c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Whether or not extensions are enabled.
565c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool extensions_enabled_;
566c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
567c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Whether to notify users when they attempt to install an extension.
568c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool show_extensions_prompts_;
569c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
570c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // The backend that will do IO on behalf of this instance.
57121d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  scoped_refptr<ExtensionServiceBackend> backend_;
572c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
573c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Used by dispatchers to limit API quota for individual extensions.
574c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  ExtensionsQuotaService quota_service_;
575c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
576201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // Record that Init() has been called, and NotificationType::EXTENSIONS_READY
577201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // has fired.
578c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool ready_;
579c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
580c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Our extension updater, if updates are turned on.
581ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  scoped_ptr<ExtensionUpdater> updater_;
582c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
583c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // The model that tracks extensions with BrowserAction buttons.
584c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  ExtensionToolbarModel toolbar_model_;
585c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
586c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Map unloaded extensions' ids to their paths. When a temporarily loaded
587c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // extension is unloaded, we lose the infomation about it and don't have
588c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // any in the extension preferences file.
589c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  typedef std::map<std::string, FilePath> UnloadedExtensionPathMap;
590c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  UnloadedExtensionPathMap unloaded_extension_paths_;
591c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
5923345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // Map disabled extensions' ids to their paths. When a temporarily loaded
5933345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // extension is disabled before it is reloaded, keep track of the path so that
5943345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // it can be re-enabled upon a successful load.
5953345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  typedef std::map<std::string, FilePath> DisabledExtensionPathMap;
5963345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  DisabledExtensionPathMap disabled_extension_paths_;
5973345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick
598c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Map of inspector cookies that are detached, waiting for an extension to be
599c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // reloaded.
600c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  typedef std::map<std::string, int> OrphanedDevTools;
601c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  OrphanedDevTools orphaned_dev_tools_;
602c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
603c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  NotificationRegistrar registrar_;
6043345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  PrefChangeRegistrar pref_change_registrar_;
605c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
606c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Keeps track of menu items added by extensions.
607c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  ExtensionMenuManager menu_manager_;
608c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
609c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Keeps track of favicon-sized omnibox icons for extensions.
610c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  ExtensionIconManager omnibox_icon_manager_;
6113345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  ExtensionIconManager omnibox_popup_icon_manager_;
612c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
613c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // List of registered component extensions (see Extension::Location).
614c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions;
615c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  RegisteredComponentExtensions component_extension_manifests_;
616c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
617ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Manages the promotion of the web store.
618ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  AppsPromo apps_promo_;
619731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick
620731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick  // Flag to make sure event routers are only initialized once.
621731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick  bool event_routers_initialized_;
622731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick
62372a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  scoped_ptr<ExtensionBrowserEventRouter> browser_event_router_;
62472a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen
625ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  scoped_ptr<ExtensionPreferenceEventRouter> preference_event_router_;
626ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
62772a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // A collection of external extension providers.  Each provider reads
62872a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // a source of external extension information.  Examples include the
62972a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // windows registry and external_extensions.json.
63072a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  ProviderCollection external_extension_providers_;
63172a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen
63272a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // Set to true by OnExternalExtensionUpdateUrlFound() when an external
63372a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // extension URL is found.  Used in CheckForExternalUpdates() to see
63472a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // if an update check is needed to install pending extensions.
63572a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  bool external_extension_url_added_;
63672a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen
637ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  NaClModuleInfoList nacl_module_list_;
638ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
63921d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
6403345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick                           InstallAppsWithUnlimtedStorage);
64121d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
6423345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick                           InstallAppsAndCheckStorageProtection);
64321d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  DISALLOW_COPY_AND_ASSIGN(ExtensionService);
644c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch};
645c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
64621d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#endif  // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
647