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

Side by Side Diff: chrome/browser/profiles/profile_manager.cc

Issue 7630002: Fix regression where component extensions were being loaded for login profile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added myself as OWNER Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/profiles/profile_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // path->name mappings here, if the user syncs a local account to a 188 // path->name mappings here, if the user syncs a local account to a
189 // different Google account. 189 // different Google account.
190 path_map->SetString(dir_base, profile_name); 190 path_map->SetString(dir_base, profile_name);
191 } 191 }
192 192
193 Profile* ProfileManager::GetDefaultProfile(const FilePath& user_data_dir) { 193 Profile* ProfileManager::GetDefaultProfile(const FilePath& user_data_dir) {
194 FilePath default_profile_dir(user_data_dir); 194 FilePath default_profile_dir(user_data_dir);
195 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir()); 195 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir());
196 #if defined(OS_CHROMEOS) 196 #if defined(OS_CHROMEOS)
197 if (!logged_in_) { 197 if (!logged_in_) {
198 Profile* profile; 198 Profile* profile = GetProfile(default_profile_dir);
199 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
200
201 // For cros, return the OTR profile so we never accidentally keep 199 // For cros, return the OTR profile so we never accidentally keep
202 // user data in an unencrypted profile. But doing this makes 200 // 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 201 // 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. 202 // if the login-profile switch is passed so that we can test this.
205 // TODO(davemoore) Fix the tests so they allow OTR profiles. 203 // TODO(davemoore) Fix the tests so they allow OTR profiles.
206 if (!command_line.HasSwitch(switches::kTestType) || 204 if (ShouldGoOffTheRecord())
207 command_line.HasSwitch(switches::kLoginProfile)) { 205 return profile->GetOffTheRecordProfile();
208 // Don't init extensions for this profile
209 profile = GetProfile(default_profile_dir);
210 profile = profile->GetOffTheRecordProfile();
211 } else {
212 profile = GetProfile(default_profile_dir);
213 }
214 return profile; 206 return profile;
215 } 207 }
216 #endif 208 #endif
217 return GetProfile(default_profile_dir); 209 return GetProfile(default_profile_dir);
218 } 210 }
219 211
220 bool ProfileManager::IsValidProfile(Profile* profile) { 212 bool ProfileManager::IsValidProfile(Profile* profile) {
221 for (ProfilesInfoMap::iterator iter = profiles_info_.begin(); 213 for (ProfilesInfoMap::iterator iter = profiles_info_.begin();
222 iter != profiles_info_.end(); ++iter) { 214 iter != profiles_info_.end(); ++iter) {
223 if (iter->second->created) { 215 if (iter->second->created) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 // Make sure that we're not loading a profile with the same ID as a profile 297 // Make sure that we're not loading a profile with the same ID as a profile
306 // that's already loaded. 298 // that's already loaded.
307 if (GetProfileByPath(profile->GetPath())) { 299 if (GetProfileByPath(profile->GetPath())) {
308 NOTREACHED() << "Attempted to add profile with the same path (" << 300 NOTREACHED() << "Attempted to add profile with the same path (" <<
309 profile->GetPath().value() << 301 profile->GetPath().value() <<
310 ") as an already-loaded profile."; 302 ") as an already-loaded profile.";
311 return false; 303 return false;
312 } 304 }
313 305
314 RegisterProfile(profile, true); 306 RegisterProfile(profile, true);
315 DoFinalInit(profile, false); 307 DoFinalInit(profile, ShouldGoOffTheRecord());
316 return true; 308 return true;
317 } 309 }
318 310
319 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile(Profile* profile, 311 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile(Profile* profile,
320 bool created) { 312 bool created) {
321 ProfileInfo* info = new ProfileInfo(profile, created); 313 ProfileInfo* info = new ProfileInfo(profile, created);
322 profiles_info_.insert(std::make_pair(profile->GetPath(), info)); 314 profiles_info_.insert(std::make_pair(profile->GetPath(), info));
323 return info; 315 return info;
324 } 316 }
325 317
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 void ProfileManager::OnProfileCreated(Profile* profile, bool success) { 366 void ProfileManager::OnProfileCreated(Profile* profile, bool success) {
375 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 367 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
376 368
377 ProfilesInfoMap::iterator iter = profiles_info_.find(profile->GetPath()); 369 ProfilesInfoMap::iterator iter = profiles_info_.find(profile->GetPath());
378 DCHECK(iter != profiles_info_.end()); 370 DCHECK(iter != profiles_info_.end());
379 ProfileInfo* info = iter->second.get(); 371 ProfileInfo* info = iter->second.get();
380 372
381 std::vector<ProfileManagerObserver*> observers; 373 std::vector<ProfileManagerObserver*> observers;
382 info->observers.swap(observers); 374 info->observers.swap(observers);
383 375
384 bool go_off_the_record = false; 376 bool go_off_the_record = ShouldGoOffTheRecord();
385 if (success) { 377 if (success) {
386 #if defined(OS_CHROMEOS)
387 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
388 if (!logged_in_ &&
389 (!command_line.HasSwitch(switches::kTestType) ||
390 command_line.HasSwitch(switches::kLoginProfile))) {
391 go_off_the_record = true;
392 }
393 #endif
394 if (!go_off_the_record) { 378 if (!go_off_the_record) {
395 for (size_t i = 0; i < observers.size(); ++i) { 379 for (size_t i = 0; i < observers.size(); ++i) {
396 observers[i]->OnProfileCreated( 380 observers[i]->OnProfileCreated(
397 profile, ProfileManagerObserver::STATUS_CREATED); 381 profile, ProfileManagerObserver::STATUS_CREATED);
398 } 382 }
399 } 383 }
400 DoFinalInit(profile, go_off_the_record); 384 DoFinalInit(profile, go_off_the_record);
401 info->created = true; 385 info->created = true;
402 } else { 386 } else {
403 profile = NULL; 387 profile = NULL;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 profile->GetPath(), 526 profile->GetPath(),
543 l10n_util::GetStringUTF16(IDS_DEFAULT_PROFILE_NAME), 0); 527 l10n_util::GetStringUTF16(IDS_DEFAULT_PROFILE_NAME), 0);
544 } else { 528 } else {
545 cache.AddProfileToCache( 529 cache.AddProfileToCache(
546 profile->GetPath(), 530 profile->GetPath(),
547 cache.ChooseNameForNewProfile(), 531 cache.ChooseNameForNewProfile(),
548 cache.ChooseAvatarIconIndexForNewProfile()); 532 cache.ChooseAvatarIconIndexForNewProfile());
549 } 533 }
550 } 534 }
551 535
536 bool ProfileManager::ShouldGoOffTheRecord() {
537 bool go_off_the_record = false;
538 #if defined(OS_CHROMEOS)
539 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
540 if (!logged_in_ &&
541 (!command_line.HasSwitch(switches::kTestType) ||
542 command_line.HasSwitch(switches::kLoginProfile))) {
543 go_off_the_record = true;
544 }
545 #endif
546 return go_off_the_record;
547 }
548
552 void ProfileManager::ScheduleProfileForDeletion(const FilePath& profile_dir) { 549 void ProfileManager::ScheduleProfileForDeletion(const FilePath& profile_dir) {
553 // TODO(sail): Due to bug 88586 we don't delete the profile instance. Once we 550 // TODO(sail): Due to bug 88586 we don't delete the profile instance. Once we
554 // start deleting the profile instance we need to close background apps too. 551 // start deleting the profile instance we need to close background apps too.
555 Profile* profile = GetProfileByPath(profile_dir); 552 Profile* profile = GetProfileByPath(profile_dir);
556 if (profile) 553 if (profile)
557 BrowserList::CloseAllBrowsersWithProfile(profile); 554 BrowserList::CloseAllBrowsersWithProfile(profile);
558 profiles_to_delete_.push_back(profile_dir); 555 profiles_to_delete_.push_back(profile_dir);
559 ProfileInfoCache& cache = GetProfileInfoCache(); 556 ProfileInfoCache& cache = GetProfileInfoCache();
560 cache.DeleteProfileFromCache(profile_dir); 557 cache.DeleteProfileFromCache(profile_dir);
561 } 558 }
562 559
563 // static 560 // static
564 bool ProfileManager::IsMultipleProfilesEnabled() { 561 bool ProfileManager::IsMultipleProfilesEnabled() {
565 #if defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS) 562 #if defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS)
566 return true; 563 return true;
567 #endif 564 #endif
568 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles); 565 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles);
569 } 566 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698