Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cocoa/browser_window_controller.h" | 5 #import "chrome/browser/cocoa/browser_window_controller.h" |
| 6 | 6 |
| 7 #include <Carbon/Carbon.h> | 7 #include <Carbon/Carbon.h> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/l10n_util_mac.h" | 10 #include "app/l10n_util_mac.h" |
| 11 #include "app/menus/simple_menu_model.h" | |
| 11 #include "base/mac_util.h" | 12 #include "base/mac_util.h" |
| 12 #include "base/nsimage_cache_mac.h" | 13 #include "base/nsimage_cache_mac.h" |
| 13 #include "base/scoped_nsdisable_screen_updates.h" | 14 #include "base/scoped_nsdisable_screen_updates.h" |
| 14 #import "base/scoped_nsobject.h" | 15 #import "base/scoped_nsobject.h" |
| 15 #include "base/sys_string_conversions.h" | 16 #include "base/sys_string_conversions.h" |
| 16 #include "chrome/app/chrome_dll_resource.h" // IDC_* | 17 #include "chrome/app/chrome_dll_resource.h" // IDC_* |
| 17 #include "chrome/browser/browser.h" | 18 #include "chrome/browser/browser.h" |
| 18 #include "chrome/browser/browser_list.h" | 19 #include "chrome/browser/browser_list.h" |
| 19 #include "chrome/browser/browser_theme_provider.h" | 20 #include "chrome/browser/browser_theme_provider.h" |
| 20 #include "chrome/browser/dock_info.h" | 21 #include "chrome/browser/dock_info.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 31 #import "chrome/browser/cocoa/download_shelf_controller.h" | 32 #import "chrome/browser/cocoa/download_shelf_controller.h" |
| 32 #import "chrome/browser/cocoa/event_utils.h" | 33 #import "chrome/browser/cocoa/event_utils.h" |
| 33 #import "chrome/browser/cocoa/fast_resize_view.h" | 34 #import "chrome/browser/cocoa/fast_resize_view.h" |
| 34 #import "chrome/browser/cocoa/find_bar_cocoa_controller.h" | 35 #import "chrome/browser/cocoa/find_bar_cocoa_controller.h" |
| 35 #import "chrome/browser/cocoa/find_bar_bridge.h" | 36 #import "chrome/browser/cocoa/find_bar_bridge.h" |
| 36 #import "chrome/browser/cocoa/focus_tracker.h" | 37 #import "chrome/browser/cocoa/focus_tracker.h" |
| 37 #import "chrome/browser/cocoa/fullscreen_controller.h" | 38 #import "chrome/browser/cocoa/fullscreen_controller.h" |
| 38 #import "chrome/browser/cocoa/fullscreen_window.h" | 39 #import "chrome/browser/cocoa/fullscreen_window.h" |
| 39 #import "chrome/browser/cocoa/infobar_container_controller.h" | 40 #import "chrome/browser/cocoa/infobar_container_controller.h" |
| 40 #import "chrome/browser/cocoa/location_bar/autocomplete_text_field_editor.h" | 41 #import "chrome/browser/cocoa/location_bar/autocomplete_text_field_editor.h" |
| 42 #import "chrome/browser/cocoa/menu_controller.h" | |
| 41 #import "chrome/browser/cocoa/sad_tab_controller.h" | 43 #import "chrome/browser/cocoa/sad_tab_controller.h" |
| 42 #import "chrome/browser/cocoa/status_bubble_mac.h" | 44 #import "chrome/browser/cocoa/status_bubble_mac.h" |
| 43 #import "chrome/browser/cocoa/tab_contents_controller.h" | 45 #import "chrome/browser/cocoa/tab_contents_controller.h" |
| 44 #import "chrome/browser/cocoa/tab_strip_model_observer_bridge.h" | 46 #import "chrome/browser/cocoa/tab_strip_model_observer_bridge.h" |
| 45 #import "chrome/browser/cocoa/tab_strip_controller.h" | 47 #import "chrome/browser/cocoa/tab_strip_controller.h" |
| 46 #import "chrome/browser/cocoa/tab_strip_view.h" | 48 #import "chrome/browser/cocoa/tab_strip_view.h" |
| 47 #import "chrome/browser/cocoa/tab_view.h" | 49 #import "chrome/browser/cocoa/tab_view.h" |
| 48 #import "chrome/browser/cocoa/tabpose_window.h" | 50 #import "chrome/browser/cocoa/tabpose_window.h" |
| 49 #import "chrome/browser/cocoa/toolbar_controller.h" | 51 #import "chrome/browser/cocoa/toolbar_controller.h" |
| 50 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 52 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 @interface NSWindow(NSPrivateApis) | 137 @interface NSWindow(NSPrivateApis) |
| 136 // Note: These functions are private, use -[NSObject respondsToSelector:] | 138 // Note: These functions are private, use -[NSObject respondsToSelector:] |
| 137 // before calling them. | 139 // before calling them. |
| 138 | 140 |
| 139 - (void)setBottomCornerRounded:(BOOL)rounded; | 141 - (void)setBottomCornerRounded:(BOOL)rounded; |
| 140 | 142 |
| 141 - (NSRect)_growBoxRect; | 143 - (NSRect)_growBoxRect; |
| 142 | 144 |
| 143 @end | 145 @end |
| 144 | 146 |
| 147 // BrowserWindowPopupMenuController subclasses MenuController to | |
|
viettrungluu
2010/08/20 17:02:00
Why is this in browser_window_controller.mm?
| |
| 148 // provide menu items for the popup context menu. | |
| 149 @interface BrowserWindowPopupMenuController : MenuController { | |
| 150 scoped_ptr<menus::SimpleMenuModel> popupModel_; | |
|
viettrungluu
2010/08/20 17:02:00
@private
| |
| 151 } | |
| 152 | |
| 153 - (id)initWithDelegate:(menus::SimpleMenuModel::Delegate*)delegate; | |
| 154 @end | |
| 155 | |
| 156 @implementation BrowserWindowPopupMenuController | |
| 157 - (menus::SimpleMenuModel*)newModelFor:(menus::SimpleMenuModel::Delegate*)delega te { | |
|
viettrungluu
2010/08/20 17:02:00
80 chars
| |
| 158 menus::SimpleMenuModel* result = new menus::SimpleMenuModel(delegate); | |
| 159 result->AddItemWithStringId(IDC_COPY_URL, | |
| 160 IDS_APP_MENU_COPY_URL); | |
| 161 result->AddItemWithStringId(IDC_SHOW_AS_TAB, | |
| 162 IDS_SHOW_AS_TAB); | |
| 163 result->AddSeparator(); | |
| 164 result->AddItemWithStringId(IDC_RELOAD, IDS_APP_MENU_RELOAD); | |
| 165 result->AddItemWithStringId(IDC_FORWARD, | |
| 166 IDS_CONTENT_CONTEXT_FORWARD); | |
| 167 result->AddItemWithStringId(IDC_BACK, | |
| 168 IDS_CONTENT_CONTEXT_BACK); | |
| 169 return result; | |
| 170 } | |
| 171 | |
| 172 - (id)initWithDelegate:(menus::SimpleMenuModel::Delegate*)delegate { | |
| 173 if ((self = [super init]) != nil) { | |
|
viettrungluu
2010/08/20 17:02:00
'!= nil' not needed
| |
| 174 popupModel_.reset([self newModelFor:delegate]); | |
| 175 [self setModel: popupModel_.get()]; | |
|
viettrungluu
2010/08/20 17:02:00
no space after ':'
| |
| 176 } | |
| 177 | |
| 178 return self; | |
| 179 } | |
| 180 @end | |
| 145 | 181 |
| 146 // IncognitoImageView subclasses NSImageView to allow mouse events to pass | 182 // IncognitoImageView subclasses NSImageView to allow mouse events to pass |
| 147 // through it so you can drag the window by dragging on the spy guy | 183 // through it so you can drag the window by dragging on the spy guy |
| 148 @interface IncognitoImageView : NSImageView | 184 @interface IncognitoImageView : NSImageView |
| 149 @end | 185 @end |
| 150 | 186 |
| 151 @implementation IncognitoImageView | 187 @implementation IncognitoImageView |
| 152 - (BOOL)mouseDownCanMoveWindow { | 188 - (BOOL)mouseDownCanMoveWindow { |
| 153 return YES; | 189 return YES; |
| 154 } | 190 } |
| (...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1633 - (BOOL)useVerticalTabs { | 1669 - (BOOL)useVerticalTabs { |
| 1634 return browser_->tabstrip_model()->delegate()->UseVerticalTabs(); | 1670 return browser_->tabstrip_model()->delegate()->UseVerticalTabs(); |
| 1635 } | 1671 } |
| 1636 | 1672 |
| 1637 - (void)sheetDidEnd:(NSWindow*)sheet | 1673 - (void)sheetDidEnd:(NSWindow*)sheet |
| 1638 returnCode:(NSInteger)code | 1674 returnCode:(NSInteger)code |
| 1639 context:(void*)context { | 1675 context:(void*)context { |
| 1640 [sheet orderOut:self]; | 1676 [sheet orderOut:self]; |
| 1641 } | 1677 } |
| 1642 | 1678 |
| 1679 - (NSMenu*)popupContextMenu { | |
|
viettrungluu
2010/08/20 17:02:00
Should you check that this is a popup window?
| |
| 1680 if (!popupMenuController_) { | |
| 1681 popupMenuController_.reset( | |
| 1682 [[BrowserWindowPopupMenuController alloc] initWithDelegate:windowShim_.g et()]); | |
|
viettrungluu
2010/08/20 17:02:00
80 chars
| |
| 1683 } | |
| 1684 | |
| 1685 return [popupMenuController_ menu]; | |
| 1686 } | |
| 1643 @end // @implementation BrowserWindowController | 1687 @end // @implementation BrowserWindowController |
| 1644 | 1688 |
| 1645 | 1689 |
| 1646 @implementation BrowserWindowController(Fullscreen) | 1690 @implementation BrowserWindowController(Fullscreen) |
| 1647 | 1691 |
| 1648 - (void)setFullscreen:(BOOL)fullscreen { | 1692 - (void)setFullscreen:(BOOL)fullscreen { |
| 1649 // The logic in this function is a bit complicated and very carefully | 1693 // The logic in this function is a bit complicated and very carefully |
| 1650 // arranged. See the below comments for more details. | 1694 // arranged. See the below comments for more details. |
| 1651 | 1695 |
| 1652 if (fullscreen == [self isFullscreen]) | 1696 if (fullscreen == [self isFullscreen]) |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1886 | 1930 |
| 1887 - (BOOL)supportsBookmarkBar { | 1931 - (BOOL)supportsBookmarkBar { |
| 1888 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 1932 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
| 1889 } | 1933 } |
| 1890 | 1934 |
| 1891 - (BOOL)isNormalWindow { | 1935 - (BOOL)isNormalWindow { |
| 1892 return browser_->type() == Browser::TYPE_NORMAL; | 1936 return browser_->type() == Browser::TYPE_NORMAL; |
| 1893 } | 1937 } |
| 1894 | 1938 |
| 1895 @end // @implementation BrowserWindowController(WindowType) | 1939 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |