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 |
344 views::MenuButton* ToolbarView::app_menu() const { | 375 views::MenuButton* ToolbarView::app_menu() const { |
345 return app_menu_; | 376 return app_menu_; |
346 } | 377 } |
347 | 378 |
348 //////////////////////////////////////////////////////////////////////////////// | 379 //////////////////////////////////////////////////////////////////////////////// |
349 // ToolbarView, AccessiblePaneView overrides: | 380 // ToolbarView, AccessiblePaneView overrides: |
350 | 381 |
351 bool ToolbarView::SetPaneFocus(views::View* initial_focus) { | 382 bool ToolbarView::SetPaneFocus(views::View* initial_focus) { |
352 if (!AccessiblePaneView::SetPaneFocus(initial_focus)) | 383 if (!AccessiblePaneView::SetPaneFocus(initial_focus)) |
353 return false; | 384 return false; |
(...skipping 14 matching lines...) Expand all Loading... |
368 return GetWidget()->GetAccelerator(id, accel); | 399 return GetWidget()->GetAccelerator(id, accel); |
369 } | 400 } |
370 | 401 |
371 //////////////////////////////////////////////////////////////////////////////// | 402 //////////////////////////////////////////////////////////////////////////////// |
372 // ToolbarView, views::MenuButtonListener implementation: | 403 // ToolbarView, views::MenuButtonListener implementation: |
373 | 404 |
374 void ToolbarView::OnMenuButtonClicked(views::View* source, | 405 void ToolbarView::OnMenuButtonClicked(views::View* source, |
375 const gfx::Point& point) { | 406 const gfx::Point& point) { |
376 TRACE_EVENT0("views", "ToolbarView::OnMenuButtonClicked"); | 407 TRACE_EVENT0("views", "ToolbarView::OnMenuButtonClicked"); |
377 DCHECK_EQ(VIEW_ID_APP_MENU, source->id()); | 408 DCHECK_EQ(VIEW_ID_APP_MENU, source->id()); |
378 | 409 ShowAppMenu(false); // Not for drop. |
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_); | |
402 } | 410 } |
403 | 411 |
404 //////////////////////////////////////////////////////////////////////////////// | 412 //////////////////////////////////////////////////////////////////////////////// |
405 // ToolbarView, LocationBarView::Delegate implementation: | 413 // ToolbarView, LocationBarView::Delegate implementation: |
406 | 414 |
407 WebContents* ToolbarView::GetWebContents() { | 415 WebContents* ToolbarView::GetWebContents() { |
408 return browser_->tab_strip_model()->GetActiveWebContents(); | 416 return browser_->tab_strip_model()->GetActiveWebContents(); |
409 } | 417 } |
410 | 418 |
411 ToolbarModel* ToolbarView::GetToolbarModel() { | 419 ToolbarModel* ToolbarView::GetToolbarModel() { |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 | 800 |
793 void ToolbarView::OnShowHomeButtonChanged() { | 801 void ToolbarView::OnShowHomeButtonChanged() { |
794 Layout(); | 802 Layout(); |
795 SchedulePaint(); | 803 SchedulePaint(); |
796 } | 804 } |
797 | 805 |
798 int ToolbarView::content_shadow_height() const { | 806 int ToolbarView::content_shadow_height() const { |
799 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ? | 807 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ? |
800 kContentShadowHeightAsh : kContentShadowHeight; | 808 kContentShadowHeightAsh : kContentShadowHeight; |
801 } | 809 } |
OLD | NEW |