| 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 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/mac/bundle_locations.h" | 12 #include "base/mac/bundle_locations.h" |
| 13 #import "base/mac/foundation_util.h" | 13 #import "base/mac/foundation_util.h" |
| 14 #include "base/mac/mac_util.h" | 14 #include "base/mac/mac_util.h" |
| 15 #import "base/mac/sdk_forward_declarations.h" | 15 #import "base/mac/sdk_forward_declarations.h" |
| 16 #include "base/strings/sys_string_conversions.h" | 16 #include "base/strings/sys_string_conversions.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "chrome/app/chrome_command_ids.h" // IDC_* | 18 #include "chrome/app/chrome_command_ids.h" // IDC_* |
| 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 20 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" | 20 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" |
| 21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/devtools/devtools_window.h" | 22 #include "chrome/browser/devtools/devtools_window.h" |
| 23 #include "chrome/browser/extensions/extension_commands_global_registry.h" | 23 #include "chrome/browser/extensions/extension_commands_global_registry.h" |
| 24 #include "chrome/browser/permissions/permission_request_manager.h" |
| 24 #include "chrome/browser/profiles/avatar_menu.h" | 25 #include "chrome/browser/profiles/avatar_menu.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/profiles/profile_attributes_storage.h" | 27 #include "chrome/browser/profiles/profile_attributes_storage.h" |
| 27 #include "chrome/browser/profiles/profile_manager.h" | 28 #include "chrome/browser/profiles/profile_manager.h" |
| 28 #include "chrome/browser/profiles/profiles_state.h" | 29 #include "chrome/browser/profiles/profiles_state.h" |
| 29 #include "chrome/browser/themes/theme_service.h" | 30 #include "chrome/browser/themes/theme_service.h" |
| 30 #include "chrome/browser/themes/theme_service_factory.h" | 31 #include "chrome/browser/themes/theme_service_factory.h" |
| 31 #include "chrome/browser/translate/chrome_translate_client.h" | 32 #include "chrome/browser/translate/chrome_translate_client.h" |
| 32 #include "chrome/browser/ui/bookmarks/bookmark_editor.h" | 33 #include "chrome/browser/ui/bookmarks/bookmark_editor.h" |
| 33 #include "chrome/browser/ui/browser.h" | 34 #include "chrome/browser/ui/browser.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" | 71 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" |
| 71 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" | 72 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" |
| 72 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 73 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 73 #import "chrome/browser/ui/cocoa/translate/translate_bubble_controller.h" | 74 #import "chrome/browser/ui/cocoa/translate/translate_bubble_controller.h" |
| 74 #include "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h" | 75 #include "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h" |
| 75 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 76 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
| 76 #include "chrome/browser/ui/location_bar/location_bar.h" | 77 #include "chrome/browser/ui/location_bar/location_bar.h" |
| 77 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 78 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 78 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" | 79 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" |
| 79 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h" | 80 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h" |
| 80 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | |
| 81 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 81 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
| 82 #include "chrome/common/chrome_switches.h" | 82 #include "chrome/common/chrome_switches.h" |
| 83 #include "chrome/common/extensions/command.h" | 83 #include "chrome/common/extensions/command.h" |
| 84 #include "chrome/common/pref_names.h" | 84 #include "chrome/common/pref_names.h" |
| 85 #include "chrome/grit/generated_resources.h" | 85 #include "chrome/grit/generated_resources.h" |
| 86 #include "chrome/grit/locale_settings.h" | 86 #include "chrome/grit/locale_settings.h" |
| 87 #include "components/bookmarks/browser/bookmark_model.h" | 87 #include "components/bookmarks/browser/bookmark_model.h" |
| 88 #include "components/bookmarks/managed/managed_bookmark_service.h" | 88 #include "components/bookmarks/managed/managed_bookmark_service.h" |
| 89 #include "components/signin/core/common/profile_management_switches.h" | 89 #include "components/signin/core/common/profile_management_switches.h" |
| 90 #include "components/translate/core/browser/translate_manager.h" | 90 #include "components/translate/core/browser/translate_manager.h" |
| (...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 [toolbarController_ setStarredState:isStarred]; | 1009 [toolbarController_ setStarredState:isStarred]; |
| 1010 } | 1010 } |
| 1011 | 1011 |
| 1012 - (void)setCurrentPageIsTranslated:(BOOL)on { | 1012 - (void)setCurrentPageIsTranslated:(BOOL)on { |
| 1013 [toolbarController_ setTranslateIconLit:on]; | 1013 [toolbarController_ setTranslateIconLit:on]; |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 - (void)onActiveTabChanged:(content::WebContents*)oldContents | 1016 - (void)onActiveTabChanged:(content::WebContents*)oldContents |
| 1017 to:(content::WebContents*)newContents { | 1017 to:(content::WebContents*)newContents { |
| 1018 // No need to remove previous bubble. It will close itself. | 1018 // No need to remove previous bubble. It will close itself. |
| 1019 PermissionBubbleManager* manager(nullptr); | 1019 PermissionRequestManager* manager(nullptr); |
| 1020 if (oldContents) { | 1020 if (oldContents) { |
| 1021 manager = PermissionBubbleManager::FromWebContents(oldContents); | 1021 manager = PermissionRequestManager::FromWebContents(oldContents); |
| 1022 if (manager) | 1022 if (manager) |
| 1023 manager->HideBubble(); | 1023 manager->HideBubble(); |
| 1024 } | 1024 } |
| 1025 | 1025 |
| 1026 if (newContents) { | 1026 if (newContents) { |
| 1027 manager = PermissionBubbleManager::FromWebContents(newContents); | 1027 manager = PermissionRequestManager::FromWebContents(newContents); |
| 1028 if (manager) | 1028 if (manager) |
| 1029 manager->DisplayPendingRequests(); | 1029 manager->DisplayPendingRequests(); |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 // If the web contents want to focus on the location bar, do not call the | 1032 // If the web contents want to focus on the location bar, do not call the |
| 1033 // animation since the location bar will drop down when it's focused. | 1033 // animation since the location bar will drop down when it's focused. |
| 1034 bool willFocusLocationBar = | 1034 bool willFocusLocationBar = |
| 1035 newContents && newContents->FocusLocationBarByDefault(); | 1035 newContents && newContents->FocusLocationBarByDefault(); |
| 1036 if ([self isInAnyFullscreenMode] && !willFocusLocationBar) | 1036 if ([self isInAnyFullscreenMode] && !willFocusLocationBar) |
| 1037 [[self fullscreenToolbarController] revealToolbarForTabStripChanges]; | 1037 [[self fullscreenToolbarController] revealToolbarForTabStripChanges]; |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1627 [translateBubbleController_ showWindow:nil]; | 1627 [translateBubbleController_ showWindow:nil]; |
| 1628 | 1628 |
| 1629 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | 1629 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
| 1630 [center addObserver:self | 1630 [center addObserver:self |
| 1631 selector:@selector(translateBubbleWindowWillClose:) | 1631 selector:@selector(translateBubbleWindowWillClose:) |
| 1632 name:NSWindowWillCloseNotification | 1632 name:NSWindowWillCloseNotification |
| 1633 object:[translateBubbleController_ window]]; | 1633 object:[translateBubbleController_ window]]; |
| 1634 } | 1634 } |
| 1635 | 1635 |
| 1636 - (void)dismissPermissionBubble { | 1636 - (void)dismissPermissionBubble { |
| 1637 PermissionBubbleManager* manager = [self permissionBubbleManager]; | 1637 PermissionRequestManager* manager = [self permissionRequestManager]; |
| 1638 if (manager) | 1638 if (manager) |
| 1639 manager->HideBubble(); | 1639 manager->HideBubble(); |
| 1640 } | 1640 } |
| 1641 | 1641 |
| 1642 // Nil out the weak translate bubble controller reference. | 1642 // Nil out the weak translate bubble controller reference. |
| 1643 - (void)translateBubbleWindowWillClose:(NSNotification*)notification { | 1643 - (void)translateBubbleWindowWillClose:(NSNotification*)notification { |
| 1644 DCHECK_EQ([notification object], [translateBubbleController_ window]); | 1644 DCHECK_EQ([notification object], [translateBubbleController_ window]); |
| 1645 | 1645 |
| 1646 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | 1646 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
| 1647 [center removeObserver:self | 1647 [center removeObserver:self |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2053 | 2053 |
| 2054 - (NSRect)savedRegularWindowFrame { | 2054 - (NSRect)savedRegularWindowFrame { |
| 2055 return savedRegularWindowFrame_; | 2055 return savedRegularWindowFrame_; |
| 2056 } | 2056 } |
| 2057 | 2057 |
| 2058 - (BOOL)isFullscreenTransitionInProgress { | 2058 - (BOOL)isFullscreenTransitionInProgress { |
| 2059 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_; | 2059 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_; |
| 2060 } | 2060 } |
| 2061 | 2061 |
| 2062 @end // @implementation BrowserWindowController(WindowType) | 2062 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |