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_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" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
13 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 13 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/profiles/profile_info_util.h" | 15 #include "chrome/browser/profiles/profile_info_util.h" |
16 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 16 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
| 17 #include "chrome/browser/ui/browser_tabstrip.h" |
17 #include "chrome/browser/ui/browser_window_state.h" | 18 #include "chrome/browser/ui/browser_window_state.h" |
18 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" | 19 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" |
19 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" | 20 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" |
20 #import "chrome/browser/ui/cocoa/fast_resize_view.h" | 21 #import "chrome/browser/ui/cocoa/fast_resize_view.h" |
21 #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" |
22 #import "chrome/browser/ui/cocoa/floating_bar_backing_view.h" | 23 #import "chrome/browser/ui/cocoa/floating_bar_backing_view.h" |
23 #import "chrome/browser/ui/cocoa/framed_browser_window.h" | 24 #import "chrome/browser/ui/cocoa/framed_browser_window.h" |
24 #import "chrome/browser/ui/cocoa/fullscreen_window.h" | 25 #import "chrome/browser/ui/cocoa/fullscreen_window.h" |
25 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 26 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
26 #import "chrome/browser/ui/cocoa/nsview_additions.h" | 27 #import "chrome/browser/ui/cocoa/nsview_additions.h" |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 | 476 |
476 bool contentShifted = | 477 bool contentShifted = |
477 NSMaxY(tabContentFrame) != NSMaxY(newFrame) || | 478 NSMaxY(tabContentFrame) != NSMaxY(newFrame) || |
478 NSMinX(tabContentFrame) != NSMinX(newFrame); | 479 NSMinX(tabContentFrame) != NSMinX(newFrame); |
479 | 480 |
480 tabContentFrame = newFrame; | 481 tabContentFrame = newFrame; |
481 [tabContentView setFrame:tabContentFrame]; | 482 [tabContentView setFrame:tabContentFrame]; |
482 | 483 |
483 // If the relayout shifts the content area up or down, let the renderer know. | 484 // If the relayout shifts the content area up or down, let the renderer know. |
484 if (contentShifted) { | 485 if (contentShifted) { |
485 if (WebContents* contents = browser_->GetActiveWebContents()) { | 486 if (WebContents* contents = chrome::GetActiveWebContents(browser_.get())) { |
486 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) | 487 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) |
487 rwhv->WindowFrameChanged(); | 488 rwhv->WindowFrameChanged(); |
488 } | 489 } |
489 } | 490 } |
490 } | 491 } |
491 | 492 |
492 - (BOOL)shouldShowBookmarkBar { | 493 - (BOOL)shouldShowBookmarkBar { |
493 DCHECK(browser_.get()); | 494 DCHECK(browser_.get()); |
494 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) ? | 495 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) ? |
495 YES : NO; | 496 YES : NO; |
496 } | 497 } |
497 | 498 |
498 - (BOOL)shouldShowDetachedBookmarkBar { | 499 - (BOOL)shouldShowDetachedBookmarkBar { |
499 DCHECK(browser_.get()); | 500 DCHECK(browser_.get()); |
500 TabContents* tab = browser_->GetActiveTabContents(); | 501 TabContents* tab = chrome::GetActiveTabContents(browser_.get()); |
501 return (tab && tab->bookmark_tab_helper()->ShouldShowBookmarkBar() && | 502 return (tab && tab->bookmark_tab_helper()->ShouldShowBookmarkBar() && |
502 ![previewableContentsController_ isShowingPreview]); | 503 ![previewableContentsController_ isShowingPreview]); |
503 } | 504 } |
504 | 505 |
505 - (void)adjustToolbarAndBookmarkBarForCompression:(CGFloat)compression { | 506 - (void)adjustToolbarAndBookmarkBarForCompression:(CGFloat)compression { |
506 CGFloat newHeight = | 507 CGFloat newHeight = |
507 [toolbarController_ desiredHeightForCompression:compression]; | 508 [toolbarController_ desiredHeightForCompression:compression]; |
508 NSRect toolbarFrame = [[toolbarController_ view] frame]; | 509 NSRect toolbarFrame = [[toolbarController_ view] frame]; |
509 CGFloat deltaH = newHeight - toolbarFrame.size.height; | 510 CGFloat deltaH = newHeight - toolbarFrame.size.height; |
510 | 511 |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 - (void)disableBarVisibilityUpdates { | 879 - (void)disableBarVisibilityUpdates { |
879 // Early escape if there's nothing to do. | 880 // Early escape if there's nothing to do. |
880 if (!barVisibilityUpdatesEnabled_) | 881 if (!barVisibilityUpdatesEnabled_) |
881 return; | 882 return; |
882 | 883 |
883 barVisibilityUpdatesEnabled_ = NO; | 884 barVisibilityUpdatesEnabled_ = NO; |
884 [presentationModeController_ cancelAnimationAndTimers]; | 885 [presentationModeController_ cancelAnimationAndTimers]; |
885 } | 886 } |
886 | 887 |
887 @end // @implementation BrowserWindowController(Private) | 888 @end // @implementation BrowserWindowController(Private) |
OLD | NEW |