| 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 #include "chrome/browser/profiles/profile_manager.h" | 5 #include "chrome/browser/profiles/profile_manager.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 158 |
| 159 // Count number of extensions in this profile, if we know. | 159 // Count number of extensions in this profile, if we know. |
| 160 if (extension_count != -1) | 160 if (extension_count != -1) |
| 161 UMA_HISTOGRAM_COUNTS_10000("Profile.AppCount", extension_count); | 161 UMA_HISTOGRAM_COUNTS_10000("Profile.AppCount", extension_count); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void QueueProfileDirectoryForDeletion(const base::FilePath& path) { | 164 void QueueProfileDirectoryForDeletion(const base::FilePath& path) { |
| 165 ProfilesToDelete().push_back(path); | 165 ProfilesToDelete().push_back(path); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void OpenBrowserWindowForProfile(bool always_create, |
| 169 chrome::HostDesktopType desktop_type, |
| 170 Profile* profile, |
| 171 Profile::CreateStatus status) { |
| 172 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 173 |
| 174 if (status == Profile::CREATE_STATUS_INITIALIZED) { |
| 175 ProfileManager::FindOrCreateNewWindowForProfile( |
| 176 profile, |
| 177 chrome::startup::IS_NOT_PROCESS_STARTUP, |
| 178 chrome::startup::IS_NOT_FIRST_RUN, |
| 179 desktop_type, |
| 180 always_create); |
| 181 } |
| 182 } |
| 183 |
| 168 #if defined(OS_CHROMEOS) | 184 #if defined(OS_CHROMEOS) |
| 169 void CheckCryptohomeIsMounted(chromeos::DBusMethodCallStatus call_status, | 185 void CheckCryptohomeIsMounted(chromeos::DBusMethodCallStatus call_status, |
| 170 bool is_mounted) { | 186 bool is_mounted) { |
| 171 if (call_status != chromeos::DBUS_METHOD_CALL_SUCCESS) { | 187 if (call_status != chromeos::DBUS_METHOD_CALL_SUCCESS) { |
| 172 LOG(ERROR) << "IsMounted call failed."; | 188 LOG(ERROR) << "IsMounted call failed."; |
| 173 return; | 189 return; |
| 174 } | 190 } |
| 175 if (!is_mounted) | 191 if (!is_mounted) |
| 176 LOG(ERROR) << "Cryptohome is not mounted."; | 192 LOG(ERROR) << "Cryptohome is not mounted."; |
| 177 } | 193 } |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 | 637 |
| 622 content::RecordAction(UserMetricsAction("NewWindow")); | 638 content::RecordAction(UserMetricsAction("NewWindow")); |
| 623 CommandLine command_line(CommandLine::NO_PROGRAM); | 639 CommandLine command_line(CommandLine::NO_PROGRAM); |
| 624 int return_code; | 640 int return_code; |
| 625 StartupBrowserCreator browser_creator; | 641 StartupBrowserCreator browser_creator; |
| 626 browser_creator.LaunchBrowser(command_line, profile, base::FilePath(), | 642 browser_creator.LaunchBrowser(command_line, profile, base::FilePath(), |
| 627 process_startup, is_first_run, &return_code); | 643 process_startup, is_first_run, &return_code); |
| 628 #endif // defined(OS_IOS) | 644 #endif // defined(OS_IOS) |
| 629 } | 645 } |
| 630 | 646 |
| 647 // static |
| 648 void ProfileManager::SwitchToProfile( |
| 649 const base::FilePath& path, |
| 650 chrome::HostDesktopType desktop_type, |
| 651 bool always_create) { |
| 652 g_browser_process->profile_manager()->CreateProfileAsync( |
| 653 path, |
| 654 base::Bind(&OpenBrowserWindowForProfile, |
| 655 always_create, |
| 656 desktop_type), |
| 657 string16(), |
| 658 string16(), |
| 659 false); |
| 660 } |
| 661 |
| 631 void ProfileManager::Observe( | 662 void ProfileManager::Observe( |
| 632 int type, | 663 int type, |
| 633 const content::NotificationSource& source, | 664 const content::NotificationSource& source, |
| 634 const content::NotificationDetails& details) { | 665 const content::NotificationDetails& details) { |
| 635 #if defined(OS_CHROMEOS) | 666 #if defined(OS_CHROMEOS) |
| 636 if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) { | 667 if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) { |
| 637 logged_in_ = true; | 668 logged_in_ = true; |
| 638 | 669 |
| 639 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 670 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 640 if (!command_line.HasSwitch(switches::kTestType)) { | 671 if (!command_line.HasSwitch(switches::kTestType)) { |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 ProfileManager::ProfileInfo::ProfileInfo( | 1189 ProfileManager::ProfileInfo::ProfileInfo( |
| 1159 Profile* profile, | 1190 Profile* profile, |
| 1160 bool created) | 1191 bool created) |
| 1161 : profile(profile), | 1192 : profile(profile), |
| 1162 created(created) { | 1193 created(created) { |
| 1163 } | 1194 } |
| 1164 | 1195 |
| 1165 ProfileManager::ProfileInfo::~ProfileInfo() { | 1196 ProfileManager::ProfileInfo::~ProfileInfo() { |
| 1166 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); | 1197 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); |
| 1167 } | 1198 } |
| OLD | NEW |