summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorstevet@chromium.org <stevet@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 17:23:10 +0000
committerstevet@chromium.org <stevet@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 17:23:10 +0000
commit3ad9f6efd5e32fe5b465eb839b9669c60dd3865e (patch)
treec875b0427052207de9f948c8b9e04f54a521ac65 /chrome
parente2ad553f4153c58c61cbbc7336240df20ed480cf (diff)
downloadchromium_src-3ad9f6efd5e32fe5b465eb839b9669c60dd3865e.zip
chromium_src-3ad9f6efd5e32fe5b465eb839b9669c60dd3865e.tar.gz
chromium_src-3ad9f6efd5e32fe5b465eb839b9669c60dd3865e.tar.bz2
Add a startup check to create profile shortcuts for legacy Chrome profiles.
We do this by adding a per-profile pref that tracks whether or not a shortcut has been created for it. We check that flag at Profile startup and create a new shortcut if needed (while setting the flag to avoid creating future shortcuts). BUG=109447 TEST=Start Chrome in v16 or v17 and create a new profile. Update Chrome to the latest version (including this patch) and ensure that starting a window with one of the two original profiles creates a desktop shortcut with that Profile's data. Ensure that if we then delete the shortcut for the profile, but start a new window for the profile, another shortcut is not created. Review URL: http://codereview.chromium.org/9253016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118316 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/profiles/profile_impl.cc5
-rw-r--r--chrome/browser/profiles/profile_manager.cc22
-rw-r--r--chrome/browser/profiles/profile_manager.h6
-rw-r--r--chrome/browser/profiles/profile_shortcut_manager_win.cc6
-rw-r--r--chrome/browser/profiles/profile_shortcut_manager_win.h7
-rw-r--r--chrome/common/pref_names.cc4
-rw-r--r--chrome/common/pref_names.h1
7 files changed, 48 insertions, 3 deletions
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 323afcd..0a17b3f 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -227,6 +227,9 @@ void ProfileImpl::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterBooleanPref(prefs::kClearSiteDataOnExit,
false,
PrefService::SYNCABLE_PREF);
+ prefs->RegisterBooleanPref(prefs::kProfileShortcutCreated,
+ false,
+ PrefService::UNSYNCABLE_PREF);
prefs->RegisterIntegerPref(prefs::kProfileAvatarIndex,
-1,
PrefService::SYNCABLE_PREF);
@@ -327,7 +330,7 @@ void ProfileImpl::DoFinalInit() {
base::Bind(&CreateDirectoryNoResult, base_cache_path_));
}
- // Now that the profile is hooked up to recieve pref change notifications to
+ // Now that the profile is hooked up to receive pref change notifications to
// kGoogleServicesUsername, initialize components that depend on it to reflect
// the current value.
UpdateProfileUserNameCache();
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index 7c7879e..034c306 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -551,6 +551,9 @@ void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) {
InitProfileUserPrefs(profile);
AddProfileToCache(profile);
DoFinalInitLogging(profile);
+#if defined(OS_WIN)
+ CreateDesktopShortcut(profile);
+#endif
}
void ProfileManager::DoFinalInitForServices(Profile* profile,
@@ -714,6 +717,25 @@ void ProfileManager::AddProfileToCache(Profile* profile) {
icon_index);
}
+#if defined(OS_WIN)
+void ProfileManager::CreateDesktopShortcut(Profile* profile) {
+ // Some distributions can not create desktop shortcuts, in which case
+ // profile_shortcut_manager_ will not be set.
+ if (!profile_shortcut_manager_.get())
+ return;
+
+ bool shortcut_created =
+ profile->GetPrefs()->GetBoolean(prefs::kProfileShortcutCreated);
+ if (!shortcut_created && GetNumberOfProfiles() > 1) {
+ profile_shortcut_manager_->AddProfileShortcut(profile->GetPath());
+
+ // We only ever create the shortcut for a profile once, so set a pref
+ // reminding us to skip this in the future.
+ profile->GetPrefs()->SetBoolean(prefs::kProfileShortcutCreated, true);
+ }
+}
+#endif
+
void ProfileManager::InitProfileUserPrefs(Profile* profile) {
ProfileInfoCache& cache = GetProfileInfoCache();
diff --git a/chrome/browser/profiles/profile_manager.h b/chrome/browser/profiles/profile_manager.h
index 84a9bcc..6fb574d 100644
--- a/chrome/browser/profiles/profile_manager.h
+++ b/chrome/browser/profiles/profile_manager.h
@@ -252,6 +252,12 @@ class ProfileManager : public base::NonThreadSafe,
// Adds |profile| to the profile info cache if it hasn't been added yet.
void AddProfileToCache(Profile* profile);
+#if defined(OS_WIN)
+ // Creates a profile desktop shortcut for |profile| if we are in multi
+ // profile mode and the shortcut has not been created before.
+ void CreateDesktopShortcut(Profile* profile);
+#endif
+
// Initializes user prefs of |profile|. This includes profile name and
// avatar values
void InitProfileUserPrefs(Profile* profile);
diff --git a/chrome/browser/profiles/profile_shortcut_manager_win.cc b/chrome/browser/profiles/profile_shortcut_manager_win.cc
index 7228e37..fe8d2ed 100644
--- a/chrome/browser/profiles/profile_shortcut_manager_win.cc
+++ b/chrome/browser/profiles/profile_shortcut_manager_win.cc
@@ -213,7 +213,7 @@ ProfileShortcutManagerWin::ProfileShortcutManagerWin() {
ProfileShortcutManagerWin::~ProfileShortcutManagerWin() {
}
-void ProfileShortcutManagerWin::OnProfileAdded(
+void ProfileShortcutManagerWin::AddProfileShortcut(
const FilePath& profile_path) {
ProfileInfoCache& cache =
g_browser_process->profile_manager()->GetProfileInfoCache();
@@ -286,6 +286,10 @@ void ProfileShortcutManagerWin::OnProfileAdded(
}
}
+void ProfileShortcutManagerWin::OnProfileAdded(
+ const FilePath& profile_path) {
+}
+
void ProfileShortcutManagerWin::OnProfileWillBeRemoved(
const FilePath& profile_path) {
ProfileInfoCache& cache =
diff --git a/chrome/browser/profiles/profile_shortcut_manager_win.h b/chrome/browser/profiles/profile_shortcut_manager_win.h
index 2435e565..8725dfd 100644
--- a/chrome/browser/profiles/profile_shortcut_manager_win.h
+++ b/chrome/browser/profiles/profile_shortcut_manager_win.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -18,6 +18,11 @@ class ProfileShortcutManagerWin : public ProfileInfoCacheObserver {
ProfileShortcutManagerWin();
virtual ~ProfileShortcutManagerWin();
+ // Create a profile shortcut for the profile with path |profile_path|, plus
+ // update the original profile shortcut if |profile_path| is the second
+ // profile created.
+ virtual void AddProfileShortcut(const FilePath& profile_path);
+
// ProfileInfoCacheObserver:
virtual void OnProfileAdded(const FilePath& profile_path) OVERRIDE;
virtual void OnProfileWillBeRemoved(
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 274d17c..5327c70 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -818,6 +818,10 @@ const char kDefaultZoomLevel[] = "profile.default_zoom_level";
// be displayed at the default zoom level.
const char kPerHostZoomLevels[] = "profile.per_host_zoom_levels";
+// Boolean that specifies whether or not a shortcut has been created for this
+// profile in multi-profiles mode.
+const char kProfileShortcutCreated[] = "profile.shortcut_created";
+
// Boolean that is true if Autofill is enabled and allowed to save profile data.
const char kAutofillEnabled[] = "autofill.enabled";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 38616e6..8076ba6 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -295,6 +295,7 @@ extern const char kBlockThirdPartyCookies[];
extern const char kClearSiteDataOnExit[];
extern const char kDefaultZoomLevel[];
extern const char kPerHostZoomLevels[];
+extern const char kProfileShortcutCreated[];
extern const char kAutofillEnabled[];
extern const char kAutofillAuxiliaryProfilesEnabled[];
extern const char kAutofillPositiveUploadRate[];