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

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

Issue 10880064: Make extension commands grant the activeTab permission. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 const Extension* extension = service->extensions()->GetByID(extension_id); 70 const Extension* extension = service->extensions()->GetByID(extension_id);
71 CHECK(extension); 71 CHECK(extension);
72 ExtensionAction* script_badge = extension->script_badge(); 72 ExtensionAction* script_badge = extension->script_badge();
73 CHECK(script_badge); 73 CHECK(script_badge);
74 74
75 switch (mouse_button) { 75 switch (mouse_button) {
76 case 1: // left 76 case 1: // left
77 case 2: { // middle 77 case 2: { // middle
78 extensions::TabHelper::FromWebContents(web_contents())-> 78 extensions::TabHelper::FromWebContents(web_contents())->
79 active_tab_permission_manager()->GrantIfRequested(extension); 79 active_tab_permission_granter()->GrantIfRequested(extension);
80 80
81 TabContents* tab_contents = TabContents::FromWebContents(web_contents()); 81 TabContents* tab_contents = TabContents::FromWebContents(web_contents());
82 // Even if clicking the badge doesn't immediately cause the extension to 82 // Even if clicking the badge doesn't immediately cause the extension to
83 // run script on the page, we want to help users associate clicking with 83 // run script on the page, we want to help users associate clicking with
84 // the extension having permission to modify the page, so we make the icon 84 // the extension having permission to modify the page, so we make the icon
85 // full-colored immediately. 85 // full-colored immediately.
86 if (script_badge->SetAppearance(SessionID::IdForTab(web_contents()), 86 if (script_badge->SetAppearance(SessionID::IdForTab(web_contents()),
87 ExtensionAction::ACTIVE)) 87 ExtensionAction::ACTIVE))
88 NotifyChange(); 88 NotifyChange();
89 89
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 current_actions_.erase(it); 270 current_actions_.erase(it);
271 break; 271 break;
272 } 272 }
273 } 273 }
274 274
275 CHECK_EQ(size_before, current_actions_.size() + 1); 275 CHECK_EQ(size_before, current_actions_.size() + 1);
276 return true; 276 return true;
277 } 277 }
278 278
279 } // namespace extensions 279 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/page_action_controller.cc ('k') | chrome/browser/extensions/tab_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698