OLD | NEW |
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.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #import "base/mac/mac_util.h" | 8 #import "base/mac/mac_util.h" |
9 | 9 |
10 #include "base/mac/sdk_forward_declarations.h" | 10 #include "base/mac/sdk_forward_declarations.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "chrome/browser/ui/browser_navigator_params.h" | 26 #include "chrome/browser/ui/browser_navigator_params.h" |
27 #include "chrome/browser/ui/browser_window.h" | 27 #include "chrome/browser/ui/browser_window.h" |
28 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 28 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
29 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" | 29 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" |
30 #import "chrome/browser/ui/cocoa/fast_resize_view.h" | 30 #import "chrome/browser/ui/cocoa/fast_resize_view.h" |
31 #import "chrome/browser/ui/cocoa/history_overlay_controller.h" | 31 #import "chrome/browser/ui/cocoa/history_overlay_controller.h" |
32 #import "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h" | 32 #import "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h" |
33 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 33 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
34 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" | 34 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" |
35 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 35 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
36 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" | 36 #import "chrome/browser/ui/cocoa/fullscreen_toolbar_controller.h" |
37 #import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h" | 37 #import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h" |
38 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" | 38 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" |
39 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" | 39 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" |
40 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 40 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
41 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 41 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
42 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_test.h" | 42 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_test.h" |
43 #include "chrome/browser/ui/extensions/application_launch.h" | 43 #include "chrome/browser/ui/extensions/application_launch.h" |
44 #include "chrome/browser/ui/find_bar/find_bar.h" | 44 #include "chrome/browser/ui/find_bar/find_bar.h" |
45 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 45 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
46 #include "chrome/browser/ui/infobar_container_delegate.h" | 46 #include "chrome/browser/ui/infobar_container_delegate.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 178 |
179 // Exceptions are allowed to overlap |exposed_view_|. Exceptions must still | 179 // Exceptions are allowed to overlap |exposed_view_|. Exceptions must still |
180 // be Z-order behind |exposed_view_|. | 180 // be Z-order behind |exposed_view_|. |
181 base::scoped_nsobject<NSArray> exceptions_; | 181 base::scoped_nsobject<NSArray> exceptions_; |
182 | 182 |
183 DISALLOW_COPY_AND_ASSIGN(ViewExposedChecker); | 183 DISALLOW_COPY_AND_ASSIGN(ViewExposedChecker); |
184 }; | 184 }; |
185 | 185 |
186 } // namespace | 186 } // namespace |
187 | 187 |
188 // Mock PresentationModeController used to test if the toolbar reveal animation | 188 // Mock FullscreenToolbarController used to test if the toolbar reveal animation |
189 // is called correctly. | 189 // is called correctly. |
190 @interface MockPresentationModeController : PresentationModeController | 190 @interface MockFullscreenToolbarController : FullscreenToolbarController |
191 | 191 |
192 // True if revealToolbarForTabStripChanges was called. | 192 // True if revealToolbarForTabStripChanges was called. |
193 @property(nonatomic, assign) BOOL isRevealingToolbarForTabstrip; | 193 @property(nonatomic, assign) BOOL isRevealingToolbarForTabstrip; |
194 | 194 |
195 // Initializer. | 195 // Initializer. |
196 - (id)initWithBrowserController:(BrowserWindowController*)controller; | 196 - (id)initWithBrowserController:(BrowserWindowController*)controller; |
197 | 197 |
198 // Sets isRevealingToolbarForTabstrip back to false. | 198 // Sets isRevealingToolbarForTabstrip back to false. |
199 - (void)resetToolbarFlag; | 199 - (void)resetToolbarFlag; |
200 | 200 |
201 // Overridden to set isRevealingToolbarForTabstrip to true when it's called. | 201 // Overridden to set isRevealingToolbarForTabstrip to true when it's called. |
202 - (void)revealToolbarForTabStripChanges; | 202 - (void)revealToolbarForTabStripChanges; |
203 | 203 |
204 // Overridden so that we don't have to deal with the DCHECKs when the | 204 // Overridden so that we don't have to deal with the DCHECKs when the |
205 // BWC exits fullscreen. | 205 // BWC exits fullscreen. |
206 - (void)exitPresentationMode; | 206 - (void)exitFullscreenMode; |
207 | 207 |
208 @end | 208 @end |
209 | 209 |
210 @implementation MockPresentationModeController | 210 @implementation MockFullscreenToolbarController |
211 | 211 |
212 @synthesize isRevealingToolbarForTabstrip = isRevealingToolbarForTabstrip_; | 212 @synthesize isRevealingToolbarForTabstrip = isRevealingToolbarForTabstrip_; |
213 | 213 |
214 - (id)initWithBrowserController:(BrowserWindowController*)controller { | 214 - (id)initWithBrowserController:(BrowserWindowController*)controller { |
215 if ((self = [super | 215 if ((self = [super |
216 initWithBrowserController:controller | 216 initWithBrowserController:controller |
217 style:fullscreen_mac::OMNIBOX_TABS_HIDDEN])) { | 217 style:fullscreen_mac::OMNIBOX_TABS_HIDDEN])) { |
218 } | 218 } |
219 | 219 |
220 return self; | 220 return self; |
221 } | 221 } |
222 | 222 |
223 - (void)resetToolbarFlag { | 223 - (void)resetToolbarFlag { |
224 isRevealingToolbarForTabstrip_ = NO; | 224 isRevealingToolbarForTabstrip_ = NO; |
225 } | 225 } |
226 | 226 |
227 - (void)revealToolbarForTabStripChanges { | 227 - (void)revealToolbarForTabStripChanges { |
228 isRevealingToolbarForTabstrip_ = YES; | 228 isRevealingToolbarForTabstrip_ = YES; |
229 } | 229 } |
230 | 230 |
231 - (void)exitPresentationMode { | 231 - (void)exitFullscreenMode { |
232 } | 232 } |
233 | 233 |
234 @end | 234 @end |
235 | 235 |
236 @interface InfoBarContainerController(TestingAPI) | 236 @interface InfoBarContainerController(TestingAPI) |
237 - (BOOL)isTopInfoBarAnimationRunning; | 237 - (BOOL)isTopInfoBarAnimationRunning; |
238 @end | 238 @end |
239 | 239 |
240 @implementation InfoBarContainerController(TestingAPI) | 240 @implementation InfoBarContainerController(TestingAPI) |
241 - (BOOL)isTopInfoBarAnimationRunning { | 241 - (BOOL)isTopInfoBarAnimationRunning { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 timer.Start( | 365 timer.Start( |
366 FROM_HERE, | 366 FROM_HERE, |
367 base::TimeDelta::FromMilliseconds(15), | 367 base::TimeDelta::FromMilliseconds(15), |
368 base::Bind(&CheckBookmarkBarAnimation, | 368 base::Bind(&CheckBookmarkBarAnimation, |
369 [controller() bookmarkBarController], | 369 [controller() bookmarkBarController], |
370 runner->QuitClosure())); | 370 runner->QuitClosure())); |
371 runner->Run(); | 371 runner->Run(); |
372 } | 372 } |
373 | 373 |
374 void VerifyFullscreenToolbarVisibility(fullscreen_mac::SlidingStyle style) { | 374 void VerifyFullscreenToolbarVisibility(fullscreen_mac::SlidingStyle style) { |
375 EXPECT_EQ([[controller() presentationModeController] slidingStyle], style); | 375 EXPECT_EQ([[controller() fullscreenToolbarController] slidingStyle], style); |
376 | 376 |
377 NSRect toolbarFrame = [[[controller() toolbarController] view] frame]; | 377 NSRect toolbarFrame = [[[controller() toolbarController] view] frame]; |
378 NSRect screenFrame = [[[controller() window] screen] frame]; | 378 NSRect screenFrame = [[[controller() window] screen] frame]; |
379 if (style == fullscreen_mac::OMNIBOX_TABS_PRESENT) | 379 if (style == fullscreen_mac::OMNIBOX_TABS_PRESENT) |
380 EXPECT_LE(NSMaxY(toolbarFrame), NSMaxY(screenFrame)); | 380 EXPECT_LE(NSMaxY(toolbarFrame), NSMaxY(screenFrame)); |
381 else | 381 else |
382 EXPECT_GE(NSMinY(toolbarFrame), NSMaxY(screenFrame)); | 382 EXPECT_GE(NSMinY(toolbarFrame), NSMaxY(screenFrame)); |
383 } | 383 } |
384 | 384 |
385 NSInteger GetExpectedTopInfoBarTipHeight() { | 385 NSInteger GetExpectedTopInfoBarTipHeight() { |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 // Tests that the preference is set to true by default. | 754 // Tests that the preference is set to true by default. |
755 PrefService* prefs = browser()->profile()->GetPrefs(); | 755 PrefService* prefs = browser()->profile()->GetPrefs(); |
756 EXPECT_TRUE(prefs->GetBoolean(prefs::kShowFullscreenToolbar)); | 756 EXPECT_TRUE(prefs->GetBoolean(prefs::kShowFullscreenToolbar)); |
757 | 757 |
758 // Toggle fullscreen and check if the toolbar is shown. | 758 // Toggle fullscreen and check if the toolbar is shown. |
759 ToggleFullscreenAndWaitForNotification(); | 759 ToggleFullscreenAndWaitForNotification(); |
760 VerifyFullscreenToolbarVisibility(fullscreen_mac::OMNIBOX_TABS_PRESENT); | 760 VerifyFullscreenToolbarVisibility(fullscreen_mac::OMNIBOX_TABS_PRESENT); |
761 | 761 |
762 // Toggle the visibility of the fullscreen toolbar. Verify that the toolbar | 762 // Toggle the visibility of the fullscreen toolbar. Verify that the toolbar |
763 // is hidden and the preference is correctly updated. | 763 // is hidden and the preference is correctly updated. |
764 [[controller() presentationModeController] setToolbarFraction:0.0]; | 764 [[controller() fullscreenToolbarController] setToolbarFraction:0.0]; |
765 [[controller() presentationModeController] setMenuBarRevealProgress:0.0]; | 765 [[controller() fullscreenToolbarController] setMenuBarRevealProgress:0.0]; |
766 chrome::ExecuteCommand(browser(), IDC_TOGGLE_FULLSCREEN_TOOLBAR); | 766 chrome::ExecuteCommand(browser(), IDC_TOGGLE_FULLSCREEN_TOOLBAR); |
767 EXPECT_FALSE(prefs->GetBoolean(prefs::kShowFullscreenToolbar)); | 767 EXPECT_FALSE(prefs->GetBoolean(prefs::kShowFullscreenToolbar)); |
768 VerifyFullscreenToolbarVisibility(fullscreen_mac::OMNIBOX_TABS_HIDDEN); | 768 VerifyFullscreenToolbarVisibility(fullscreen_mac::OMNIBOX_TABS_HIDDEN); |
769 | 769 |
770 // Toggle out and back into fullscreen and verify that the toolbar is still | 770 // Toggle out and back into fullscreen and verify that the toolbar is still |
771 // hidden. | 771 // hidden. |
772 ToggleFullscreenAndWaitForNotification(); | 772 ToggleFullscreenAndWaitForNotification(); |
773 ToggleFullscreenAndWaitForNotification(); | 773 ToggleFullscreenAndWaitForNotification(); |
774 [[controller() presentationModeController] setMenuBarRevealProgress:0.0]; | 774 [[controller() fullscreenToolbarController] setMenuBarRevealProgress:0.0]; |
775 VerifyFullscreenToolbarVisibility(fullscreen_mac::OMNIBOX_TABS_HIDDEN); | 775 VerifyFullscreenToolbarVisibility(fullscreen_mac::OMNIBOX_TABS_HIDDEN); |
776 | 776 |
777 chrome::ExecuteCommand(browser(), IDC_TOGGLE_FULLSCREEN_TOOLBAR); | 777 chrome::ExecuteCommand(browser(), IDC_TOGGLE_FULLSCREEN_TOOLBAR); |
778 EXPECT_TRUE(prefs->GetBoolean(prefs::kShowFullscreenToolbar)); | 778 EXPECT_TRUE(prefs->GetBoolean(prefs::kShowFullscreenToolbar)); |
779 } | 779 } |
780 | 780 |
781 // Tests that the toolbar (tabstrip and omnibox) reveal animation is correctly | 781 // Tests that the toolbar (tabstrip and omnibox) reveal animation is correctly |
782 // triggered by the changes in the tabstrip. The animation should not trigger | 782 // triggered by the changes in the tabstrip. The animation should not trigger |
783 // if the current tab is a NTP, since the location bar would be focused. | 783 // if the current tab is a NTP, since the location bar would be focused. |
784 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, | 784 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, |
785 FullscreenToolbarExposedForTabstripChanges) { | 785 FullscreenToolbarExposedForTabstripChanges) { |
786 base::scoped_nsobject<MockPresentationModeController> | 786 base::scoped_nsobject<MockFullscreenToolbarController> |
787 presentationModeController([[MockPresentationModeController alloc] | 787 fullscreenToolbarController([[MockFullscreenToolbarController alloc] |
788 initWithBrowserController:controller()]); | 788 initWithBrowserController:controller()]); |
789 [controller() setPresentationModeController:presentationModeController.get()]; | 789 [controller() |
| 790 setFullscreenToolbarController:fullscreenToolbarController.get()]; |
790 | 791 |
791 ToggleFullscreenAndWaitForNotification(); | 792 ToggleFullscreenAndWaitForNotification(); |
792 | 793 |
793 // Insert a non-NTP new tab in the foreground. | 794 // Insert a non-NTP new tab in the foreground. |
794 AddTabAtIndex(0, GURL("http://google.com"), ui::PAGE_TRANSITION_LINK); | 795 AddTabAtIndex(0, GURL("http://google.com"), ui::PAGE_TRANSITION_LINK); |
795 ASSERT_FALSE([[controller() toolbarController] isLocationBarFocused]); | 796 ASSERT_FALSE([[controller() toolbarController] isLocationBarFocused]); |
796 EXPECT_TRUE([presentationModeController isRevealingToolbarForTabstrip]); | 797 EXPECT_TRUE([fullscreenToolbarController isRevealingToolbarForTabstrip]); |
797 [presentationModeController resetToolbarFlag]; | 798 [fullscreenToolbarController resetToolbarFlag]; |
798 | 799 |
799 // Insert a new tab in the background. | 800 // Insert a new tab in the background. |
800 AddTabAtBackground(0, GURL("about:blank")); | 801 AddTabAtBackground(0, GURL("about:blank")); |
801 EXPECT_TRUE([presentationModeController isRevealingToolbarForTabstrip]); | 802 EXPECT_TRUE([fullscreenToolbarController isRevealingToolbarForTabstrip]); |
802 [presentationModeController resetToolbarFlag]; | 803 [fullscreenToolbarController resetToolbarFlag]; |
803 | 804 |
804 // Insert a NTP new tab in the foreground. | 805 // Insert a NTP new tab in the foreground. |
805 AddTabAtIndex(0, GURL("about:blank"), ui::PAGE_TRANSITION_LINK); | 806 AddTabAtIndex(0, GURL("about:blank"), ui::PAGE_TRANSITION_LINK); |
806 ASSERT_TRUE([[controller() toolbarController] isLocationBarFocused]); | 807 ASSERT_TRUE([[controller() toolbarController] isLocationBarFocused]); |
807 EXPECT_FALSE([presentationModeController isRevealingToolbarForTabstrip]); | 808 EXPECT_FALSE([fullscreenToolbarController isRevealingToolbarForTabstrip]); |
808 [presentationModeController resetToolbarFlag]; | 809 [fullscreenToolbarController resetToolbarFlag]; |
809 | 810 |
810 // Insert a new tab in the background. The animation should not be triggered | 811 // Insert a new tab in the background. The animation should not be triggered |
811 // since the location bar should still be focused. | 812 // since the location bar should still be focused. |
812 AddTabAtBackground(1, GURL("http://google.com")); | 813 AddTabAtBackground(1, GURL("http://google.com")); |
813 ASSERT_TRUE([[controller() toolbarController] isLocationBarFocused]); | 814 ASSERT_TRUE([[controller() toolbarController] isLocationBarFocused]); |
814 EXPECT_FALSE([presentationModeController isRevealingToolbarForTabstrip]); | 815 EXPECT_FALSE([fullscreenToolbarController isRevealingToolbarForTabstrip]); |
815 [presentationModeController resetToolbarFlag]; | 816 [fullscreenToolbarController resetToolbarFlag]; |
816 | 817 |
817 // Switch to a non-NTP tab. | 818 // Switch to a non-NTP tab. |
818 TabStripModel* model = browser()->tab_strip_model(); | 819 TabStripModel* model = browser()->tab_strip_model(); |
819 model->ActivateTabAt(1, true); | 820 model->ActivateTabAt(1, true); |
820 ASSERT_FALSE([[controller() toolbarController] isLocationBarFocused]); | 821 ASSERT_FALSE([[controller() toolbarController] isLocationBarFocused]); |
821 EXPECT_TRUE([presentationModeController isRevealingToolbarForTabstrip]); | 822 EXPECT_TRUE([fullscreenToolbarController isRevealingToolbarForTabstrip]); |
822 [presentationModeController resetToolbarFlag]; | 823 [fullscreenToolbarController resetToolbarFlag]; |
823 } | 824 } |
OLD | NEW |