| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 76 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
| 77 #include "chrome/browser/ui/location_bar/location_bar.h" | 77 #include "chrome/browser/ui/location_bar/location_bar.h" |
| 78 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 78 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 79 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" | 79 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" |
| 80 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h" | 80 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h" |
| 81 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | 81 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
| 82 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 82 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
| 83 #include "chrome/common/chrome_switches.h" | 83 #include "chrome/common/chrome_switches.h" |
| 84 #include "chrome/common/extensions/command.h" | 84 #include "chrome/common/extensions/command.h" |
| 85 #include "chrome/common/pref_names.h" | 85 #include "chrome/common/pref_names.h" |
| 86 #include "chrome/common/url_constants.h" | |
| 87 #include "chrome/grit/generated_resources.h" | 86 #include "chrome/grit/generated_resources.h" |
| 88 #include "chrome/grit/locale_settings.h" | 87 #include "chrome/grit/locale_settings.h" |
| 89 #include "components/bookmarks/browser/bookmark_model.h" | 88 #include "components/bookmarks/browser/bookmark_model.h" |
| 90 #include "components/bookmarks/managed/managed_bookmark_service.h" | 89 #include "components/bookmarks/managed/managed_bookmark_service.h" |
| 91 #include "components/signin/core/common/profile_management_switches.h" | 90 #include "components/signin/core/common/profile_management_switches.h" |
| 92 #include "components/translate/core/browser/translate_manager.h" | 91 #include "components/translate/core/browser/translate_manager.h" |
| 93 #include "components/translate/core/browser/translate_ui_delegate.h" | 92 #include "components/translate/core/browser/translate_ui_delegate.h" |
| 94 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 93 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 95 #include "content/public/browser/render_view_host.h" | 94 #include "content/public/browser/render_view_host.h" |
| 96 #include "content/public/browser/render_widget_host.h" | 95 #include "content/public/browser/render_widget_host.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // animated. Basically, the BWC doesn't see the global picture, but it sees | 176 // animated. Basically, the BWC doesn't see the global picture, but it sees |
| 178 // grows and shrinks in small increments (as dictated by the animation). Thus | 177 // grows and shrinks in small increments (as dictated by the animation). Thus |
| 179 // window growth/shrinkage (at the top/bottom) have to be tracked incrementally. | 178 // window growth/shrinkage (at the top/bottom) have to be tracked incrementally. |
| 180 // Allowing shrinking from the zoomed state also requires tracking: We check on | 179 // Allowing shrinking from the zoomed state also requires tracking: We check on |
| 181 // any shrink whether we're both zoomed and have previously grown -- if so, we | 180 // any shrink whether we're both zoomed and have previously grown -- if so, we |
| 182 // set a flag, and constrain any resize by the allowed amounts. On further | 181 // set a flag, and constrain any resize by the allowed amounts. On further |
| 183 // shrinks, we check the flag (since the size/position of the window will no | 182 // shrinks, we check the flag (since the size/position of the window will no |
| 184 // longer indicate that the window is shrinking from an apparent zoomed state) | 183 // longer indicate that the window is shrinking from an apparent zoomed state) |
| 185 // and if it's set we continue to constrain the resize. | 184 // and if it's set we continue to constrain the resize. |
| 186 | 185 |
| 187 using content::OpenURLParams; | |
| 188 using content::Referrer; | |
| 189 using content::RenderWidgetHostView; | 186 using content::RenderWidgetHostView; |
| 190 using content::WebContents; | 187 using content::WebContents; |
| 191 | 188 |
| 192 namespace { | 189 namespace { |
| 193 | 190 |
| 194 void SetUpBrowserWindowCommandHandler(NSWindow* window) { | 191 void SetUpBrowserWindowCommandHandler(NSWindow* window) { |
| 195 // Make the window handle browser window commands. | 192 // Make the window handle browser window commands. |
| 196 [base::mac::ObjCCastStrict<ChromeEventProcessingWindow>(window) | 193 [base::mac::ObjCCastStrict<ChromeEventProcessingWindow>(window) |
| 197 setCommandHandler:[[[BrowserWindowCommandHandler alloc] init] | 194 setCommandHandler:[[[BrowserWindowCommandHandler alloc] init] |
| 198 autorelease]]; | 195 autorelease]]; |
| (...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1698 | 1695 |
| 1699 // The FindBar needs to know its own position to properly detect overlaps | 1696 // The FindBar needs to know its own position to properly detect overlaps |
| 1700 // with find results. The position changes whenever the window is resized, | 1697 // with find results. The position changes whenever the window is resized, |
| 1701 // and |layoutSubviews| computes the FindBar's position. | 1698 // and |layoutSubviews| computes the FindBar's position. |
| 1702 // TODO: calling |layoutSubviews| here is a waste, find a better way to | 1699 // TODO: calling |layoutSubviews| here is a waste, find a better way to |
| 1703 // do this. | 1700 // do this. |
| 1704 if ([findBarCocoaController_ isFindBarVisible]) | 1701 if ([findBarCocoaController_ isFindBarVisible]) |
| 1705 [self layoutSubviews]; | 1702 [self layoutSubviews]; |
| 1706 } | 1703 } |
| 1707 | 1704 |
| 1708 // Handle the openLearnMoreAboutCrashLink: action from SadTabView when | |
| 1709 // "Learn more" link in "Aw snap" page (i.e. crash page or sad tab) is | |
| 1710 // clicked. Decoupling the action from its target makes unit testing possible. | |
| 1711 - (void)openLearnMoreAboutCrashLink:(id)sender { | |
| 1712 if (WebContents* contents = [self webContents]) { | |
| 1713 OpenURLParams params(GURL(chrome::kCrashReasonURL), Referrer(), CURRENT_TAB, | |
| 1714 ui::PAGE_TRANSITION_LINK, false); | |
| 1715 contents->OpenURL(params); | |
| 1716 } | |
| 1717 } | |
| 1718 | |
| 1719 // Delegate method called when window did move. (See below for why we don't use | 1705 // Delegate method called when window did move. (See below for why we don't use |
| 1720 // |-windowWillMove:|, which is called less frequently than |-windowDidMove| | 1706 // |-windowWillMove:|, which is called less frequently than |-windowDidMove| |
| 1721 // instead.) | 1707 // instead.) |
| 1722 - (void)windowDidMove:(NSNotification*)notification { | 1708 - (void)windowDidMove:(NSNotification*)notification { |
| 1723 [self saveWindowPositionIfNeeded]; | 1709 [self saveWindowPositionIfNeeded]; |
| 1724 | 1710 |
| 1725 NSWindow* window = [self window]; | 1711 NSWindow* window = [self window]; |
| 1726 NSRect windowFrame = [window frame]; | 1712 NSRect windowFrame = [window frame]; |
| 1727 NSRect workarea = [[window screen] visibleFrame]; | 1713 NSRect workarea = [[window screen] visibleFrame]; |
| 1728 | 1714 |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2065 | 2051 |
| 2066 - (BOOL)isTabbedWindow { | 2052 - (BOOL)isTabbedWindow { |
| 2067 return browser_->is_type_tabbed(); | 2053 return browser_->is_type_tabbed(); |
| 2068 } | 2054 } |
| 2069 | 2055 |
| 2070 - (NSRect)savedRegularWindowFrame { | 2056 - (NSRect)savedRegularWindowFrame { |
| 2071 return savedRegularWindowFrame_; | 2057 return savedRegularWindowFrame_; |
| 2072 } | 2058 } |
| 2073 | 2059 |
| 2074 @end // @implementation BrowserWindowController(WindowType) | 2060 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |