| 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 #import "base/mac/mac_util.h" | 7 #import "base/mac/mac_util.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 11 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
| 12 #include "chrome/browser/infobars/infobar_service.h" | 12 #include "chrome/browser/infobars/infobar_service.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_commands.h" | 16 #include "chrome/browser/ui/browser_commands.h" |
| 17 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
| 18 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
| 19 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" | 19 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" |
| 20 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 20 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
| 21 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" | 21 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" |
| 22 #import "chrome/browser/ui/cocoa/fast_resize_view.h" | 22 #import "chrome/browser/ui/cocoa/fast_resize_view.h" |
| 23 #import "chrome/browser/ui/cocoa/history_overlay_controller.h" | 23 #import "chrome/browser/ui/cocoa/history_overlay_controller.h" |
| 24 #import "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h" |
| 24 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 25 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
| 25 #import "chrome/browser/ui/cocoa/nsview_additions.h" | 26 #import "chrome/browser/ui/cocoa/nsview_additions.h" |
| 26 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" | 27 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" |
| 27 #include "chrome/browser/ui/extensions/application_launch.h" | 28 #include "chrome/browser/ui/extensions/application_launch.h" |
| 28 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 29 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 29 #include "chrome/browser/ui/find_bar/find_bar.h" | 30 #include "chrome/browser/ui/find_bar/find_bar.h" |
| 30 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 31 #include "chrome/test/base/in_process_browser_test.h" | 32 #include "chrome/test/base/in_process_browser_test.h" |
| 32 #include "chrome/test/base/testing_profile.h" | 33 #include "chrome/test/base/testing_profile.h" |
| 33 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 BrowserWindowController* controller() const { | 102 BrowserWindowController* controller() const { |
| 102 return [BrowserWindowController browserWindowControllerForWindow: | 103 return [BrowserWindowController browserWindowControllerForWindow: |
| 103 browser()->window()->GetNativeWindow()]; | 104 browser()->window()->GetNativeWindow()]; |
| 104 } | 105 } |
| 105 | 106 |
| 106 void ShowInfoBar() { | 107 void ShowInfoBar() { |
| 107 content::WebContents* web_contents = | 108 content::WebContents* web_contents = |
| 108 browser()->tab_strip_model()->GetActiveWebContents(); | 109 browser()->tab_strip_model()->GetActiveWebContents(); |
| 109 InfoBarService* service = | 110 InfoBarService* service = |
| 110 InfoBarService::FromWebContents(web_contents); | 111 InfoBarService::FromWebContents(web_contents); |
| 111 info_bar_delegate_.reset(new DummyInfoBar(service)); | 112 scoped_ptr<InfoBarDelegate> info_bar_delegate(new DummyInfoBar(service)); |
| 112 [[controller() infoBarContainerController] | 113 service->AddInfoBar(info_bar_delegate.Pass()); |
| 113 addInfoBar:info_bar_delegate_->CreateInfoBar(service) | |
| 114 animate:NO]; | |
| 115 } | 114 } |
| 116 | 115 |
| 117 NSView* GetViewWithID(ViewID view_id) const { | 116 NSView* GetViewWithID(ViewID view_id) const { |
| 118 switch (view_id) { | 117 switch (view_id) { |
| 119 case VIEW_ID_FULLSCREEN_FLOATING_BAR: | 118 case VIEW_ID_FULLSCREEN_FLOATING_BAR: |
| 120 return [controller() floatingBarBackingView]; | 119 return [controller() floatingBarBackingView]; |
| 121 case VIEW_ID_TOOLBAR: | 120 case VIEW_ID_TOOLBAR: |
| 122 return [[controller() toolbarController] view]; | 121 return [[controller() toolbarController] view]; |
| 123 case VIEW_ID_BOOKMARK_BAR: | 122 case VIEW_ID_BOOKMARK_BAR: |
| 124 return [[controller() bookmarkBarController] view]; | 123 return [[controller() bookmarkBarController] view]; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 CGFloat GetViewHeight(ViewID viewID) const { | 155 CGFloat GetViewHeight(ViewID viewID) const { |
| 157 CGFloat height = NSHeight([GetViewWithID(viewID) frame]); | 156 CGFloat height = NSHeight([GetViewWithID(viewID) frame]); |
| 158 if (viewID == VIEW_ID_INFO_BAR) { | 157 if (viewID == VIEW_ID_INFO_BAR) { |
| 159 height -= [[controller() infoBarContainerController] | 158 height -= [[controller() infoBarContainerController] |
| 160 overlappingTipHeight]; | 159 overlappingTipHeight]; |
| 161 } | 160 } |
| 162 return height; | 161 return height; |
| 163 } | 162 } |
| 164 | 163 |
| 165 private: | 164 private: |
| 166 scoped_ptr<InfoBarDelegate> info_bar_delegate_; | |
| 167 | |
| 168 DISALLOW_COPY_AND_ASSIGN(BrowserWindowControllerTest); | 165 DISALLOW_COPY_AND_ASSIGN(BrowserWindowControllerTest); |
| 169 }; | 166 }; |
| 170 | 167 |
| 171 // Tests that adding the first profile moves the Lion fullscreen button over | 168 // Tests that adding the first profile moves the Lion fullscreen button over |
| 172 // correctly. | 169 // correctly. |
| 173 // DISABLED_ because it regularly times out: http://crbug.com/159002. | 170 // DISABLED_ because it regularly times out: http://crbug.com/159002. |
| 174 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, | 171 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, |
| 175 DISABLED_ProfileAvatarFullscreenButton) { | 172 DISABLED_ProfileAvatarFullscreenButton) { |
| 176 if (base::mac::IsOSSnowLeopard()) | 173 if (base::mac::IsOSSnowLeopard()) |
| 177 return; | 174 return; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 NSWindow* popupWindow = popup_browser->window()->GetNativeWindow(); | 361 NSWindow* popupWindow = popup_browser->window()->GetNativeWindow(); |
| 365 BrowserWindowController* popupController = | 362 BrowserWindowController* popupController = |
| 366 [BrowserWindowController browserWindowControllerForWindow:popupWindow]; | 363 [BrowserWindowController browserWindowControllerForWindow:popupWindow]; |
| 367 EXPECT_FALSE([popupController hasToolbar]); | 364 EXPECT_FALSE([popupController hasToolbar]); |
| 368 | 365 |
| 369 // Show infobar for controller. | 366 // Show infobar for controller. |
| 370 content::WebContents* web_contents = | 367 content::WebContents* web_contents = |
| 371 popup_browser->tab_strip_model()->GetActiveWebContents(); | 368 popup_browser->tab_strip_model()->GetActiveWebContents(); |
| 372 InfoBarService* service = InfoBarService::FromWebContents(web_contents); | 369 InfoBarService* service = InfoBarService::FromWebContents(web_contents); |
| 373 scoped_ptr<InfoBarDelegate> info_bar_delegate(new DummyInfoBar(service)); | 370 scoped_ptr<InfoBarDelegate> info_bar_delegate(new DummyInfoBar(service)); |
| 374 [[popupController infoBarContainerController] | 371 service->AddInfoBar(info_bar_delegate.Pass()); |
| 375 addInfoBar:info_bar_delegate->CreateInfoBar(service) | |
| 376 animate:NO]; | |
| 377 | |
| 378 EXPECT_TRUE( | 372 EXPECT_TRUE( |
| 379 [[popupController infoBarContainerController] | 373 [[popupController infoBarContainerController] |
| 380 shouldSuppressTopInfoBarTip]); | 374 shouldSuppressTopInfoBarTip]); |
| 381 } | 375 } |
| 382 | 376 |
| 383 // Verify that AllowOverlappingViews is set while the history overlay is | 377 // Verify that AllowOverlappingViews is set while the history overlay is |
| 384 // visible. | 378 // visible. |
| 385 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, | 379 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, |
| 386 AllowOverlappingViewsHistoryOverlay) { | 380 AllowOverlappingViewsHistoryOverlay) { |
| 387 content::WebContentsView* web_contents_view = | 381 content::WebContentsView* web_contents_view = |
| 388 browser()->tab_strip_model()->GetActiveWebContents()->GetView(); | 382 browser()->tab_strip_model()->GetActiveWebContents()->GetView(); |
| 389 EXPECT_FALSE(web_contents_view->GetAllowOverlappingViews()); | 383 EXPECT_FALSE(web_contents_view->GetAllowOverlappingViews()); |
| 390 | 384 |
| 391 base::scoped_nsobject<HistoryOverlayController> overlay( | 385 base::scoped_nsobject<HistoryOverlayController> overlay( |
| 392 [[HistoryOverlayController alloc] initForMode:kHistoryOverlayModeBack]); | 386 [[HistoryOverlayController alloc] initForMode:kHistoryOverlayModeBack]); |
| 393 [overlay showPanelForView:web_contents_view->GetNativeView()]; | 387 [overlay showPanelForView:web_contents_view->GetNativeView()]; |
| 394 EXPECT_TRUE(web_contents_view->GetAllowOverlappingViews()); | 388 EXPECT_TRUE(web_contents_view->GetAllowOverlappingViews()); |
| 395 | 389 |
| 396 overlay.reset(); | 390 overlay.reset(); |
| 397 EXPECT_FALSE(web_contents_view->GetAllowOverlappingViews()); | 391 EXPECT_FALSE(web_contents_view->GetAllowOverlappingViews()); |
| 398 } | 392 } |
| OLD | NEW |