OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/app_controller_mac.h" | 5 #import "chrome/browser/app_controller_mac.h" |
6 | 6 |
7 #include "apps/app_shim/app_shim_mac.h" | 7 #include "apps/app_shim/app_shim_mac.h" |
8 #include "apps/app_shim/extension_app_shim_handler_mac.h" | 8 #include "apps/app_shim/extension_app_shim_handler_mac.h" |
9 #include "apps/shell_window_registry.h" | 9 #include "apps/shell_window_registry.h" |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 // window remain. It seems that the new key window for the app is not set | 554 // window remain. It seems that the new key window for the app is not set |
555 // until after this notification is fired, so a check is performed after the | 555 // until after this notification is fired, so a check is performed after the |
556 // run loop is allowed to spin. | 556 // run loop is allowed to spin. |
557 [self performSelector:@selector(checkForAnyKeyWindows) | 557 [self performSelector:@selector(checkForAnyKeyWindows) |
558 withObject:nil | 558 withObject:nil |
559 afterDelay:0.0]; | 559 afterDelay:0.0]; |
560 } | 560 } |
561 | 561 |
562 // If the window changed to a new BrowserWindowController, update the profile. | 562 // If the window changed to a new BrowserWindowController, update the profile. |
563 id windowController = [[notify object] windowController]; | 563 id windowController = [[notify object] windowController]; |
564 if ([notify name] == NSWindowDidBecomeMainNotification && | 564 if (![windowController isKindOfClass:[BrowserWindowController class]]) |
565 [windowController isKindOfClass:[BrowserWindowController class]]) { | 565 return; |
| 566 |
| 567 if ([notify name] == NSWindowDidBecomeMainNotification) { |
566 // If the profile is incognito, use the original profile. | 568 // If the profile is incognito, use the original profile. |
567 Profile* newProfile = [windowController profile]->GetOriginalProfile(); | 569 Profile* newProfile = [windowController profile]->GetOriginalProfile(); |
568 [self windowChangedToProfile:newProfile]; | 570 [self windowChangedToProfile:newProfile]; |
569 } else if (chrome::GetTotalBrowserCount() == 0) { | 571 } else if (chrome::GetTotalBrowserCount() == 0) { |
570 [self windowChangedToProfile: | 572 [self windowChangedToProfile: |
571 g_browser_process->profile_manager()->GetLastUsedProfile()]; | 573 g_browser_process->profile_manager()->GetLastUsedProfile()]; |
572 } | 574 } |
573 } | 575 } |
574 | 576 |
575 - (void)activeSpaceDidChange:(NSNotification*)notify { | 577 - (void)activeSpaceDidChange:(NSNotification*)notify { |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 // handles requests from services. | 1253 // handles requests from services. |
1252 NSArray* types = [NSArray arrayWithObjects:NSStringPboardType, nil]; | 1254 NSArray* types = [NSArray arrayWithObjects:NSStringPboardType, nil]; |
1253 [app registerServicesMenuSendTypes:types returnTypes:types]; | 1255 [app registerServicesMenuSendTypes:types returnTypes:types]; |
1254 } | 1256 } |
1255 | 1257 |
1256 - (Profile*)lastProfile { | 1258 - (Profile*)lastProfile { |
1257 // Return the profile of the last-used BrowserWindowController, if available. | 1259 // Return the profile of the last-used BrowserWindowController, if available. |
1258 if (lastProfile_) | 1260 if (lastProfile_) |
1259 return lastProfile_; | 1261 return lastProfile_; |
1260 | 1262 |
1261 // On first launch, no profile will be stored, so use last from Local State. | 1263 // On first launch, use the logic that ChromeBrowserMain uses to determine |
1262 if (g_browser_process->profile_manager()) | 1264 // the initial profile. |
1263 return g_browser_process->profile_manager()->GetLastUsedProfile(); | 1265 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 1266 if (!profile_manager) |
| 1267 return NULL; |
1264 | 1268 |
1265 return NULL; | 1269 return profile_manager->GetProfile(GetStartupProfilePath( |
| 1270 profile_manager->user_data_dir(), |
| 1271 *CommandLine::ForCurrentProcess())); |
1266 } | 1272 } |
1267 | 1273 |
1268 // Various methods to open URLs that we get in a native fashion. We use | 1274 // Various methods to open URLs that we get in a native fashion. We use |
1269 // StartupBrowserCreator here because on the other platforms, URLs to open come | 1275 // StartupBrowserCreator here because on the other platforms, URLs to open come |
1270 // through the ProcessSingleton, and it calls StartupBrowserCreator. It's best | 1276 // through the ProcessSingleton, and it calls StartupBrowserCreator. It's best |
1271 // to bottleneck the openings through that for uniform handling. | 1277 // to bottleneck the openings through that for uniform handling. |
1272 | 1278 |
1273 - (void)openUrls:(const std::vector<GURL>&)urls { | 1279 - (void)openUrls:(const std::vector<GURL>&)urls { |
1274 // If the browser hasn't started yet, just queue up the URLs. | 1280 // If the browser hasn't started yet, just queue up the URLs. |
1275 if (!startupComplete_) { | 1281 if (!startupComplete_) { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1483 | 1489 |
1484 //--------------------------------------------------------------------------- | 1490 //--------------------------------------------------------------------------- |
1485 | 1491 |
1486 namespace app_controller_mac { | 1492 namespace app_controller_mac { |
1487 | 1493 |
1488 bool IsOpeningNewWindow() { | 1494 bool IsOpeningNewWindow() { |
1489 return g_is_opening_new_window; | 1495 return g_is_opening_new_window; |
1490 } | 1496 } |
1491 | 1497 |
1492 } // namespace app_controller_mac | 1498 } // namespace app_controller_mac |
OLD | NEW |