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

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

Issue 939803002: [Extensions] Update renderers when all-urls is granted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test Created 5 years, 10 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>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 void AlwaysRunOnVisibleOrigin(const Extension* extension); 61 void AlwaysRunOnVisibleOrigin(const Extension* extension);
62 62
63 // Notifies the ActiveScriptController that the action for |extension| has 63 // Notifies the ActiveScriptController that the action for |extension| has
64 // been clicked, running any pending tasks that were previously shelved. 64 // been clicked, running any pending tasks that were previously shelved.
65 void OnClicked(const Extension* extension); 65 void OnClicked(const Extension* extension);
66 66
67 // Returns true if the given |extension| has a pending script that wants to 67 // Returns true if the given |extension| has a pending script that wants to
68 // run. 68 // run.
69 bool WantsToRun(const Extension* extension); 69 bool WantsToRun(const Extension* extension);
70 70
71 int num_page_requests() const { return num_page_requests_; }
72
71 #if defined(UNIT_TEST) 73 #if defined(UNIT_TEST)
72 // Only used in tests. 74 // Only used in tests.
73 PermissionsData::AccessType RequiresUserConsentForScriptInjectionForTesting( 75 PermissionsData::AccessType RequiresUserConsentForScriptInjectionForTesting(
74 const Extension* extension, 76 const Extension* extension,
75 UserScript::InjectionType type) { 77 UserScript::InjectionType type) {
76 return RequiresUserConsentForScriptInjection(extension, type); 78 return RequiresUserConsentForScriptInjection(extension, type);
77 } 79 }
78 void RequestScriptInjectionForTesting(const Extension* extension, 80 void RequestScriptInjectionForTesting(const Extension* extension,
79 const base::Closure& callback) { 81 const base::Closure& callback) {
80 return RequestScriptInjection(extension, callback); 82 return RequestScriptInjection(extension, callback);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 bool OnMessageReceived(const IPC::Message& message) override; 122 bool OnMessageReceived(const IPC::Message& message) override;
121 void DidNavigateMainFrame( 123 void DidNavigateMainFrame(
122 const content::LoadCommittedDetails& details, 124 const content::LoadCommittedDetails& details,
123 const content::FrameNavigateParams& params) override; 125 const content::FrameNavigateParams& params) override;
124 126
125 // ExtensionRegistryObserver: 127 // ExtensionRegistryObserver:
126 void OnExtensionUnloaded(content::BrowserContext* browser_context, 128 void OnExtensionUnloaded(content::BrowserContext* browser_context,
127 const Extension* extension, 129 const Extension* extension,
128 UnloadedExtensionInfo::Reason reason) override; 130 UnloadedExtensionInfo::Reason reason) override;
129 131
132 // The total number of requests from the renderer on the current page,
133 // including any that are pending or were immediately granted.
134 // Right now, used only in tests.
135 int num_page_requests_;
136
130 // The associated browser context. 137 // The associated browser context.
131 content::BrowserContext* browser_context_; 138 content::BrowserContext* browser_context_;
132 139
133 // Whether or not the feature was used for any extensions. This may not be the 140 // Whether or not the feature was used for any extensions. This may not be the
134 // case if the user never enabled the scripts-require-action flag. 141 // case if the user never enabled the scripts-require-action flag.
135 bool was_used_on_page_; 142 bool was_used_on_page_;
136 143
137 // The map of extension_id:pending_request of all pending requests. 144 // The map of extension_id:pending_request of all pending requests.
138 PendingRequestMap pending_requests_; 145 PendingRequestMap pending_requests_;
139 146
140 // The extensions which have been granted permission to run on the given page. 147 // The extensions which have been granted permission to run on the given page.
141 // TODO(rdevlin.cronin): Right now, this just keeps track of extensions that 148 // TODO(rdevlin.cronin): Right now, this just keeps track of extensions that
142 // have been permitted to run on the page via this interface. Instead, it 149 // have been permitted to run on the page via this interface. Instead, it
143 // should incorporate more fully with ActiveTab. 150 // should incorporate more fully with ActiveTab.
144 std::set<std::string> permitted_extensions_; 151 std::set<std::string> permitted_extensions_;
145 152
146 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 153 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
147 extension_registry_observer_; 154 extension_registry_observer_;
148 155
149 DISALLOW_COPY_AND_ASSIGN(ActiveScriptController); 156 DISALLOW_COPY_AND_ASSIGN(ActiveScriptController);
150 }; 157 };
151 158
152 } // namespace extensions 159 } // namespace extensions
153 160
154 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_ 161 #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