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

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

Issue 7432006: Add an experimental permissions API for extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix clang Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/file_path.h" 16 #include "base/file_path.h"
17 #include "base/gtest_prod_util.h" 17 #include "base/gtest_prod_util.h"
18 #include "base/memory/linked_ptr.h" 18 #include "base/memory/linked_ptr.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
21 #include "base/task.h" 21 #include "base/task.h"
22 #include "base/time.h" 22 #include "base/time.h"
23 #include "base/tuple.h" 23 #include "base/tuple.h"
24 #include "chrome/browser/extensions/apps_promo.h" 24 #include "chrome/browser/extensions/apps_promo.h"
25 #include "chrome/browser/extensions/extension_app_api.h" 25 #include "chrome/browser/extensions/extension_app_api.h"
26 #include "chrome/browser/extensions/extension_icon_manager.h" 26 #include "chrome/browser/extensions/extension_icon_manager.h"
27 #include "chrome/browser/extensions/extension_menu_manager.h" 27 #include "chrome/browser/extensions/extension_menu_manager.h"
28 #include "chrome/browser/extensions/extension_prefs.h" 28 #include "chrome/browser/extensions/extension_prefs.h"
29 #include "chrome/browser/extensions/extension_permissions_api.h"
29 #include "chrome/browser/extensions/extension_process_manager.h" 30 #include "chrome/browser/extensions/extension_process_manager.h"
30 #include "chrome/browser/extensions/extension_toolbar_model.h" 31 #include "chrome/browser/extensions/extension_toolbar_model.h"
31 #include "chrome/browser/extensions/extensions_quota_service.h" 32 #include "chrome/browser/extensions/extensions_quota_service.h"
32 #include "chrome/browser/extensions/external_extension_provider_interface.h" 33 #include "chrome/browser/extensions/external_extension_provider_interface.h"
33 #include "chrome/browser/extensions/pending_extension_manager.h" 34 #include "chrome/browser/extensions/pending_extension_manager.h"
34 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h" 35 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h"
35 #include "chrome/browser/prefs/pref_change_registrar.h" 36 #include "chrome/browser/prefs/pref_change_registrar.h"
36 #include "chrome/common/extensions/extension.h" 37 #include "chrome/common/extensions/extension.h"
37 #include "content/browser/browser_thread.h" 38 #include "content/browser/browser_thread.h"
38 #include "content/common/notification_observer.h" 39 #include "content/common/notification_observer.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 314
314 // Updates the |extension|'s granted permissions lists to include all 315 // Updates the |extension|'s granted permissions lists to include all
315 // permissions in the |extension|'s manifest. 316 // permissions in the |extension|'s manifest.
316 void GrantPermissions(const Extension* extension); 317 void GrantPermissions(const Extension* extension);
317 318
318 // Updates the |extension|'s granted permissions lists to include all 319 // Updates the |extension|'s granted permissions lists to include all
319 // permissions in the |extension|'s manifest and re-enables the 320 // permissions in the |extension|'s manifest and re-enables the
320 // extension. 321 // extension.
321 void GrantPermissionsAndEnableExtension(const Extension* extension); 322 void GrantPermissionsAndEnableExtension(const Extension* extension);
322 323
324 // Sets the |extension|'s active permissions to |permissions|.
325 void UpdateActivePermissions(const Extension* extension,
326 const ExtensionPermissionSet* permissions);
327
323 // Loads the extension from the directory |extension_path|. 328 // Loads the extension from the directory |extension_path|.
324 void LoadExtension(const FilePath& extension_path); 329 void LoadExtension(const FilePath& extension_path);
325 330
326 // Same as above, but for use with command line switch --load-extension=path. 331 // Same as above, but for use with command line switch --load-extension=path.
327 void LoadExtensionFromCommandLine(const FilePath& extension_path); 332 void LoadExtensionFromCommandLine(const FilePath& extension_path);
328 333
329 // Loads any component extensions. 334 // Loads any component extensions.
330 void LoadComponentExtensions(); 335 void LoadComponentExtensions();
331 336
332 // Loads particular component extension. 337 // Loads particular component extension.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 void AddExtension(const Extension* extension); 403 void AddExtension(const Extension* extension);
399 404
400 // Called by the backend when an unpacked extension has been loaded. 405 // Called by the backend when an unpacked extension has been loaded.
401 void OnLoadSingleExtension(const Extension* extension, 406 void OnLoadSingleExtension(const Extension* extension,
402 bool prompt_for_plugins); 407 bool prompt_for_plugins);
403 408
404 // Called by the backend when an extension has been installed. 409 // Called by the backend when an extension has been installed.
405 void OnExtensionInstalled( 410 void OnExtensionInstalled(
406 const Extension* extension, bool from_webstore); 411 const Extension* extension, bool from_webstore);
407 412
408 // Checks if the privileges requested by |extension| have increased, and if 413 // Initializes the |extension|'s active permission set and disables the
409 // so, disables the extension and prompts the user to approve the change. 414 // extension if the privilege level has increased (e.g., due to an upgrade).
410 void DisableIfPrivilegeIncrease(const Extension* extension); 415 void InitializePermissions(const Extension* extension);
411 416
412 // Go through each extensions in pref, unload blacklisted extensions 417 // Go through each extensions in pref, unload blacklisted extensions
413 // and update the blacklist state in pref. 418 // and update the blacklist state in pref.
414 virtual void UpdateExtensionBlacklist( 419 virtual void UpdateExtensionBlacklist(
415 const std::vector<std::string>& blacklist) OVERRIDE; 420 const std::vector<std::string>& blacklist) OVERRIDE;
416 421
417 // Go through each extension and unload those that the network admin has 422 // Go through each extension and unload those that the network admin has
418 // put on the blacklist (not to be confused with the Google managed blacklist 423 // put on the blacklist (not to be confused with the Google managed blacklist
419 // set of extensions. 424 // set of extensions.
420 virtual void CheckAdminBlacklist() OVERRIDE; 425 virtual void CheckAdminBlacklist() OVERRIDE;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 ExtensionToolbarModel* toolbar_model() { return &toolbar_model_; } 466 ExtensionToolbarModel* toolbar_model() { return &toolbar_model_; }
462 467
463 ExtensionsQuotaService* quota_service() { return &quota_service_; } 468 ExtensionsQuotaService* quota_service() { return &quota_service_; }
464 469
465 ExtensionMenuManager* menu_manager() { return &menu_manager_; } 470 ExtensionMenuManager* menu_manager() { return &menu_manager_; }
466 471
467 AppNotificationManager* app_notification_manager() { 472 AppNotificationManager* app_notification_manager() {
468 return &app_notification_manager_; 473 return &app_notification_manager_;
469 } 474 }
470 475
476 ExtensionPermissionsManager* permissions_manager() {
477 return &permissions_manager_;
478 }
479
471 ExtensionBrowserEventRouter* browser_event_router() { 480 ExtensionBrowserEventRouter* browser_event_router() {
472 return browser_event_router_.get(); 481 return browser_event_router_.get();
473 } 482 }
474 483
475 #if defined(OS_CHROMEOS) 484 #if defined(OS_CHROMEOS)
476 ExtensionFileBrowserEventRouter* file_browser_event_router() { 485 ExtensionFileBrowserEventRouter* file_browser_event_router() {
477 return file_browser_event_router_.get(); 486 return file_browser_event_router_.get();
478 } 487 }
479 #endif 488 #endif
480 489
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 // Clear all persistent data that may have been stored by the extension. 588 // Clear all persistent data that may have been stored by the extension.
580 void ClearExtensionData(const GURL& extension_url); 589 void ClearExtensionData(const GURL& extension_url);
581 590
582 // Look up an extension by ID, optionally including either or both of enabled 591 // Look up an extension by ID, optionally including either or both of enabled
583 // and disabled extensions. 592 // and disabled extensions.
584 const Extension* GetExtensionByIdInternal(const std::string& id, 593 const Extension* GetExtensionByIdInternal(const std::string& id,
585 bool include_enabled, 594 bool include_enabled,
586 bool include_disabled, 595 bool include_disabled,
587 bool include_terminated) const; 596 bool include_terminated) const;
588 597
589
590 // Adds the given extension to the list of terminated extensions if 598 // Adds the given extension to the list of terminated extensions if
591 // it is not already there and unloads it. 599 // it is not already there and unloads it.
592 void TrackTerminatedExtension(const Extension* extension); 600 void TrackTerminatedExtension(const Extension* extension);
593 601
594 // Removes the extension with the given id from the list of 602 // Removes the extension with the given id from the list of
595 // terminated extensions if it is there. 603 // terminated extensions if it is there.
596 void UntrackTerminatedExtension(const std::string& id); 604 void UntrackTerminatedExtension(const std::string& id);
597 605
598 // Handles sending notification that |extension| was loaded. 606 // Handles sending notification that |extension| was loaded.
599 void NotifyExtensionLoaded(const Extension* extension); 607 void NotifyExtensionLoaded(const Extension* extension);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 709
702 NotificationRegistrar registrar_; 710 NotificationRegistrar registrar_;
703 PrefChangeRegistrar pref_change_registrar_; 711 PrefChangeRegistrar pref_change_registrar_;
704 712
705 // Keeps track of menu items added by extensions. 713 // Keeps track of menu items added by extensions.
706 ExtensionMenuManager menu_manager_; 714 ExtensionMenuManager menu_manager_;
707 715
708 // Keeps track of app notifications. 716 // Keeps track of app notifications.
709 AppNotificationManager app_notification_manager_; 717 AppNotificationManager app_notification_manager_;
710 718
719 // Keeps track of extension permissions.
720 ExtensionPermissionsManager permissions_manager_;
721
711 // Keeps track of favicon-sized omnibox icons for extensions. 722 // Keeps track of favicon-sized omnibox icons for extensions.
712 ExtensionIconManager omnibox_icon_manager_; 723 ExtensionIconManager omnibox_icon_manager_;
713 ExtensionIconManager omnibox_popup_icon_manager_; 724 ExtensionIconManager omnibox_popup_icon_manager_;
714 725
715 // List of registered component extensions (see Extension::Location). 726 // List of registered component extensions (see Extension::Location).
716 typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions; 727 typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions;
717 RegisteredComponentExtensions component_extension_manifests_; 728 RegisteredComponentExtensions component_extension_manifests_;
718 729
719 // Manages the promotion of the web store. 730 // Manages the promotion of the web store.
720 AppsPromo apps_promo_; 731 AppsPromo apps_promo_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 NaClModuleInfoList nacl_module_list_; 764 NaClModuleInfoList nacl_module_list_;
754 765
755 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 766 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
756 InstallAppsWithUnlimtedStorage); 767 InstallAppsWithUnlimtedStorage);
757 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 768 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
758 InstallAppsAndCheckStorageProtection); 769 InstallAppsAndCheckStorageProtection);
759 DISALLOW_COPY_AND_ASSIGN(ExtensionService); 770 DISALLOW_COPY_AND_ASSIGN(ExtensionService);
760 }; 771 };
761 772
762 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ 773 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs_unittest.cc ('k') | chrome/browser/extensions/extension_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698