OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <Carbon/Carbon.h> | 7 #include <Carbon/Carbon.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 #include <numeric> | 10 #include <numeric> |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "chrome/browser/themes/theme_service.h" | 28 #include "chrome/browser/themes/theme_service.h" |
29 #include "chrome/browser/themes/theme_service_factory.h" | 29 #include "chrome/browser/themes/theme_service_factory.h" |
30 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
31 #include "chrome/browser/ui/browser_list.h" | 31 #include "chrome/browser/ui/browser_list.h" |
32 #import "chrome/browser/ui/cocoa/background_gradient_view.h" | 32 #import "chrome/browser/ui/cocoa/background_gradient_view.h" |
33 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 33 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
34 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" | 34 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" |
35 #import "chrome/browser/ui/cocoa/browser/avatar_button.h" | 35 #import "chrome/browser/ui/cocoa/browser/avatar_button.h" |
36 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 36 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
37 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" | 37 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" |
| 38 #import "chrome/browser/ui/cocoa/browser_window_utils.h" |
38 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" | 39 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" |
39 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" | 40 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" |
40 #import "chrome/browser/ui/cocoa/event_utils.h" | 41 #import "chrome/browser/ui/cocoa/event_utils.h" |
41 #import "chrome/browser/ui/cocoa/fast_resize_view.h" | 42 #import "chrome/browser/ui/cocoa/fast_resize_view.h" |
42 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | 43 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
43 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" | 44 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" |
44 #import "chrome/browser/ui/cocoa/framed_browser_window.h" | 45 #import "chrome/browser/ui/cocoa/framed_browser_window.h" |
45 #import "chrome/browser/ui/cocoa/fullscreen_window.h" | 46 #import "chrome/browser/ui/cocoa/fullscreen_window.h" |
46 #import "chrome/browser/ui/cocoa/image_utils.h" | 47 #import "chrome/browser/ui/cocoa/image_utils.h" |
47 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 48 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
(...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1580 | 1581 |
1581 if (browser_->is_devtools()) | 1582 if (browser_->is_devtools()) |
1582 style |= THEMED_DEVTOOLS; | 1583 style |= THEMED_DEVTOOLS; |
1583 if (browser_->is_type_popup()) | 1584 if (browser_->is_type_popup()) |
1584 style |= THEMED_POPUP; | 1585 style |= THEMED_POPUP; |
1585 | 1586 |
1586 return style; | 1587 return style; |
1587 } | 1588 } |
1588 | 1589 |
1589 - (NSPoint)themePatternPhase { | 1590 - (NSPoint)themePatternPhase { |
1590 // Our patterns want to be drawn from the upper left hand corner of the view. | |
1591 // Cocoa wants to do it from the lower left of the window. | |
1592 // | |
1593 // Rephase our pattern to fit this view. Some other views (Tabs, Toolbar etc.) | |
1594 // will phase their patterns relative to this so all the views look right. | |
1595 // | |
1596 // To line up the background pattern with the pattern in the browser window | |
1597 // the background pattern for the tabs needs to be moved left by 5 pixels. | |
1598 const CGFloat kPatternHorizontalOffset = -5; | |
1599 // To match Windows and CrOS, have to offset vertically by 2 pixels. | |
1600 // Without tab strip, offset an extra pixel (determined by experimentation). | |
1601 const CGFloat kPatternVerticalOffset = 2; | |
1602 const CGFloat kPatternVerticalOffsetNoTabStrip = 3; | |
1603 | |
1604 // When we have a tab strip, line up with the top of the tab, otherwise, | |
1605 // line up with the top of the window. | |
1606 NSView* windowChromeView = [[[self window] contentView] superview]; | 1591 NSView* windowChromeView = [[[self window] contentView] superview]; |
1607 if ([self hasTabStrip]) { | 1592 return [BrowserWindowUtils themePatternPhaseFor:windowChromeView |
1608 NSView* tabStripView = [self tabStripView]; | 1593 withTabStrip:[self tabStripView]]; |
1609 NSRect tabStripViewWindowBounds = [tabStripView bounds]; | |
1610 tabStripViewWindowBounds = | |
1611 [tabStripView convertRect:tabStripViewWindowBounds | |
1612 toView:windowChromeView]; | |
1613 return NSMakePoint(NSMinX(tabStripViewWindowBounds) | |
1614 + kPatternHorizontalOffset, | |
1615 NSMinY(tabStripViewWindowBounds) | |
1616 + [TabStripController defaultTabHeight] | |
1617 + kPatternVerticalOffset); | |
1618 } else { | |
1619 return NSMakePoint(kPatternHorizontalOffset, | |
1620 NSHeight([windowChromeView bounds]) | |
1621 + kPatternVerticalOffsetNoTabStrip); | |
1622 } | |
1623 } | 1594 } |
1624 | 1595 |
1625 - (NSPoint)bookmarkBubblePoint { | 1596 - (NSPoint)bookmarkBubblePoint { |
1626 return [toolbarController_ bookmarkBubblePoint]; | 1597 return [toolbarController_ bookmarkBubblePoint]; |
1627 } | 1598 } |
1628 | 1599 |
1629 // Show the bookmark bubble (e.g. user just clicked on the STAR). | 1600 // Show the bookmark bubble (e.g. user just clicked on the STAR). |
1630 - (void)showBookmarkBubbleForURL:(const GURL&)url | 1601 - (void)showBookmarkBubbleForURL:(const GURL&)url |
1631 alreadyBookmarked:(BOOL)alreadyMarked { | 1602 alreadyBookmarked:(BOOL)alreadyMarked { |
1632 if (!bookmarkBubbleController_) { | 1603 if (!bookmarkBubbleController_) { |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2185 | 2156 |
2186 - (BOOL)supportsBookmarkBar { | 2157 - (BOOL)supportsBookmarkBar { |
2187 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2158 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
2188 } | 2159 } |
2189 | 2160 |
2190 - (BOOL)isTabbedWindow { | 2161 - (BOOL)isTabbedWindow { |
2191 return browser_->is_type_tabbed(); | 2162 return browser_->is_type_tabbed(); |
2192 } | 2163 } |
2193 | 2164 |
2194 @end // @implementation BrowserWindowController(WindowType) | 2165 @end // @implementation BrowserWindowController(WindowType) |
OLD | NEW |