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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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" |
84 #include "chrome/common/chrome_switches.h" | 85 #include "chrome/common/chrome_switches.h" |
85 #include "chrome/common/json_pref_store.h" | 86 #include "chrome/common/json_pref_store.h" |
86 #include "chrome/common/notification_service.h" | 87 #include "chrome/common/notification_service.h" |
87 #include "chrome/common/pref_names.h" | 88 #include "chrome/common/pref_names.h" |
88 #include "chrome/common/render_messages.h" | 89 #include "chrome/common/render_messages.h" |
89 #include "grit/browser_resources.h" | 90 #include "grit/browser_resources.h" |
90 #include "grit/locale_settings.h" | 91 #include "grit/locale_settings.h" |
91 #include "net/base/transport_security_state.h" | 92 #include "net/base/transport_security_state.h" |
92 #include "webkit/database/database_tracker.h" | 93 #include "webkit/database/database_tracker.h" |
93 | 94 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } | 166 } |
166 | 167 |
167 FilePath GetCachePath(const FilePath& base) { | 168 FilePath GetCachePath(const FilePath& base) { |
168 return base.Append(chrome::kCacheDirname); | 169 return base.Append(chrome::kCacheDirname); |
169 } | 170 } |
170 | 171 |
171 FilePath GetMediaCachePath(const FilePath& base) { | 172 FilePath GetMediaCachePath(const FilePath& base) { |
172 return base.Append(chrome::kMediaCacheDirname); | 173 return base.Append(chrome::kMediaCacheDirname); |
173 } | 174 } |
174 | 175 |
175 bool HasACacheSubdir(const FilePath &dir) { | |
176 return file_util::PathExists(GetCachePath(dir)) || | |
177 file_util::PathExists(GetMediaCachePath(dir)); | |
178 } | |
179 | |
180 // Simple task to log the size of the current profile. | 176 // Simple task to log the size of the current profile. |
181 class ProfileSizeTask : public Task { | 177 class ProfileSizeTask : public Task { |
182 public: | 178 public: |
183 explicit ProfileSizeTask(const FilePath& path) : path_(path) {} | 179 explicit ProfileSizeTask(const FilePath& path) : path_(path) {} |
184 virtual ~ProfileSizeTask() {} | 180 virtual ~ProfileSizeTask() {} |
185 | 181 |
186 virtual void Run(); | 182 virtual void Run(); |
187 private: | 183 private: |
188 FilePath path_; | 184 FilePath path_; |
189 }; | 185 }; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 269 |
274 PrefService* prefs = GetPrefs(); | 270 PrefService* prefs = GetPrefs(); |
275 pref_change_registrar_.Init(prefs); | 271 pref_change_registrar_.Init(prefs); |
276 pref_change_registrar_.Add(prefs::kSpellCheckDictionary, this); | 272 pref_change_registrar_.Add(prefs::kSpellCheckDictionary, this); |
277 pref_change_registrar_.Add(prefs::kEnableSpellCheck, this); | 273 pref_change_registrar_.Add(prefs::kEnableSpellCheck, this); |
278 pref_change_registrar_.Add(prefs::kEnableAutoSpellCorrect, this); | 274 pref_change_registrar_.Add(prefs::kEnableAutoSpellCorrect, this); |
279 | 275 |
280 // Convert active labs into switches. Modifies the current command line. | 276 // Convert active labs into switches. Modifies the current command line. |
281 about_flags::ConvertFlagsToSwitches(prefs, CommandLine::ForCurrentProcess()); | 277 about_flags::ConvertFlagsToSwitches(prefs, CommandLine::ForCurrentProcess()); |
282 | 278 |
283 #if defined(OS_MACOSX) | 279 // It would be nice to use PathService for fetching this directory, but |
284 // If the profile directory doesn't already have a cache directory and it | 280 // the cache directory depends on the profile directory, which isn't available |
285 // is under ~/Library/Application Support, use a suitable cache directory | 281 // to PathService. |
286 // under ~/Library/Caches. For example, a profile directory of | 282 chrome::GetUserCacheDirectory(path_, &base_cache_path_); |
287 // ~/Library/Application Support/Google/Chrome/MyProfileName that doesn't | 283 file_util::CreateDirectory(base_cache_path_); |
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_; | |
323 | 284 |
324 // Listen for theme installations from our original profile. | 285 // Listen for theme installations from our original profile. |
325 registrar_.Add(this, NotificationType::THEME_INSTALLED, | 286 registrar_.Add(this, NotificationType::THEME_INSTALLED, |
326 Source<Profile>(GetOriginalProfile())); | 287 Source<Profile>(GetOriginalProfile())); |
327 | 288 |
328 // Listen for bookmark model load, to bootstrap the sync service. | 289 // Listen for bookmark model load, to bootstrap the sync service. |
329 registrar_.Add(this, NotificationType::BOOKMARK_MODEL_LOADED, | 290 registrar_.Add(this, NotificationType::BOOKMARK_MODEL_LOADED, |
330 Source<Profile>(this)); | 291 Source<Profile>(this)); |
331 | 292 |
332 ssl_config_service_manager_.reset( | 293 ssl_config_service_manager_.reset( |
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1350 #if defined(OS_CHROMEOS) | 1311 #if defined(OS_CHROMEOS) |
1351 chromeos::ProxyConfigServiceImpl* | 1312 chromeos::ProxyConfigServiceImpl* |
1352 ProfileImpl::GetChromeOSProxyConfigServiceImpl() { | 1313 ProfileImpl::GetChromeOSProxyConfigServiceImpl() { |
1353 if (!chromeos_proxy_config_service_impl_) { | 1314 if (!chromeos_proxy_config_service_impl_) { |
1354 chromeos_proxy_config_service_impl_ = | 1315 chromeos_proxy_config_service_impl_ = |
1355 new chromeos::ProxyConfigServiceImpl(); | 1316 new chromeos::ProxyConfigServiceImpl(); |
1356 } | 1317 } |
1357 return chromeos_proxy_config_service_impl_; | 1318 return chromeos_proxy_config_service_impl_; |
1358 } | 1319 } |
1359 #endif // defined(OS_CHROMEOS) | 1320 #endif // defined(OS_CHROMEOS) |
OLD | NEW |