| OLD | NEW | 
|     1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |     1 // Copyright (c) 2012 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/profiles/profile_impl.h" |     5 #include "chrome/browser/profiles/profile_impl.h" | 
|     6  |     6  | 
|     7 #include "base/bind.h" |     7 #include "base/bind.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/compiler_specific.h" |    10 #include "base/compiler_specific.h" | 
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   152 // not in resources. |   152 // not in resources. | 
|   153 static const char kReadmeText[] = |   153 static const char kReadmeText[] = | 
|   154     "%s settings and storage represent user-selected preferences and " |   154     "%s settings and storage represent user-selected preferences and " | 
|   155     "information and MUST not be extracted, overwritten or modified except " |   155     "information and MUST not be extracted, overwritten or modified except " | 
|   156     "through %s defined APIs."; |   156     "through %s defined APIs."; | 
|   157  |   157  | 
|   158 // Value written to prefs for EXIT_CRASHED and EXIT_SESSION_ENDED. |   158 // Value written to prefs for EXIT_CRASHED and EXIT_SESSION_ENDED. | 
|   159 const char* const kPrefExitTypeCrashed = "Crashed"; |   159 const char* const kPrefExitTypeCrashed = "Crashed"; | 
|   160 const char* const kPrefExitTypeSessionEnded = "SessionEnded"; |   160 const char* const kPrefExitTypeSessionEnded = "SessionEnded"; | 
|   161  |   161  | 
 |   162 #if defined(OS_WIN) | 
 |   163 const int kCurrentProfileIconVersion = 1; | 
 |   164 #endif | 
 |   165  | 
|   162 // Helper method needed because PostTask cannot currently take a Callback |   166 // Helper method needed because PostTask cannot currently take a Callback | 
|   163 // function with non-void return type. |   167 // function with non-void return type. | 
|   164 void CreateDirectoryAndSignal(const base::FilePath& path, |   168 void CreateDirectoryAndSignal(const base::FilePath& path, | 
|   165                               base::WaitableEvent* done_creating) { |   169                               base::WaitableEvent* done_creating) { | 
|   166   DVLOG(1) << "Creating directory " << path.value(); |   170   DVLOG(1) << "Creating directory " << path.value(); | 
|   167   file_util::CreateDirectory(path); |   171   file_util::CreateDirectory(path); | 
|   168   done_creating->Signal(); |   172   done_creating->Signal(); | 
|   169 } |   173 } | 
|   170  |   174  | 
|   171 // Task that blocks the FILE thread until CreateDirectoryAndSignal() finishes on |   175 // Task that blocks the FILE thread until CreateDirectoryAndSignal() finishes on | 
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   726           EXIT_NORMAL : EXIT_CRASHED; |   730           EXIT_NORMAL : EXIT_CRASHED; | 
|   727   } else { |   731   } else { | 
|   728     last_session_exit_type_ = |   732     last_session_exit_type_ = | 
|   729         SessionTypePrefValueToExitType(exit_type_pref_value); |   733         SessionTypePrefValueToExitType(exit_type_pref_value); | 
|   730   } |   734   } | 
|   731   // Mark the session as open. |   735   // Mark the session as open. | 
|   732   prefs_->SetString(prefs::kSessionExitType, kPrefExitTypeCrashed); |   736   prefs_->SetString(prefs::kSessionExitType, kPrefExitTypeCrashed); | 
|   733   // Force this to true in case we fallback and use it. |   737   // Force this to true in case we fallback and use it. | 
|   734   // TODO(sky): remove this in a couple of releases (m28ish). |   738   // TODO(sky): remove this in a couple of releases (m28ish). | 
|   735   prefs_->SetBoolean(prefs::kSessionExitedCleanly, true); |   739   prefs_->SetBoolean(prefs::kSessionExitedCleanly, true); | 
 |   740 #if defined(OS_WIN) | 
 |   741   if (prefs_->GetInteger(prefs::kProfileIconVersion) < | 
 |   742       kCurrentProfileIconVersion) { | 
 |   743     // Ensure the profile's icon file has been created. | 
 |   744     ProfileShortcutManager* profile_shortcut_manager = | 
 |   745         g_browser_process->profile_manager()->profile_shortcut_manager(); | 
 |   746     if (profile_shortcut_manager) { | 
 |   747       profile_shortcut_manager->CreateProfileIcon(GetPath()); | 
 |   748       prefs_->SetInteger(prefs::kProfileIconVersion, | 
 |   749                          kCurrentProfileIconVersion); | 
 |   750     } | 
 |   751   } | 
 |   752 #endif | 
|   736  |   753  | 
|   737   BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices( |   754   BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices( | 
|   738       this, false); |   755       this, false); | 
|   739  |   756  | 
|   740   DCHECK(!net_pref_observer_); |   757   DCHECK(!net_pref_observer_); | 
|   741   net_pref_observer_.reset(new NetPrefObserver( |   758   net_pref_observer_.reset(new NetPrefObserver( | 
|   742       prefs_.get(), |   759       prefs_.get(), | 
|   743       prerender::PrerenderManagerFactory::GetForProfile(this), |   760       prerender::PrerenderManagerFactory::GetForProfile(this), | 
|   744       predictor_)); |   761       predictor_)); | 
|   745  |   762  | 
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1137                                      base::FilePath* cache_path, |  1154                                      base::FilePath* cache_path, | 
|  1138                                      int* max_size) { |  1155                                      int* max_size) { | 
|  1139   DCHECK(cache_path); |  1156   DCHECK(cache_path); | 
|  1140   DCHECK(max_size); |  1157   DCHECK(max_size); | 
|  1141   base::FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); |  1158   base::FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); | 
|  1142   if (!path.empty()) |  1159   if (!path.empty()) | 
|  1143     *cache_path = path; |  1160     *cache_path = path; | 
|  1144   *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |  1161   *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 
|  1145                                  prefs_->GetInteger(prefs::kDiskCacheSize); |  1162                                  prefs_->GetInteger(prefs::kDiskCacheSize); | 
|  1146 } |  1163 } | 
| OLD | NEW |