Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 #include "chrome/browser/tabs/pinned_tab_service.h" | 71 #include "chrome/browser/tabs/pinned_tab_service.h" |
| 72 #include "chrome/browser/themes/browser_theme_provider.h" | 72 #include "chrome/browser/themes/browser_theme_provider.h" |
| 73 #include "chrome/browser/transport_security_persister.h" | 73 #include "chrome/browser/transport_security_persister.h" |
| 74 #include "chrome/browser/user_style_sheet_watcher.h" | 74 #include "chrome/browser/user_style_sheet_watcher.h" |
| 75 #include "chrome/browser/visitedlink_event_listener.h" | 75 #include "chrome/browser/visitedlink_event_listener.h" |
| 76 #include "chrome/browser/visitedlink_master.h" | 76 #include "chrome/browser/visitedlink_master.h" |
| 77 #include "chrome/browser/web_resource/web_resource_service.h" | 77 #include "chrome/browser/web_resource/web_resource_service.h" |
| 78 #include "chrome/browser/webdata/web_data_service.h" | 78 #include "chrome/browser/webdata/web_data_service.h" |
| 79 #include "chrome/common/chrome_constants.h" | 79 #include "chrome/common/chrome_constants.h" |
| 80 #include "chrome/common/chrome_paths.h" | 80 #include "chrome/common/chrome_paths.h" |
| 81 #include "chrome/common/chrome_paths_internal.h" | |
| 81 #include "chrome/common/chrome_switches.h" | 82 #include "chrome/common/chrome_switches.h" |
| 82 #include "chrome/common/json_pref_store.h" | 83 #include "chrome/common/json_pref_store.h" |
| 83 #include "chrome/common/notification_service.h" | 84 #include "chrome/common/notification_service.h" |
| 84 #include "chrome/common/pref_names.h" | 85 #include "chrome/common/pref_names.h" |
| 85 #include "chrome/common/render_messages.h" | 86 #include "chrome/common/render_messages.h" |
| 86 #include "grit/browser_resources.h" | 87 #include "grit/browser_resources.h" |
| 87 #include "grit/locale_settings.h" | 88 #include "grit/locale_settings.h" |
| 88 #include "net/base/transport_security_state.h" | 89 #include "net/base/transport_security_state.h" |
| 89 #include "webkit/database/database_tracker.h" | 90 #include "webkit/database/database_tracker.h" |
| 90 | 91 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 } | 163 } |
| 163 | 164 |
| 164 FilePath GetCachePath(const FilePath& base) { | 165 FilePath GetCachePath(const FilePath& base) { |
| 165 return base.Append(chrome::kCacheDirname); | 166 return base.Append(chrome::kCacheDirname); |
| 166 } | 167 } |
| 167 | 168 |
| 168 FilePath GetMediaCachePath(const FilePath& base) { | 169 FilePath GetMediaCachePath(const FilePath& base) { |
| 169 return base.Append(chrome::kMediaCacheDirname); | 170 return base.Append(chrome::kMediaCacheDirname); |
| 170 } | 171 } |
| 171 | 172 |
| 172 bool HasACacheSubdir(const FilePath &dir) { | |
| 173 return file_util::PathExists(GetCachePath(dir)) || | |
| 174 file_util::PathExists(GetMediaCachePath(dir)); | |
| 175 } | |
| 176 | |
| 177 // Simple task to log the size of the current profile. | 173 // Simple task to log the size of the current profile. |
| 178 class ProfileSizeTask : public Task { | 174 class ProfileSizeTask : public Task { |
| 179 public: | 175 public: |
| 180 explicit ProfileSizeTask(const FilePath& path) : path_(path) {} | 176 explicit ProfileSizeTask(const FilePath& path) : path_(path) {} |
| 181 virtual ~ProfileSizeTask() {} | 177 virtual ~ProfileSizeTask() {} |
| 182 | 178 |
| 183 virtual void Run(); | 179 virtual void Run(); |
| 184 private: | 180 private: |
| 185 FilePath path_; | 181 FilePath path_; |
| 186 }; | 182 }; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 | 266 |
| 271 PrefService* prefs = GetPrefs(); | 267 PrefService* prefs = GetPrefs(); |
| 272 pref_change_registrar_.Init(prefs); | 268 pref_change_registrar_.Init(prefs); |
| 273 pref_change_registrar_.Add(prefs::kSpellCheckDictionary, this); | 269 pref_change_registrar_.Add(prefs::kSpellCheckDictionary, this); |
| 274 pref_change_registrar_.Add(prefs::kEnableSpellCheck, this); | 270 pref_change_registrar_.Add(prefs::kEnableSpellCheck, this); |
| 275 pref_change_registrar_.Add(prefs::kEnableAutoSpellCorrect, this); | 271 pref_change_registrar_.Add(prefs::kEnableAutoSpellCorrect, this); |
| 276 | 272 |
| 277 // Convert active labs into switches. Modifies the current command line. | 273 // Convert active labs into switches. Modifies the current command line. |
| 278 about_flags::ConvertFlagsToSwitches(prefs, CommandLine::ForCurrentProcess()); | 274 about_flags::ConvertFlagsToSwitches(prefs, CommandLine::ForCurrentProcess()); |
| 279 | 275 |
| 280 #if defined(OS_MACOSX) | 276 // It would be nice to use PathService for fetching this directory, but |
| 281 // If the profile directory doesn't already have a cache directory and it | 277 // the cache directory depends on the profile directory, which isn't available |
| 282 // is under ~/Library/Application Support, use a suitable cache directory | 278 // to PathService. |
| 283 // under ~/Library/Caches. For example, a profile directory of | 279 if (!chrome::GetUserCacheDirectory(path_, &base_cache_path_)) |
|
akalin
2010/11/22 23:22:44
All implementations of GetUserCacheDirectory() alr
| |
| 284 // ~/Library/Application Support/Google/Chrome/MyProfileName that doesn't | |
| 285 // have a "Cache" or "MediaCache" subdirectory would use the cache directory | |
| 286 // ~/Library/Caches/Google/Chrome/MyProfileName. | |
| 287 // | |
| 288 // TODO(akalin): Come up with unit tests for this. | |
| 289 if (!HasACacheSubdir(path_)) { | |
| 290 FilePath app_data_path, user_cache_path; | |
| 291 if (PathService::Get(base::DIR_APP_DATA, &app_data_path) && | |
| 292 PathService::Get(base::DIR_USER_CACHE, &user_cache_path) && | |
| 293 app_data_path.AppendRelativePath(path_, &user_cache_path)) { | |
| 294 base_cache_path_ = user_cache_path; | |
| 295 } | |
| 296 } | |
| 297 #elif defined(OS_POSIX) // Posix minus Mac. | |
| 298 // See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html | |
| 299 // for a spec on where cache files go. The net effect for most systems is we | |
| 300 // use ~/.cache/chromium/ for Chromium and ~/.cache/google-chrome/ for | |
| 301 // official builds. | |
| 302 // If we're using a different user-data-dir, though, fall through | |
| 303 // to the "normal" cache directory (a subdirectory of that). | |
| 304 // TODO(evan): all of this logic belongs in path_service; refactor and remove | |
| 305 // this IsOverriden business. | |
| 306 if (!PathService::IsOverridden(chrome::DIR_USER_DATA)) { | |
| 307 #if defined(GOOGLE_CHROME_BUILD) | |
| 308 const char kCacheDir[] = "google-chrome"; | |
| 309 #else | |
| 310 const char kCacheDir[] = "chromium"; | |
| 311 #endif | |
| 312 PathService::Get(base::DIR_USER_CACHE, &base_cache_path_); | |
| 313 base_cache_path_ = base_cache_path_.Append(kCacheDir); | |
| 314 if (!file_util::PathExists(base_cache_path_)) | |
| 315 file_util::CreateDirectory(base_cache_path_); | |
| 316 } | |
| 317 #endif | |
| 318 if (base_cache_path_.empty()) | |
| 319 base_cache_path_ = path_; | 280 base_cache_path_ = path_; |
| 281 file_util::CreateDirectory(base_cache_path_); | |
| 320 | 282 |
| 321 // Listen for theme installations from our original profile. | 283 // Listen for theme installations from our original profile. |
| 322 registrar_.Add(this, NotificationType::THEME_INSTALLED, | 284 registrar_.Add(this, NotificationType::THEME_INSTALLED, |
| 323 Source<Profile>(GetOriginalProfile())); | 285 Source<Profile>(GetOriginalProfile())); |
| 324 | 286 |
| 325 // Listen for bookmark model load, to bootstrap the sync service. | 287 // Listen for bookmark model load, to bootstrap the sync service. |
| 326 registrar_.Add(this, NotificationType::BOOKMARK_MODEL_LOADED, | 288 registrar_.Add(this, NotificationType::BOOKMARK_MODEL_LOADED, |
| 327 Source<Profile>(this)); | 289 Source<Profile>(this)); |
| 328 | 290 |
| 329 ssl_config_service_manager_.reset( | 291 ssl_config_service_manager_.reset( |
| (...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1336 #if defined(OS_CHROMEOS) | 1298 #if defined(OS_CHROMEOS) |
| 1337 chromeos::ProxyConfigServiceImpl* | 1299 chromeos::ProxyConfigServiceImpl* |
| 1338 ProfileImpl::GetChromeOSProxyConfigServiceImpl() { | 1300 ProfileImpl::GetChromeOSProxyConfigServiceImpl() { |
| 1339 if (!chromeos_proxy_config_service_impl_) { | 1301 if (!chromeos_proxy_config_service_impl_) { |
| 1340 chromeos_proxy_config_service_impl_ = | 1302 chromeos_proxy_config_service_impl_ = |
| 1341 new chromeos::ProxyConfigServiceImpl(); | 1303 new chromeos::ProxyConfigServiceImpl(); |
| 1342 } | 1304 } |
| 1343 return chromeos_proxy_config_service_impl_; | 1305 return chromeos_proxy_config_service_impl_; |
| 1344 } | 1306 } |
| 1345 #endif // defined(OS_CHROMEOS) | 1307 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |