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

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

Issue 496403003: Remove NOTIFICATION_EXTENSION_PAGE_ACTIONS_UPDATED (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Latest master for CQ Created 6 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/extension_action/extension_action_api.h » ('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 #include "chrome/browser/extensions/active_script_controller.h" 5 #include "chrome/browser/extensions/active_script_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "chrome/browser/extensions/active_tab_permission_granter.h" 12 #include "chrome/browser/extensions/active_tab_permission_granter.h"
13 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
13 #include "chrome/browser/extensions/extension_action.h" 14 #include "chrome/browser/extensions/extension_action.h"
14 #include "chrome/browser/extensions/extension_action_manager.h" 15 #include "chrome/browser/extensions/extension_action_manager.h"
15 #include "chrome/browser/extensions/extension_util.h" 16 #include "chrome/browser/extensions/extension_util.h"
16 #include "chrome/browser/extensions/location_bar_controller.h" 17 #include "chrome/browser/extensions/location_bar_controller.h"
17 #include "chrome/browser/extensions/permissions_updater.h" 18 #include "chrome/browser/extensions/permissions_updater.h"
18 #include "chrome/browser/extensions/tab_helper.h" 19 #include "chrome/browser/extensions/tab_helper.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/sessions/session_tab_helper.h" 21 #include "chrome/browser/sessions/session_tab_helper.h"
21 #include "chrome/common/extensions/api/extension_action/action_info.h" 22 #include "chrome/common/extensions/api/extension_action/action_info.h"
22 #include "components/crx_file/id_util.h" 23 #include "components/crx_file/id_util.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 212
212 void ActiveScriptController::RequestScriptInjection( 213 void ActiveScriptController::RequestScriptInjection(
213 const Extension* extension, 214 const Extension* extension,
214 const base::Closure& callback) { 215 const base::Closure& callback) {
215 CHECK(extension); 216 CHECK(extension);
216 PendingRequestList& list = pending_requests_[extension->id()]; 217 PendingRequestList& list = pending_requests_[extension->id()];
217 list.push_back(callback); 218 list.push_back(callback);
218 219
219 // If this was the first entry, notify the location bar that there's a new 220 // If this was the first entry, notify the location bar that there's a new
220 // icon. 221 // icon.
221 if (list.size() == 1u) 222 if (list.size() == 1u) {
222 LocationBarController::NotifyChange(web_contents()); 223 ExtensionActionAPI::Get(web_contents()->GetBrowserContext())->
224 NotifyPageActionsChanged(web_contents());
225 }
223 } 226 }
224 227
225 void ActiveScriptController::RunPendingForExtension( 228 void ActiveScriptController::RunPendingForExtension(
226 const Extension* extension) { 229 const Extension* extension) {
227 DCHECK(extension); 230 DCHECK(extension);
228 231
229 content::NavigationEntry* visible_entry = 232 content::NavigationEntry* visible_entry =
230 web_contents()->GetController().GetVisibleEntry(); 233 web_contents()->GetController().GetVisibleEntry();
231 // Refuse to run if there's no visible entry, because we have no idea of 234 // Refuse to run if there's no visible entry, because we have no idea of
232 // determining if it's the proper page. This should rarely, if ever, happen. 235 // determining if it's the proper page. This should rarely, if ever, happen.
(...skipping 21 matching lines...) Expand all
254 active_tab_permission_granter()->GrantIfRequested(extension); 257 active_tab_permission_granter()->GrantIfRequested(extension);
255 258
256 // Run all pending injections for the given extension. 259 // Run all pending injections for the given extension.
257 for (PendingRequestList::iterator request = requests.begin(); 260 for (PendingRequestList::iterator request = requests.begin();
258 request != requests.end(); 261 request != requests.end();
259 ++request) { 262 ++request) {
260 request->Run(); 263 request->Run();
261 } 264 }
262 265
263 // Inform the location bar that the action is now gone. 266 // Inform the location bar that the action is now gone.
264 LocationBarController::NotifyChange(web_contents()); 267 ExtensionActionAPI::Get(web_contents()->GetBrowserContext())->
268 NotifyPageActionsChanged(web_contents());
265 } 269 }
266 270
267 void ActiveScriptController::OnRequestScriptInjectionPermission( 271 void ActiveScriptController::OnRequestScriptInjectionPermission(
268 const std::string& extension_id, 272 const std::string& extension_id,
269 UserScript::InjectionType script_type, 273 UserScript::InjectionType script_type,
270 int64 request_id) { 274 int64 request_id) {
271 if (!crx_file::id_util::IdIsValid(extension_id)) { 275 if (!crx_file::id_util::IdIsValid(extension_id)) {
272 NOTREACHED() << "'" << extension_id << "' is not a valid id."; 276 NOTREACHED() << "'" << extension_id << "' is not a valid id.";
273 return; 277 return;
274 } 278 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 UMA_HISTOGRAM_COUNTS_100( 349 UMA_HISTOGRAM_COUNTS_100(
346 "Extensions.ActiveScriptController.PermittedExtensions", 350 "Extensions.ActiveScriptController.PermittedExtensions",
347 permitted_extensions_.size()); 351 permitted_extensions_.size());
348 UMA_HISTOGRAM_COUNTS_100( 352 UMA_HISTOGRAM_COUNTS_100(
349 "Extensions.ActiveScriptController.DeniedExtensions", 353 "Extensions.ActiveScriptController.DeniedExtensions",
350 pending_requests_.size()); 354 pending_requests_.size());
351 } 355 }
352 } 356 }
353 357
354 } // namespace extensions 358 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/extension_action/extension_action_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698