OLD | NEW |
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/barrier_closure.h" | 7 #include "base/barrier_closure.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/strings/string_util.h" | |
11 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 11 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
13 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 12 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
14 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 13 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
15 #include "chrome/browser/chromeos/base/file_flusher.h" | 14 #include "chrome/browser/chromeos/base/file_flusher.h" |
16 #include "chrome/browser/chromeos/login/helper.h" | 15 #include "chrome/browser/chromeos/login/helper.h" |
17 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" | 16 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" |
18 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 17 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
19 #include "chrome/browser/download/download_prefs.h" | 18 #include "chrome/browser/download/download_prefs.h" |
20 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 return std::string(); | 131 return std::string(); |
133 | 132 |
134 std::string profile_dir = profile->GetPath().BaseName().value(); | 133 std::string profile_dir = profile->GetPath().BaseName().value(); |
135 | 134 |
136 // Don't strip prefix if the dir is not supposed to be prefixed. | 135 // Don't strip prefix if the dir is not supposed to be prefixed. |
137 if (!ShouldAddProfileDirPrefix(profile_dir)) | 136 if (!ShouldAddProfileDirPrefix(profile_dir)) |
138 return profile_dir; | 137 return profile_dir; |
139 | 138 |
140 // Check that profile directory starts with the correct prefix. | 139 // Check that profile directory starts with the correct prefix. |
141 std::string prefix(chrome::kProfileDirPrefix); | 140 std::string prefix(chrome::kProfileDirPrefix); |
142 if (!base::StartsWith(profile_dir, prefix, base::CompareCase::SENSITIVE)) { | 141 if (profile_dir.find(prefix) != 0) { |
143 // This happens when creating a TestingProfile in browser tests. | 142 // This happens when creating a TestingProfile in browser tests. |
144 return std::string(); | 143 return std::string(); |
145 } | 144 } |
146 | 145 |
147 return profile_dir.substr(prefix.length()); | 146 return profile_dir.substr(prefix.length(), |
| 147 profile_dir.length() - prefix.length()); |
148 } | 148 } |
149 | 149 |
150 // static | 150 // static |
151 base::FilePath ProfileHelper::GetUserProfileDir( | 151 base::FilePath ProfileHelper::GetUserProfileDir( |
152 const std::string& user_id_hash) { | 152 const std::string& user_id_hash) { |
153 CHECK(!user_id_hash.empty()); | 153 CHECK(!user_id_hash.empty()); |
154 return ShouldAddProfileDirPrefix(user_id_hash) | 154 return ShouldAddProfileDirPrefix(user_id_hash) |
155 ? base::FilePath(chrome::kProfileDirPrefix + user_id_hash) | 155 ? base::FilePath(chrome::kProfileDirPrefix + user_id_hash) |
156 : base::FilePath(user_id_hash); | 156 : base::FilePath(user_id_hash); |
157 } | 157 } |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 DownloadPrefs::FromBrowserContext(profile)->DownloadPath()); | 490 DownloadPrefs::FromBrowserContext(profile)->DownloadPath()); |
491 // Let extension system handle extension files. | 491 // Let extension system handle extension files. |
492 excludes.push_back(base::FilePath(extensions::kInstallDirectoryName)); | 492 excludes.push_back(base::FilePath(extensions::kInstallDirectoryName)); |
493 // Do not flush Drive cache. | 493 // Do not flush Drive cache. |
494 excludes.push_back(base::FilePath(chromeos::kDriveCacheDirname)); | 494 excludes.push_back(base::FilePath(chromeos::kDriveCacheDirname)); |
495 | 495 |
496 profile_flusher_->RequestFlush(profile->GetPath(), excludes, base::Closure()); | 496 profile_flusher_->RequestFlush(profile->GetPath(), excludes, base::Closure()); |
497 } | 497 } |
498 | 498 |
499 } // namespace chromeos | 499 } // namespace chromeos |
OLD | NEW |