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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/i18n/number_formatting.h" | 9 #include "base/i18n/number_formatting.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 location_bar_->GetPageActionView(extension_action)->image_view()-> | 343 location_bar_->GetPageActionView(extension_action)->image_view()-> |
344 ExecuteAction(ExtensionPopup::SHOW); | 344 ExecuteAction(ExtensionPopup::SHOW); |
345 } | 345 } |
346 } | 346 } |
347 | 347 |
348 void ToolbarView::ShowBrowserActionPopup( | 348 void ToolbarView::ShowBrowserActionPopup( |
349 const extensions::Extension* extension) { | 349 const extensions::Extension* extension) { |
350 browser_actions_->ShowPopup(extension, true); | 350 browser_actions_->ShowPopup(extension, true); |
351 } | 351 } |
352 | 352 |
353 void ToolbarView::ShowAppMenu(bool for_drop) { | |
354 if (wrench_menu_.get() && wrench_menu_->IsShowing()) | |
355 return; | |
356 | |
357 bool use_new_menu = false; | |
358 bool supports_new_separators = false; | |
359 // TODO: remove this. | |
360 #if !defined(OS_LINUX) || defined(OS_CHROMEOS) | |
361 supports_new_separators = | |
362 GetNativeTheme() == ui::NativeThemeAura::instance(); | |
363 use_new_menu = supports_new_separators; | |
364 #endif | |
365 | |
366 if (keyboard::KeyboardController::GetInstance() && | |
367 keyboard::KeyboardController::GetInstance()->keyboard_visible()) { | |
368 keyboard::KeyboardController::GetInstance()->HideKeyboard( | |
369 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); | |
370 } | |
371 | |
372 wrench_menu_.reset(new WrenchMenu(browser_, | |
373 use_new_menu, | |
374 supports_new_separators, | |
375 for_drop)); | |
376 wrench_menu_model_.reset(new WrenchMenuModel(this, browser_, use_new_menu)); | |
377 wrench_menu_->Init(wrench_menu_model_.get()); | |
378 | |
379 FOR_EACH_OBSERVER(views::MenuListener, menu_listeners_, OnMenuOpened()); | |
380 | |
381 wrench_menu_->RunMenu(app_menu_); | |
382 } | |
383 | |
353 views::MenuButton* ToolbarView::app_menu() const { | 384 views::MenuButton* ToolbarView::app_menu() const { |
354 return app_menu_; | 385 return app_menu_; |
355 } | 386 } |
356 | 387 |
357 //////////////////////////////////////////////////////////////////////////////// | 388 //////////////////////////////////////////////////////////////////////////////// |
358 // ToolbarView, AccessiblePaneView overrides: | 389 // ToolbarView, AccessiblePaneView overrides: |
359 | 390 |
360 bool ToolbarView::SetPaneFocus(views::View* initial_focus) { | 391 bool ToolbarView::SetPaneFocus(views::View* initial_focus) { |
361 if (!AccessiblePaneView::SetPaneFocus(initial_focus)) | 392 if (!AccessiblePaneView::SetPaneFocus(initial_focus)) |
362 return false; | 393 return false; |
(...skipping 14 matching lines...) Expand all Loading... | |
377 return GetWidget()->GetAccelerator(id, accel); | 408 return GetWidget()->GetAccelerator(id, accel); |
378 } | 409 } |
379 | 410 |
380 //////////////////////////////////////////////////////////////////////////////// | 411 //////////////////////////////////////////////////////////////////////////////// |
381 // ToolbarView, views::MenuButtonListener implementation: | 412 // ToolbarView, views::MenuButtonListener implementation: |
382 | 413 |
383 void ToolbarView::OnMenuButtonClicked(views::View* source, | 414 void ToolbarView::OnMenuButtonClicked(views::View* source, |
384 const gfx::Point& point) { | 415 const gfx::Point& point) { |
385 TRACE_EVENT0("views", "ToolbarView::OnMenuButtonClicked"); | 416 TRACE_EVENT0("views", "ToolbarView::OnMenuButtonClicked"); |
386 DCHECK_EQ(VIEW_ID_APP_MENU, source->id()); | 417 DCHECK_EQ(VIEW_ID_APP_MENU, source->id()); |
387 | 418 ShowAppMenu(false); // not for drop |
Finnur
2014/07/18 10:40:40
Nit: Capitalize 'n' and add period.
Devlin
2014/07/18 15:44:32
Done.
| |
388 bool use_new_menu = false; | |
389 bool supports_new_separators = false; | |
390 // TODO: remove this. | |
391 #if !defined(OS_LINUX) || defined(OS_CHROMEOS) | |
392 supports_new_separators = | |
393 GetNativeTheme() == ui::NativeThemeAura::instance(); | |
394 use_new_menu = supports_new_separators; | |
395 #endif | |
396 | |
397 if (keyboard::KeyboardController::GetInstance() && | |
398 keyboard::KeyboardController::GetInstance()->keyboard_visible()) { | |
399 keyboard::KeyboardController::GetInstance()->HideKeyboard( | |
400 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); | |
401 } | |
402 | |
403 wrench_menu_.reset(new WrenchMenu(browser_, use_new_menu, | |
404 supports_new_separators)); | |
405 wrench_menu_model_.reset(new WrenchMenuModel(this, browser_, use_new_menu)); | |
406 wrench_menu_->Init(wrench_menu_model_.get()); | |
407 | |
408 FOR_EACH_OBSERVER(views::MenuListener, menu_listeners_, OnMenuOpened()); | |
409 | |
410 wrench_menu_->RunMenu(app_menu_); | |
411 } | 419 } |
412 | 420 |
413 //////////////////////////////////////////////////////////////////////////////// | 421 //////////////////////////////////////////////////////////////////////////////// |
414 // ToolbarView, LocationBarView::Delegate implementation: | 422 // ToolbarView, LocationBarView::Delegate implementation: |
415 | 423 |
416 WebContents* ToolbarView::GetWebContents() { | 424 WebContents* ToolbarView::GetWebContents() { |
417 return browser_->tab_strip_model()->GetActiveWebContents(); | 425 return browser_->tab_strip_model()->GetActiveWebContents(); |
418 } | 426 } |
419 | 427 |
420 ToolbarModel* ToolbarView::GetToolbarModel() { | 428 ToolbarModel* ToolbarView::GetToolbarModel() { |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
849 | 857 |
850 void ToolbarView::OnShowHomeButtonChanged() { | 858 void ToolbarView::OnShowHomeButtonChanged() { |
851 Layout(); | 859 Layout(); |
852 SchedulePaint(); | 860 SchedulePaint(); |
853 } | 861 } |
854 | 862 |
855 int ToolbarView::content_shadow_height() const { | 863 int ToolbarView::content_shadow_height() const { |
856 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ? | 864 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ? |
857 kContentShadowHeightAsh : kContentShadowHeight; | 865 kContentShadowHeightAsh : kContentShadowHeight; |
858 } | 866 } |
OLD | NEW |