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

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

Issue 1809813002: [Extensions] Show a "refresh" bubble when needed with click-to-script (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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_EXTENSION_ACTION_RUNNER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_RUNNER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_RUNNER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_RUNNER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
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/callback.h" 15 #include "base/callback.h"
16 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/weak_ptr.h"
18 #include "base/scoped_observer.h" 19 #include "base/scoped_observer.h"
19 #include "chrome/browser/extensions/extension_action.h" 20 #include "chrome/browser/extensions/extension_action.h"
21 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_bubble_delegate.h"
20 #include "content/public/browser/web_contents_observer.h" 22 #include "content/public/browser/web_contents_observer.h"
21 #include "extensions/browser/blocked_action_type.h" 23 #include "extensions/browser/blocked_action_type.h"
22 #include "extensions/browser/extension_registry_observer.h" 24 #include "extensions/browser/extension_registry_observer.h"
23 #include "extensions/common/permissions/permissions_data.h" 25 #include "extensions/common/permissions/permissions_data.h"
24 #include "extensions/common/user_script.h" 26 #include "extensions/common/user_script.h"
25 27
26 namespace content { 28 namespace content {
27 class BrowserContext; 29 class BrowserContext;
28 class WebContents; 30 class WebContents;
29 } 31 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 73
72 // Returns a bitmask of BlockedActionType for the actions that have been 74 // Returns a bitmask of BlockedActionType for the actions that have been
73 // blocked for the given extension. 75 // blocked for the given extension.
74 int GetBlockedActions(const Extension* extension); 76 int GetBlockedActions(const Extension* extension);
75 77
76 // Returns true if the given |extension| has any blocked actions. 78 // Returns true if the given |extension| has any blocked actions.
77 bool WantsToRun(const Extension* extension); 79 bool WantsToRun(const Extension* extension);
78 80
79 int num_page_requests() const { return num_page_requests_; } 81 int num_page_requests() const { return num_page_requests_; }
80 82
83 void set_default_bubble_close_action_for_testing(
84 scoped_ptr<ToolbarActionsBarBubbleDelegate::CloseAction> action) {
85 default_bubble_close_action_for_testing_ = std::move(action);
86 }
87
81 #if defined(UNIT_TEST) 88 #if defined(UNIT_TEST)
82 // Only used in tests. 89 // Only used in tests.
83 PermissionsData::AccessType RequiresUserConsentForScriptInjectionForTesting( 90 PermissionsData::AccessType RequiresUserConsentForScriptInjectionForTesting(
84 const Extension* extension, 91 const Extension* extension,
85 UserScript::InjectionType type) { 92 UserScript::InjectionType type) {
86 return RequiresUserConsentForScriptInjection(extension, type); 93 return RequiresUserConsentForScriptInjection(extension, type);
87 } 94 }
88 void RequestScriptInjectionForTesting(const Extension* extension, 95 void RequestScriptInjectionForTesting(const Extension* extension,
89 UserScript::RunLocation run_location, 96 UserScript::RunLocation run_location,
90 const base::Closure& callback) { 97 const base::Closure& callback) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // Grants permission for the given request to run. 141 // Grants permission for the given request to run.
135 void PermitScriptInjection(int64_t request_id); 142 void PermitScriptInjection(int64_t request_id);
136 143
137 // Notifies the ExtensionActionAPI of a change (either that an extension now 144 // Notifies the ExtensionActionAPI of a change (either that an extension now
138 // wants permission to run, or that it has been run). 145 // wants permission to run, or that it has been run).
139 void NotifyChange(const Extension* extension); 146 void NotifyChange(const Extension* extension);
140 147
141 // Log metrics. 148 // Log metrics.
142 void LogUMA() const; 149 void LogUMA() const;
143 150
151 // Shows the bubble to prompt the user to refresh the page to run the blocked
152 // actions for the given |extension|.
asargent_no_longer_on_chrome 2016/03/21 23:31:15 I could not help thinking of "the old lady who swa
Devlin 2016/03/23 21:48:46 heh hopefully it doesn't get any more complicated
153 void ShowBlockedActionBubble(const Extension* extension);
154
155 // Called when the blocked actions bubble is closed.
156 void OnBlockedActionBubbleClosed(
157 const std::string& extension_id,
158 ToolbarActionsBarBubbleDelegate::CloseAction action);
159
144 // content::WebContentsObserver implementation. 160 // content::WebContentsObserver implementation.
145 bool OnMessageReceived(const IPC::Message& message, 161 bool OnMessageReceived(const IPC::Message& message,
146 content::RenderFrameHost* render_frame_host) override; 162 content::RenderFrameHost* render_frame_host) override;
147 void DidNavigateMainFrame( 163 void DidNavigateMainFrame(
148 const content::LoadCommittedDetails& details, 164 const content::LoadCommittedDetails& details,
149 const content::FrameNavigateParams& params) override; 165 const content::FrameNavigateParams& params) override;
150 166
151 // ExtensionRegistryObserver: 167 // ExtensionRegistryObserver:
152 void OnExtensionUnloaded(content::BrowserContext* browser_context, 168 void OnExtensionUnloaded(content::BrowserContext* browser_context,
153 const Extension* extension, 169 const Extension* extension,
(...skipping 16 matching lines...) Expand all
170 186
171 // A set of ids for which the webRequest API was blocked on the page. 187 // A set of ids for which the webRequest API was blocked on the page.
172 std::set<std::string> web_request_blocked_; 188 std::set<std::string> web_request_blocked_;
173 189
174 // The extensions which have been granted permission to run on the given page. 190 // The extensions which have been granted permission to run on the given page.
175 // TODO(rdevlin.cronin): Right now, this just keeps track of extensions that 191 // TODO(rdevlin.cronin): Right now, this just keeps track of extensions that
176 // have been permitted to run on the page via this interface. Instead, it 192 // have been permitted to run on the page via this interface. Instead, it
177 // should incorporate more fully with ActiveTab. 193 // should incorporate more fully with ActiveTab.
178 std::set<std::string> permitted_extensions_; 194 std::set<std::string> permitted_extensions_;
179 195
196 // If true, ignore active tab being granted rather than running pending
197 // actions.
198 bool ignore_active_tab_granted_;
199
200 // If non-null, the bubble action to simulate for testing.
201 scoped_ptr<ToolbarActionsBarBubbleDelegate::CloseAction>
202 default_bubble_close_action_for_testing_;
203
180 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 204 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
181 extension_registry_observer_; 205 extension_registry_observer_;
182 206
207 base::WeakPtrFactory<ExtensionActionRunner> weak_factory_;
208
183 DISALLOW_COPY_AND_ASSIGN(ExtensionActionRunner); 209 DISALLOW_COPY_AND_ASSIGN(ExtensionActionRunner);
184 }; 210 };
185 211
186 } // namespace extensions 212 } // namespace extensions
187 213
188 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_RUNNER_H_ 214 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_RUNNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698