Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 6913026: Compact Navigation prototype (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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(OS_LINUX) 7 #if defined(OS_LINUX)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
(...skipping 27 matching lines...) Expand all
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/toolbar/wrench_menu_model.h" 44 #include "chrome/browser/ui/toolbar/wrench_menu_model.h"
45 #include "chrome/browser/ui/view_ids.h" 45 #include "chrome/browser/ui/view_ids.h"
46 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 46 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
47 #include "chrome/browser/ui/views/browser_dialogs.h" 47 #include "chrome/browser/ui/views/browser_dialogs.h"
48 #include "chrome/browser/ui/views/compact_nav/compact_location_bar_view.h"
49 #include "chrome/browser/ui/views/compact_nav/compact_location_bar_view_host.h"
50 #include "chrome/browser/ui/views/compact_nav/compact_navigation_bar.h"
51 #include "chrome/browser/ui/views/compact_nav/compact_options_bar.h"
48 #include "chrome/browser/ui/views/default_search_view.h" 52 #include "chrome/browser/ui/views/default_search_view.h"
49 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" 53 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h"
50 #include "chrome/browser/ui/views/download/download_shelf_view.h" 54 #include "chrome/browser/ui/views/download/download_shelf_view.h"
51 #include "chrome/browser/ui/views/frame/browser_view_layout.h" 55 #include "chrome/browser/ui/views/frame/browser_view_layout.h"
52 #include "chrome/browser/ui/views/frame/contents_container.h" 56 #include "chrome/browser/ui/views/frame/contents_container.h"
53 #include "chrome/browser/ui/views/fullscreen_exit_bubble.h" 57 #include "chrome/browser/ui/views/fullscreen_exit_bubble.h"
54 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" 58 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
55 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" 59 #include "chrome/browser/ui/views/location_bar/location_icon_view.h"
56 #include "chrome/browser/ui/views/status_bubble_views.h" 60 #include "chrome/browser/ui/views/status_bubble_views.h"
57 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" 61 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h"
(...skipping 13 matching lines...) Expand all
71 #include "content/browser/renderer_host/render_widget_host_view.h" 75 #include "content/browser/renderer_host/render_widget_host_view.h"
72 #include "content/browser/tab_contents/tab_contents.h" 76 #include "content/browser/tab_contents/tab_contents.h"
73 #include "content/browser/tab_contents/tab_contents_view.h" 77 #include "content/browser/tab_contents/tab_contents_view.h"
74 #include "content/browser/user_metrics.h" 78 #include "content/browser/user_metrics.h"
75 #include "content/common/notification_service.h" 79 #include "content/common/notification_service.h"
76 #include "grit/app_resources.h" 80 #include "grit/app_resources.h"
77 #include "grit/chromium_strings.h" 81 #include "grit/chromium_strings.h"
78 #include "grit/generated_resources.h" 82 #include "grit/generated_resources.h"
79 #include "grit/locale_settings.h" 83 #include "grit/locale_settings.h"
80 #include "grit/theme_resources.h" 84 #include "grit/theme_resources.h"
85 #include "grit/theme_resources_standard.h"
81 #include "grit/webkit_resources.h" 86 #include "grit/webkit_resources.h"
82 #include "ui/base/accessibility/accessible_view_state.h" 87 #include "ui/base/accessibility/accessible_view_state.h"
83 #include "ui/base/l10n/l10n_util.h" 88 #include "ui/base/l10n/l10n_util.h"
84 #include "ui/base/resource/resource_bundle.h" 89 #include "ui/base/resource/resource_bundle.h"
85 #include "ui/gfx/canvas_skia.h" 90 #include "ui/gfx/canvas_skia.h"
86 #include "views/controls/single_split_view.h" 91 #include "views/controls/single_split_view.h"
87 #include "views/events/event.h" 92 #include "views/events/event.h"
88 #include "views/focus/external_focus_tracker.h" 93 #include "views/focus/external_focus_tracker.h"
89 #include "views/focus/view_storage.h" 94 #include "views/focus/view_storage.h"
90 #include "views/layout/grid_layout.h" 95 #include "views/layout/grid_layout.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 profile ? profile : browser->profile(), 153 profile ? profile : browser->profile(),
149 Browser::TYPE_NORMAL, true); 154 Browser::TYPE_NORMAL, true);
150 if (normal_browser && normal_browser->window()) 155 if (normal_browser && normal_browser->window())
151 return normal_browser->window()->GetNativeHandle(); 156 return normal_browser->window()->GetNativeHandle();
152 } 157 }
153 158
154 return browser->window()->GetNativeHandle(); 159 return browser->window()->GetNativeHandle();
155 } 160 }
156 #endif // defined(OS_CHROMEOS) 161 #endif // defined(OS_CHROMEOS)
157 162
163 namespace {
164 // A space we insert between the tabstrip and the content in
165 // Compact mode.
166 class Spacer : public views::View {
167 SkBitmap* background_;
Peter Kasting 2011/05/03 18:04:24 Nit: Put this in a section.
SteveT 2011/05/06 18:48:43 Spacer class was removed since we eventually ended
168 public:
169 explicit Spacer(SkBitmap* bitmap) : background_(bitmap) {}
170
171 private:
172 DISALLOW_COPY_AND_ASSIGN(Spacer);
173 };
174
175 // TODO(sky): wire this back up.
176 /*
177 // A chromeos implementation of Tab that shows the compact location bar.
178 class ChromeosTab : public Tab {
Peter Kasting 2011/05/03 18:04:24 Nit: Wouldn't ChromeOSTab be better? (2 classes)
SteveT 2011/05/06 18:48:43 Actually, this commented out code that sky/oshima
179 public:
180 ChromeosTab(TabStrip* tab_strip, chromeos::BrowserView* browser_view)
181 : Tab(tab_strip),
182 browser_view_(browser_view) {
183 }
184 virtual ~ChromeosTab() {}
185
186 // Overridden from views::View.
187 virtual void OnMouseEntered(const views::MouseEvent& event) {
Peter Kasting 2011/05/03 18:04:24 Nit: Use OVERRIDE (here and elsewhere) I also sug
SteveT 2011/05/06 18:48:43 Deleted, as above.
188 TabRenderer::OnMouseEntered(event);
189 browser_view_->ShowCompactLocationBarUnderSelectedTab();
190 }
191
192 private:
193 chromeos::BrowserView* browser_view_;
194
195 DISALLOW_COPY_AND_ASSIGN(ChromeosTab);
196 };
197
198 // A Tabstrip that uses ChromeosTab as a Tab implementation.
199 class ChromeosTabStrip : public TabStrip {
200 public:
201 ChromeosTabStrip(TabStripModel* model, chromeos::BrowserView* browser_view)
202 : TabStrip(model), browser_view_(browser_view) {
203 }
204 virtual ~ChromeosTabStrip() {}
205
206 protected:
207 // Overridden from TabStrip.
208 virtual Tab* CreateTab() {
209 return new ChromeosTab(this, browser_view_);
210 }
211
212 private:
213 chromeos::BrowserView* browser_view_;
214
215 DISALLOW_COPY_AND_ASSIGN(ChromeosTabStrip);
216 };
217 */
218 }
219
158 /////////////////////////////////////////////////////////////////////////////// 220 ///////////////////////////////////////////////////////////////////////////////
159 // BookmarkExtensionBackground, private: 221 // BookmarkExtensionBackground, private:
160 // This object serves as the views::Background object which is used to layout 222 // This object serves as the views::Background object which is used to layout
161 // and paint the bookmark bar. 223 // and paint the bookmark bar.
162 class BookmarkExtensionBackground : public views::Background { 224 class BookmarkExtensionBackground : public views::Background {
163 public: 225 public:
164 explicit BookmarkExtensionBackground(BrowserView* browser_view, 226 explicit BookmarkExtensionBackground(BrowserView* browser_view,
165 DetachableToolbarView* host_view, 227 DetachableToolbarView* host_view,
166 Browser* browser); 228 Browser* browser);
167 229
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 359
298 BrowserView::BrowserView(Browser* browser) 360 BrowserView::BrowserView(Browser* browser)
299 : views::ClientView(NULL, NULL), 361 : views::ClientView(NULL, NULL),
300 last_focused_view_storage_id_( 362 last_focused_view_storage_id_(
301 views::ViewStorage::GetInstance()->CreateStorageID()), 363 views::ViewStorage::GetInstance()->CreateStorageID()),
302 frame_(NULL), 364 frame_(NULL),
303 browser_(browser), 365 browser_(browser),
304 active_bookmark_bar_(NULL), 366 active_bookmark_bar_(NULL),
305 tabstrip_(NULL), 367 tabstrip_(NULL),
306 toolbar_(NULL), 368 toolbar_(NULL),
369 compact_navigation_bar_(NULL),
370 compact_options_bar_(NULL),
371 spacer_(NULL),
307 infobar_container_(NULL), 372 infobar_container_(NULL),
308 sidebar_container_(NULL), 373 sidebar_container_(NULL),
309 sidebar_split_(NULL), 374 sidebar_split_(NULL),
310 contents_container_(NULL), 375 contents_container_(NULL),
311 devtools_container_(NULL), 376 devtools_container_(NULL),
312 preview_container_(NULL), 377 preview_container_(NULL),
313 contents_(NULL), 378 contents_(NULL),
314 contents_split_(NULL), 379 contents_split_(NULL),
315 initialized_(false), 380 initialized_(false),
316 ignore_layout_(true) 381 ignore_layout_(true)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 if (window) { 436 if (window) {
372 return static_cast<BrowserView*>( 437 return static_cast<BrowserView*>(
373 g_object_get_data(G_OBJECT(window), kBrowserViewKey)); 438 g_object_get_data(G_OBJECT(window), kBrowserViewKey));
374 } 439 }
375 #endif 440 #endif
376 return NULL; 441 return NULL;
377 } 442 }
378 443
379 gfx::Rect BrowserView::GetToolbarBounds() const { 444 gfx::Rect BrowserView::GetToolbarBounds() const {
380 gfx::Rect toolbar_bounds(toolbar_->bounds()); 445 gfx::Rect toolbar_bounds(toolbar_->bounds());
446 // In compact navigation mode, the spacer essentially replaces the toolbar.
447 // We must provide it's height in order to have the client area divider paint
448 // properly.
449 if (UseCompactNavigationBar())
450 toolbar_bounds = spacer_->bounds();
381 if (toolbar_bounds.IsEmpty()) 451 if (toolbar_bounds.IsEmpty())
382 return toolbar_bounds; 452 return toolbar_bounds;
383 // When using vertical tabs, the toolbar appears to extend behind the tab 453 // When using vertical tabs, the toolbar appears to extend behind the tab
384 // column. 454 // column.
385 if (UseVerticalTabs()) 455 if (UseVerticalTabs())
386 toolbar_bounds.Inset(tabstrip_->x() - toolbar_bounds.x(), 0, 0, 0); 456 toolbar_bounds.Inset(tabstrip_->x() - toolbar_bounds.x(), 0, 0, 0);
387 // The apparent toolbar edges are outside the "real" toolbar edges. 457 // The apparent toolbar edges are outside the "real" toolbar edges.
388 toolbar_bounds.Inset(-views::NonClientFrameView::kClientEdgeThickness, 0); 458 toolbar_bounds.Inset(-views::NonClientFrameView::kClientEdgeThickness, 0);
389 return toolbar_bounds; 459 return toolbar_bounds;
390 } 460 }
391 461
392 gfx::Rect BrowserView::GetClientAreaBounds() const { 462 gfx::Rect BrowserView::GetClientAreaBounds() const {
393 gfx::Rect container_bounds = contents_->bounds(); 463 gfx::Rect container_bounds = contents_->bounds();
394 gfx::Point container_origin = container_bounds.origin(); 464 gfx::Point container_origin = container_bounds.origin();
395 ConvertPointToView(this, parent(), &container_origin); 465 ConvertPointToView(this, parent(), &container_origin);
396 container_bounds.set_origin(container_origin); 466 container_bounds.set_origin(container_origin);
397 return container_bounds; 467 return container_bounds;
398 } 468 }
399 469
400 gfx::Rect BrowserView::GetFindBarBoundingBox() const { 470 gfx::Rect BrowserView::GetFindBarBoundingBox() const {
401 return GetBrowserViewLayout()->GetFindBarBoundingBox(); 471 return GetBrowserViewLayout()->GetFindBarBoundingBox();
402 } 472 }
403 473
474 gfx::Rect BrowserView::GetCompactNavigationBarBounds() const {
475 return compact_navigation_bar_->bounds();
476 }
477
478 gfx::Rect BrowserView::GetCompactOptionsBarBounds() const {
479 return compact_options_bar_->bounds();
480 }
481
404 int BrowserView::GetTabStripHeight() const { 482 int BrowserView::GetTabStripHeight() const {
405 // We want to return tabstrip_->height(), but we might be called in the midst 483 // 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. 484 // 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. 485 // So return what the tabstrip height _ought_ to be right now.
408 return IsTabStripVisible() ? tabstrip_->GetPreferredSize().height() : 0; 486 return IsTabStripVisible() ? tabstrip_->GetPreferredSize().height() : 0;
409 } 487 }
410 488
411 gfx::Point BrowserView::OffsetPointForToolbarBackgroundImage( 489 gfx::Point BrowserView::OffsetPointForToolbarBackgroundImage(
412 const gfx::Point& point) const { 490 const gfx::Point& point) const {
413 // The background image starts tiling horizontally at the window left edge and 491 // The background image starts tiling horizontally at the window left edge and
(...skipping 11 matching lines...) Expand all
425 } 503 }
426 504
427 bool BrowserView::IsTabStripVisible() const { 505 bool BrowserView::IsTabStripVisible() const {
428 return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); 506 return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP);
429 } 507 }
430 508
431 bool BrowserView::UseVerticalTabs() const { 509 bool BrowserView::UseVerticalTabs() const {
432 return browser_->tabstrip_model()->delegate()->UseVerticalTabs(); 510 return browser_->tabstrip_model()->delegate()->UseVerticalTabs();
433 } 511 }
434 512
513 bool BrowserView::UseCompactNavigationBar() const {
514 return browser_->tabstrip_model()->delegate()->UseCompactNavigationBar();
515 }
516
435 bool BrowserView::IsOffTheRecord() const { 517 bool BrowserView::IsOffTheRecord() const {
436 return browser_->profile()->IsOffTheRecord(); 518 return browser_->profile()->IsOffTheRecord();
437 } 519 }
438 520
439 bool BrowserView::ShouldShowOffTheRecordAvatar() const { 521 bool BrowserView::ShouldShowOffTheRecordAvatar() const {
440 return IsOffTheRecord() && IsBrowserTypeNormal(); 522 return IsOffTheRecord() && IsBrowserTypeNormal();
441 } 523 }
442 524
443 bool BrowserView::AcceleratorPressed(const views::Accelerator& accelerator) { 525 bool BrowserView::AcceleratorPressed(const views::Accelerator& accelerator) {
444 #if defined(OS_CHROMEOS) 526 #if defined(OS_CHROMEOS)
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 if (loading_animation_timer_.IsRunning()) { 779 if (loading_animation_timer_.IsRunning()) {
698 last_animation_time_ = base::TimeTicks(); 780 last_animation_time_ = base::TimeTicks();
699 loading_animation_timer_.Stop(); 781 loading_animation_timer_.Stop();
700 // Loads are now complete, update the state if a task was scheduled. 782 // Loads are now complete, update the state if a task was scheduled.
701 LoadingAnimationCallback(); 783 LoadingAnimationCallback();
702 } 784 }
703 } 785 }
704 } 786 }
705 787
706 void BrowserView::SetStarredState(bool is_starred) { 788 void BrowserView::SetStarredState(bool is_starred) {
707 toolbar_->location_bar()->SetStarToggled(is_starred); 789 GetLocationBarView()->SetStarToggled(is_starred);
708 } 790 }
709 791
710 gfx::Rect BrowserView::GetRestoredBounds() const { 792 gfx::Rect BrowserView::GetRestoredBounds() const {
711 return frame_->GetWindow()->GetNormalBounds(); 793 return frame_->GetWindow()->GetNormalBounds();
712 } 794 }
713 795
714 gfx::Rect BrowserView::GetBounds() const { 796 gfx::Rect BrowserView::GetBounds() const {
715 return frame_->GetWindow()->GetBounds(); 797 return frame_->GetWindow()->GetBounds();
716 } 798 }
717 799
(...skipping 26 matching lines...) Expand all
744 ProcessFullscreen(IsFullscreen()); 826 ProcessFullscreen(IsFullscreen());
745 } 827 }
746 828
747 void BrowserView::RestoreFocus() { 829 void BrowserView::RestoreFocus() {
748 TabContents* selected_tab_contents = GetSelectedTabContents(); 830 TabContents* selected_tab_contents = GetSelectedTabContents();
749 if (selected_tab_contents) 831 if (selected_tab_contents)
750 selected_tab_contents->view()->RestoreFocus(); 832 selected_tab_contents->view()->RestoreFocus();
751 } 833 }
752 834
753 LocationBar* BrowserView::GetLocationBar() const { 835 LocationBar* BrowserView::GetLocationBar() const {
754 return toolbar_->location_bar(); 836 return GetLocationBarView();
755 } 837 }
756 838
757 void BrowserView::SetFocusToLocationBar(bool select_all) { 839 void BrowserView::SetFocusToLocationBar(bool select_all) {
758 LocationBarView* location_bar = toolbar_->location_bar(); 840 if (UseCompactNavigationBar()) {
841 // If focus ever goes to the location bar, we should make sure it is shown
842 // in compact mode. This includes all accelerators that move focus there.
843 ShowCompactLocationBarUnderSelectedTab();
844 }
845 LocationBarView* location_bar = GetLocationBarView();
759 if (location_bar->IsFocusableInRootView()) { 846 if (location_bar->IsFocusableInRootView()) {
760 // Location bar got focus. 847 // Location bar got focus.
761 location_bar->FocusLocation(select_all); 848 location_bar->FocusLocation(select_all);
762 } else { 849 } else {
763 // If none of location bar/compact navigation bar got focus, 850 // If none of location bar/compact navigation bar got focus,
764 // then clear focus. 851 // then clear focus.
765 views::FocusManager* focus_manager = GetFocusManager(); 852 views::FocusManager* focus_manager = GetFocusManager();
766 DCHECK(focus_manager); 853 DCHECK(focus_manager);
767 focus_manager->ClearFocus(); 854 focus_manager->ClearFocus();
768 } 855 }
769 } 856 }
770 857
771 void BrowserView::UpdateReloadStopState(bool is_loading, bool force) { 858 void BrowserView::UpdateReloadStopState(bool is_loading, bool force) {
772 toolbar_->reload_button()->ChangeMode( 859 ReloadButton* reload_button = NULL;
860 if (UseCompactNavigationBar()) {
861 reload_button = compact_location_bar_view_host_->
862 GetCompactLocationBarView()->reload_button();
863 } else {
864 reload_button = toolbar_->reload_button();
865 }
866 reload_button->ChangeMode(
773 is_loading ? ReloadButton::MODE_STOP : ReloadButton::MODE_RELOAD, force); 867 is_loading ? ReloadButton::MODE_STOP : ReloadButton::MODE_RELOAD, force);
774 } 868 }
775 869
776 void BrowserView::UpdateToolbar(TabContentsWrapper* contents, 870 void BrowserView::UpdateToolbar(TabContentsWrapper* contents,
777 bool should_restore_state) { 871 bool should_restore_state) {
778 toolbar_->Update(contents->tab_contents(), should_restore_state); 872 if (UseCompactNavigationBar()) {
873 if (compact_location_bar_view_host_->IsVisible()) {
874 compact_location_bar_view_host_->Update(
875 should_restore_state ? contents->tab_contents() : NULL, true);
876 }
877 } else {
878 toolbar_->Update(contents->tab_contents(), should_restore_state);
879 }
779 } 880 }
780 881
781 void BrowserView::FocusToolbar() { 882 void BrowserView::FocusToolbar() {
782 // Start the traversal within the main toolbar, passing it the storage id 883 // Start the traversal within the main toolbar, passing it the storage id
783 // of the view where focus should be returned if the user exits the toolbar. 884 // of the view where focus should be returned if the user exits the toolbar.
784 SaveFocusedView(); 885 SaveFocusedView();
785 toolbar_->SetPaneFocus(last_focused_view_storage_id_, NULL); 886 if (UseCompactNavigationBar()) {
887 if (!compact_location_bar_view_host_->IsVisible())
888 compact_location_bar_view_host_->Update(browser()->active_index(), true);
889 compact_location_bar_view_host_->GetCompactLocationBarView()->SetPaneFocus(
890 last_focused_view_storage_id_, NULL);
891 } else {
892 toolbar_->SetPaneFocus(last_focused_view_storage_id_, NULL);
893 }
786 } 894 }
787 895
788 void BrowserView::FocusBookmarksToolbar() { 896 void BrowserView::FocusBookmarksToolbar() {
789 if (active_bookmark_bar_ && bookmark_bar_view_->IsVisible()) { 897 if (active_bookmark_bar_ && bookmark_bar_view_->IsVisible()) {
790 SaveFocusedView(); 898 SaveFocusedView();
791 bookmark_bar_view_->SetPaneFocus(last_focused_view_storage_id_, NULL); 899 bookmark_bar_view_->SetPaneFocus(last_focused_view_storage_id_, NULL);
792 } 900 }
793 } 901 }
794 902
795 void BrowserView::FocusAppMenu() { 903 void BrowserView::FocusAppMenu() {
796 // Chrome doesn't have a traditional menu bar, but it has a menu button in the 904 // Chrome doesn't have a traditional menu bar, but it has a menu button in the
797 // main toolbar that plays the same role. If the user presses a key that 905 // main toolbar that plays the same role. If the user presses a key that
798 // would typically focus the menu bar, tell the toolbar to focus the menu 906 // would typically focus the menu bar, tell the toolbar to focus the menu
799 // button. If the user presses the key again, return focus to the previous 907 // button. If the user presses the key again, return focus to the previous
800 // location. 908 // location.
801 // 909 //
802 // Not used on the Mac, which has a normal menu bar. 910 // Not used on the Mac, which has a normal menu bar.
803 if (toolbar_->IsAppMenuFocused()) { 911 if (toolbar_->IsAppMenuFocused()) {
804 RestoreFocus(); 912 RestoreFocus();
805 } else { 913 } else {
806 SaveFocusedView(); 914 SaveFocusedView();
915 // TODO(mad): find out how to add this to compact nav view.
807 toolbar_->SetPaneFocusAndFocusAppMenu(last_focused_view_storage_id_); 916 toolbar_->SetPaneFocusAndFocusAppMenu(last_focused_view_storage_id_);
808 } 917 }
809 } 918 }
810 919
811 void BrowserView::RotatePaneFocus(bool forwards) { 920 void BrowserView::RotatePaneFocus(bool forwards) {
812 // This gets called when the user presses F6 (forwards) or Shift+F6 921 // This gets called when the user presses F6 (forwards) or Shift+F6
813 // (backwards) to rotate to the next pane. Here, our "panes" are the 922 // (backwards) to rotate to the next pane. Here, our "panes" are the
814 // tab contents and each of our accessible toolbars, infobars, downloads 923 // tab contents and each of our accessible toolbars, infobars, downloads
815 // shelf, etc. When a pane has focus, all of its controls are accessible 924 // shelf, etc. When a pane has focus, all of its controls are accessible
816 // in the tab traversal, and the tab traversal is "trapped" within that pane. 925 // 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
896 1005
897 bool BrowserView::IsBookmarkBarAnimating() const { 1006 bool BrowserView::IsBookmarkBarAnimating() const {
898 return bookmark_bar_view_.get() && bookmark_bar_view_->is_animating(); 1007 return bookmark_bar_view_.get() && bookmark_bar_view_->is_animating();
899 } 1008 }
900 1009
901 bool BrowserView::IsTabStripEditable() const { 1010 bool BrowserView::IsTabStripEditable() const {
902 return tabstrip_->IsTabStripEditable(); 1011 return tabstrip_->IsTabStripEditable();
903 } 1012 }
904 1013
905 bool BrowserView::IsToolbarVisible() const { 1014 bool BrowserView::IsToolbarVisible() const {
906 return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || 1015 if (UseCompactNavigationBar()) {
907 browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); 1016 return false;
1017 } else {
1018 return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) ||
1019 browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR);
1020 }
908 } 1021 }
909 1022
910 void BrowserView::DisableInactiveFrame() { 1023 void BrowserView::DisableInactiveFrame() {
911 #if defined(OS_WIN) 1024 #if defined(OS_WIN)
912 frame_->GetWindow()->DisableInactiveRendering(); 1025 frame_->GetWindow()->DisableInactiveRendering();
913 #endif // No tricks are needed to get the right behavior on Linux. 1026 #endif // No tricks are needed to get the right behavior on Linux.
914 } 1027 }
915 1028
916 void BrowserView::ConfirmSetDefaultSearchProvider( 1029 void BrowserView::ConfirmSetDefaultSearchProvider(
917 TabContents* tab_contents, 1030 TabContents* tab_contents,
(...skipping 23 matching lines...) Expand all
941 1054
942 views::Window* BrowserView::DoShowAboutChromeDialog() { 1055 views::Window* BrowserView::DoShowAboutChromeDialog() {
943 return browser::ShowAboutChromeView(GetWindow()->GetNativeWindow(), 1056 return browser::ShowAboutChromeView(GetWindow()->GetNativeWindow(),
944 browser_->profile()); 1057 browser_->profile());
945 } 1058 }
946 1059
947 void BrowserView::ShowUpdateChromeDialog() { 1060 void BrowserView::ShowUpdateChromeDialog() {
948 UpdateRecommendedMessageBox::ShowMessageBox(GetWindow()->GetNativeWindow()); 1061 UpdateRecommendedMessageBox::ShowMessageBox(GetWindow()->GetNativeWindow());
949 } 1062 }
950 1063
1064 void BrowserView::ShowCompactLocationBarUnderSelectedTab() {
1065 if (!UseCompactNavigationBar())
1066 return;
1067 compact_location_bar_view_host_->Update(browser()->active_index(), true);
1068 }
1069
951 void BrowserView::ShowTaskManager() { 1070 void BrowserView::ShowTaskManager() {
952 browser::ShowTaskManager(); 1071 browser::ShowTaskManager();
953 } 1072 }
954 1073
955 void BrowserView::ShowBackgroundPages() { 1074 void BrowserView::ShowBackgroundPages() {
956 browser::ShowBackgroundPages(); 1075 browser::ShowBackgroundPages();
957 } 1076 }
958 1077
959 void BrowserView::ShowBookmarkBubble(const GURL& url, bool already_bookmarked) { 1078 void BrowserView::ShowBookmarkBubble(const GURL& url, bool already_bookmarked) {
960 toolbar_->location_bar()->ShowStarBubble(url, !already_bookmarked); 1079 GetLocationBarView()->ShowStarBubble(url, !already_bookmarked);
961 } 1080 }
962 1081
963 void BrowserView::SetDownloadShelfVisible(bool visible) { 1082 void BrowserView::SetDownloadShelfVisible(bool visible) {
964 // This can be called from the superclass destructor, when it destroys our 1083 // This can be called from the superclass destructor, when it destroys our
965 // child views. At that point, browser_ is already gone. 1084 // child views. At that point, browser_ is already gone.
966 if (browser_ == NULL) 1085 if (browser_ == NULL)
967 return; 1086 return;
968 1087
969 if (visible && IsDownloadShelfVisible() != visible) { 1088 if (visible && IsDownloadShelfVisible() != visible) {
970 // Invoke GetDownloadShelf to force the shelf to be created. 1089 // Invoke GetDownloadShelf to force the shelf to be created.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 void BrowserView::ShowPageInfo(Profile* profile, 1170 void BrowserView::ShowPageInfo(Profile* profile,
1052 const GURL& url, 1171 const GURL& url,
1053 const NavigationEntry::SSLStatus& ssl, 1172 const NavigationEntry::SSLStatus& ssl,
1054 bool show_history) { 1173 bool show_history) {
1055 gfx::NativeWindow parent = GetWindow()->GetNativeWindow(); 1174 gfx::NativeWindow parent = GetWindow()->GetNativeWindow();
1056 1175
1057 browser::ShowPageInfoBubble(parent, profile, url, ssl, show_history); 1176 browser::ShowPageInfoBubble(parent, profile, url, ssl, show_history);
1058 } 1177 }
1059 1178
1060 void BrowserView::ShowAppMenu() { 1179 void BrowserView::ShowAppMenu() {
1180 // TODO(mad): find out how to add this to compact nav view.
1061 toolbar_->app_menu()->Activate(); 1181 toolbar_->app_menu()->Activate();
1062 } 1182 }
1063 1183
1064 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, 1184 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
1065 bool* is_keyboard_shortcut) { 1185 bool* is_keyboard_shortcut) {
1066 if (event.type != WebKit::WebInputEvent::RawKeyDown) 1186 if (event.type != WebKit::WebInputEvent::RawKeyDown)
1067 return false; 1187 return false;
1068 1188
1069 #if defined(OS_WIN) 1189 #if defined(OS_WIN)
1070 // As Alt+F4 is the close-app keyboard shortcut, it needs processing 1190 // As Alt+F4 is the close-app keyboard shortcut, it needs processing
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 void BrowserView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { 1266 void BrowserView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {
1147 // TODO(ben): figure out why are these two code paths so different 1267 // TODO(ben): figure out why are these two code paths so different
1148 #if defined(OS_LINUX) && !defined(TOUCH_UI) 1268 #if defined(OS_LINUX) && !defined(TOUCH_UI)
1149 HandleWebKeyboardEvent(GetWidget(), event); 1269 HandleWebKeyboardEvent(GetWidget(), event);
1150 #else 1270 #else
1151 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, 1271 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event,
1152 GetFocusManager()); 1272 GetFocusManager());
1153 #endif 1273 #endif
1154 } 1274 }
1155 1275
1276 void BrowserView::ToggleUseCompactNavigationBar() {
1277 bool use_compact_navigation_bar = UseCompactNavigationBar();
1278 // Compact Navigation Bar only works with horizontal tabs for now!
1279 if (use_compact_navigation_bar && UseVerticalTabs())
1280 browser()->ExecuteCommand(IDC_TOGGLE_VERTICAL_TABS);
1281 compact_location_bar_view_host_->SetEnabled(use_compact_navigation_bar);
1282 compact_location_bar_view_host_->Hide(!use_compact_navigation_bar);
1283 Layout();
1284 }
1285
1156 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always 1286 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always
1157 // enabled in the page menu regardless of whether the command will do 1287 // enabled in the page menu regardless of whether the command will do
1158 // anything. When someone selects the menu item, we just act as if they hit 1288 // anything. When someone selects the menu item, we just act as if they hit
1159 // the keyboard shortcut for the command by sending the associated key press 1289 // the keyboard shortcut for the command by sending the associated key press
1160 // to windows. The real fix to this bug is to disable the commands when they 1290 // to windows. The real fix to this bug is to disable the commands when they
1161 // won't do anything. We'll need something like an overall clipboard command 1291 // won't do anything. We'll need something like an overall clipboard command
1162 // manager to do that. 1292 // manager to do that.
1163 void BrowserView::Cut() { 1293 void BrowserView::Cut() {
1164 ui_controls::SendKeyPress(GetNativeHandle(), ui::VKEY_X, 1294 ui_controls::SendKeyPress(GetNativeHandle(), ui::VKEY_X,
1165 true, false, false, false); 1295 true, false, false, false);
1166 } 1296 }
1167 1297
1168 void BrowserView::Copy() { 1298 void BrowserView::Copy() {
1169 ui_controls::SendKeyPress(GetNativeHandle(), ui::VKEY_C, 1299 ui_controls::SendKeyPress(GetNativeHandle(), ui::VKEY_C,
1170 true, false, false, false); 1300 true, false, false, false);
1171 } 1301 }
1172 1302
1173 void BrowserView::Paste() { 1303 void BrowserView::Paste() {
1174 ui_controls::SendKeyPress(GetNativeHandle(), ui::VKEY_V, 1304 ui_controls::SendKeyPress(GetNativeHandle(), ui::VKEY_V,
1175 true, false, false, false); 1305 true, false, false, false);
1176 } 1306 }
1177 1307
1178 void BrowserView::ToggleTabStripMode() { 1308 void BrowserView::ToggleTabStripMode() {
1309 // Compact Navigation Bar only works with horizontal tabs for now!
1310 if (UseVerticalTabs() && UseCompactNavigationBar())
1311 browser()->ExecuteCommand(IDC_COMPACT_NAVBAR);
1312
1179 InitTabStrip(browser_->tabstrip_model()); 1313 InitTabStrip(browser_->tabstrip_model());
1180 frame_->TabStripDisplayModeChanged(); 1314 frame_->TabStripDisplayModeChanged();
1181 } 1315 }
1182 1316
1183 void BrowserView::PrepareForInstant() { 1317 void BrowserView::PrepareForInstant() {
1184 contents_->FadeActiveContents(); 1318 contents_->FadeActiveContents();
1185 } 1319 }
1186 1320
1187 void BrowserView::ShowInstant(TabContentsWrapper* preview) { 1321 void BrowserView::ShowInstant(TabContentsWrapper* preview) {
1188 if (!preview_container_) 1322 if (!preview_container_)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 #endif 1366 #endif
1233 1367
1234 /////////////////////////////////////////////////////////////////////////////// 1368 ///////////////////////////////////////////////////////////////////////////////
1235 // BrowserView, BrowserWindowTesting implementation: 1369 // BrowserView, BrowserWindowTesting implementation:
1236 1370
1237 BookmarkBarView* BrowserView::GetBookmarkBarView() const { 1371 BookmarkBarView* BrowserView::GetBookmarkBarView() const {
1238 return bookmark_bar_view_.get(); 1372 return bookmark_bar_view_.get();
1239 } 1373 }
1240 1374
1241 LocationBarView* BrowserView::GetLocationBarView() const { 1375 LocationBarView* BrowserView::GetLocationBarView() const {
1242 return toolbar_->location_bar(); 1376 if (UseCompactNavigationBar()) {
1377 return compact_location_bar_view_host_->GetCompactLocationBarView()->
1378 location_bar_view();
1379 } else {
1380 return toolbar_ ? toolbar_->location_bar() : NULL;
1381 }
1243 } 1382 }
1244 1383
1245 views::View* BrowserView::GetTabContentsContainerView() const { 1384 views::View* BrowserView::GetTabContentsContainerView() const {
1246 return contents_container_->GetFocusView(); 1385 return contents_container_->GetFocusView();
1247 } 1386 }
1248 1387
1249 views::View* BrowserView::GetSidebarContainerView() const { 1388 views::View* BrowserView::GetSidebarContainerView() const {
1250 if (!sidebar_container_) 1389 if (!sidebar_container_)
1251 return NULL; 1390 return NULL;
1252 return sidebar_container_->GetFocusView(); 1391 return sidebar_container_->GetFocusView();
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 // Comment out for one cycle to see if this fixes dist tests. 1684 // Comment out for one cycle to see if this fixes dist tests.
1546 // tabstrip_->DestroyDragController(); 1685 // tabstrip_->DestroyDragController();
1547 1686
1548 status_bubble_->Reposition(); 1687 status_bubble_->Reposition();
1549 1688
1550 BrowserBubbleHost::WindowMoved(); 1689 BrowserBubbleHost::WindowMoved();
1551 1690
1552 browser::HideBookmarkBubbleView(); 1691 browser::HideBookmarkBubbleView();
1553 1692
1554 // Close the omnibox popup, if any. 1693 // Close the omnibox popup, if any.
1555 if (toolbar_ && toolbar_->location_bar()) 1694 LocationBarView* location_bar_view = GetLocationBarView();
1556 toolbar_->location_bar()->location_entry()->ClosePopup(); 1695 if (location_bar_view)
1696 location_bar_view->location_entry()->ClosePopup();
1557 } 1697 }
1558 1698
1559 /////////////////////////////////////////////////////////////////////////////// 1699 ///////////////////////////////////////////////////////////////////////////////
1560 // BrowserView, views::ClientView overrides: 1700 // BrowserView, views::ClientView overrides:
1561 1701
1562 bool BrowserView::CanClose() { 1702 bool BrowserView::CanClose() {
1563 // You cannot close a frame for which there is an active originating drag 1703 // You cannot close a frame for which there is an active originating drag
1564 // session. 1704 // session.
1565 if (tabstrip_ && !tabstrip_->IsTabStripCloseable()) 1705 if (tabstrip_ && !tabstrip_->IsTabStripCloseable())
1566 return false; 1706 return false;
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 jumplist_.reset(new JumpList); 1963 jumplist_.reset(new JumpList);
1824 jumplist_->AddObserver(browser_->profile()); 1964 jumplist_->AddObserver(browser_->profile());
1825 } 1965 }
1826 1966
1827 if (AeroPeekManager::Enabled()) { 1967 if (AeroPeekManager::Enabled()) {
1828 aeropeek_manager_.reset(new AeroPeekManager( 1968 aeropeek_manager_.reset(new AeroPeekManager(
1829 frame_->GetWindow()->GetNativeWindow())); 1969 frame_->GetWindow()->GetNativeWindow()));
1830 browser_->tabstrip_model()->AddObserver(aeropeek_manager_.get()); 1970 browser_->tabstrip_model()->AddObserver(aeropeek_manager_.get());
1831 } 1971 }
1832 #endif 1972 #endif
1973 compact_location_bar_view_host_.reset(new CompactLocationBarViewHost(this));
1974 compact_navigation_bar_ = new CompactNavigationBar(this);
1975 compact_navigation_bar_->SetID(VIEW_ID_COMPACT_NAV_BAR);
1976 AddChildView(compact_navigation_bar_);
1977 compact_navigation_bar_->Init();
1978 compact_options_bar_ = new CompactOptionsBar(this);
1979 compact_options_bar_->SetID(VIEW_ID_COMPACT_OPT_BAR);
1980 AddChildView(compact_options_bar_);
1981 compact_options_bar_->Init();
1982
1983 ThemeProvider* theme_provider = frame()->GetThemeProviderForFrame();
1984 SkBitmap* theme_toolbar = theme_provider->GetBitmapNamed(IDR_THEME_TOOLBAR);
1985 spacer_ = new Spacer(theme_toolbar);
1986 spacer_->SetID(VIEW_ID_SPACER);
1987 AddChildView(spacer_);
1833 1988
1834 // We're now initialized and ready to process Layout requests. 1989 // We're now initialized and ready to process Layout requests.
1835 ignore_layout_ = false; 1990 ignore_layout_ = false;
1836 } 1991 }
1837 1992
1838 void BrowserView::LoadingAnimationCallback() { 1993 void BrowserView::LoadingAnimationCallback() {
1839 base::TimeTicks now = base::TimeTicks::Now(); 1994 base::TimeTicks now = base::TimeTicks::Now();
1840 if (!last_animation_time_.is_null()) { 1995 if (!last_animation_time_.is_null()) {
1841 UMA_HISTOGRAM_TIMES( 1996 UMA_HISTOGRAM_TIMES(
1842 "Tabs.LoadingAnimationTime", 1997 "Tabs.LoadingAnimationTime",
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 *old_view = new_view; 2246 *old_view = new_view;
2092 return changed; 2247 return changed;
2093 } 2248 }
2094 2249
2095 void BrowserView::ProcessFullscreen(bool fullscreen) { 2250 void BrowserView::ProcessFullscreen(bool fullscreen) {
2096 // Reduce jankiness during the following position changes by: 2251 // Reduce jankiness during the following position changes by:
2097 // * Hiding the window until it's in the final position 2252 // * Hiding the window until it's in the final position
2098 // * Ignoring all intervening Layout() calls, which resize the webpage and 2253 // * Ignoring all intervening Layout() calls, which resize the webpage and
2099 // thus are slow and look ugly 2254 // thus are slow and look ugly
2100 ignore_layout_ = true; 2255 ignore_layout_ = true;
2101 LocationBarView* location_bar = toolbar_->location_bar(); 2256 LocationBarView* location_bar = GetLocationBarView();
2102 #if defined(OS_WIN) 2257 #if defined(OS_WIN)
2103 OmniboxViewWin* omnibox_view = 2258 OmniboxViewWin* omnibox_view =
2104 static_cast<OmniboxViewWin*>(location_bar->location_entry()); 2259 static_cast<OmniboxViewWin*>(location_bar->location_entry());
2105 #endif 2260 #endif
2106 if (!fullscreen) { 2261 if (!fullscreen) {
2107 // Hide the fullscreen bubble as soon as possible, since the mode toggle can 2262 // Hide the fullscreen bubble as soon as possible, since the mode toggle can
2108 // take enough time for the user to notice. 2263 // take enough time for the user to notice.
2109 fullscreen_bubble_.reset(); 2264 fullscreen_bubble_.reset();
2110 } else { 2265 } else {
2111 // Move focus out of the location bar if necessary. 2266 // Move focus out of the location bar if necessary.
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
2457 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 2612 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
2458 2613
2459 return view; 2614 return view;
2460 } 2615 }
2461 #endif 2616 #endif
2462 2617
2463 // static 2618 // static
2464 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { 2619 FindBar* BrowserWindow::CreateFindBar(Browser* browser) {
2465 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); 2620 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window()));
2466 } 2621 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698