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

Unified Diff: chrome/browser/profiles/profile_impl.cc

Issue 14137032: Create profile .ico file on profile creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rework, set pref through callback Created 7 years, 7 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profiles/profile_impl.cc
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 6b8fa17a0ac89e8ed8edf00d2aaffffc06d552b9..4b1ef5b27d430dbd35a602e8c164a948ed120971 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -159,6 +159,10 @@ static const char kReadmeText[] =
const char* const kPrefExitTypeCrashed = "Crashed";
const char* const kPrefExitTypeSessionEnded = "SessionEnded";
+#if defined(OS_WIN)
+const int kCurrentProfileIconVersion = 1;
+#endif
+
// Helper method needed because PostTask cannot currently take a Callback
// function with non-void return type.
void CreateDirectoryAndSignal(const base::FilePath& path,
@@ -354,7 +358,8 @@ ProfileImpl::ProfileImpl(
last_session_exit_type_(EXIT_NORMAL),
start_time_(Time::Now()),
delegate_(delegate),
- predictor_(NULL) {
+ predictor_(NULL),
+ weak_ptr_factory_(this) {
DCHECK(!path.empty()) << "Using an empty path will attempt to write " <<
"profile files to the root directory!";
@@ -733,6 +738,20 @@ void ProfileImpl::OnPrefsLoaded(bool success) {
// Force this to true in case we fallback and use it.
// TODO(sky): remove this in a couple of releases (m28ish).
prefs_->SetBoolean(prefs::kSessionExitedCleanly, true);
+#if defined(OS_WIN)
+ if (prefs_->GetInteger(prefs::kProfileIconVersion) <
Alexei Svitkine (slow) 2013/06/05 14:06:03 I would prefer if you refactor this into a helper
calamity 2013/06/07 04:26:26 Done.
+ kCurrentProfileIconVersion) {
+ // Ensure the profile's icon file has been created.
+ ProfileShortcutManager* profile_shortcut_manager =
+ g_browser_process->profile_manager()->profile_shortcut_manager();
+ if (profile_shortcut_manager) {
+ profile_shortcut_manager->CreateProfileIcon(
+ GetPath(),
+ base::Bind(&ProfileImpl::OnProfileIconCreateSuccess,
+ weak_ptr_factory_.GetWeakPtr()));
+ }
+ }
+#endif
BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices(
this, false);
@@ -747,6 +766,10 @@ void ProfileImpl::OnPrefsLoaded(bool success) {
DoFinalInit();
}
+void ProfileImpl::OnProfileIconCreateSuccess() {
+ prefs_->SetInteger(prefs::kProfileIconVersion, kCurrentProfileIconVersion);
+}
+
bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) {
Version profile_version(ChromeVersionService::GetVersion(prefs_.get()));
Version arg_version(version);

Powered by Google App Engine
This is Rietveld 408576698