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

Side by Side Diff: chrome/browser/chromeos/profiles/profile_helper.cc

Issue 218903005: Make push messaging not create InvalidationService for login and guest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make code resilient against tests that do not create the Default profile first. Created 6 years, 8 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/chromeos/profiles/profile_helper.h" 5 #include "chrome/browser/chromeos/profiles/profile_helper.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/browsing_data/browsing_data_helper.h" 10 #include "chrome/browser/browsing_data/browsing_data_helper.h"
11 #include "chrome/browser/chromeos/login/oauth2_login_manager_factory.h" 11 #include "chrome/browser/chromeos/login/oauth2_login_manager_factory.h"
12 #include "chrome/browser/chromeos/login/user.h" 12 #include "chrome/browser/chromeos/login/user.h"
13 #include "chrome/browser/chromeos/login/user_manager.h" 13 #include "chrome/browser/chromeos/login/user_manager.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/profiles/profile_manager.h" 15 #include "chrome/browser/profiles/profile_manager.h"
16 #include "chrome/common/chrome_constants.h" 16 #include "chrome/common/chrome_constants.h"
17 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
18 #include "chromeos/chromeos_switches.h" 18 #include "chromeos/chromeos_switches.h"
19 19
20 namespace chromeos { 20 namespace chromeos {
21 21
22 namespace { 22 namespace {
23 23
24 base::FilePath GetSigninProfileDir() {
25 ProfileManager* profile_manager = g_browser_process->profile_manager();
26 base::FilePath user_data_dir = profile_manager->user_data_dir();
27 return user_data_dir.AppendASCII(chrome::kInitialProfile);
28 }
29
30 bool ShouldAddProfileDirPrefix(const std::string& user_id_hash) { 24 bool ShouldAddProfileDirPrefix(const std::string& user_id_hash) {
31 // Do not add profile dir prefix for legacy profile dir and test 25 // Do not add profile dir prefix for legacy profile dir and test
32 // user profile. The reason of not adding prefix for test user profile 26 // user profile. The reason of not adding prefix for test user profile
33 // is to keep the promise that TestingProfile::kTestUserProfileDir and 27 // is to keep the promise that TestingProfile::kTestUserProfileDir and
34 // chrome::kTestUserProfileDir are always in sync. Otherwise, 28 // chrome::kTestUserProfileDir are always in sync. Otherwise,
35 // TestingProfile::kTestUserProfileDir needs to be dynamically calculated 29 // TestingProfile::kTestUserProfileDir needs to be dynamically calculated
36 // based on whether multi profile is enabled or not. 30 // based on whether multi profile is enabled or not.
37 return user_id_hash != chrome::kLegacyProfileDir && 31 return user_id_hash != chrome::kLegacyProfileDir &&
38 user_id_hash != chrome::kTestUserProfileDir; 32 user_id_hash != chrome::kTestUserProfileDir;
39 } 33 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 66
73 // static 67 // static
74 base::FilePath ProfileHelper::GetProfileDirByLegacyLoginProfileSwitch() { 68 base::FilePath ProfileHelper::GetProfileDirByLegacyLoginProfileSwitch() {
75 const std::string login_profile_value = 69 const std::string login_profile_value =
76 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 70 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
77 chromeos::switches::kLoginProfile); 71 chromeos::switches::kLoginProfile);
78 return ProfileHelper::GetUserProfileDir(login_profile_value); 72 return ProfileHelper::GetUserProfileDir(login_profile_value);
79 } 73 }
80 74
81 // static 75 // static
76 base::FilePath ProfileHelper::GetSigninProfileDir() {
77 ProfileManager* profile_manager = g_browser_process->profile_manager();
78 base::FilePath user_data_dir = profile_manager->user_data_dir();
79 return user_data_dir.AppendASCII(chrome::kInitialProfile);
80 }
81
82 // static
82 Profile* ProfileHelper::GetSigninProfile() { 83 Profile* ProfileHelper::GetSigninProfile() {
83 ProfileManager* profile_manager = g_browser_process->profile_manager(); 84 ProfileManager* profile_manager = g_browser_process->profile_manager();
84 return profile_manager->GetProfile(GetSigninProfileDir())-> 85 return profile_manager->GetProfile(GetSigninProfileDir())->
85 GetOffTheRecordProfile(); 86 GetOffTheRecordProfile();
86 } 87 }
87 88
88 // static 89 // static
89 std::string ProfileHelper::GetUserIdHashFromProfile(Profile* profile) { 90 std::string ProfileHelper::GetUserIdHashFromProfile(Profile* profile) {
90 if (!profile) 91 if (!profile)
91 return std::string(); 92 return std::string();
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 //////////////////////////////////////////////////////////////////////////////// 212 ////////////////////////////////////////////////////////////////////////////////
212 // ProfileHelper, UserManager::UserSessionStateObserver implementation: 213 // ProfileHelper, UserManager::UserSessionStateObserver implementation:
213 214
214 void ProfileHelper::ActiveUserHashChanged(const std::string& hash) { 215 void ProfileHelper::ActiveUserHashChanged(const std::string& hash) {
215 active_user_id_hash_ = hash; 216 active_user_id_hash_ = hash;
216 base::FilePath profile_path = GetProfilePathByUserIdHash(hash); 217 base::FilePath profile_path = GetProfilePathByUserIdHash(hash);
217 VLOG(1) << "Switching to profile path: " << profile_path.value(); 218 VLOG(1) << "Switching to profile path: " << profile_path.value();
218 } 219 }
219 220
220 } // namespace chromeos 221 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/profiles/profile_helper.h ('k') | chrome/browser/chromeos/profiles/profile_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698