Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2217)

Unified Diff: chrome/browser/app_controller_mac.mm

Issue 127343004: Avoid loading the last used browser profile in app_controller_mac when it's not needed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: need FPL Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/app_controller_mac.mm
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index 79b2d8902c673089474f0415415b087702024cd8..101b8a7f739463882a8c1aee745d342fb5991a6e 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -561,8 +561,10 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver {
// If the window changed to a new BrowserWindowController, update the profile.
id windowController = [[notify object] windowController];
- if ([notify name] == NSWindowDidBecomeMainNotification &&
- [windowController isKindOfClass:[BrowserWindowController class]]) {
+ if (![windowController isKindOfClass:[BrowserWindowController class]])
+ return;
+
+ if ([notify name] == NSWindowDidBecomeMainNotification) {
// If the profile is incognito, use the original profile.
Profile* newProfile = [windowController profile]->GetOriginalProfile();
[self windowChangedToProfile:newProfile];
@@ -1258,11 +1260,15 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver {
if (lastProfile_)
return lastProfile_;
- // On first launch, no profile will be stored, so use last from Local State.
- if (g_browser_process->profile_manager())
- return g_browser_process->profile_manager()->GetLastUsedProfile();
+ // On first launch, use the logic that ChromeBrowserMain uses to determine
+ // the initial profile.
+ ProfileManager* profile_manager = g_browser_process->profile_manager();
+ if (!profile_manager)
+ return NULL;
- return NULL;
+ return profile_manager->GetProfile(GetStartupProfilePath(
+ profile_manager->user_data_dir(),
+ *CommandLine::ForCurrentProcess()));
}
// Various methods to open URLs that we get in a native fashion. We use

Powered by Google App Engine
This is Rietveld 408576698