| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/toolbar/toolbar_view.h" | 5 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 location_bar_->GetPageActionView(extension_action)->image_view()-> | 334 location_bar_->GetPageActionView(extension_action)->image_view()-> |
| 335 ExecuteAction(ExtensionPopup::SHOW); | 335 ExecuteAction(ExtensionPopup::SHOW); |
| 336 } | 336 } |
| 337 } | 337 } |
| 338 | 338 |
| 339 void ToolbarView::ShowBrowserActionPopup( | 339 void ToolbarView::ShowBrowserActionPopup( |
| 340 const extensions::Extension* extension) { | 340 const extensions::Extension* extension) { |
| 341 browser_actions_->ShowPopup(extension, true); | 341 browser_actions_->ShowPopup(extension, true); |
| 342 } | 342 } |
| 343 | 343 |
| 344 void ToolbarView::ShowAppMenu(bool for_drop) { | |
| 345 if (wrench_menu_.get() && wrench_menu_->IsShowing()) | |
| 346 return; | |
| 347 | |
| 348 int run_flags = 0; | |
| 349 bool use_new_menu = false; | |
| 350 // TODO: remove this. | |
| 351 #if !defined(OS_LINUX) || defined(OS_CHROMEOS) | |
| 352 if (GetNativeTheme() == ui::NativeThemeAura::instance()) { | |
| 353 use_new_menu = true; | |
| 354 run_flags |= WrenchMenu::SUPPORTS_NEW_SEPARATORS | WrenchMenu::USE_NEW_MENU; | |
| 355 } | |
| 356 #endif | |
| 357 | |
| 358 if (keyboard::KeyboardController::GetInstance() && | |
| 359 keyboard::KeyboardController::GetInstance()->keyboard_visible()) { | |
| 360 keyboard::KeyboardController::GetInstance()->HideKeyboard( | |
| 361 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); | |
| 362 } | |
| 363 | |
| 364 if (for_drop) | |
| 365 run_flags |= WrenchMenu::FOR_DROP; | |
| 366 wrench_menu_.reset(new WrenchMenu(browser_, run_flags)); | |
| 367 wrench_menu_model_.reset(new WrenchMenuModel(this, browser_, use_new_menu)); | |
| 368 wrench_menu_->Init(wrench_menu_model_.get()); | |
| 369 | |
| 370 FOR_EACH_OBSERVER(views::MenuListener, menu_listeners_, OnMenuOpened()); | |
| 371 | |
| 372 wrench_menu_->RunMenu(app_menu_); | |
| 373 } | |
| 374 | |
| 375 views::MenuButton* ToolbarView::app_menu() const { | 344 views::MenuButton* ToolbarView::app_menu() const { |
| 376 return app_menu_; | 345 return app_menu_; |
| 377 } | 346 } |
| 378 | 347 |
| 379 //////////////////////////////////////////////////////////////////////////////// | 348 //////////////////////////////////////////////////////////////////////////////// |
| 380 // ToolbarView, AccessiblePaneView overrides: | 349 // ToolbarView, AccessiblePaneView overrides: |
| 381 | 350 |
| 382 bool ToolbarView::SetPaneFocus(views::View* initial_focus) { | 351 bool ToolbarView::SetPaneFocus(views::View* initial_focus) { |
| 383 if (!AccessiblePaneView::SetPaneFocus(initial_focus)) | 352 if (!AccessiblePaneView::SetPaneFocus(initial_focus)) |
| 384 return false; | 353 return false; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 399 return GetWidget()->GetAccelerator(id, accel); | 368 return GetWidget()->GetAccelerator(id, accel); |
| 400 } | 369 } |
| 401 | 370 |
| 402 //////////////////////////////////////////////////////////////////////////////// | 371 //////////////////////////////////////////////////////////////////////////////// |
| 403 // ToolbarView, views::MenuButtonListener implementation: | 372 // ToolbarView, views::MenuButtonListener implementation: |
| 404 | 373 |
| 405 void ToolbarView::OnMenuButtonClicked(views::View* source, | 374 void ToolbarView::OnMenuButtonClicked(views::View* source, |
| 406 const gfx::Point& point) { | 375 const gfx::Point& point) { |
| 407 TRACE_EVENT0("views", "ToolbarView::OnMenuButtonClicked"); | 376 TRACE_EVENT0("views", "ToolbarView::OnMenuButtonClicked"); |
| 408 DCHECK_EQ(VIEW_ID_APP_MENU, source->id()); | 377 DCHECK_EQ(VIEW_ID_APP_MENU, source->id()); |
| 409 ShowAppMenu(false); // Not for drop. | 378 |
| 379 bool use_new_menu = false; |
| 380 bool supports_new_separators = false; |
| 381 // TODO: remove this. |
| 382 #if !defined(OS_LINUX) || defined(OS_CHROMEOS) |
| 383 supports_new_separators = |
| 384 GetNativeTheme() == ui::NativeThemeAura::instance(); |
| 385 use_new_menu = supports_new_separators; |
| 386 #endif |
| 387 |
| 388 if (keyboard::KeyboardController::GetInstance() && |
| 389 keyboard::KeyboardController::GetInstance()->keyboard_visible()) { |
| 390 keyboard::KeyboardController::GetInstance()->HideKeyboard( |
| 391 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); |
| 392 } |
| 393 |
| 394 wrench_menu_.reset(new WrenchMenu(browser_, use_new_menu, |
| 395 supports_new_separators)); |
| 396 wrench_menu_model_.reset(new WrenchMenuModel(this, browser_, use_new_menu)); |
| 397 wrench_menu_->Init(wrench_menu_model_.get()); |
| 398 |
| 399 FOR_EACH_OBSERVER(views::MenuListener, menu_listeners_, OnMenuOpened()); |
| 400 |
| 401 wrench_menu_->RunMenu(app_menu_); |
| 410 } | 402 } |
| 411 | 403 |
| 412 //////////////////////////////////////////////////////////////////////////////// | 404 //////////////////////////////////////////////////////////////////////////////// |
| 413 // ToolbarView, LocationBarView::Delegate implementation: | 405 // ToolbarView, LocationBarView::Delegate implementation: |
| 414 | 406 |
| 415 WebContents* ToolbarView::GetWebContents() { | 407 WebContents* ToolbarView::GetWebContents() { |
| 416 return browser_->tab_strip_model()->GetActiveWebContents(); | 408 return browser_->tab_strip_model()->GetActiveWebContents(); |
| 417 } | 409 } |
| 418 | 410 |
| 419 ToolbarModel* ToolbarView::GetToolbarModel() { | 411 ToolbarModel* ToolbarView::GetToolbarModel() { |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 | 792 |
| 801 void ToolbarView::OnShowHomeButtonChanged() { | 793 void ToolbarView::OnShowHomeButtonChanged() { |
| 802 Layout(); | 794 Layout(); |
| 803 SchedulePaint(); | 795 SchedulePaint(); |
| 804 } | 796 } |
| 805 | 797 |
| 806 int ToolbarView::content_shadow_height() const { | 798 int ToolbarView::content_shadow_height() const { |
| 807 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ? | 799 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ? |
| 808 kContentShadowHeightAsh : kContentShadowHeight; | 800 kContentShadowHeightAsh : kContentShadowHeight; |
| 809 } | 801 } |
| OLD | NEW |