| OLD | NEW |
| 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_action_view.h" | 5 #include "chrome/browser/ui/views/browser_action_view.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/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/api/commands/command_service_factory.h" | 9 #include "chrome/browser/extensions/api/commands/command_service_factory.h" |
| 10 #include "chrome/browser/extensions/extension_action.h" | 10 #include "chrome/browser/extensions/extension_action.h" |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 | 305 |
| 306 // The return value of this method is returned via OnMousePressed. | 306 // The return value of this method is returned via OnMousePressed. |
| 307 // We need to return false here since we're handing off focus to another | 307 // We need to return false here since we're handing off focus to another |
| 308 // widget/view, and true will grab it right back and try to send events | 308 // widget/view, and true will grab it right back and try to send events |
| 309 // to us. | 309 // to us. |
| 310 return false; | 310 return false; |
| 311 } | 311 } |
| 312 | 312 |
| 313 bool BrowserActionButton::OnMousePressed(const ui::MouseEvent& event) { | 313 bool BrowserActionButton::OnMousePressed(const ui::MouseEvent& event) { |
| 314 if (!event.IsRightMouseButton()) { | 314 if (!event.IsRightMouseButton()) { |
| 315 return IsPopup() ? MenuButton::OnMousePressed(event) | 315 return IsPopup() ? MenuButton::OnMousePressed(event) : |
| 316 : TextButton::OnMousePressed(event); | 316 TextButton::OnMousePressed(event); |
| 317 } | 317 } |
| 318 | 318 |
| 319 // See comments in MenuButton::Activate() as to why this is needed. | 319 // See comments in MenuButton::Activate() as to why this is needed. |
| 320 SetMouseHandler(NULL); | 320 SetMouseHandler(NULL); |
| 321 | 321 |
| 322 ShowContextMenu(gfx::Point(), true); | 322 ShowContextMenu(gfx::Point(), true); |
| 323 return false; | 323 return false; |
| 324 } | 324 } |
| 325 | 325 |
| 326 void BrowserActionButton::OnMouseReleased(const ui::MouseEvent& event) { | 326 void BrowserActionButton::OnMouseReleased(const ui::MouseEvent& event) { |
| 327 if (IsPopup() || context_menu_) { | 327 if (IsPopup() || context_menu_) { |
| 328 // TODO(erikkay) this never actually gets called (probably because of the | 328 // TODO(erikkay) this never actually gets called (probably because of the |
| 329 // loss of focus). | 329 // loss of focus). |
| 330 MenuButton::OnMouseReleased(event); | 330 MenuButton::OnMouseReleased(event); |
| 331 } else { | 331 } else { |
| 332 TextButton::OnMouseReleased(event); | 332 TextButton::OnMouseReleased(event); |
| 333 } | 333 } |
| 334 } | 334 } |
| 335 | 335 |
| 336 void BrowserActionButton::OnMouseExited(const ui::MouseEvent& event) { | 336 void BrowserActionButton::OnMouseExited(const ui::MouseEvent& event) { |
| 337 if (IsPopup() || context_menu_) | 337 if (IsPopup() || context_menu_) |
| 338 MenuButton::OnMouseExited(event); | 338 MenuButton::OnMouseExited(event); |
| 339 else | 339 else |
| 340 TextButton::OnMouseExited(event); | 340 TextButton::OnMouseExited(event); |
| 341 } | 341 } |
| 342 | 342 |
| 343 bool BrowserActionButton::OnKeyReleased(const ui::KeyEvent& event) { | 343 bool BrowserActionButton::OnKeyReleased(const ui::KeyEvent& event) { |
| 344 return IsPopup() ? MenuButton::OnKeyReleased(event) | 344 return IsPopup() ? MenuButton::OnKeyReleased(event) : |
| 345 : TextButton::OnKeyReleased(event); | 345 TextButton::OnKeyReleased(event); |
| 346 } |
| 347 |
| 348 ui::EventResult BrowserActionButton::OnGestureEvent(ui::GestureEvent* event) { |
| 349 return IsPopup() ? MenuButton::OnGestureEvent(event) : |
| 350 TextButton::OnGestureEvent(event); |
| 346 } | 351 } |
| 347 | 352 |
| 348 bool BrowserActionButton::AcceleratorPressed( | 353 bool BrowserActionButton::AcceleratorPressed( |
| 349 const ui::Accelerator& accelerator) { | 354 const ui::Accelerator& accelerator) { |
| 350 delegate_->OnBrowserActionExecuted(this); | 355 delegate_->OnBrowserActionExecuted(this); |
| 351 return true; | 356 return true; |
| 352 } | 357 } |
| 353 | 358 |
| 354 void BrowserActionButton::SetButtonPushed() { | 359 void BrowserActionButton::SetButtonPushed() { |
| 355 SetState(views::CustomButton::BS_PUSHED); | 360 SetState(views::CustomButton::BS_PUSHED); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 | 402 |
| 398 extensions::Command browser_action_command; | 403 extensions::Command browser_action_command; |
| 399 if (!only_if_active || !command_service->GetBrowserActionCommand( | 404 if (!only_if_active || !command_service->GetBrowserActionCommand( |
| 400 extension_->id(), | 405 extension_->id(), |
| 401 extensions::CommandService::ACTIVE_ONLY, | 406 extensions::CommandService::ACTIVE_ONLY, |
| 402 &browser_action_command, | 407 &browser_action_command, |
| 403 NULL)) { | 408 NULL)) { |
| 404 GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this); | 409 GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this); |
| 405 } | 410 } |
| 406 } | 411 } |
| OLD | NEW |