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/ui/views/location_bar/page_action_image_view.cc

Issue 430093003: Page action extension icons should handle tap events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: kViewClassName no longer public Created 6 years, 4 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
« no previous file with comments | « chrome/browser/ui/views/location_bar/page_action_image_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/extensions/api/commands/command_service.h" 8 #include "chrome/browser/extensions/api/commands/command_service.h"
9 #include "chrome/browser/extensions/extension_action.h" 9 #include "chrome/browser/extensions/extension_action.h"
10 #include "chrome/browser/extensions/extension_action_icon_factory.h" 10 #include "chrome/browser/extensions/extension_action_icon_factory.h"
(...skipping 15 matching lines...) Expand all
26 #include "ui/accessibility/ax_view_state.h" 26 #include "ui/accessibility/ax_view_state.h"
27 #include "ui/events/event.h" 27 #include "ui/events/event.h"
28 #include "ui/gfx/canvas.h" 28 #include "ui/gfx/canvas.h"
29 #include "ui/gfx/image/image.h" 29 #include "ui/gfx/image/image.h"
30 #include "ui/views/controls/menu/menu_runner.h" 30 #include "ui/views/controls/menu/menu_runner.h"
31 31
32 using content::WebContents; 32 using content::WebContents;
33 using extensions::LocationBarController; 33 using extensions::LocationBarController;
34 using extensions::Extension; 34 using extensions::Extension;
35 35
36 // static
37 const char PageActionImageView::kViewClassName[] = "PageActionImageView";
38
36 PageActionImageView::PageActionImageView(LocationBarView* owner, 39 PageActionImageView::PageActionImageView(LocationBarView* owner,
37 ExtensionAction* page_action, 40 ExtensionAction* page_action,
38 Browser* browser) 41 Browser* browser)
39 : owner_(owner), 42 : owner_(owner),
40 page_action_(page_action), 43 page_action_(page_action),
41 browser_(browser), 44 browser_(browser),
42 current_tab_id_(-1), 45 current_tab_id_(-1),
43 preview_enabled_(false), 46 preview_enabled_(false),
44 popup_(NULL) { 47 popup_(NULL) {
45 const Extension* extension = extensions::ExtensionRegistry::Get( 48 const Extension* extension = extensions::ExtensionRegistry::Get(
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 case LocationBarController::ACTION_SHOW_CONTEXT_MENU: 109 case LocationBarController::ACTION_SHOW_CONTEXT_MENU:
107 // We are never passing OnClicked a right-click button, so assume that 110 // We are never passing OnClicked a right-click button, so assume that
108 // we're never going to be asked to show a context menu. 111 // we're never going to be asked to show a context menu.
109 // TODO(kalman): if this changes, update this class to pass the real 112 // TODO(kalman): if this changes, update this class to pass the real
110 // mouse button through to the LocationBarController. 113 // mouse button through to the LocationBarController.
111 NOTREACHED(); 114 NOTREACHED();
112 break; 115 break;
113 } 116 }
114 } 117 }
115 118
119 const char* PageActionImageView::GetClassName() const {
120 return kViewClassName;
121 }
122
116 void PageActionImageView::GetAccessibleState(ui::AXViewState* state) { 123 void PageActionImageView::GetAccessibleState(ui::AXViewState* state) {
117 state->role = ui::AX_ROLE_BUTTON; 124 state->role = ui::AX_ROLE_BUTTON;
118 state->name = base::UTF8ToUTF16(tooltip_); 125 state->name = base::UTF8ToUTF16(tooltip_);
119 } 126 }
120 127
121 bool PageActionImageView::OnMousePressed(const ui::MouseEvent& event) { 128 bool PageActionImageView::OnMousePressed(const ui::MouseEvent& event) {
122 // We want to show the bubble on mouse release; that is the standard behavior 129 // We want to show the bubble on mouse release; that is the standard behavior
123 // for buttons. (Also, triggering on mouse press causes bugs like 130 // for buttons. (Also, triggering on mouse press causes bugs like
124 // http://crbug.com/33155.) 131 // http://crbug.com/33155.)
125 return true; 132 return true;
(...skipping 14 matching lines...) Expand all
140 147
141 bool PageActionImageView::OnKeyPressed(const ui::KeyEvent& event) { 148 bool PageActionImageView::OnKeyPressed(const ui::KeyEvent& event) {
142 if (event.key_code() == ui::VKEY_SPACE || 149 if (event.key_code() == ui::VKEY_SPACE ||
143 event.key_code() == ui::VKEY_RETURN) { 150 event.key_code() == ui::VKEY_RETURN) {
144 ExecuteAction(ExtensionPopup::SHOW); 151 ExecuteAction(ExtensionPopup::SHOW);
145 return true; 152 return true;
146 } 153 }
147 return false; 154 return false;
148 } 155 }
149 156
157 void PageActionImageView::OnGestureEvent(ui::GestureEvent* event) {
158 if (event->type() == ui::ET_GESTURE_TAP) {
159 ExecuteAction(ExtensionPopup::SHOW);
160 event->SetHandled();
161 }
162 }
163
150 void PageActionImageView::ShowContextMenuForView( 164 void PageActionImageView::ShowContextMenuForView(
151 View* source, 165 View* source,
152 const gfx::Point& point, 166 const gfx::Point& point,
153 ui::MenuSourceType source_type) { 167 ui::MenuSourceType source_type) {
154 const Extension* extension = extensions::ExtensionRegistry::Get( 168 const Extension* extension = extensions::ExtensionRegistry::Get(
155 owner_->profile())->enabled_extensions().GetByID( 169 owner_->profile())->enabled_extensions().GetByID(
156 page_action()->extension_id()); 170 page_action()->extension_id());
157 if (!extension->ShowConfigureContextMenus()) 171 if (!extension->ShowConfigureContextMenus())
158 return; 172 return;
159 173
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 273
260 popup_ = ExtensionPopup::ShowPopup(popup_url, browser_, this, arrow, 274 popup_ = ExtensionPopup::ShowPopup(popup_url, browser_, this, arrow,
261 show_action); 275 show_action);
262 popup_->GetWidget()->AddObserver(this); 276 popup_->GetWidget()->AddObserver(this);
263 } 277 }
264 278
265 void PageActionImageView::HidePopup() { 279 void PageActionImageView::HidePopup() {
266 if (popup_) 280 if (popup_)
267 popup_->GetWidget()->Close(); 281 popup_->GetWidget()->Close();
268 } 282 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/page_action_image_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698