| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser_list.h" | 8 #include "chrome/browser/browser_list.h" |
| 9 #include "chrome/browser/extensions/extension_browser_event_router.h" | 9 #include "chrome/browser/extensions/extension_browser_event_router.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; | 106 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; |
| 107 } | 107 } |
| 108 | 108 |
| 109 bool PageActionImageView::OnMousePressed(const views::MouseEvent& event) { | 109 bool PageActionImageView::OnMousePressed(const views::MouseEvent& event) { |
| 110 // We want to show the bubble on mouse release; that is the standard behavior | 110 // We want to show the bubble on mouse release; that is the standard behavior |
| 111 // for buttons. (Also, triggering on mouse press causes bugs like | 111 // for buttons. (Also, triggering on mouse press causes bugs like |
| 112 // http://crbug.com/33155.) | 112 // http://crbug.com/33155.) |
| 113 return true; | 113 return true; |
| 114 } | 114 } |
| 115 | 115 |
| 116 void PageActionImageView::OnMouseReleased(const views::MouseEvent& event, | 116 void PageActionImageView::OnMouseReleased(const views::MouseEvent& event) { |
| 117 bool canceled) { | 117 if (!HitTest(event.location())) |
| 118 if (canceled || !HitTest(event.location())) | |
| 119 return; | 118 return; |
| 120 | 119 |
| 121 int button = -1; | 120 int button = -1; |
| 122 if (event.IsLeftMouseButton()) { | 121 if (event.IsLeftMouseButton()) { |
| 123 button = 1; | 122 button = 1; |
| 124 } else if (event.IsMiddleMouseButton()) { | 123 } else if (event.IsMiddleMouseButton()) { |
| 125 button = 2; | 124 button = 2; |
| 126 } else if (event.IsRightMouseButton()) { | 125 } else if (event.IsRightMouseButton()) { |
| 127 // Get the top left point of this button in screen coordinates. | 126 // Get the top left point of this button in screen coordinates. |
| 128 gfx::Point menu_origin; | 127 gfx::Point menu_origin; |
| 129 ConvertPointToScreen(this, &menu_origin); | 128 ConvertPointToScreen(this, &menu_origin); |
| 130 // Make the menu appear below the button. | 129 // Make the menu appear below the button. |
| 131 menu_origin.Offset(0, height()); | 130 menu_origin.Offset(0, height()); |
| 132 ShowContextMenu(menu_origin, true); | 131 ShowContextMenu(menu_origin, true); |
| 133 return; | 132 return; |
| 134 } | 133 } |
| 135 | 134 |
| 136 ExecuteAction(button, false); // inspect_with_devtools | 135 ExecuteAction(button, false); // inspect_with_devtools |
| 137 } | 136 } |
| 138 | 137 |
| 139 bool PageActionImageView::OnKeyPressed(const views::KeyEvent& e) { | 138 bool PageActionImageView::OnKeyPressed(const views::KeyEvent& event) { |
| 140 if (e.key_code() == ui::VKEY_SPACE || e.key_code() == ui::VKEY_RETURN) { | 139 if (event.key_code() == ui::VKEY_SPACE || |
| 140 event.key_code() == ui::VKEY_RETURN) { |
| 141 ExecuteAction(1, false); | 141 ExecuteAction(1, false); |
| 142 return true; | 142 return true; |
| 143 } | 143 } |
| 144 return false; | 144 return false; |
| 145 } | 145 } |
| 146 | 146 |
| 147 void PageActionImageView::ShowContextMenu(const gfx::Point& p, | 147 void PageActionImageView::ShowContextMenu(const gfx::Point& p, |
| 148 bool is_mouse_gesture) { | 148 bool is_mouse_gesture) { |
| 149 const Extension* extension = profile_->GetExtensionService()-> | 149 const Extension* extension = profile_->GetExtensionService()-> |
| 150 GetExtensionById(page_action()->extension_id(), false); | 150 GetExtensionById(page_action()->extension_id(), false); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 void PageActionImageView::ExtensionPopupIsClosing(ExtensionPopup* popup) { | 237 void PageActionImageView::ExtensionPopupIsClosing(ExtensionPopup* popup) { |
| 238 DCHECK_EQ(popup_, popup); | 238 DCHECK_EQ(popup_, popup); |
| 239 // ExtensionPopup is ref-counted, so we don't need to delete it. | 239 // ExtensionPopup is ref-counted, so we don't need to delete it. |
| 240 popup_ = NULL; | 240 popup_ = NULL; |
| 241 } | 241 } |
| 242 | 242 |
| 243 void PageActionImageView::HidePopup() { | 243 void PageActionImageView::HidePopup() { |
| 244 if (popup_) | 244 if (popup_) |
| 245 popup_->Close(); | 245 popup_->Close(); |
| 246 } | 246 } |
| OLD | NEW |