Index: chrome/browser/app_controller_mac.mm |
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm |
index b6c2f6fc2fe82e22192fceed3d75257fa6d77cb0..8bf93f67787d63ad9163566e4220b84d8c62ba60 100644 |
--- a/chrome/browser/app_controller_mac.mm |
+++ b/chrome/browser/app_controller_mac.mm |
@@ -44,6 +44,7 @@ |
#include "chrome/browser/sessions/tab_restore_service_factory.h" |
#include "chrome/browser/signin/signin_manager_factory.h" |
#include "chrome/browser/signin/signin_promo.h" |
+#include "chrome/browser/signin/signin_ui_util.h" |
#include "chrome/browser/sync/profile_sync_service.h" |
#include "chrome/browser/sync/sync_ui_util.h" |
#include "chrome/browser/ui/browser.h" |
@@ -58,8 +59,6 @@ |
#import "chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.h" |
#include "chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.h" |
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" |
-#import "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
-#import "chrome/browser/ui/cocoa/browser_window_controller.h" |
#import "chrome/browser/ui/cocoa/confirm_quit.h" |
#import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" |
#import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h" |
@@ -67,13 +66,11 @@ |
#import "chrome/browser/ui/cocoa/history_menu_bridge.h" |
#include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" |
#import "chrome/browser/ui/cocoa/profiles/profile_menu_controller.h" |
-#import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
-#import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" |
-#include "chrome/browser/ui/cocoa/task_manager_mac.h" |
#include "chrome/browser/ui/extensions/application_launch.h" |
#include "chrome/browser/ui/host_desktop.h" |
#include "chrome/browser/ui/startup/startup_browser_creator.h" |
#include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
+#include "chrome/browser/ui/tabs/tab_strip_model.h" |
#include "chrome/browser/ui/user_manager.h" |
#include "chrome/browser/web_applications/web_app_mac.h" |
#include "chrome/common/chrome_paths_internal.h" |
@@ -558,8 +555,8 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver { |
// main window should be the one that handles the close menu item action. |
window = mainWindow; |
} |
- enableCloseTabShortcut = |
- [[window windowController] isKindOfClass:[TabWindowController class]]; |
+ Browser* browser = chrome::FindBrowserWithWindow(window); |
+ enableCloseTabShortcut = browser && browser->is_type_tabbed(); |
} |
[self adjustCloseWindowMenuItemKeyEquivalent:enableCloseTabShortcut]; |
@@ -578,14 +575,9 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver { |
} |
- (void)windowDidBecomeMain:(NSNotification*)notify { |
- // If the window changed to a new BrowserWindowController, update the profile. |
- id windowController = [[notify object] windowController]; |
- if (![windowController isKindOfClass:[BrowserWindowController class]]) |
- return; |
- |
- // If the profile is incognito, use the original profile. |
- Profile* newProfile = [windowController profile]->GetOriginalProfile(); |
- [self windowChangedToProfile:newProfile]; |
+ Browser* browser = chrome::FindBrowserWithWindow([notify object]); |
+ if (browser) |
+ [self windowChangedToProfile:browser->profile()->GetOriginalProfile()]; |
} |
- (void)windowDidResignMain:(NSNotification*)notify { |
@@ -952,9 +944,11 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver { |
lastProfile->GetOriginalProfile()); |
enable = signin->IsSigninAllowed() && |
![self keyWindowIsModal]; |
- [BrowserWindowController updateSigninItem:item |
Robert Sesek
2015/03/31 22:46:35
Could you move this method to AppController instea
Andre
2015/03/31 23:09:44
Done.
|
- shouldShow:enable |
- currentProfile:lastProfile]; |
+ base::string16 label = |
+ signin_ui_util::GetSigninMenuLabel(lastProfile); |
+ NSMenuItem* menuItem = static_cast<NSMenuItem*>(item); |
+ [menuItem setTitle:l10n_util::FixUpWindowsStyleLabel(label)]; |
+ [menuItem setHidden:!enable]; |
break; |
} |
#if defined(GOOGLE_CHROME_BUILD) |
@@ -1001,7 +995,7 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver { |
// and is getting here because the foreground window is not a browser window. |
if ([sender respondsToSelector:@selector(window)]) { |
id delegate = [[sender window] windowController]; |
- if ([delegate isKindOfClass:[BrowserWindowController class]]) { |
+ if ([delegate respondsToSelector:@selector(commandDispatch:)]) { |
[delegate commandDispatch:sender]; |
return; |
} |
@@ -1145,7 +1139,8 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver { |
DCHECK(sender); |
if ([sender respondsToSelector:@selector(window)]) { |
id delegate = [[sender window] windowController]; |
- if ([delegate isKindOfClass:[BrowserWindowController class]]) { |
+ if ([delegate respondsToSelector: |
+ @selector(commandDispatchUsingKeyModifiers:)]) { |
Robert Sesek
2015/03/31 22:46:35
nit: indent +4
Andre
2015/03/31 23:09:44
Done.
|
[delegate commandDispatchUsingKeyModifiers:sender]; |
} |
} |
@@ -1318,7 +1313,7 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver { |
} |
- (Profile*)lastProfile { |
- // Return the profile of the last-used BrowserWindowController, if available. |
+ // Return the profile of the last-used Browser, if available. |
if (lastProfile_) |
return lastProfile_; |