| 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 <cmath> | 7 #include <cmath> |
| 8 #include <numeric> | 8 #include <numeric> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" | 56 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" |
| 57 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" | 57 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" |
| 58 #import "chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h" | 58 #import "chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h" |
| 59 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h" | 59 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h" |
| 60 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" | 60 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" |
| 61 #import "chrome/browser/ui/cocoa/tabpose_window.h" | 61 #import "chrome/browser/ui/cocoa/tabpose_window.h" |
| 62 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 62 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
| 63 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" | 63 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" |
| 64 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" | 64 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" |
| 65 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 65 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 66 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
| 66 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 67 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
| 67 #include "chrome/browser/ui/omnibox/location_bar.h" | 68 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 68 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 69 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 69 #include "chrome/browser/ui/tabs/dock_info.h" | 70 #include "chrome/browser/ui/tabs/dock_info.h" |
| 70 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 71 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 71 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" | 72 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" |
| 72 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" | 73 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" |
| 73 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 74 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
| 74 #include "chrome/common/chrome_switches.h" | 75 #include "chrome/common/chrome_switches.h" |
| 75 #include "chrome/common/url_constants.h" | 76 #include "chrome/common/url_constants.h" |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 statusBubble_ = NULL; | 522 statusBubble_ = NULL; |
| 522 // We can't actually use |-autorelease| here because there's an embedded | 523 // We can't actually use |-autorelease| here because there's an embedded |
| 523 // run loop in the |-performClose:| which contains its own autorelease pool. | 524 // run loop in the |-performClose:| which contains its own autorelease pool. |
| 524 // Instead call it after a zero-length delay, which gets us back to the main | 525 // Instead call it after a zero-length delay, which gets us back to the main |
| 525 // event loop. | 526 // event loop. |
| 526 [self performSelector:@selector(autorelease) | 527 [self performSelector:@selector(autorelease) |
| 527 withObject:nil | 528 withObject:nil |
| 528 afterDelay:0]; | 529 afterDelay:0]; |
| 529 } | 530 } |
| 530 | 531 |
| 531 - (void)attachConstrainedWindow:(ConstrainedWindowMac*)window { | |
| 532 [tabStripController_ attachConstrainedWindow:window]; | |
| 533 } | |
| 534 | |
| 535 - (void)removeConstrainedWindow:(ConstrainedWindowMac*)window { | |
| 536 [tabStripController_ removeConstrainedWindow:window]; | |
| 537 } | |
| 538 | |
| 539 - (BOOL)canAttachConstrainedWindow { | |
| 540 return ![previewableContentsController_ isShowingPreview]; | |
| 541 } | |
| 542 | |
| 543 - (void)updateDevToolsForContents:(WebContents*)contents { | 532 - (void)updateDevToolsForContents:(WebContents*)contents { |
| 544 [devToolsController_ updateDevToolsForWebContents:contents | 533 [devToolsController_ updateDevToolsForWebContents:contents |
| 545 withProfile:browser_->profile()]; | 534 withProfile:browser_->profile()]; |
| 546 } | 535 } |
| 547 | 536 |
| 548 - (void)setDevToolsDockToRight:(bool)dock_to_right { | 537 - (void)setDevToolsDockToRight:(bool)dock_to_right { |
| 549 [devToolsController_ setDockToRight:dock_to_right | 538 [devToolsController_ setDockToRight:dock_to_right |
| 550 withProfile:browser_->profile()]; | 539 withProfile:browser_->profile()]; |
| 551 } | 540 } |
| 552 | 541 |
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 - (NSRect)regularWindowFrame { | 1514 - (NSRect)regularWindowFrame { |
| 1526 return [self isFullscreen] ? savedRegularWindowFrame_ : | 1515 return [self isFullscreen] ? savedRegularWindowFrame_ : |
| 1527 [[self window] frame]; | 1516 [[self window] frame]; |
| 1528 } | 1517 } |
| 1529 | 1518 |
| 1530 // (Override of |TabWindowController| method.) | 1519 // (Override of |TabWindowController| method.) |
| 1531 - (BOOL)hasTabStrip { | 1520 - (BOOL)hasTabStrip { |
| 1532 return [self supportsWindowFeature:Browser::FEATURE_TABSTRIP]; | 1521 return [self supportsWindowFeature:Browser::FEATURE_TABSTRIP]; |
| 1533 } | 1522 } |
| 1534 | 1523 |
| 1524 - (BOOL)isTabDraggable:(NSView*)tabView { |
| 1525 // TODO(avi, thakis): GTMWindowSheetController has no api to move tabsheets |
| 1526 // between windows. Until then, we have to prevent having to move a tabsheet |
| 1527 // between windows, e.g. no tearing off of tabs. |
| 1528 int index = [tabStripController_ modelIndexForTabView:tabView]; |
| 1529 TabContents* contents = chrome::GetTabContentsAt(browser_.get(), index); |
| 1530 if (!contents) |
| 1531 return NO; |
| 1532 return !contents->constrained_window_tab_helper()->constrained_window_count(); |
| 1533 } |
| 1534 |
| 1535 // TabStripControllerDelegate protocol. | 1535 // TabStripControllerDelegate protocol. |
| 1536 - (void)onActivateTabWithContents:(WebContents*)contents { | 1536 - (void)onActivateTabWithContents:(WebContents*)contents { |
| 1537 // Update various elements that are interested in knowing the current | 1537 // Update various elements that are interested in knowing the current |
| 1538 // WebContents. | 1538 // WebContents. |
| 1539 | 1539 |
| 1540 // Update all the UI bits. | 1540 // Update all the UI bits. |
| 1541 windowShim_->UpdateTitleBar(); | 1541 windowShim_->UpdateTitleBar(); |
| 1542 | 1542 |
| 1543 [devToolsController_ updateDevToolsForWebContents:contents | 1543 [devToolsController_ updateDevToolsForWebContents:contents |
| 1544 withProfile:browser_->profile()]; | 1544 withProfile:browser_->profile()]; |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1913 [previewableContentsController_ hidePreview]; | 1913 [previewableContentsController_ hidePreview]; |
| 1914 [self updateBookmarkBarVisibilityWithAnimation:NO]; | 1914 [self updateBookmarkBarVisibilityWithAnimation:NO]; |
| 1915 } | 1915 } |
| 1916 | 1916 |
| 1917 - (void)commitInstant { | 1917 - (void)commitInstant { |
| 1918 InstantController* instant = browser_->instant_controller()->instant(); | 1918 InstantController* instant = browser_->instant_controller()->instant(); |
| 1919 if (instant && instant->IsCurrent()) | 1919 if (instant && instant->IsCurrent()) |
| 1920 instant->CommitCurrentPreview(INSTANT_COMMIT_FOCUS_LOST); | 1920 instant->CommitCurrentPreview(INSTANT_COMMIT_FOCUS_LOST); |
| 1921 } | 1921 } |
| 1922 | 1922 |
| 1923 - (BOOL)isInstantTabShowing { |
| 1924 return previewableContentsController_ && |
| 1925 [previewableContentsController_ isShowingPreview]; |
| 1926 } |
| 1923 | 1927 |
| 1924 - (NSRect)instantFrame { | 1928 - (NSRect)instantFrame { |
| 1925 // The view's bounds are in its own coordinate system. Convert that to the | 1929 // The view's bounds are in its own coordinate system. Convert that to the |
| 1926 // window base coordinate system, then translate it into the screen's | 1930 // window base coordinate system, then translate it into the screen's |
| 1927 // coordinate system. | 1931 // coordinate system. |
| 1928 NSView* view = [previewableContentsController_ view]; | 1932 NSView* view = [previewableContentsController_ view]; |
| 1929 if (!view) | 1933 if (!view) |
| 1930 return NSZeroRect; | 1934 return NSZeroRect; |
| 1931 | 1935 |
| 1932 NSRect frame = [view convertRect:[view bounds] toView:nil]; | 1936 NSRect frame = [view convertRect:[view bounds] toView:nil]; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2197 | 2201 |
| 2198 - (BOOL)supportsBookmarkBar { | 2202 - (BOOL)supportsBookmarkBar { |
| 2199 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2203 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
| 2200 } | 2204 } |
| 2201 | 2205 |
| 2202 - (BOOL)isTabbedWindow { | 2206 - (BOOL)isTabbedWindow { |
| 2203 return browser_->is_type_tabbed(); | 2207 return browser_->is_type_tabbed(); |
| 2204 } | 2208 } |
| 2205 | 2209 |
| 2206 @end // @implementation BrowserWindowController(WindowType) | 2210 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |