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

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

Issue 597413003: Introduce an "ExtensionWantsToAct" method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master for CQ Created 6 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/extensions/active_script_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_ACTIVE_SCRIPT_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/scoped_observer.h" 15 #include "base/scoped_observer.h"
16 #include "content/public/browser/web_contents_observer.h" 16 #include "content/public/browser/web_contents_observer.h"
17 #include "extensions/browser/extension_registry_observer.h" 17 #include "extensions/browser/extension_registry_observer.h"
18 #include "extensions/common/permissions/permissions_data.h" 18 #include "extensions/common/permissions/permissions_data.h"
19 #include "extensions/common/user_script.h" 19 #include "extensions/common/user_script.h"
20 20
21 namespace content { 21 namespace content {
22 class BrowserContext;
22 class WebContents; 23 class WebContents;
23 } 24 }
24 25
25 namespace IPC { 26 namespace IPC {
26 class Message; 27 class Message;
27 } 28 }
28 29
29 class ExtensionAction; 30 class ExtensionAction;
30 31
31 namespace extensions { 32 namespace extensions {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 102
102 // Handle the RequestScriptInjectionPermission message. 103 // Handle the RequestScriptInjectionPermission message.
103 void OnRequestScriptInjectionPermission( 104 void OnRequestScriptInjectionPermission(
104 const std::string& extension_id, 105 const std::string& extension_id,
105 UserScript::InjectionType script_type, 106 UserScript::InjectionType script_type,
106 int64 request_id); 107 int64 request_id);
107 108
108 // Grants permission for the given request to run. 109 // Grants permission for the given request to run.
109 void PermitScriptInjection(int64 request_id); 110 void PermitScriptInjection(int64 request_id);
110 111
112 // Notifies the ExtensionActionAPI of a change (either that an extension now
113 // wants permission to run, or that it has been run).
114 void NotifyChange(const Extension* extension);
115
111 // Log metrics. 116 // Log metrics.
112 void LogUMA() const; 117 void LogUMA() const;
113 118
114 // content::WebContentsObserver implementation. 119 // content::WebContentsObserver implementation.
115 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 120 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
116 virtual void DidNavigateMainFrame( 121 virtual void DidNavigateMainFrame(
117 const content::LoadCommittedDetails& details, 122 const content::LoadCommittedDetails& details,
118 const content::FrameNavigateParams& params) OVERRIDE; 123 const content::FrameNavigateParams& params) OVERRIDE;
119 124
120 // ExtensionRegistryObserver: 125 // ExtensionRegistryObserver:
121 virtual void OnExtensionUnloaded( 126 virtual void OnExtensionUnloaded(
122 content::BrowserContext* browser_context, 127 content::BrowserContext* browser_context,
123 const Extension* extension, 128 const Extension* extension,
124 UnloadedExtensionInfo::Reason reason) OVERRIDE; 129 UnloadedExtensionInfo::Reason reason) OVERRIDE;
125 130
131 // The associated browser context.
132 content::BrowserContext* browser_context_;
133
126 // Whether or not the ActiveScriptController is enabled (corresponding to the 134 // Whether or not the ActiveScriptController is enabled (corresponding to the
127 // kActiveScriptEnforcement switch). If it is not, it acts as an empty shell, 135 // kActiveScriptEnforcement switch). If it is not, it acts as an empty shell,
128 // always allowing scripts to run and never displaying actions. 136 // always allowing scripts to run and never displaying actions.
129 bool enabled_; 137 bool enabled_;
130 138
131 // The map of extension_id:pending_request of all pending requests. 139 // The map of extension_id:pending_request of all pending requests.
132 PendingRequestMap pending_requests_; 140 PendingRequestMap pending_requests_;
133 141
134 // The extensions which have been granted permission to run on the given page. 142 // The extensions which have been granted permission to run on the given page.
135 // TODO(rdevlin.cronin): Right now, this just keeps track of extensions that 143 // TODO(rdevlin.cronin): Right now, this just keeps track of extensions that
136 // have been permitted to run on the page via this interface. Instead, it 144 // have been permitted to run on the page via this interface. Instead, it
137 // should incorporate more fully with ActiveTab. 145 // should incorporate more fully with ActiveTab.
138 std::set<std::string> permitted_extensions_; 146 std::set<std::string> permitted_extensions_;
139 147
140 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 148 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
141 extension_registry_observer_; 149 extension_registry_observer_;
142 150
143 DISALLOW_COPY_AND_ASSIGN(ActiveScriptController); 151 DISALLOW_COPY_AND_ASSIGN(ActiveScriptController);
144 }; 152 };
145 153
146 } // namespace extensions 154 } // namespace extensions
147 155
148 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_ 156 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/active_script_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698