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

Side by Side Diff: chrome/browser/ui/views/browser_actions_container.cc

Issue 10914122: Test ActiveTab (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 suppress_chevron_(false), 74 suppress_chevron_(false),
74 resize_amount_(0), 75 resize_amount_(0),
75 animation_target_size_(0), 76 animation_target_size_(0),
76 drop_indicator_position_(-1), 77 drop_indicator_position_(-1),
77 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), 78 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)),
78 ALLOW_THIS_IN_INITIALIZER_LIST(show_menu_task_factory_(this)) { 79 ALLOW_THIS_IN_INITIALIZER_LIST(show_menu_task_factory_(this)) {
79 set_id(VIEW_ID_BROWSER_ACTION_TOOLBAR); 80 set_id(VIEW_ID_BROWSER_ACTION_TOOLBAR);
80 81
81 if (profile_->GetExtensionService()) { 82 if (profile_->GetExtensionService()) {
82 model_ = profile_->GetExtensionService()->toolbar_model(); 83 model_ = profile_->GetExtensionService()->toolbar_model();
83 model_->AddObserver(this); 84 model_->AddObserver(this);
84 } 85 }
85 86
87 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews(
88 browser->profile(), this, owner_view->GetFocusManager()));
89
86 resize_animation_.reset(new ui::SlideAnimation(this)); 90 resize_animation_.reset(new ui::SlideAnimation(this));
87 resize_area_ = new views::ResizeArea(this); 91 resize_area_ = new views::ResizeArea(this);
88 AddChildView(resize_area_); 92 AddChildView(resize_area_);
89 93
90 chevron_ = new views::MenuButton(NULL, string16(), this, false); 94 chevron_ = new views::MenuButton(NULL, string16(), this, false);
91 chevron_->set_border(NULL); 95 chevron_->set_border(NULL);
92 chevron_->EnableCanvasFlippingForRTLUI(true); 96 chevron_->EnableCanvasFlippingForRTLUI(true);
93 chevron_->SetAccessibleName( 97 chevron_->SetAccessibleName(
94 l10n_util::GetStringUTF16(IDS_ACCNAME_EXTENSIONS_CHEVRON)); 98 l10n_util::GetStringUTF16(IDS_ACCNAME_EXTENSIONS_CHEVRON));
95 chevron_->SetVisible(false); 99 chevron_->SetVisible(false);
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 void BrowserActionsContainer::OnBrowserActionVisibilityChanged() { 476 void BrowserActionsContainer::OnBrowserActionVisibilityChanged() {
473 SetVisible(!browser_action_views_.empty()); 477 SetVisible(!browser_action_views_.empty());
474 owner_view_->Layout(); 478 owner_view_->Layout();
475 owner_view_->SchedulePaint(); 479 owner_view_->SchedulePaint();
476 } 480 }
477 481
478 gfx::Point BrowserActionsContainer::GetViewContentOffset() const { 482 gfx::Point BrowserActionsContainer::GetViewContentOffset() const {
479 return gfx::Point(0, ToolbarView::kVertSpacing); 483 return gfx::Point(0, ToolbarView::kVertSpacing);
480 } 484 }
481 485
486 extensions::ActiveTabPermissionManager*
487 BrowserActionsContainer::GetActiveTabPermissionGranter() {
488 TabContents* tab = chrome::GetActiveTabContents(browser_);
489 return tab ? tab->extension_tab_helper()->active_tab_permission_manager()
490 : NULL;
491 }
492
482 void BrowserActionsContainer::MoveBrowserAction(const std::string& extension_id, 493 void BrowserActionsContainer::MoveBrowserAction(const std::string& extension_id,
483 size_t new_index) { 494 size_t new_index) {
484 ExtensionService* service = profile_->GetExtensionService(); 495 ExtensionService* service = profile_->GetExtensionService();
485 if (service) { 496 if (service) {
486 const Extension* extension = service->GetExtensionById(extension_id, false); 497 const Extension* extension = service->GetExtensionById(extension_id, false);
487 model_->MoveBrowserAction(extension, new_index); 498 model_->MoveBrowserAction(extension, new_index);
488 SchedulePaint(); 499 SchedulePaint();
489 } 500 }
490 } 501 }
491 502
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 views::BubbleBorder::ArrowLocation arrow_location = base::i18n::IsRTL() ? 822 views::BubbleBorder::ArrowLocation arrow_location = base::i18n::IsRTL() ?
812 views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT; 823 views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT;
813 popup_ = ExtensionPopup::ShowPopup(popup_url, 824 popup_ = ExtensionPopup::ShowPopup(popup_url,
814 browser_, 825 browser_,
815 reference_view, 826 reference_view,
816 arrow_location); 827 arrow_location);
817 popup_->GetWidget()->AddObserver(this); 828 popup_->GetWidget()->AddObserver(this);
818 popup_button_ = button; 829 popup_button_ = button;
819 popup_button_->SetButtonPushed(); 830 popup_button_->SetButtonPushed();
820 } 831 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698