| 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/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 6 | 6 |
| 7 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 34 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 35 #include "chrome/browser/sidebar/sidebar_container.h" | 35 #include "chrome/browser/sidebar/sidebar_container.h" |
| 36 #include "chrome/browser/sidebar/sidebar_manager.h" | 36 #include "chrome/browser/sidebar/sidebar_manager.h" |
| 37 #include "chrome/browser/tabs/tab_strip_model.h" | 37 #include "chrome/browser/tabs/tab_strip_model.h" |
| 38 #include "chrome/browser/themes/theme_service.h" | 38 #include "chrome/browser/themes/theme_service.h" |
| 39 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 39 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
| 40 #include "chrome/browser/ui/browser.h" | 40 #include "chrome/browser/ui/browser.h" |
| 41 #include "chrome/browser/ui/browser_dialogs.h" | 41 #include "chrome/browser/ui/browser_dialogs.h" |
| 42 #include "chrome/browser/ui/browser_list.h" | 42 #include "chrome/browser/ui/browser_list.h" |
| 43 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 43 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 44 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
| 44 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 45 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
| 45 #include "chrome/browser/ui/view_ids.h" | 46 #include "chrome/browser/ui/view_ids.h" |
| 46 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | 47 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
| 47 #include "chrome/browser/ui/views/browser_dialogs.h" | 48 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 49 #include "chrome/browser/ui/views/compact_nav/compact_location_bar_view.h" |
| 50 #include "chrome/browser/ui/views/compact_nav/compact_location_bar_view_host.h" |
| 51 #include "chrome/browser/ui/views/compact_nav/compact_navigation_bar.h" |
| 52 #include "chrome/browser/ui/views/compact_nav/compact_options_bar.h" |
| 48 #include "chrome/browser/ui/views/default_search_view.h" | 53 #include "chrome/browser/ui/views/default_search_view.h" |
| 49 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" | 54 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" |
| 50 #include "chrome/browser/ui/views/download/download_shelf_view.h" | 55 #include "chrome/browser/ui/views/download/download_shelf_view.h" |
| 51 #include "chrome/browser/ui/views/frame/browser_view_layout.h" | 56 #include "chrome/browser/ui/views/frame/browser_view_layout.h" |
| 52 #include "chrome/browser/ui/views/frame/contents_container.h" | 57 #include "chrome/browser/ui/views/frame/contents_container.h" |
| 53 #include "chrome/browser/ui/views/fullscreen_exit_bubble.h" | 58 #include "chrome/browser/ui/views/fullscreen_exit_bubble.h" |
| 54 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" | 59 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" |
| 55 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 60 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 56 #include "chrome/browser/ui/views/status_bubble_views.h" | 61 #include "chrome/browser/ui/views/status_bubble_views.h" |
| 57 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" | 62 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 71 #include "content/browser/renderer_host/render_widget_host_view.h" | 76 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 72 #include "content/browser/tab_contents/tab_contents.h" | 77 #include "content/browser/tab_contents/tab_contents.h" |
| 73 #include "content/browser/tab_contents/tab_contents_view.h" | 78 #include "content/browser/tab_contents/tab_contents_view.h" |
| 74 #include "content/browser/user_metrics.h" | 79 #include "content/browser/user_metrics.h" |
| 75 #include "content/common/notification_service.h" | 80 #include "content/common/notification_service.h" |
| 76 #include "grit/app_resources.h" | 81 #include "grit/app_resources.h" |
| 77 #include "grit/chromium_strings.h" | 82 #include "grit/chromium_strings.h" |
| 78 #include "grit/generated_resources.h" | 83 #include "grit/generated_resources.h" |
| 79 #include "grit/locale_settings.h" | 84 #include "grit/locale_settings.h" |
| 80 #include "grit/theme_resources.h" | 85 #include "grit/theme_resources.h" |
| 86 #include "grit/theme_resources_standard.h" |
| 81 #include "grit/webkit_resources.h" | 87 #include "grit/webkit_resources.h" |
| 82 #include "ui/base/accessibility/accessible_view_state.h" | 88 #include "ui/base/accessibility/accessible_view_state.h" |
| 83 #include "ui/base/l10n/l10n_util.h" | 89 #include "ui/base/l10n/l10n_util.h" |
| 84 #include "ui/base/resource/resource_bundle.h" | 90 #include "ui/base/resource/resource_bundle.h" |
| 85 #include "ui/gfx/canvas_skia.h" | 91 #include "ui/gfx/canvas_skia.h" |
| 86 #include "views/controls/single_split_view.h" | 92 #include "views/controls/single_split_view.h" |
| 87 #include "views/events/event.h" | 93 #include "views/events/event.h" |
| 88 #include "views/focus/external_focus_tracker.h" | 94 #include "views/focus/external_focus_tracker.h" |
| 89 #include "views/focus/view_storage.h" | 95 #include "views/focus/view_storage.h" |
| 90 #include "views/layout/grid_layout.h" | 96 #include "views/layout/grid_layout.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 | 303 |
| 298 BrowserView::BrowserView(Browser* browser) | 304 BrowserView::BrowserView(Browser* browser) |
| 299 : views::ClientView(NULL, NULL), | 305 : views::ClientView(NULL, NULL), |
| 300 last_focused_view_storage_id_( | 306 last_focused_view_storage_id_( |
| 301 views::ViewStorage::GetInstance()->CreateStorageID()), | 307 views::ViewStorage::GetInstance()->CreateStorageID()), |
| 302 frame_(NULL), | 308 frame_(NULL), |
| 303 browser_(browser), | 309 browser_(browser), |
| 304 active_bookmark_bar_(NULL), | 310 active_bookmark_bar_(NULL), |
| 305 tabstrip_(NULL), | 311 tabstrip_(NULL), |
| 306 toolbar_(NULL), | 312 toolbar_(NULL), |
| 313 compact_navigation_bar_(NULL), |
| 314 compact_options_bar_(NULL), |
| 315 compact_spacer_(NULL), |
| 307 infobar_container_(NULL), | 316 infobar_container_(NULL), |
| 308 sidebar_container_(NULL), | 317 sidebar_container_(NULL), |
| 309 sidebar_split_(NULL), | 318 sidebar_split_(NULL), |
| 310 contents_container_(NULL), | 319 contents_container_(NULL), |
| 311 devtools_container_(NULL), | 320 devtools_container_(NULL), |
| 312 preview_container_(NULL), | 321 preview_container_(NULL), |
| 313 contents_(NULL), | 322 contents_(NULL), |
| 314 contents_split_(NULL), | 323 contents_split_(NULL), |
| 315 initialized_(false), | 324 initialized_(false), |
| 316 ignore_layout_(true) | 325 ignore_layout_(true) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 if (window) { | 380 if (window) { |
| 372 return static_cast<BrowserView*>( | 381 return static_cast<BrowserView*>( |
| 373 g_object_get_data(G_OBJECT(window), kBrowserViewKey)); | 382 g_object_get_data(G_OBJECT(window), kBrowserViewKey)); |
| 374 } | 383 } |
| 375 #endif | 384 #endif |
| 376 return NULL; | 385 return NULL; |
| 377 } | 386 } |
| 378 | 387 |
| 379 gfx::Rect BrowserView::GetToolbarBounds() const { | 388 gfx::Rect BrowserView::GetToolbarBounds() const { |
| 380 gfx::Rect toolbar_bounds(toolbar_->bounds()); | 389 gfx::Rect toolbar_bounds(toolbar_->bounds()); |
| 390 // In compact navigation mode, the spacer essentially replaces the toolbar. |
| 391 // We must provide it's height in order to have the client area divider paint |
| 392 // properly. |
| 393 if (UseCompactNavigationBar()) |
| 394 toolbar_bounds = compact_spacer_->bounds(); |
| 381 if (toolbar_bounds.IsEmpty()) | 395 if (toolbar_bounds.IsEmpty()) |
| 382 return toolbar_bounds; | 396 return toolbar_bounds; |
| 383 // When using vertical tabs, the toolbar appears to extend behind the tab | 397 // When using vertical tabs, the toolbar appears to extend behind the tab |
| 384 // column. | 398 // column. |
| 385 if (UseVerticalTabs()) | 399 if (UseVerticalTabs()) |
| 386 toolbar_bounds.Inset(tabstrip_->x() - toolbar_bounds.x(), 0, 0, 0); | 400 toolbar_bounds.Inset(tabstrip_->x() - toolbar_bounds.x(), 0, 0, 0); |
| 387 // The apparent toolbar edges are outside the "real" toolbar edges. | 401 // The apparent toolbar edges are outside the "real" toolbar edges. |
| 388 toolbar_bounds.Inset(-views::NonClientFrameView::kClientEdgeThickness, 0); | 402 toolbar_bounds.Inset(-views::NonClientFrameView::kClientEdgeThickness, 0); |
| 389 return toolbar_bounds; | 403 return toolbar_bounds; |
| 390 } | 404 } |
| 391 | 405 |
| 392 gfx::Rect BrowserView::GetClientAreaBounds() const { | 406 gfx::Rect BrowserView::GetClientAreaBounds() const { |
| 393 gfx::Rect container_bounds = contents_->bounds(); | 407 gfx::Rect container_bounds = contents_->bounds(); |
| 394 gfx::Point container_origin = container_bounds.origin(); | 408 gfx::Point container_origin = container_bounds.origin(); |
| 395 ConvertPointToView(this, parent(), &container_origin); | 409 ConvertPointToView(this, parent(), &container_origin); |
| 396 container_bounds.set_origin(container_origin); | 410 container_bounds.set_origin(container_origin); |
| 397 return container_bounds; | 411 return container_bounds; |
| 398 } | 412 } |
| 399 | 413 |
| 400 gfx::Rect BrowserView::GetFindBarBoundingBox() const { | 414 gfx::Rect BrowserView::GetFindBarBoundingBox() const { |
| 401 return GetBrowserViewLayout()->GetFindBarBoundingBox(); | 415 return GetBrowserViewLayout()->GetFindBarBoundingBox(); |
| 402 } | 416 } |
| 403 | 417 |
| 418 gfx::Rect BrowserView::GetCompactNavigationBarBounds() const { |
| 419 return compact_navigation_bar_->bounds(); |
| 420 } |
| 421 |
| 422 gfx::Rect BrowserView::GetCompactOptionsBarBounds() const { |
| 423 return compact_options_bar_->bounds(); |
| 424 } |
| 425 |
| 404 int BrowserView::GetTabStripHeight() const { | 426 int BrowserView::GetTabStripHeight() const { |
| 405 // We want to return tabstrip_->height(), but we might be called in the midst | 427 // We want to return tabstrip_->height(), but we might be called in the midst |
| 406 // of layout, when that hasn't yet been updated to reflect the current state. | 428 // of layout, when that hasn't yet been updated to reflect the current state. |
| 407 // So return what the tabstrip height _ought_ to be right now. | 429 // So return what the tabstrip height _ought_ to be right now. |
| 408 return IsTabStripVisible() ? tabstrip_->GetPreferredSize().height() : 0; | 430 return IsTabStripVisible() ? tabstrip_->GetPreferredSize().height() : 0; |
| 409 } | 431 } |
| 410 | 432 |
| 411 gfx::Point BrowserView::OffsetPointForToolbarBackgroundImage( | 433 gfx::Point BrowserView::OffsetPointForToolbarBackgroundImage( |
| 412 const gfx::Point& point) const { | 434 const gfx::Point& point) const { |
| 413 // The background image starts tiling horizontally at the window left edge and | 435 // The background image starts tiling horizontally at the window left edge and |
| (...skipping 11 matching lines...) Expand all Loading... |
| 425 } | 447 } |
| 426 | 448 |
| 427 bool BrowserView::IsTabStripVisible() const { | 449 bool BrowserView::IsTabStripVisible() const { |
| 428 return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); | 450 return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); |
| 429 } | 451 } |
| 430 | 452 |
| 431 bool BrowserView::UseVerticalTabs() const { | 453 bool BrowserView::UseVerticalTabs() const { |
| 432 return browser_->tabstrip_model()->delegate()->UseVerticalTabs(); | 454 return browser_->tabstrip_model()->delegate()->UseVerticalTabs(); |
| 433 } | 455 } |
| 434 | 456 |
| 457 bool BrowserView::UseCompactNavigationBar() const { |
| 458 return browser_->tabstrip_model()->delegate()->UseCompactNavigationBar(); |
| 459 } |
| 460 |
| 435 bool BrowserView::IsOffTheRecord() const { | 461 bool BrowserView::IsOffTheRecord() const { |
| 436 return browser_->profile()->IsOffTheRecord(); | 462 return browser_->profile()->IsOffTheRecord(); |
| 437 } | 463 } |
| 438 | 464 |
| 439 bool BrowserView::ShouldShowOffTheRecordAvatar() const { | 465 bool BrowserView::ShouldShowOffTheRecordAvatar() const { |
| 440 return IsOffTheRecord() && IsBrowserTypeNormal(); | 466 return IsOffTheRecord() && IsBrowserTypeNormal(); |
| 441 } | 467 } |
| 442 | 468 |
| 443 bool BrowserView::AcceleratorPressed(const views::Accelerator& accelerator) { | 469 bool BrowserView::AcceleratorPressed(const views::Accelerator& accelerator) { |
| 444 #if defined(OS_CHROMEOS) | 470 #if defined(OS_CHROMEOS) |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 if (loading_animation_timer_.IsRunning()) { | 726 if (loading_animation_timer_.IsRunning()) { |
| 701 last_animation_time_ = base::TimeTicks(); | 727 last_animation_time_ = base::TimeTicks(); |
| 702 loading_animation_timer_.Stop(); | 728 loading_animation_timer_.Stop(); |
| 703 // Loads are now complete, update the state if a task was scheduled. | 729 // Loads are now complete, update the state if a task was scheduled. |
| 704 LoadingAnimationCallback(); | 730 LoadingAnimationCallback(); |
| 705 } | 731 } |
| 706 } | 732 } |
| 707 } | 733 } |
| 708 | 734 |
| 709 void BrowserView::SetStarredState(bool is_starred) { | 735 void BrowserView::SetStarredState(bool is_starred) { |
| 710 toolbar_->location_bar()->SetStarToggled(is_starred); | 736 GetLocationBarView()->SetStarToggled(is_starred); |
| 711 } | 737 } |
| 712 | 738 |
| 713 gfx::Rect BrowserView::GetRestoredBounds() const { | 739 gfx::Rect BrowserView::GetRestoredBounds() const { |
| 714 return frame_->GetWindow()->GetNormalBounds(); | 740 return frame_->GetWindow()->GetNormalBounds(); |
| 715 } | 741 } |
| 716 | 742 |
| 717 gfx::Rect BrowserView::GetBounds() const { | 743 gfx::Rect BrowserView::GetBounds() const { |
| 718 return frame_->GetWindow()->GetBounds(); | 744 return frame_->GetWindow()->GetBounds(); |
| 719 } | 745 } |
| 720 | 746 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 747 ProcessFullscreen(IsFullscreen()); | 773 ProcessFullscreen(IsFullscreen()); |
| 748 } | 774 } |
| 749 | 775 |
| 750 void BrowserView::RestoreFocus() { | 776 void BrowserView::RestoreFocus() { |
| 751 TabContents* selected_tab_contents = GetSelectedTabContents(); | 777 TabContents* selected_tab_contents = GetSelectedTabContents(); |
| 752 if (selected_tab_contents) | 778 if (selected_tab_contents) |
| 753 selected_tab_contents->view()->RestoreFocus(); | 779 selected_tab_contents->view()->RestoreFocus(); |
| 754 } | 780 } |
| 755 | 781 |
| 756 LocationBar* BrowserView::GetLocationBar() const { | 782 LocationBar* BrowserView::GetLocationBar() const { |
| 757 return toolbar_->location_bar(); | 783 return GetLocationBarView(); |
| 758 } | 784 } |
| 759 | 785 |
| 760 void BrowserView::SetFocusToLocationBar(bool select_all) { | 786 void BrowserView::SetFocusToLocationBar(bool select_all) { |
| 761 LocationBarView* location_bar = toolbar_->location_bar(); | 787 if (UseCompactNavigationBar()) { |
| 788 // If focus ever goes to the location bar, we should make sure it is shown |
| 789 // in compact mode. This includes all accelerators that move focus there. |
| 790 ShowCompactLocationBarUnderSelectedTab(); |
| 791 } |
| 792 LocationBarView* location_bar = GetLocationBarView(); |
| 762 if (location_bar->IsFocusableInRootView()) { | 793 if (location_bar->IsFocusableInRootView()) { |
| 763 // Location bar got focus. | 794 // Location bar got focus. |
| 764 location_bar->FocusLocation(select_all); | 795 location_bar->FocusLocation(select_all); |
| 765 } else { | 796 } else { |
| 766 // If none of location bar/compact navigation bar got focus, | 797 // If none of location bar/compact navigation bar got focus, |
| 767 // then clear focus. | 798 // then clear focus. |
| 768 views::FocusManager* focus_manager = GetFocusManager(); | 799 views::FocusManager* focus_manager = GetFocusManager(); |
| 769 DCHECK(focus_manager); | 800 DCHECK(focus_manager); |
| 770 focus_manager->ClearFocus(); | 801 focus_manager->ClearFocus(); |
| 771 } | 802 } |
| 772 } | 803 } |
| 773 | 804 |
| 774 void BrowserView::UpdateReloadStopState(bool is_loading, bool force) { | 805 void BrowserView::UpdateReloadStopState(bool is_loading, bool force) { |
| 775 toolbar_->reload_button()->ChangeMode( | 806 ReloadButton* reload_button = NULL; |
| 807 if (UseCompactNavigationBar()) { |
| 808 reload_button = compact_location_bar_view_host_-> |
| 809 GetCompactLocationBarView()->reload_button(); |
| 810 } else { |
| 811 reload_button = toolbar_->reload_button(); |
| 812 } |
| 813 reload_button->ChangeMode( |
| 776 is_loading ? ReloadButton::MODE_STOP : ReloadButton::MODE_RELOAD, force); | 814 is_loading ? ReloadButton::MODE_STOP : ReloadButton::MODE_RELOAD, force); |
| 777 } | 815 } |
| 778 | 816 |
| 779 void BrowserView::UpdateToolbar(TabContentsWrapper* contents, | 817 void BrowserView::UpdateToolbar(TabContentsWrapper* contents, |
| 780 bool should_restore_state) { | 818 bool should_restore_state) { |
| 781 toolbar_->Update(contents->tab_contents(), should_restore_state); | 819 if (UseCompactNavigationBar()) { |
| 820 if (compact_location_bar_view_host_->IsVisible()) { |
| 821 compact_location_bar_view_host_->Update( |
| 822 should_restore_state ? contents->tab_contents() : NULL, true); |
| 823 } |
| 824 } else { |
| 825 toolbar_->Update(contents->tab_contents(), should_restore_state); |
| 826 } |
| 782 } | 827 } |
| 783 | 828 |
| 784 void BrowserView::FocusToolbar() { | 829 void BrowserView::FocusToolbar() { |
| 785 // Start the traversal within the main toolbar, passing it the storage id | 830 // Start the traversal within the main toolbar, passing it the storage id |
| 786 // of the view where focus should be returned if the user exits the toolbar. | 831 // of the view where focus should be returned if the user exits the toolbar. |
| 787 SaveFocusedView(); | 832 SaveFocusedView(); |
| 788 toolbar_->SetPaneFocus(last_focused_view_storage_id_, NULL); | 833 if (UseCompactNavigationBar()) { |
| 834 if (!compact_location_bar_view_host_->IsVisible()) |
| 835 compact_location_bar_view_host_->UpdateOnTabChange( |
| 836 browser()->active_index(), true); |
| 837 compact_location_bar_view_host_->GetCompactLocationBarView()->SetPaneFocus( |
| 838 last_focused_view_storage_id_, NULL); |
| 839 } else { |
| 840 toolbar_->SetPaneFocus(last_focused_view_storage_id_, NULL); |
| 841 } |
| 789 } | 842 } |
| 790 | 843 |
| 791 void BrowserView::FocusBookmarksToolbar() { | 844 void BrowserView::FocusBookmarksToolbar() { |
| 792 if (active_bookmark_bar_ && bookmark_bar_view_->IsVisible()) { | 845 if (active_bookmark_bar_ && bookmark_bar_view_->IsVisible()) { |
| 793 SaveFocusedView(); | 846 SaveFocusedView(); |
| 794 bookmark_bar_view_->SetPaneFocus(last_focused_view_storage_id_, NULL); | 847 bookmark_bar_view_->SetPaneFocus(last_focused_view_storage_id_, NULL); |
| 795 } | 848 } |
| 796 } | 849 } |
| 797 | 850 |
| 798 void BrowserView::FocusAppMenu() { | 851 void BrowserView::FocusAppMenu() { |
| 799 // Chrome doesn't have a traditional menu bar, but it has a menu button in the | 852 // Chrome doesn't have a traditional menu bar, but it has a menu button in the |
| 800 // main toolbar that plays the same role. If the user presses a key that | 853 // main toolbar that plays the same role. If the user presses a key that |
| 801 // would typically focus the menu bar, tell the toolbar to focus the menu | 854 // would typically focus the menu bar, tell the toolbar to focus the menu |
| 802 // button. If the user presses the key again, return focus to the previous | 855 // button. If the user presses the key again, return focus to the previous |
| 803 // location. | 856 // location. |
| 804 // | 857 // |
| 805 // Not used on the Mac, which has a normal menu bar. | 858 // Not used on the Mac, which has a normal menu bar. |
| 806 if (toolbar_->IsAppMenuFocused()) { | 859 if (toolbar_->IsAppMenuFocused()) { |
| 807 RestoreFocus(); | 860 RestoreFocus(); |
| 808 } else { | 861 } else { |
| 809 SaveFocusedView(); | 862 SaveFocusedView(); |
| 863 // TODO(mad): find out how to add this to compact nav view. |
| 810 toolbar_->SetPaneFocusAndFocusAppMenu(last_focused_view_storage_id_); | 864 toolbar_->SetPaneFocusAndFocusAppMenu(last_focused_view_storage_id_); |
| 811 } | 865 } |
| 812 } | 866 } |
| 813 | 867 |
| 814 void BrowserView::RotatePaneFocus(bool forwards) { | 868 void BrowserView::RotatePaneFocus(bool forwards) { |
| 815 // This gets called when the user presses F6 (forwards) or Shift+F6 | 869 // This gets called when the user presses F6 (forwards) or Shift+F6 |
| 816 // (backwards) to rotate to the next pane. Here, our "panes" are the | 870 // (backwards) to rotate to the next pane. Here, our "panes" are the |
| 817 // tab contents and each of our accessible toolbars, infobars, downloads | 871 // tab contents and each of our accessible toolbars, infobars, downloads |
| 818 // shelf, etc. When a pane has focus, all of its controls are accessible | 872 // shelf, etc. When a pane has focus, all of its controls are accessible |
| 819 // in the tab traversal, and the tab traversal is "trapped" within that pane. | 873 // in the tab traversal, and the tab traversal is "trapped" within that pane. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 | 953 |
| 900 bool BrowserView::IsBookmarkBarAnimating() const { | 954 bool BrowserView::IsBookmarkBarAnimating() const { |
| 901 return bookmark_bar_view_.get() && bookmark_bar_view_->is_animating(); | 955 return bookmark_bar_view_.get() && bookmark_bar_view_->is_animating(); |
| 902 } | 956 } |
| 903 | 957 |
| 904 bool BrowserView::IsTabStripEditable() const { | 958 bool BrowserView::IsTabStripEditable() const { |
| 905 return tabstrip_->IsTabStripEditable(); | 959 return tabstrip_->IsTabStripEditable(); |
| 906 } | 960 } |
| 907 | 961 |
| 908 bool BrowserView::IsToolbarVisible() const { | 962 bool BrowserView::IsToolbarVisible() const { |
| 909 return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || | 963 if (UseCompactNavigationBar()) { |
| 910 browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); | 964 return false; |
| 965 } else { |
| 966 return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || |
| 967 browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); |
| 968 } |
| 911 } | 969 } |
| 912 | 970 |
| 913 void BrowserView::DisableInactiveFrame() { | 971 void BrowserView::DisableInactiveFrame() { |
| 914 #if defined(OS_WIN) | 972 #if defined(OS_WIN) |
| 915 frame_->GetWindow()->DisableInactiveRendering(); | 973 frame_->GetWindow()->DisableInactiveRendering(); |
| 916 #endif // No tricks are needed to get the right behavior on Linux. | 974 #endif // No tricks are needed to get the right behavior on Linux. |
| 917 } | 975 } |
| 918 | 976 |
| 919 void BrowserView::ConfirmSetDefaultSearchProvider( | 977 void BrowserView::ConfirmSetDefaultSearchProvider( |
| 920 TabContents* tab_contents, | 978 TabContents* tab_contents, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 944 | 1002 |
| 945 views::Window* BrowserView::DoShowAboutChromeDialog() { | 1003 views::Window* BrowserView::DoShowAboutChromeDialog() { |
| 946 return browser::ShowAboutChromeView(GetWindow()->GetNativeWindow(), | 1004 return browser::ShowAboutChromeView(GetWindow()->GetNativeWindow(), |
| 947 browser_->profile()); | 1005 browser_->profile()); |
| 948 } | 1006 } |
| 949 | 1007 |
| 950 void BrowserView::ShowUpdateChromeDialog() { | 1008 void BrowserView::ShowUpdateChromeDialog() { |
| 951 UpdateRecommendedMessageBox::ShowMessageBox(GetWindow()->GetNativeWindow()); | 1009 UpdateRecommendedMessageBox::ShowMessageBox(GetWindow()->GetNativeWindow()); |
| 952 } | 1010 } |
| 953 | 1011 |
| 1012 void BrowserView::ShowCompactLocationBarUnderSelectedTab() { |
| 1013 if (!UseCompactNavigationBar()) |
| 1014 return; |
| 1015 compact_location_bar_view_host_->UpdateOnTabChange(browser()->active_index(), |
| 1016 true); |
| 1017 } |
| 1018 |
| 954 void BrowserView::ShowTaskManager() { | 1019 void BrowserView::ShowTaskManager() { |
| 955 browser::ShowTaskManager(); | 1020 browser::ShowTaskManager(); |
| 956 } | 1021 } |
| 957 | 1022 |
| 958 void BrowserView::ShowBackgroundPages() { | 1023 void BrowserView::ShowBackgroundPages() { |
| 959 browser::ShowBackgroundPages(); | 1024 browser::ShowBackgroundPages(); |
| 960 } | 1025 } |
| 961 | 1026 |
| 962 void BrowserView::ShowBookmarkBubble(const GURL& url, bool already_bookmarked) { | 1027 void BrowserView::ShowBookmarkBubble(const GURL& url, bool already_bookmarked) { |
| 963 toolbar_->location_bar()->ShowStarBubble(url, !already_bookmarked); | 1028 GetLocationBarView()->ShowStarBubble(url, !already_bookmarked); |
| 964 } | 1029 } |
| 965 | 1030 |
| 966 void BrowserView::SetDownloadShelfVisible(bool visible) { | 1031 void BrowserView::SetDownloadShelfVisible(bool visible) { |
| 967 // This can be called from the superclass destructor, when it destroys our | 1032 // This can be called from the superclass destructor, when it destroys our |
| 968 // child views. At that point, browser_ is already gone. | 1033 // child views. At that point, browser_ is already gone. |
| 969 if (browser_ == NULL) | 1034 if (browser_ == NULL) |
| 970 return; | 1035 return; |
| 971 | 1036 |
| 972 if (visible && IsDownloadShelfVisible() != visible) { | 1037 if (visible && IsDownloadShelfVisible() != visible) { |
| 973 // Invoke GetDownloadShelf to force the shelf to be created. | 1038 // Invoke GetDownloadShelf to force the shelf to be created. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 void BrowserView::ShowPageInfo(Profile* profile, | 1119 void BrowserView::ShowPageInfo(Profile* profile, |
| 1055 const GURL& url, | 1120 const GURL& url, |
| 1056 const NavigationEntry::SSLStatus& ssl, | 1121 const NavigationEntry::SSLStatus& ssl, |
| 1057 bool show_history) { | 1122 bool show_history) { |
| 1058 gfx::NativeWindow parent = GetWindow()->GetNativeWindow(); | 1123 gfx::NativeWindow parent = GetWindow()->GetNativeWindow(); |
| 1059 | 1124 |
| 1060 browser::ShowPageInfoBubble(parent, profile, url, ssl, show_history); | 1125 browser::ShowPageInfoBubble(parent, profile, url, ssl, show_history); |
| 1061 } | 1126 } |
| 1062 | 1127 |
| 1063 void BrowserView::ShowAppMenu() { | 1128 void BrowserView::ShowAppMenu() { |
| 1129 // TODO(mad): find out how to add this to compact nav view. |
| 1064 toolbar_->app_menu()->Activate(); | 1130 toolbar_->app_menu()->Activate(); |
| 1065 } | 1131 } |
| 1066 | 1132 |
| 1067 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | 1133 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
| 1068 bool* is_keyboard_shortcut) { | 1134 bool* is_keyboard_shortcut) { |
| 1069 if (event.type != WebKit::WebInputEvent::RawKeyDown) | 1135 if (event.type != WebKit::WebInputEvent::RawKeyDown) |
| 1070 return false; | 1136 return false; |
| 1071 | 1137 |
| 1072 #if defined(OS_WIN) | 1138 #if defined(OS_WIN) |
| 1073 // As Alt+F4 is the close-app keyboard shortcut, it needs processing | 1139 // As Alt+F4 is the close-app keyboard shortcut, it needs processing |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1149 void BrowserView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { | 1215 void BrowserView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { |
| 1150 // TODO(ben): figure out why are these two code paths so different | 1216 // TODO(ben): figure out why are these two code paths so different |
| 1151 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) | 1217 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) |
| 1152 HandleWebKeyboardEvent(GetWidget(), event); | 1218 HandleWebKeyboardEvent(GetWidget(), event); |
| 1153 #else | 1219 #else |
| 1154 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, | 1220 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, |
| 1155 GetFocusManager()); | 1221 GetFocusManager()); |
| 1156 #endif | 1222 #endif |
| 1157 } | 1223 } |
| 1158 | 1224 |
| 1225 void BrowserView::ToggleUseCompactNavigationBar() { |
| 1226 bool use_compact_navigation_bar = UseCompactNavigationBar(); |
| 1227 // Compact Navigation Bar only works with horizontal tabs for now! |
| 1228 if (use_compact_navigation_bar && UseVerticalTabs()) |
| 1229 browser()->ExecuteCommand(IDC_TOGGLE_VERTICAL_TABS); |
| 1230 compact_location_bar_view_host_->SetEnabled(use_compact_navigation_bar); |
| 1231 compact_location_bar_view_host_->Hide(!use_compact_navigation_bar); |
| 1232 Layout(); |
| 1233 } |
| 1234 |
| 1159 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always | 1235 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always |
| 1160 // enabled in the page menu regardless of whether the command will do | 1236 // enabled in the page menu regardless of whether the command will do |
| 1161 // anything. When someone selects the menu item, we just act as if they hit | 1237 // anything. When someone selects the menu item, we just act as if they hit |
| 1162 // the keyboard shortcut for the command by sending the associated key press | 1238 // the keyboard shortcut for the command by sending the associated key press |
| 1163 // to windows. The real fix to this bug is to disable the commands when they | 1239 // to windows. The real fix to this bug is to disable the commands when they |
| 1164 // won't do anything. We'll need something like an overall clipboard command | 1240 // won't do anything. We'll need something like an overall clipboard command |
| 1165 // manager to do that. | 1241 // manager to do that. |
| 1166 void BrowserView::Cut() { | 1242 void BrowserView::Cut() { |
| 1167 ui_controls::SendKeyPress(GetNativeHandle(), ui::VKEY_X, | 1243 ui_controls::SendKeyPress(GetNativeHandle(), ui::VKEY_X, |
| 1168 true, false, false, false); | 1244 true, false, false, false); |
| 1169 } | 1245 } |
| 1170 | 1246 |
| 1171 void BrowserView::Copy() { | 1247 void BrowserView::Copy() { |
| 1172 ui_controls::SendKeyPress(GetNativeHandle(), ui::VKEY_C, | 1248 ui_controls::SendKeyPress(GetNativeHandle(), ui::VKEY_C, |
| 1173 true, false, false, false); | 1249 true, false, false, false); |
| 1174 } | 1250 } |
| 1175 | 1251 |
| 1176 void BrowserView::Paste() { | 1252 void BrowserView::Paste() { |
| 1177 ui_controls::SendKeyPress(GetNativeHandle(), ui::VKEY_V, | 1253 ui_controls::SendKeyPress(GetNativeHandle(), ui::VKEY_V, |
| 1178 true, false, false, false); | 1254 true, false, false, false); |
| 1179 } | 1255 } |
| 1180 | 1256 |
| 1181 void BrowserView::ToggleTabStripMode() { | 1257 void BrowserView::ToggleTabStripMode() { |
| 1258 // Compact Navigation Bar only works with horizontal tabs for now! |
| 1259 if (UseVerticalTabs() && UseCompactNavigationBar()) |
| 1260 browser()->ExecuteCommand(IDC_COMPACT_NAVBAR); |
| 1261 |
| 1182 InitTabStrip(browser_->tabstrip_model()); | 1262 InitTabStrip(browser_->tabstrip_model()); |
| 1183 frame_->TabStripDisplayModeChanged(); | 1263 frame_->TabStripDisplayModeChanged(); |
| 1184 } | 1264 } |
| 1185 | 1265 |
| 1186 void BrowserView::PrepareForInstant() { | 1266 void BrowserView::PrepareForInstant() { |
| 1187 contents_->FadeActiveContents(); | 1267 contents_->FadeActiveContents(); |
| 1188 } | 1268 } |
| 1189 | 1269 |
| 1190 void BrowserView::ShowInstant(TabContentsWrapper* preview) { | 1270 void BrowserView::ShowInstant(TabContentsWrapper* preview) { |
| 1191 if (!preview_container_) | 1271 if (!preview_container_) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 #endif | 1315 #endif |
| 1236 | 1316 |
| 1237 /////////////////////////////////////////////////////////////////////////////// | 1317 /////////////////////////////////////////////////////////////////////////////// |
| 1238 // BrowserView, BrowserWindowTesting implementation: | 1318 // BrowserView, BrowserWindowTesting implementation: |
| 1239 | 1319 |
| 1240 BookmarkBarView* BrowserView::GetBookmarkBarView() const { | 1320 BookmarkBarView* BrowserView::GetBookmarkBarView() const { |
| 1241 return bookmark_bar_view_.get(); | 1321 return bookmark_bar_view_.get(); |
| 1242 } | 1322 } |
| 1243 | 1323 |
| 1244 LocationBarView* BrowserView::GetLocationBarView() const { | 1324 LocationBarView* BrowserView::GetLocationBarView() const { |
| 1245 return toolbar_->location_bar(); | 1325 if (UseCompactNavigationBar()) { |
| 1326 return compact_location_bar_view_host_->GetCompactLocationBarView()-> |
| 1327 location_bar_view(); |
| 1328 } else { |
| 1329 return toolbar_ ? toolbar_->location_bar() : NULL; |
| 1330 } |
| 1246 } | 1331 } |
| 1247 | 1332 |
| 1248 views::View* BrowserView::GetTabContentsContainerView() const { | 1333 views::View* BrowserView::GetTabContentsContainerView() const { |
| 1249 return contents_container_->GetFocusView(); | 1334 return contents_container_->GetFocusView(); |
| 1250 } | 1335 } |
| 1251 | 1336 |
| 1252 views::View* BrowserView::GetSidebarContainerView() const { | 1337 views::View* BrowserView::GetSidebarContainerView() const { |
| 1253 if (!sidebar_container_) | 1338 if (!sidebar_container_) |
| 1254 return NULL; | 1339 return NULL; |
| 1255 return sidebar_container_->GetFocusView(); | 1340 return sidebar_container_->GetFocusView(); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1556 // Comment out for one cycle to see if this fixes dist tests. | 1641 // Comment out for one cycle to see if this fixes dist tests. |
| 1557 // tabstrip_->DestroyDragController(); | 1642 // tabstrip_->DestroyDragController(); |
| 1558 | 1643 |
| 1559 status_bubble_->Reposition(); | 1644 status_bubble_->Reposition(); |
| 1560 | 1645 |
| 1561 BrowserBubbleHost::WindowMoved(); | 1646 BrowserBubbleHost::WindowMoved(); |
| 1562 | 1647 |
| 1563 browser::HideBookmarkBubbleView(); | 1648 browser::HideBookmarkBubbleView(); |
| 1564 | 1649 |
| 1565 // Close the omnibox popup, if any. | 1650 // Close the omnibox popup, if any. |
| 1566 if (toolbar_ && toolbar_->location_bar()) | 1651 LocationBarView* location_bar_view = GetLocationBarView(); |
| 1567 toolbar_->location_bar()->location_entry()->ClosePopup(); | 1652 if (location_bar_view) |
| 1653 location_bar_view->location_entry()->ClosePopup(); |
| 1568 } | 1654 } |
| 1569 | 1655 |
| 1570 /////////////////////////////////////////////////////////////////////////////// | 1656 /////////////////////////////////////////////////////////////////////////////// |
| 1571 // BrowserView, views::ClientView overrides: | 1657 // BrowserView, views::ClientView overrides: |
| 1572 | 1658 |
| 1573 bool BrowserView::CanClose() { | 1659 bool BrowserView::CanClose() { |
| 1574 // You cannot close a frame for which there is an active originating drag | 1660 // You cannot close a frame for which there is an active originating drag |
| 1575 // session. | 1661 // session. |
| 1576 if (tabstrip_ && !tabstrip_->IsTabStripCloseable()) | 1662 if (tabstrip_ && !tabstrip_->IsTabStripCloseable()) |
| 1577 return false; | 1663 return false; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1836 jumplist_.reset(new JumpList); | 1922 jumplist_.reset(new JumpList); |
| 1837 jumplist_->AddObserver(browser_->profile()); | 1923 jumplist_->AddObserver(browser_->profile()); |
| 1838 } | 1924 } |
| 1839 | 1925 |
| 1840 if (AeroPeekManager::Enabled()) { | 1926 if (AeroPeekManager::Enabled()) { |
| 1841 aeropeek_manager_.reset(new AeroPeekManager( | 1927 aeropeek_manager_.reset(new AeroPeekManager( |
| 1842 frame_->GetWindow()->GetNativeWindow())); | 1928 frame_->GetWindow()->GetNativeWindow())); |
| 1843 browser_->tabstrip_model()->AddObserver(aeropeek_manager_.get()); | 1929 browser_->tabstrip_model()->AddObserver(aeropeek_manager_.get()); |
| 1844 } | 1930 } |
| 1845 #endif | 1931 #endif |
| 1932 // Only create our compact navigation classes if the switch is enabled. Note |
| 1933 // that we directly check the switch and not the pref as the switch may be on |
| 1934 // and the pref could be off (currently not selected in the context menu). |
| 1935 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1936 switches::kEnableCompactNavigation)) { |
| 1937 compact_location_bar_view_host_.reset(new CompactLocationBarViewHost(this)); |
| 1938 compact_navigation_bar_ = new CompactNavigationBar(this); |
| 1939 compact_navigation_bar_->SetID(VIEW_ID_COMPACT_NAV_BAR); |
| 1940 AddChildView(compact_navigation_bar_); |
| 1941 compact_navigation_bar_->Init(); |
| 1942 compact_options_bar_ = new CompactOptionsBar(this); |
| 1943 compact_options_bar_->SetID(VIEW_ID_COMPACT_OPT_BAR); |
| 1944 AddChildView(compact_options_bar_); |
| 1945 compact_options_bar_->Init(); |
| 1946 } |
| 1947 |
| 1948 // Use an empty view for the spacer since all it does is that it replaces the |
| 1949 // toolbar area in compact navigation mode. |
| 1950 compact_spacer_ = new views::View(); |
| 1951 compact_spacer_->SetID(VIEW_ID_COMPACT_NAV_BAR_SPACER); |
| 1952 AddChildView(compact_spacer_); |
| 1846 | 1953 |
| 1847 // We're now initialized and ready to process Layout requests. | 1954 // We're now initialized and ready to process Layout requests. |
| 1848 ignore_layout_ = false; | 1955 ignore_layout_ = false; |
| 1849 } | 1956 } |
| 1850 | 1957 |
| 1851 void BrowserView::LoadingAnimationCallback() { | 1958 void BrowserView::LoadingAnimationCallback() { |
| 1852 base::TimeTicks now = base::TimeTicks::Now(); | 1959 base::TimeTicks now = base::TimeTicks::Now(); |
| 1853 if (!last_animation_time_.is_null()) { | 1960 if (!last_animation_time_.is_null()) { |
| 1854 UMA_HISTOGRAM_TIMES( | 1961 UMA_HISTOGRAM_TIMES( |
| 1855 "Tabs.LoadingAnimationTime", | 1962 "Tabs.LoadingAnimationTime", |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2104 *old_view = new_view; | 2211 *old_view = new_view; |
| 2105 return changed; | 2212 return changed; |
| 2106 } | 2213 } |
| 2107 | 2214 |
| 2108 void BrowserView::ProcessFullscreen(bool fullscreen) { | 2215 void BrowserView::ProcessFullscreen(bool fullscreen) { |
| 2109 // Reduce jankiness during the following position changes by: | 2216 // Reduce jankiness during the following position changes by: |
| 2110 // * Hiding the window until it's in the final position | 2217 // * Hiding the window until it's in the final position |
| 2111 // * Ignoring all intervening Layout() calls, which resize the webpage and | 2218 // * Ignoring all intervening Layout() calls, which resize the webpage and |
| 2112 // thus are slow and look ugly | 2219 // thus are slow and look ugly |
| 2113 ignore_layout_ = true; | 2220 ignore_layout_ = true; |
| 2114 LocationBarView* location_bar = toolbar_->location_bar(); | 2221 LocationBarView* location_bar = GetLocationBarView(); |
| 2115 #if defined(OS_WIN) | 2222 #if defined(OS_WIN) |
| 2116 OmniboxViewWin* omnibox_view = | 2223 OmniboxViewWin* omnibox_view = |
| 2117 static_cast<OmniboxViewWin*>(location_bar->location_entry()); | 2224 static_cast<OmniboxViewWin*>(location_bar->location_entry()); |
| 2118 #endif | 2225 #endif |
| 2119 if (!fullscreen) { | 2226 if (!fullscreen) { |
| 2120 // Hide the fullscreen bubble as soon as possible, since the mode toggle can | 2227 // Hide the fullscreen bubble as soon as possible, since the mode toggle can |
| 2121 // take enough time for the user to notice. | 2228 // take enough time for the user to notice. |
| 2122 fullscreen_bubble_.reset(); | 2229 fullscreen_bubble_.reset(); |
| 2123 } else { | 2230 } else { |
| 2124 // Move focus out of the location bar if necessary. | 2231 // Move focus out of the location bar if necessary. |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2470 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 2577 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 2471 | 2578 |
| 2472 return view; | 2579 return view; |
| 2473 } | 2580 } |
| 2474 #endif | 2581 #endif |
| 2475 | 2582 |
| 2476 // static | 2583 // static |
| 2477 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 2584 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
| 2478 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 2585 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
| 2479 } | 2586 } |
| OLD | NEW |