Chromium Code Reviews

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller_private.mm

Issue 12386019: Instant: Use only one hidden WebContents per profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" 5 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #import "base/memory/scoped_nsobject.h" 10 #import "base/memory/scoped_nsobject.h"
(...skipping 10 matching lines...)
21 #import "chrome/browser/ui/cocoa/fast_resize_view.h" 21 #import "chrome/browser/ui/cocoa/fast_resize_view.h"
22 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" 22 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h"
23 #import "chrome/browser/ui/cocoa/floating_bar_backing_view.h" 23 #import "chrome/browser/ui/cocoa/floating_bar_backing_view.h"
24 #import "chrome/browser/ui/cocoa/framed_browser_window.h" 24 #import "chrome/browser/ui/cocoa/framed_browser_window.h"
25 #import "chrome/browser/ui/cocoa/fullscreen_window.h" 25 #import "chrome/browser/ui/cocoa/fullscreen_window.h"
26 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" 26 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
27 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" 27 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h"
28 #import "chrome/browser/ui/cocoa/nsview_additions.h" 28 #import "chrome/browser/ui/cocoa/nsview_additions.h"
29 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" 29 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h"
30 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" 30 #import "chrome/browser/ui/cocoa/status_bubble_mac.h"
31 #import "chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h" 31 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h"
32 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 32 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
33 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" 33 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
34 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 34 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
35 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" 35 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
36 #include "chrome/browser/ui/search/search_model.h" 36 #include "chrome/browser/ui/search/search_model.h"
37 #include "chrome/browser/ui/search/search_ui.h" 37 #include "chrome/browser/ui/search/search_ui.h"
38 #include "chrome/browser/ui/tabs/tab_strip_model.h" 38 #include "chrome/browser/ui/tabs/tab_strip_model.h"
39 #include "chrome/common/chrome_switches.h" 39 #include "chrome/common/chrome_switches.h"
40 #include "chrome/common/pref_names.h" 40 #include "chrome/common/pref_names.h"
41 #include "content/public/browser/render_widget_host_view.h" 41 #include "content/public/browser/render_widget_host_view.h"
(...skipping 20 matching lines...)
62 const CGFloat kLocBarLeftRightInset = 1; 62 const CGFloat kLocBarLeftRightInset = 1;
63 const CGFloat kLocBarTopInset = 0; 63 const CGFloat kLocBarTopInset = 0;
64 const CGFloat kLocBarBottomInset = 1; 64 const CGFloat kLocBarBottomInset = 1;
65 65
66 } // namespace 66 } // namespace
67 67
68 @implementation BrowserWindowController(Private) 68 @implementation BrowserWindowController(Private)
69 69
70 // Create the tab strip controller. 70 // Create the tab strip controller.
71 - (void)createTabStripController { 71 - (void)createTabStripController {
72 DCHECK([previewableContentsController_ activeContainer]); 72 DCHECK([overlayableContentsController_ activeContainer]);
73 DCHECK([[previewableContentsController_ activeContainer] window]); 73 DCHECK([[overlayableContentsController_ activeContainer] window]);
74 tabStripController_.reset([[TabStripController alloc] 74 tabStripController_.reset([[TabStripController alloc]
75 initWithView:[self tabStripView] 75 initWithView:[self tabStripView]
76 switchView:[previewableContentsController_ activeContainer] 76 switchView:[overlayableContentsController_ activeContainer]
77 browser:browser_.get() 77 browser:browser_.get()
78 delegate:self]); 78 delegate:self]);
79 } 79 }
80 80
81 - (void)saveWindowPositionIfNeeded { 81 - (void)saveWindowPositionIfNeeded {
82 if (!chrome::ShouldSaveWindowPlacement(browser_.get())) 82 if (!chrome::ShouldSaveWindowPlacement(browser_.get()))
83 return; 83 return;
84 84
85 // If we're in fullscreen mode, save the position of the regular window 85 // If we're in fullscreen mode, save the position of the regular window
86 // instead. 86 // instead.
(...skipping 786 matching lines...)
873 - (CGFloat)toolbarDividerOpacity { 873 - (CGFloat)toolbarDividerOpacity {
874 if ([self isShowingInstantResults]) 874 if ([self isShowingInstantResults])
875 return 1; 875 return 1;
876 return [bookmarkBarController_ toolbarDividerOpacity]; 876 return [bookmarkBarController_ toolbarDividerOpacity];
877 } 877 }
878 878
879 - (BOOL)isShowingInstantResults { 879 - (BOOL)isShowingInstantResults {
880 if (!browser_->search_model()->mode().is_search_suggestions()) 880 if (!browser_->search_model()->mode().is_search_suggestions())
881 return NO; 881 return NO;
882 882
883 // If the search suggestions are already being displayed in the preview 883 // If the search suggestions are already being displayed in the overlay
884 // contents then return YES. 884 // contents then return YES.
885 if ([previewableContentsController_ isShowingPreview]) 885 if ([overlayableContentsController_ isShowingOverlay])
886 return YES; 886 return YES;
887 887
888 // Search suggestions might be shown directly in the web contents in some 888 // Search suggestions might be shown directly in the web contents in some
889 // cases. 889 // cases.
890 return !browser_->search_model()->mode().is_origin_default(); 890 return !browser_->search_model()->mode().is_origin_default();
891 } 891 }
892 892
893 - (void)updateContentOffsets { 893 - (void)updateContentOffsets {
894 // Normally the tab contents sits below the bookmark bar. This is achieved by 894 // Normally the tab contents sits below the bookmark bar. This is achieved by
895 // setting the offset to the height of the bookmark bar. The only exception 895 // setting the offset to the height of the bookmark bar. The only exception
896 // is on the search results page where the instant results are shown inside 896 // is on the search results page where the Instant results are shown inside
897 // the page and not in the preview contents as usual. 897 // the page and not in the overlay contents as usual.
898 CGFloat tabContentsOffset = toolbarToWebContentsOffset_; 898 CGFloat tabContentsOffset = toolbarToWebContentsOffset_;
899 if (browser_->search_model()->mode().is_search_suggestions() && 899 if (browser_->search_model()->mode().is_search_suggestions() &&
900 !browser_->search_model()->mode().is_origin_default()) { 900 !browser_->search_model()->mode().is_origin_default()) {
901 tabContentsOffset = 0; 901 tabContentsOffset = 0;
902 } 902 }
903 [previewableContentsController_ setActiveContainerOffset:tabContentsOffset]; 903 [overlayableContentsController_ setActiveContainerOffset:tabContentsOffset];
904 904
905 // Prevent the fast resize view from drawing white over the bookmark bar. 905 // Prevent the fast resize view from drawing white over the bookmark bar.
906 [[self tabContentArea] setContentOffset:toolbarToWebContentsOffset_]; 906 [[self tabContentArea] setContentOffset:toolbarToWebContentsOffset_];
907 907
908 // Prevent the dev tools splitter from overlapping the bookmark bar. 908 // Prevent the dev tools splitter from overlapping the bookmark bar.
909 if ([self isShowingInstantResults]) 909 if ([self isShowingInstantResults])
910 [devToolsController_ setTopContentOffset:0]; 910 [devToolsController_ setTopContentOffset:0];
911 else 911 else
912 [devToolsController_ setTopContentOffset:toolbarToWebContentsOffset_]; 912 [devToolsController_ setTopContentOffset:toolbarToWebContentsOffset_];
913 } 913 }
(...skipping 11 matching lines...)
925 } else { 925 } else {
926 // Toolbar is below tab contents so that the infobar arrow can appear above 926 // Toolbar is below tab contents so that the infobar arrow can appear above
927 // it. Unlike other views the toolbar never overlaps the actual web 927 // it. Unlike other views the toolbar never overlaps the actual web
928 // content. 928 // content.
929 [contentView cr_ensureSubview:toolbarView 929 [contentView cr_ensureSubview:toolbarView
930 isPositioned:NSWindowBelow 930 isPositioned:NSWindowBelow
931 relativeTo:[self tabContentArea]]; 931 relativeTo:[self tabContentArea]];
932 } 932 }
933 933
934 // The bookmark bar is always below the toolbar. In normal mode this means 934 // The bookmark bar is always below the toolbar. In normal mode this means
935 // that it is below tab contents. This allows instant results to be above 935 // that it is below tab contents. This allows Instant results to be above
936 // the bookmark bar. 936 // the bookmark bar.
937 [contentView cr_ensureSubview:[bookmarkBarController_ view] 937 [contentView cr_ensureSubview:[bookmarkBarController_ view]
938 isPositioned:NSWindowBelow 938 isPositioned:NSWindowBelow
939 relativeTo:toolbarView]; 939 relativeTo:toolbarView];
940 940
941 if (inPresentationMode) { 941 if (inPresentationMode) {
942 // In presentation mode the infobar is below all other views. 942 // In presentation mode the infobar is below all other views.
943 [contentView cr_ensureSubview:[infoBarContainerController_ view] 943 [contentView cr_ensureSubview:[infoBarContainerController_ view]
944 isPositioned:NSWindowBelow 944 isPositioned:NSWindowBelow
945 relativeTo:[self tabContentArea]]; 945 relativeTo:[self tabContentArea]];
946 } else { 946 } else {
947 // Above the toolbar but still below tab contents. Similar to the bookmark 947 // Above the toolbar but still below tab contents. Similar to the bookmark
948 // bar, this allows instant results to be above the info bar. 948 // bar, this allows Instant results to be above the info bar.
949 [contentView cr_ensureSubview:[infoBarContainerController_ view] 949 [contentView cr_ensureSubview:[infoBarContainerController_ view]
950 isPositioned:NSWindowAbove 950 isPositioned:NSWindowAbove
951 relativeTo:toolbarView]; 951 relativeTo:toolbarView];
952 } 952 }
953 953
954 // The find bar is above everything except instant search results. 954 // The find bar is above everything except Instant search results.
955 if (findBarCocoaController_) { 955 if (findBarCocoaController_) {
956 NSView* relativeView = nil; 956 NSView* relativeView = nil;
957 if (inPresentationMode) 957 if (inPresentationMode)
958 relativeView = toolbarView; 958 relativeView = toolbarView;
959 else if ([self isShowingInstantResults]) 959 else if ([self isShowingInstantResults])
960 relativeView = [infoBarContainerController_ view]; 960 relativeView = [infoBarContainerController_ view];
961 else 961 else
962 relativeView = [self tabContentArea]; 962 relativeView = [self tabContentArea];
963 [contentView cr_ensureSubview:[findBarCocoaController_ view] 963 [contentView cr_ensureSubview:[findBarCocoaController_ view]
964 isPositioned:NSWindowAbove 964 isPositioned:NSWindowAbove
965 relativeTo:relativeView]; 965 relativeTo:relativeView];
966 } 966 }
967 967
968 if (floatingBarBackingView_) { 968 if (floatingBarBackingView_) {
969 if ([floatingBarBackingView_ cr_isBelowView:[self tabContentArea]]) 969 if ([floatingBarBackingView_ cr_isBelowView:[self tabContentArea]])
970 [floatingBarBackingView_ removeFromSuperview]; 970 [floatingBarBackingView_ removeFromSuperview];
971 if ([self placeBookmarkBarBelowInfoBar]) { 971 if ([self placeBookmarkBarBelowInfoBar]) {
972 [contentView cr_ensureSubview:floatingBarBackingView_ 972 [contentView cr_ensureSubview:floatingBarBackingView_
973 isPositioned:NSWindowAbove 973 isPositioned:NSWindowAbove
974 relativeTo:[bookmarkBarController_ view]]; 974 relativeTo:[bookmarkBarController_ view]];
975 } else { 975 } else {
976 [contentView cr_ensureSubview:floatingBarBackingView_ 976 [contentView cr_ensureSubview:floatingBarBackingView_
977 isPositioned:NSWindowBelow 977 isPositioned:NSWindowBelow
978 relativeTo:[bookmarkBarController_ view]]; 978 relativeTo:[bookmarkBarController_ view]];
979 } 979 }
980 } 980 }
981 } 981 }
982 982
983 @end // @implementation BrowserWindowController(Private) 983 @end // @implementation BrowserWindowController(Private)
OLDNEW

Powered by Google App Engine