Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(624)

Side by Side Diff: chrome/browser/extensions/extension_service.h

Issue 10382149: Refactor the various ways to control what users can do to extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
17 #include "base/file_path.h" 17 #include "base/file_path.h"
18 #include "base/gtest_prod_util.h" 18 #include "base/gtest_prod_util.h"
19 #include "base/memory/linked_ptr.h" 19 #include "base/memory/linked_ptr.h"
20 #include "base/memory/ref_counted.h" 20 #include "base/memory/ref_counted.h"
21 #include "base/memory/weak_ptr.h" 21 #include "base/memory/weak_ptr.h"
22 #include "base/property_bag.h" 22 #include "base/property_bag.h"
23 #include "base/string16.h"
23 #include "base/time.h" 24 #include "base/time.h"
24 #include "base/tuple.h" 25 #include "base/tuple.h"
25 #include "chrome/browser/extensions/app_shortcut_manager.h" 26 #include "chrome/browser/extensions/app_shortcut_manager.h"
26 #include "chrome/browser/extensions/app_sync_bundle.h" 27 #include "chrome/browser/extensions/app_sync_bundle.h"
27 #include "chrome/browser/extensions/apps_promo.h" 28 #include "chrome/browser/extensions/apps_promo.h"
28 #include "chrome/browser/extensions/extension_icon_manager.h" 29 #include "chrome/browser/extensions/extension_icon_manager.h"
29 #include "chrome/browser/extensions/extension_menu_manager.h" 30 #include "chrome/browser/extensions/extension_menu_manager.h"
30 #include "chrome/browser/extensions/extension_prefs.h" 31 #include "chrome/browser/extensions/extension_prefs.h"
31 #include "chrome/browser/extensions/extension_process_manager.h" 32 #include "chrome/browser/extensions/extension_process_manager.h"
32 #include "chrome/browser/extensions/extension_sync_bundle.h" 33 #include "chrome/browser/extensions/extension_sync_bundle.h"
33 #include "chrome/browser/extensions/extension_toolbar_model.h" 34 #include "chrome/browser/extensions/extension_toolbar_model.h"
34 #include "chrome/browser/extensions/extension_warning_set.h" 35 #include "chrome/browser/extensions/extension_warning_set.h"
35 #include "chrome/browser/extensions/extensions_quota_service.h" 36 #include "chrome/browser/extensions/extensions_quota_service.h"
36 #include "chrome/browser/extensions/external_extension_provider_interface.h" 37 #include "chrome/browser/extensions/external_extension_provider_interface.h"
38 #include "chrome/browser/extensions/management_policy.h"
37 #include "chrome/browser/extensions/pending_extension_manager.h" 39 #include "chrome/browser/extensions/pending_extension_manager.h"
38 #include "chrome/browser/extensions/process_map.h" 40 #include "chrome/browser/extensions/process_map.h"
39 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h" 41 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h"
40 #include "chrome/browser/prefs/pref_change_registrar.h" 42 #include "chrome/browser/prefs/pref_change_registrar.h"
41 #include "chrome/common/extensions/extension.h" 43 #include "chrome/common/extensions/extension.h"
42 #include "chrome/common/extensions/extension_constants.h" 44 #include "chrome/common/extensions/extension_constants.h"
43 #include "chrome/common/extensions/extension_set.h" 45 #include "chrome/common/extensions/extension_set.h"
44 #include "content/public/browser/browser_thread.h" 46 #include "content/public/browser/browser_thread.h"
45 #include "content/public/browser/notification_observer.h" 47 #include "content/public/browser/notification_observer.h"
46 #include "content/public/browser/notification_registrar.h" 48 #include "content/public/browser/notification_registrar.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 136
135 virtual void SyncExtensionChangeIfNeeded( 137 virtual void SyncExtensionChangeIfNeeded(
136 const extensions::Extension& extension) = 0; 138 const extensions::Extension& extension) = 0;
137 139
138 virtual bool is_ready() = 0; 140 virtual bool is_ready() = 0;
139 }; 141 };
140 142
141 // Manages installed and running Chromium extensions. 143 // Manages installed and running Chromium extensions.
142 class ExtensionService 144 class ExtensionService
143 : public ExtensionServiceInterface, 145 : public ExtensionServiceInterface,
146 public extensions::ManagementPolicy::Provider,
144 public ExternalExtensionProviderInterface::VisitorInterface, 147 public ExternalExtensionProviderInterface::VisitorInterface,
145 public base::SupportsWeakPtr<ExtensionService>, 148 public base::SupportsWeakPtr<ExtensionService>,
146 public content::NotificationObserver { 149 public content::NotificationObserver {
147 public: 150 public:
148 using base::SupportsWeakPtr<ExtensionService>::AsWeakPtr; 151 using base::SupportsWeakPtr<ExtensionService>::AsWeakPtr;
149 152
150 // The name of the directory inside the profile where extensions are 153 // The name of the directory inside the profile where extensions are
151 // installed to. 154 // installed to.
152 static const char* kInstallDirectoryName; 155 static const char* kInstallDirectoryName;
153 156
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // callers should never set to true. 325 // callers should never set to true.
323 // 326 //
324 // We pass the |extension_id| by value to avoid having it deleted from under 327 // We pass the |extension_id| by value to avoid having it deleted from under
325 // us incase someone calls it with Extension::id() or another string that we 328 // us incase someone calls it with Extension::id() or another string that we
326 // are going to delete in this function. 329 // are going to delete in this function.
327 // 330 //
328 // TODO(aa): Remove |external_uninstall| -- this information should be passed 331 // TODO(aa): Remove |external_uninstall| -- this information should be passed
329 // to ExtensionPrefs some other way. 332 // to ExtensionPrefs some other way.
330 virtual bool UninstallExtension(std::string extension_id, 333 virtual bool UninstallExtension(std::string extension_id,
331 bool external_uninstall, 334 bool external_uninstall,
332 std::string* error); 335 string16* error);
333 336
334 virtual bool IsExtensionEnabled( 337 virtual bool IsExtensionEnabled(
335 const std::string& extension_id) const OVERRIDE; 338 const std::string& extension_id) const OVERRIDE;
336 virtual bool IsExternalExtensionUninstalled( 339 virtual bool IsExternalExtensionUninstalled(
337 const std::string& extension_id) const OVERRIDE; 340 const std::string& extension_id) const OVERRIDE;
338 341
342 // ManagementPolicy::Provider
343 // The ExtensionService exposes any restrictions imposed by an individual
Aaron Boodman 2012/05/22 15:56:11 This comment doesn't seem correct compared to the
344 // extension.
345 virtual std::string PolicyProviderName() const OVERRIDE;
346 virtual bool UserMayModifyStatus(const extensions::Extension* extension,
347 string16* error) const OVERRIDE;
348 virtual bool MustRemainEnabled(const extensions::Extension* extension,
349 string16* error) const OVERRIDE;
350
339 // Enables the extension. If the extension is already enabled, does 351 // Enables the extension. If the extension is already enabled, does
340 // nothing. 352 // nothing.
341 virtual void EnableExtension(const std::string& extension_id); 353 virtual void EnableExtension(const std::string& extension_id);
342 354
343 // Disables the extension. If the extension is already disabled, or 355 // Disables the extension. If the extension is already disabled, or
344 // cannot be disabled, does nothing. 356 // cannot be disabled, does nothing.
345 virtual void DisableExtension(const std::string& extension_id, 357 virtual void DisableExtension(const std::string& extension_id,
346 extensions::Extension::DisableReason disable_reason); 358 extensions::Extension::DisableReason disable_reason);
347 359
348 // Updates the |extension|'s granted permissions lists to include all 360 // Updates the |extension|'s granted permissions lists to include all
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 // Initializes the |extension|'s active permission set and disables the 415 // Initializes the |extension|'s active permission set and disables the
404 // extension if the privilege level has increased (e.g., due to an upgrade). 416 // extension if the privilege level has increased (e.g., due to an upgrade).
405 void InitializePermissions(const extensions::Extension* extension); 417 void InitializePermissions(const extensions::Extension* extension);
406 418
407 // Go through each extensions in pref, unload blacklisted extensions 419 // Go through each extensions in pref, unload blacklisted extensions
408 // and update the blacklist state in pref. 420 // and update the blacklist state in pref.
409 virtual void UpdateExtensionBlacklist( 421 virtual void UpdateExtensionBlacklist(
410 const std::vector<std::string>& blacklist) OVERRIDE; 422 const std::vector<std::string>& blacklist) OVERRIDE;
411 423
412 // Go through each extension and unload those that the network admin has 424 // Go through each extension and unload those that the network admin has
413 // put on the blacklist (not to be confused with the Google managed blacklist 425 // put on the blacklist (not to be confused with the Google-managed blacklist)
414 // set of extensions. 426 // set of extensions.
415 virtual void CheckAdminBlacklist() OVERRIDE; 427 virtual void CheckAdminBlacklist() OVERRIDE;
416 428
417 virtual void CheckForUpdatesSoon() OVERRIDE; 429 virtual void CheckForUpdatesSoon() OVERRIDE;
418 430
419 // SyncableService implementation. 431 // SyncableService implementation.
420 virtual SyncError MergeDataAndStartSyncing( 432 virtual SyncError MergeDataAndStartSyncing(
421 syncable::ModelType type, 433 syncable::ModelType type,
422 const SyncDataList& initial_sync_data, 434 const SyncDataList& initial_sync_data,
423 scoped_ptr<SyncChangeProcessor> sync_processor, 435 scoped_ptr<SyncChangeProcessor> sync_processor,
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 syncable::ModelType type); 669 syncable::ModelType type);
658 670
659 // Look up an extension by ID, optionally including either or both of enabled 671 // Look up an extension by ID, optionally including either or both of enabled
660 // and disabled extensions. 672 // and disabled extensions.
661 const extensions::Extension* GetExtensionByIdInternal( 673 const extensions::Extension* GetExtensionByIdInternal(
662 const std::string& id, 674 const std::string& id,
663 bool include_enabled, 675 bool include_enabled,
664 bool include_disabled, 676 bool include_disabled,
665 bool include_terminated) const; 677 bool include_terminated) const;
666 678
679 // Internal implementation for ManagementPolicy::Delegate methods.
680 // Returns |modifiable_value| if the extension can be modified.
681 bool ManagementPolicyImpl(const extensions::Extension* extension,
682 string16* error,
683 bool modifiable_value) const;
684
667 // Adds the given extension to the list of terminated extensions if 685 // Adds the given extension to the list of terminated extensions if
668 // it is not already there and unloads it. 686 // it is not already there and unloads it.
669 void TrackTerminatedExtension(const extensions::Extension* extension); 687 void TrackTerminatedExtension(const extensions::Extension* extension);
670 688
671 // Removes the extension with the given id from the list of 689 // Removes the extension with the given id from the list of
672 // terminated extensions if it is there. 690 // terminated extensions if it is there.
673 void UntrackTerminatedExtension(const std::string& id); 691 void UntrackTerminatedExtension(const std::string& id);
674 692
675 // Handles sending notification that |extension| was loaded. 693 // Handles sending notification that |extension| was loaded.
676 void NotifyExtensionLoaded(const extensions::Extension* extension); 694 void NotifyExtensionLoaded(const extensions::Extension* extension);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 scoped_ptr<ExtensionGlobalError> extension_global_error_; 866 scoped_ptr<ExtensionGlobalError> extension_global_error_;
849 867
850 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 868 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
851 InstallAppsWithUnlimtedStorage); 869 InstallAppsWithUnlimtedStorage);
852 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 870 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
853 InstallAppsAndCheckStorageProtection); 871 InstallAppsAndCheckStorageProtection);
854 DISALLOW_COPY_AND_ASSIGN(ExtensionService); 872 DISALLOW_COPY_AND_ASSIGN(ExtensionService);
855 }; 873 };
856 874
857 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ 875 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698