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

Side by Side Diff: chrome/browser/profile_impl.cc

Issue 5344003: Revert 67191 - chrome_paths: refactor and sanitize cache directory handling... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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 | « base/path_service_unittest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/profile_impl.h" 5 #include "chrome/browser/profile_impl.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/environment.h" 9 #include "base/environment.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 #include "chrome/browser/tabs/pinned_tab_service.h" 74 #include "chrome/browser/tabs/pinned_tab_service.h"
75 #include "chrome/browser/themes/browser_theme_provider.h" 75 #include "chrome/browser/themes/browser_theme_provider.h"
76 #include "chrome/browser/transport_security_persister.h" 76 #include "chrome/browser/transport_security_persister.h"
77 #include "chrome/browser/user_style_sheet_watcher.h" 77 #include "chrome/browser/user_style_sheet_watcher.h"
78 #include "chrome/browser/visitedlink_event_listener.h" 78 #include "chrome/browser/visitedlink_event_listener.h"
79 #include "chrome/browser/visitedlink_master.h" 79 #include "chrome/browser/visitedlink_master.h"
80 #include "chrome/browser/web_resource/web_resource_service.h" 80 #include "chrome/browser/web_resource/web_resource_service.h"
81 #include "chrome/browser/webdata/web_data_service.h" 81 #include "chrome/browser/webdata/web_data_service.h"
82 #include "chrome/common/chrome_constants.h" 82 #include "chrome/common/chrome_constants.h"
83 #include "chrome/common/chrome_paths.h" 83 #include "chrome/common/chrome_paths.h"
84 #include "chrome/common/chrome_paths_internal.h"
85 #include "chrome/common/chrome_switches.h" 84 #include "chrome/common/chrome_switches.h"
86 #include "chrome/common/json_pref_store.h" 85 #include "chrome/common/json_pref_store.h"
87 #include "chrome/common/notification_service.h" 86 #include "chrome/common/notification_service.h"
88 #include "chrome/common/pref_names.h" 87 #include "chrome/common/pref_names.h"
89 #include "chrome/common/render_messages.h" 88 #include "chrome/common/render_messages.h"
90 #include "grit/browser_resources.h" 89 #include "grit/browser_resources.h"
91 #include "grit/locale_settings.h" 90 #include "grit/locale_settings.h"
92 #include "net/base/transport_security_state.h" 91 #include "net/base/transport_security_state.h"
93 #include "webkit/database/database_tracker.h" 92 #include "webkit/database/database_tracker.h"
94 93
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 165 }
167 166
168 FilePath GetCachePath(const FilePath& base) { 167 FilePath GetCachePath(const FilePath& base) {
169 return base.Append(chrome::kCacheDirname); 168 return base.Append(chrome::kCacheDirname);
170 } 169 }
171 170
172 FilePath GetMediaCachePath(const FilePath& base) { 171 FilePath GetMediaCachePath(const FilePath& base) {
173 return base.Append(chrome::kMediaCacheDirname); 172 return base.Append(chrome::kMediaCacheDirname);
174 } 173 }
175 174
175 bool HasACacheSubdir(const FilePath &dir) {
176 return file_util::PathExists(GetCachePath(dir)) ||
177 file_util::PathExists(GetMediaCachePath(dir));
178 }
179
176 // Simple task to log the size of the current profile. 180 // Simple task to log the size of the current profile.
177 class ProfileSizeTask : public Task { 181 class ProfileSizeTask : public Task {
178 public: 182 public:
179 explicit ProfileSizeTask(const FilePath& path) : path_(path) {} 183 explicit ProfileSizeTask(const FilePath& path) : path_(path) {}
180 virtual ~ProfileSizeTask() {} 184 virtual ~ProfileSizeTask() {}
181 185
182 virtual void Run(); 186 virtual void Run();
183 private: 187 private:
184 FilePath path_; 188 FilePath path_;
185 }; 189 };
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 273
270 PrefService* prefs = GetPrefs(); 274 PrefService* prefs = GetPrefs();
271 pref_change_registrar_.Init(prefs); 275 pref_change_registrar_.Init(prefs);
272 pref_change_registrar_.Add(prefs::kSpellCheckDictionary, this); 276 pref_change_registrar_.Add(prefs::kSpellCheckDictionary, this);
273 pref_change_registrar_.Add(prefs::kEnableSpellCheck, this); 277 pref_change_registrar_.Add(prefs::kEnableSpellCheck, this);
274 pref_change_registrar_.Add(prefs::kEnableAutoSpellCorrect, this); 278 pref_change_registrar_.Add(prefs::kEnableAutoSpellCorrect, this);
275 279
276 // Convert active labs into switches. Modifies the current command line. 280 // Convert active labs into switches. Modifies the current command line.
277 about_flags::ConvertFlagsToSwitches(prefs, CommandLine::ForCurrentProcess()); 281 about_flags::ConvertFlagsToSwitches(prefs, CommandLine::ForCurrentProcess());
278 282
279 // It would be nice to use PathService for fetching this directory, but 283 #if defined(OS_MACOSX)
280 // the cache directory depends on the profile directory, which isn't available 284 // If the profile directory doesn't already have a cache directory and it
281 // to PathService. 285 // is under ~/Library/Application Support, use a suitable cache directory
282 chrome::GetUserCacheDirectory(path_, &base_cache_path_); 286 // under ~/Library/Caches. For example, a profile directory of
283 file_util::CreateDirectory(base_cache_path_); 287 // ~/Library/Application Support/Google/Chrome/MyProfileName that doesn't
288 // have a "Cache" or "MediaCache" subdirectory would use the cache directory
289 // ~/Library/Caches/Google/Chrome/MyProfileName.
290 //
291 // TODO(akalin): Come up with unit tests for this.
292 if (!HasACacheSubdir(path_)) {
293 FilePath app_data_path, user_cache_path;
294 if (PathService::Get(base::DIR_APP_DATA, &app_data_path) &&
295 PathService::Get(base::DIR_USER_CACHE, &user_cache_path) &&
296 app_data_path.AppendRelativePath(path_, &user_cache_path)) {
297 base_cache_path_ = user_cache_path;
298 }
299 }
300 #elif defined(OS_POSIX) // Posix minus Mac.
301 // See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
302 // for a spec on where cache files go. The net effect for most systems is we
303 // use ~/.cache/chromium/ for Chromium and ~/.cache/google-chrome/ for
304 // official builds.
305 // If we're using a different user-data-dir, though, fall through
306 // to the "normal" cache directory (a subdirectory of that).
307 // TODO(evan): all of this logic belongs in path_service; refactor and remove
308 // this IsOverriden business.
309 if (!PathService::IsOverridden(chrome::DIR_USER_DATA)) {
310 #if defined(GOOGLE_CHROME_BUILD)
311 const char kCacheDir[] = "google-chrome";
312 #else
313 const char kCacheDir[] = "chromium";
314 #endif
315 PathService::Get(base::DIR_USER_CACHE, &base_cache_path_);
316 base_cache_path_ = base_cache_path_.Append(kCacheDir);
317 if (!file_util::PathExists(base_cache_path_))
318 file_util::CreateDirectory(base_cache_path_);
319 }
320 #endif
321 if (base_cache_path_.empty())
322 base_cache_path_ = path_;
284 323
285 // Listen for theme installations from our original profile. 324 // Listen for theme installations from our original profile.
286 registrar_.Add(this, NotificationType::THEME_INSTALLED, 325 registrar_.Add(this, NotificationType::THEME_INSTALLED,
287 Source<Profile>(GetOriginalProfile())); 326 Source<Profile>(GetOriginalProfile()));
288 327
289 // Listen for bookmark model load, to bootstrap the sync service. 328 // Listen for bookmark model load, to bootstrap the sync service.
290 registrar_.Add(this, NotificationType::BOOKMARK_MODEL_LOADED, 329 registrar_.Add(this, NotificationType::BOOKMARK_MODEL_LOADED,
291 Source<Profile>(this)); 330 Source<Profile>(this));
292 331
293 ssl_config_service_manager_.reset( 332 ssl_config_service_manager_.reset(
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 #if defined(OS_CHROMEOS) 1350 #if defined(OS_CHROMEOS)
1312 chromeos::ProxyConfigServiceImpl* 1351 chromeos::ProxyConfigServiceImpl*
1313 ProfileImpl::GetChromeOSProxyConfigServiceImpl() { 1352 ProfileImpl::GetChromeOSProxyConfigServiceImpl() {
1314 if (!chromeos_proxy_config_service_impl_) { 1353 if (!chromeos_proxy_config_service_impl_) {
1315 chromeos_proxy_config_service_impl_ = 1354 chromeos_proxy_config_service_impl_ =
1316 new chromeos::ProxyConfigServiceImpl(); 1355 new chromeos::ProxyConfigServiceImpl();
1317 } 1356 }
1318 return chromeos_proxy_config_service_impl_; 1357 return chromeos_proxy_config_service_impl_;
1319 } 1358 }
1320 #endif // defined(OS_CHROMEOS) 1359 #endif // defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « base/path_service_unittest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698