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

Side by Side Diff: chrome/browser/ui/views/browser_actions_container.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/ui/views/browser_actions_container.h" 5 #include "chrome/browser/ui/views/browser_actions_container.h"
6 6
7 #include "base/compiler_specific.h"
7 #include "base/stl_util.h" 8 #include "base/stl_util.h"
8 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/tab_helper.h"
9 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/sessions/session_tab_helper.h" 13 #include "chrome/browser/sessions/session_tab_helper.h"
12 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_tabstrip.h" 15 #include "chrome/browser/ui/browser_tabstrip.h"
14 #include "chrome/browser/ui/tab_contents/tab_contents.h" 16 #include "chrome/browser/ui/tab_contents/tab_contents.h"
15 #include "chrome/browser/ui/view_ids.h" 17 #include "chrome/browser/ui/view_ids.h"
16 #include "chrome/browser/ui/views/browser_action_view.h" 18 #include "chrome/browser/ui/views/browser_action_view.h"
17 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" 19 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h"
20 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h"
18 #include "chrome/browser/ui/views/extensions/extension_popup.h" 21 #include "chrome/browser/ui/views/extensions/extension_popup.h"
19 #include "chrome/browser/ui/views/toolbar_view.h" 22 #include "chrome/browser/ui/views/toolbar_view.h"
20 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
21 #include "grit/generated_resources.h" 24 #include "grit/generated_resources.h"
22 #include "grit/theme_resources.h" 25 #include "grit/theme_resources.h"
23 #include "grit/ui_resources.h" 26 #include "grit/ui_resources.h"
24 #include "ui/base/accessibility/accessible_view_state.h" 27 #include "ui/base/accessibility/accessible_view_state.h"
25 #include "ui/base/animation/slide_animation.h" 28 #include "ui/base/animation/slide_animation.h"
26 #include "ui/base/dragdrop/drag_utils.h" 29 #include "ui/base/dragdrop/drag_utils.h"
27 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 View* owner_view) 64 View* owner_view)
62 : profile_(browser->profile()), 65 : profile_(browser->profile()),
63 browser_(browser), 66 browser_(browser),
64 owner_view_(owner_view), 67 owner_view_(owner_view),
65 popup_(NULL), 68 popup_(NULL),
66 popup_button_(NULL), 69 popup_button_(NULL),
67 model_(NULL), 70 model_(NULL),
68 container_width_(0), 71 container_width_(0),
69 chevron_(NULL), 72 chevron_(NULL),
70 overflow_menu_(NULL), 73 overflow_menu_(NULL),
71 extension_keybinding_registry_(browser->profile(),
72 owner_view->GetFocusManager(),
73 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS),
74 suppress_chevron_(false), 74 suppress_chevron_(false),
75 resize_amount_(0), 75 resize_amount_(0),
76 animation_target_size_(0), 76 animation_target_size_(0),
77 drop_indicator_position_(-1), 77 drop_indicator_position_(-1),
78 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), 78 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)),
79 ALLOW_THIS_IN_INITIALIZER_LIST(show_menu_task_factory_(this)) { 79 ALLOW_THIS_IN_INITIALIZER_LIST(show_menu_task_factory_(this)) {
80 set_id(VIEW_ID_BROWSER_ACTION_TOOLBAR); 80 set_id(VIEW_ID_BROWSER_ACTION_TOOLBAR);
81 81
82 if (profile_->GetExtensionService()) { 82 if (profile_->GetExtensionService()) {
83 model_ = profile_->GetExtensionService()->toolbar_model(); 83 model_ = profile_->GetExtensionService()->toolbar_model();
84 model_->AddObserver(this); 84 model_->AddObserver(this);
85 } 85 }
86 86
87 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews(
88 browser->profile(),
89 owner_view->GetFocusManager(),
90 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS,
91 this)),
92
87 resize_animation_.reset(new ui::SlideAnimation(this)); 93 resize_animation_.reset(new ui::SlideAnimation(this));
88 resize_area_ = new views::ResizeArea(this); 94 resize_area_ = new views::ResizeArea(this);
89 AddChildView(resize_area_); 95 AddChildView(resize_area_);
90 96
91 chevron_ = new views::MenuButton(NULL, string16(), this, false); 97 chevron_ = new views::MenuButton(NULL, string16(), this, false);
92 chevron_->set_border(NULL); 98 chevron_->set_border(NULL);
93 chevron_->EnableCanvasFlippingForRTLUI(true); 99 chevron_->EnableCanvasFlippingForRTLUI(true);
94 chevron_->SetAccessibleName( 100 chevron_->SetAccessibleName(
95 l10n_util::GetStringUTF16(IDS_ACCNAME_EXTENSIONS_CHEVRON)); 101 l10n_util::GetStringUTF16(IDS_ACCNAME_EXTENSIONS_CHEVRON));
96 chevron_->SetVisible(false); 102 chevron_->SetVisible(false);
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 void BrowserActionsContainer::OnBrowserActionVisibilityChanged() { 483 void BrowserActionsContainer::OnBrowserActionVisibilityChanged() {
478 SetVisible(!browser_action_views_.empty()); 484 SetVisible(!browser_action_views_.empty());
479 owner_view_->Layout(); 485 owner_view_->Layout();
480 owner_view_->SchedulePaint(); 486 owner_view_->SchedulePaint();
481 } 487 }
482 488
483 gfx::Point BrowserActionsContainer::GetViewContentOffset() const { 489 gfx::Point BrowserActionsContainer::GetViewContentOffset() const {
484 return gfx::Point(0, ToolbarView::kVertSpacing); 490 return gfx::Point(0, ToolbarView::kVertSpacing);
485 } 491 }
486 492
493 extensions::ActiveTabPermissionGranter*
494 BrowserActionsContainer::GetActiveTabPermissionGranter() {
495 content::WebContents* web_contents = chrome::GetActiveWebContents(browser_);
496 if (!web_contents)
497 return NULL;
498 return extensions::TabHelper::FromWebContents(web_contents)->
499 active_tab_permission_granter();
500 }
501
487 void BrowserActionsContainer::MoveBrowserAction(const std::string& extension_id, 502 void BrowserActionsContainer::MoveBrowserAction(const std::string& extension_id,
488 size_t new_index) { 503 size_t new_index) {
489 ExtensionService* service = profile_->GetExtensionService(); 504 ExtensionService* service = profile_->GetExtensionService();
490 if (service) { 505 if (service) {
491 const Extension* extension = service->GetExtensionById(extension_id, false); 506 const Extension* extension = service->GetExtensionById(extension_id, false);
492 model_->MoveBrowserAction(extension, new_index); 507 model_->MoveBrowserAction(extension, new_index);
493 SchedulePaint(); 508 SchedulePaint();
494 } 509 }
495 } 510 }
496 511
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT; 840 views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT;
826 popup_ = ExtensionPopup::ShowPopup(popup_url, 841 popup_ = ExtensionPopup::ShowPopup(popup_url,
827 browser_, 842 browser_,
828 reference_view, 843 reference_view,
829 arrow_location, 844 arrow_location,
830 show_action); 845 show_action);
831 popup_->GetWidget()->AddObserver(this); 846 popup_->GetWidget()->AddObserver(this);
832 popup_button_ = button; 847 popup_button_ = button;
833 popup_button_->SetButtonPushed(); 848 popup_button_->SetButtonPushed();
834 } 849 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698