Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <set> | 5 #include <set> |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile_manager.h" | 7 #include "chrome/browser/profiles/profile_manager.h" |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 if (!logged_in_) { | 197 if (!logged_in_) { |
| 198 Profile* profile; | 198 Profile* profile; |
| 199 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 199 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 200 | 200 |
| 201 // For cros, return the OTR profile so we never accidentally keep | 201 // For cros, return the OTR profile so we never accidentally keep |
| 202 // user data in an unencrypted profile. But doing this makes | 202 // user data in an unencrypted profile. But doing this makes |
| 203 // many of the browser and ui tests fail. We do return the OTR profile | 203 // many of the browser and ui tests fail. We do return the OTR profile |
| 204 // if the login-profile switch is passed so that we can test this. | 204 // if the login-profile switch is passed so that we can test this. |
| 205 // TODO(davemoore) Fix the tests so they allow OTR profiles. | 205 // TODO(davemoore) Fix the tests so they allow OTR profiles. |
| 206 if (!command_line.HasSwitch(switches::kTestType) || | 206 if (!command_line.HasSwitch(switches::kTestType) || |
| 207 command_line.HasSwitch(switches::kLoginProfile)) { | 207 command_line.HasSwitch(switches::kLoginProfile)) { |
|
Dmitry Polukhin
2011/08/12 08:04:31
There are 3 places with identical no trivial check
DaveMoore
2011/08/12 16:37:42
I combined two into a call, but one had some logic
| |
| 208 // Don't init extensions for this profile | 208 // Don't init extensions for this profile |
|
Dmitry Polukhin
2011/08/12 08:04:31
This comment has no sense here anymore. It should
DaveMoore
2011/08/12 16:37:42
Done.
| |
| 209 profile = GetProfile(default_profile_dir); | 209 profile = GetProfile(default_profile_dir); |
| 210 profile = profile->GetOffTheRecordProfile(); | 210 profile = profile->GetOffTheRecordProfile(); |
| 211 } else { | 211 } else { |
| 212 profile = GetProfile(default_profile_dir); | 212 profile = GetProfile(default_profile_dir); |
| 213 } | 213 } |
| 214 return profile; | 214 return profile; |
| 215 } | 215 } |
| 216 #endif | 216 #endif |
| 217 return GetProfile(default_profile_dir); | 217 return GetProfile(default_profile_dir); |
| 218 } | 218 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 // Make sure that we're not loading a profile with the same ID as a profile | 305 // Make sure that we're not loading a profile with the same ID as a profile |
| 306 // that's already loaded. | 306 // that's already loaded. |
| 307 if (GetProfileByPath(profile->GetPath())) { | 307 if (GetProfileByPath(profile->GetPath())) { |
| 308 NOTREACHED() << "Attempted to add profile with the same path (" << | 308 NOTREACHED() << "Attempted to add profile with the same path (" << |
| 309 profile->GetPath().value() << | 309 profile->GetPath().value() << |
| 310 ") as an already-loaded profile."; | 310 ") as an already-loaded profile."; |
| 311 return false; | 311 return false; |
| 312 } | 312 } |
| 313 | 313 |
| 314 RegisterProfile(profile, true); | 314 RegisterProfile(profile, true); |
| 315 DoFinalInit(profile, false); | 315 bool go_off_the_record = true; |
|
Denis Lagno
2011/08/12 06:50:02
if you want to restore the behaviour that existed
DaveMoore
2011/08/12 16:37:42
Done.
| |
| 316 #if defined(OS_CHROMEOS) | |
| 317 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 318 if (!logged_in_ && | |
| 319 (!command_line.HasSwitch(switches::kTestType) || | |
| 320 command_line.HasSwitch(switches::kLoginProfile))) { | |
|
Dmitry Polukhin
2011/08/12 08:04:31
#2
| |
| 321 go_off_the_record = true; | |
|
zel
2011/08/12 16:15:40
go_off_the_record is always true!?
DaveMoore
2011/08/12 16:37:42
Done.
| |
| 322 } | |
| 323 #endif | |
| 324 DoFinalInit(profile, go_off_the_record); | |
| 316 return true; | 325 return true; |
| 317 } | 326 } |
| 318 | 327 |
| 319 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile(Profile* profile, | 328 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile(Profile* profile, |
| 320 bool created) { | 329 bool created) { |
| 321 ProfileInfo* info = new ProfileInfo(profile, created); | 330 ProfileInfo* info = new ProfileInfo(profile, created); |
| 322 profiles_info_.insert(std::make_pair(profile->GetPath(), info)); | 331 profiles_info_.insert(std::make_pair(profile->GetPath(), info)); |
| 323 return info; | 332 return info; |
| 324 } | 333 } |
| 325 | 334 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 | 389 |
| 381 std::vector<ProfileManagerObserver*> observers; | 390 std::vector<ProfileManagerObserver*> observers; |
| 382 info->observers.swap(observers); | 391 info->observers.swap(observers); |
| 383 | 392 |
| 384 bool go_off_the_record = false; | 393 bool go_off_the_record = false; |
| 385 if (success) { | 394 if (success) { |
| 386 #if defined(OS_CHROMEOS) | 395 #if defined(OS_CHROMEOS) |
| 387 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 396 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 388 if (!logged_in_ && | 397 if (!logged_in_ && |
| 389 (!command_line.HasSwitch(switches::kTestType) || | 398 (!command_line.HasSwitch(switches::kTestType) || |
| 390 command_line.HasSwitch(switches::kLoginProfile))) { | 399 command_line.HasSwitch(switches::kLoginProfile))) { |
|
Dmitry Polukhin
2011/08/12 08:04:31
#3
| |
| 391 go_off_the_record = true; | 400 go_off_the_record = true; |
| 392 } | 401 } |
| 393 #endif | 402 #endif |
| 394 if (!go_off_the_record) { | 403 if (!go_off_the_record) { |
| 395 for (size_t i = 0; i < observers.size(); ++i) { | 404 for (size_t i = 0; i < observers.size(); ++i) { |
| 396 observers[i]->OnProfileCreated( | 405 observers[i]->OnProfileCreated( |
| 397 profile, ProfileManagerObserver::STATUS_CREATED); | 406 profile, ProfileManagerObserver::STATUS_CREATED); |
| 398 } | 407 } |
| 399 } | 408 } |
| 400 DoFinalInit(profile, go_off_the_record); | 409 DoFinalInit(profile, go_off_the_record); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 560 cache.DeleteProfileFromCache(profile_dir); | 569 cache.DeleteProfileFromCache(profile_dir); |
| 561 } | 570 } |
| 562 | 571 |
| 563 // static | 572 // static |
| 564 bool ProfileManager::IsMultipleProfilesEnabled() { | 573 bool ProfileManager::IsMultipleProfilesEnabled() { |
| 565 #if defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS) | 574 #if defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS) |
| 566 return true; | 575 return true; |
| 567 #endif | 576 #endif |
| 568 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles); | 577 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles); |
| 569 } | 578 } |
| OLD | NEW |