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

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

Issue 8493017: Cleanup extension permissions module. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years 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_PERMISSIONS_API_H__ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PERMISSIONS_API_H__
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PERMISSIONS_API_H__ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PERMISSIONS_API_H__
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "chrome/browser/extensions/extension_function.h" 12 #include "chrome/browser/extensions/extension_function.h"
13 #include "chrome/browser/extensions/extension_install_ui.h" 13 #include "chrome/browser/extensions/extension_install_ui.h"
14 #include "chrome/common/extensions/extension_permission_set.h" 14 #include "chrome/common/extensions/extension_permission_set.h"
15 #include "chrome/common/chrome_notification_types.h"
16 #include "content/public/browser/render_process_host.h"
17 15
18 class Extension; 16 class Extension;
19 class ExtensionPermissionSet; 17 class ExtensionPermissionSet;
20 class ExtensionService; 18 class ExtensionService;
21 19
22 class ExtensionPermissionsManager {
23 public:
24 explicit ExtensionPermissionsManager(ExtensionService* extension_service);
25 ~ExtensionPermissionsManager();
26
27 // Adds the set of |permissions| to the |extension|'s active permission set
28 // and sends the relevant messages and notifications. This method assumes the
29 // user has already been prompted, if necessary, for the extra permissions.
30 void AddPermissions(const Extension* extension,
31 const ExtensionPermissionSet* permissions);
32
33 // Removes the set of |permissions| from the |extension|'s active permission
34 // set and sends the relevant messages and notifications.
35 void RemovePermissions(const Extension* extension,
36 const ExtensionPermissionSet* permissions);
37
38 private:
39 enum EventType {
40 ADDED,
41 REMOVED,
42 };
43
44 // Dispatches specified event to the extension.
45 void DispatchEvent(const std::string& extension_id,
46 const char* event_name,
47 const ExtensionPermissionSet* changed_permissions);
48
49 // Issues the relevant events, messages and notifications when the
50 // |extension|'s permissions have |changed| (|changed| is the delta).
51 // Specifically, this sends the EXTENSION_PERMISSIONS_UPDATED notification,
52 // the ExtensionMsg_UpdatePermissions IPC message, and fires the
53 // onAdded/onRemoved events in the extension.
54 void NotifyPermissionsUpdated(EventType event_type,
55 const Extension* extension,
56 const ExtensionPermissionSet* changed);
57
58 ExtensionService* extension_service_;
59 };
60
61
62 // chrome.permissions.contains 20 // chrome.permissions.contains
63 class ContainsPermissionsFunction : public SyncExtensionFunction { 21 class ContainsPermissionsFunction : public SyncExtensionFunction {
64 virtual ~ContainsPermissionsFunction() {} 22 virtual ~ContainsPermissionsFunction() {}
65 virtual bool RunImpl() OVERRIDE; 23 virtual bool RunImpl() OVERRIDE;
66 DECLARE_EXTENSION_FUNCTION_NAME("permissions.contains") 24 DECLARE_EXTENSION_FUNCTION_NAME("permissions.contains")
67 }; 25 };
68 26
69 // chrome.permissions.getAll 27 // chrome.permissions.getAll
70 class GetAllPermissionsFunction : public SyncExtensionFunction { 28 class GetAllPermissionsFunction : public SyncExtensionFunction {
71 virtual ~GetAllPermissionsFunction() {} 29 virtual ~GetAllPermissionsFunction() {}
(...skipping 22 matching lines...) Expand all
94 virtual void InstallUIProceed() OVERRIDE; 52 virtual void InstallUIProceed() OVERRIDE;
95 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; 53 virtual void InstallUIAbort(bool user_initiated) OVERRIDE;
96 54
97 protected: 55 protected:
98 virtual ~RequestPermissionsFunction(); 56 virtual ~RequestPermissionsFunction();
99 virtual bool RunImpl() OVERRIDE; 57 virtual bool RunImpl() OVERRIDE;
100 58
101 private: 59 private:
102 scoped_ptr<ExtensionInstallUI> install_ui_; 60 scoped_ptr<ExtensionInstallUI> install_ui_;
103 scoped_refptr<ExtensionPermissionSet> requested_permissions_; 61 scoped_refptr<ExtensionPermissionSet> requested_permissions_;
104 const Extension* extension_;
105 DECLARE_EXTENSION_FUNCTION_NAME("permissions.request") 62 DECLARE_EXTENSION_FUNCTION_NAME("permissions.request")
106 }; 63 };
107 64
108 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PERMISSIONS_API_H__ 65 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PERMISSIONS_API_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698