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

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

Issue 10917026: Switch Extensions::TabHelper to use WebContents, WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only Created 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/script_badge_controller.h" 5 #include "chrome/browser/extensions/script_badge_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "chrome/browser/extensions/browser_event_router.h" 10 #include "chrome/browser/extensions/browser_event_router.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 return ACTION_NONE; 72 return ACTION_NONE;
73 73
74 const Extension* extension = service->extensions()->GetByID(extension_id); 74 const Extension* extension = service->extensions()->GetByID(extension_id);
75 CHECK(extension); 75 CHECK(extension);
76 ExtensionAction* script_badge = extension->script_badge(); 76 ExtensionAction* script_badge = extension->script_badge();
77 CHECK(script_badge); 77 CHECK(script_badge);
78 78
79 switch (mouse_button) { 79 switch (mouse_button) {
80 case 1: // left 80 case 1: // left
81 case 2: { // middle 81 case 2: { // middle
82 extensions::TabHelper::FromWebContents(web_contents())->
83 active_tab_permission_manager()->GrantIfRequested(extension);
84
82 TabContents* tab_contents = TabContents::FromWebContents(web_contents()); 85 TabContents* tab_contents = TabContents::FromWebContents(web_contents());
83 tab_contents->extension_tab_helper()->active_tab_permission_manager()->
84 GrantIfRequested(extension);
85
86 // Even if clicking the badge doesn't immediately cause the extension to 86 // Even if clicking the badge doesn't immediately cause the extension to
87 // run script on the page, we want to help users associate clicking with 87 // run script on the page, we want to help users associate clicking with
88 // the extension having permission to modify the page, so we make the icon 88 // the extension having permission to modify the page, so we make the icon
89 // full-colored immediately. 89 // full-colored immediately.
90 if (script_badge->SetAppearance(SessionID::IdForTab(web_contents()), 90 if (script_badge->SetAppearance(SessionID::IdForTab(web_contents()),
91 ExtensionAction::ACTIVE)) 91 ExtensionAction::ACTIVE))
92 NotifyChange(); 92 NotifyChange();
93 93
94 // Fire the scriptBadge.onClicked event. 94 // Fire the scriptBadge.onClicked event.
95 GetExtensionService()->browser_event_router()->ScriptBadgeExecuted( 95 GetExtensionService()->browser_event_router()->ScriptBadgeExecuted(
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 current_actions_.erase(it); 277 current_actions_.erase(it);
278 break; 278 break;
279 } 279 }
280 } 280 }
281 281
282 CHECK_EQ(size_before, current_actions_.size() + 1); 282 CHECK_EQ(size_before, current_actions_.size() + 1);
283 return true; 283 return true;
284 } 284 }
285 285
286 } // namespace extensions 286 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/page_action_controller.cc ('k') | chrome/browser/extensions/script_badge_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698