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

Side by Side Diff: chrome/browser/ui/views/location_bar/page_action_image_view.cc

Issue 10446034: Rename ActionBoxController -> LocationBarController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: grammar Created 8 years, 7 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/location_bar/page_action_image_view.h" 5 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/extensions/action_box_controller.h"
9 #include "chrome/browser/extensions/api/commands/command_service.h" 8 #include "chrome/browser/extensions/api/commands/command_service.h"
10 #include "chrome/browser/extensions/api/commands/command_service_factory.h" 9 #include "chrome/browser/extensions/api/commands/command_service_factory.h"
11 #include "chrome/browser/extensions/extension_browser_event_router.h" 10 #include "chrome/browser/extensions/extension_browser_event_router.h"
12 #include "chrome/browser/extensions/extension_context_menu_model.h" 11 #include "chrome/browser/extensions/extension_context_menu_model.h"
13 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/extension_tab_helper.h" 13 #include "chrome/browser/extensions/extension_tab_helper.h"
15 #include "chrome/browser/extensions/extension_tab_util.h" 14 #include "chrome/browser/extensions/extension_tab_util.h"
15 #include "chrome/browser/extensions/location_bar_controller.h"
16 #include "chrome/browser/platform_util.h" 16 #include "chrome/browser/platform_util.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/browser_list.h" 18 #include "chrome/browser/ui/browser_list.h"
19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
20 #include "chrome/browser/ui/views/frame/browser_view.h" 20 #include "chrome/browser/ui/views/frame/browser_view.h"
21 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 21 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
22 #include "chrome/common/chrome_notification_types.h" 22 #include "chrome/common/chrome_notification_types.h"
23 #include "chrome/common/extensions/extension.h" 23 #include "chrome/common/extensions/extension.h"
24 #include "chrome/common/extensions/extension_action.h" 24 #include "chrome/common/extensions/extension_action.h"
25 #include "chrome/common/extensions/extension_manifest_constants.h" 25 #include "chrome/common/extensions/extension_manifest_constants.h"
26 #include "chrome/common/extensions/extension_resource.h" 26 #include "chrome/common/extensions/extension_resource.h"
27 #include "content/public/browser/notification_details.h" 27 #include "content/public/browser/notification_details.h"
28 #include "content/public/browser/notification_source.h" 28 #include "content/public/browser/notification_source.h"
29 #include "ui/base/accessibility/accessible_view_state.h" 29 #include "ui/base/accessibility/accessible_view_state.h"
30 #include "ui/views/controls/menu/menu_item_view.h" 30 #include "ui/views/controls/menu/menu_item_view.h"
31 #include "ui/views/controls/menu/menu_model_adapter.h" 31 #include "ui/views/controls/menu/menu_model_adapter.h"
32 #include "ui/views/controls/menu/menu_runner.h" 32 #include "ui/views/controls/menu/menu_runner.h"
33 33
34 using content::WebContents; 34 using content::WebContents;
35 using extensions::ActionBoxController; 35 using extensions::LocationBarController;
36 using extensions::Extension; 36 using extensions::Extension;
37 37
38 PageActionImageView::PageActionImageView(LocationBarView* owner, 38 PageActionImageView::PageActionImageView(LocationBarView* owner,
39 ExtensionAction* page_action, 39 ExtensionAction* page_action,
40 Browser* browser) 40 Browser* browser)
41 : owner_(owner), 41 : owner_(owner),
42 page_action_(page_action), 42 page_action_(page_action),
43 browser_(browser), 43 browser_(browser),
44 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)), 44 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)),
45 current_tab_id_(-1), 45 current_tab_id_(-1),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 if (popup_) 90 if (popup_)
91 popup_->GetWidget()->RemoveObserver(this); 91 popup_->GetWidget()->RemoveObserver(this);
92 HidePopup(); 92 HidePopup();
93 } 93 }
94 94
95 void PageActionImageView::ExecuteAction(int button) { 95 void PageActionImageView::ExecuteAction(int button) {
96 TabContentsWrapper* tab_contents = owner_->GetTabContentsWrapper(); 96 TabContentsWrapper* tab_contents = owner_->GetTabContentsWrapper();
97 if (!tab_contents) 97 if (!tab_contents)
98 return; 98 return;
99 99
100 ActionBoxController* controller = 100 LocationBarController* controller =
101 tab_contents->extension_tab_helper()->action_box_controller(); 101 tab_contents->extension_tab_helper()->location_bar_controller();
102 102
103 // 1 is left click. 103 // 1 is left click.
104 switch (controller->OnClicked(page_action_->extension_id(), 1)) { 104 switch (controller->OnClicked(page_action_->extension_id(), 1)) {
105 case ActionBoxController::ACTION_NONE: 105 case LocationBarController::ACTION_NONE:
106 break; 106 break;
107 107
108 case ActionBoxController::ACTION_SHOW_POPUP: { 108 case LocationBarController::ACTION_SHOW_POPUP: {
109 bool popup_showing = popup_ != NULL; 109 bool popup_showing = popup_ != NULL;
110 110
111 // Always hide the current popup. Only one popup at a time. 111 // Always hide the current popup. Only one popup at a time.
112 HidePopup(); 112 HidePopup();
113 113
114 // If we were already showing, then treat this click as a dismiss. 114 // If we were already showing, then treat this click as a dismiss.
115 if (popup_showing) 115 if (popup_showing)
116 return; 116 return;
117 117
118 views::BubbleBorder::ArrowLocation arrow_location = base::i18n::IsRTL() ? 118 views::BubbleBorder::ArrowLocation arrow_location = base::i18n::IsRTL() ?
119 views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT; 119 views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT;
120 120
121 popup_ = ExtensionPopup::ShowPopup( 121 popup_ = ExtensionPopup::ShowPopup(
122 page_action_->GetPopupUrl(current_tab_id_), 122 page_action_->GetPopupUrl(current_tab_id_),
123 browser_, 123 browser_,
124 this, 124 this,
125 arrow_location); 125 arrow_location);
126 popup_->GetWidget()->AddObserver(this); 126 popup_->GetWidget()->AddObserver(this);
127 break; 127 break;
128 } 128 }
129 129
130 case ActionBoxController::ACTION_SHOW_CONTEXT_MENU: 130 case LocationBarController::ACTION_SHOW_CONTEXT_MENU:
131 // We are never passing OnClicked a right-click button, so assume that 131 // We are never passing OnClicked a right-click button, so assume that
132 // we're never going to be asked to show a context menu. 132 // we're never going to be asked to show a context menu.
133 // TODO(kalman): if this changes, update this class to pass the real 133 // TODO(kalman): if this changes, update this class to pass the real
134 // mouse button through to the ActionBoxController. 134 // mouse button through to the LocationBarController.
135 NOTREACHED(); 135 NOTREACHED();
136 break; 136 break;
137 } 137 }
138 } 138 }
139 139
140 void PageActionImageView::GetAccessibleState(ui::AccessibleViewState* state) { 140 void PageActionImageView::GetAccessibleState(ui::AccessibleViewState* state) {
141 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; 141 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON;
142 state->name = UTF8ToUTF16(tooltip_); 142 state->name = UTF8ToUTF16(tooltip_);
143 } 143 }
144 144
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 const Extension* unloaded_extension = 293 const Extension* unloaded_extension =
294 content::Details<extensions::UnloadedExtensionInfo>(details)->extension; 294 content::Details<extensions::UnloadedExtensionInfo>(details)->extension;
295 if (page_action_ == unloaded_extension ->page_action()) 295 if (page_action_ == unloaded_extension ->page_action())
296 owner_->UpdatePageActions(); 296 owner_->UpdatePageActions();
297 } 297 }
298 298
299 void PageActionImageView::HidePopup() { 299 void PageActionImageView::HidePopup() {
300 if (popup_) 300 if (popup_)
301 popup_->GetWidget()->Close(); 301 popup_->GetWidget()->Close();
302 } 302 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698