summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 10:23:23 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 10:23:23 +0000
commit85b48b0e6879d7bddb5a6befc77c7d7c9e08607b (patch)
tree4195e7025dc59769788b49743892f7bf72e15571 /chrome
parent0a08d2d9dd69eced7294885d01ddea42dfad6293 (diff)
downloadchromium_src-85b48b0e6879d7bddb5a6befc77c7d7c9e08607b.zip
chromium_src-85b48b0e6879d7bddb5a6befc77c7d7c9e08607b.tar.gz
chromium_src-85b48b0e6879d7bddb5a6befc77c7d7c9e08607b.tar.bz2
Revert 121860 (linker error) - Make the auto-launch experiment profile-aware.
When writing to the registry key, append a hash of the profile directory path, so as to not clobber settings between profiles and add the --profile-directory=foo component to the directory as well. BUG=112118 TEST=Test this as you would test the autolaunch experiment normally (see original autolaunch bug), but make sure to test it with multiple profiles and side-by-side installations. Note: Only the Default profile gets to set this value at present time. Review URL: https://chromiumcodereview.appspot.com/9317002 TBR=finnur@chromium.org Review URL: https://chromiumcodereview.appspot.com/9361057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121864 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/profiles/profile_shortcut_manager_win.cc14
-rw-r--r--chrome/browser/resources/options2/browser_options.html6
-rw-r--r--chrome/browser/resources/options2/browser_options.js21
-rw-r--r--chrome/browser/ui/browser_init.cc25
-rw-r--r--chrome/browser/ui/webui/options/browser_options_handler.cc35
-rw-r--r--chrome/browser/ui/webui/options/browser_options_handler.h7
-rw-r--r--chrome/browser/ui/webui/options2/browser_options_handler2.cc33
-rw-r--r--chrome/browser/ui/webui/options2/browser_options_handler2.h5
-rw-r--r--chrome/installer/setup/install.cc7
-rw-r--r--chrome/installer/setup/uninstall.cc10
-rw-r--r--chrome/installer/util/auto_launch_util.cc72
-rw-r--r--chrome/installer/util/auto_launch_util.h19
12 files changed, 45 insertions, 209 deletions
diff --git a/chrome/browser/profiles/profile_shortcut_manager_win.cc b/chrome/browser/profiles/profile_shortcut_manager_win.cc
index 5177c56..9d83ed4 100644
--- a/chrome/browser/profiles/profile_shortcut_manager_win.cc
+++ b/chrome/browser/profiles/profile_shortcut_manager_win.cc
@@ -19,7 +19,6 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
-#include "chrome/installer/util/auto_launch_util.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/shell_util.h"
#include "content/public/browser/browser_thread.h"
@@ -206,15 +205,6 @@ void UpdateChromeDesktopShortcutForProfile(
false);
}
-void DeleteAutoLaunchValueForProfile(
- const FilePath& profile_path) {
- if (auto_launch_util::WillLaunchAtLogin(FilePath(),
- profile_path.BaseName().value())) {
- auto_launch_util::SetWillLaunchAtLogin(
- false, FilePath(), profile_path.BaseName().value());
- }
-}
-
} // namespace
ProfileShortcutManagerWin::ProfileShortcutManagerWin() {
@@ -325,10 +315,6 @@ void ProfileShortcutManagerWin::OnProfileWillBeRemoved(
void ProfileShortcutManagerWin::OnProfileWasRemoved(
const FilePath& profile_path,
const string16& profile_name) {
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- base::Bind(&DeleteAutoLaunchValueForProfile, profile_path));
-
// If there is one profile left, we want to remove the badge and name from it.
ProfileInfoCache& cache =
g_browser_process->profile_manager()->GetProfileInfoCache();
diff --git a/chrome/browser/resources/options2/browser_options.html b/chrome/browser/resources/options2/browser_options.html
index e9fb1b6..1994039 100644
--- a/chrome/browser/resources/options2/browser_options.html
+++ b/chrome/browser/resources/options2/browser_options.html
@@ -261,12 +261,6 @@
</button>
<div id="default-browser-state" i18n-content="defaultBrowserUnknown">
</div>
- <div id="auto-launch-option" class="checkbox" hidden>
- <label id="auto-launch-label">
- <input id="auto-launch" type="checkbox">
- <span i18n-content="autoLaunchText"></span>
- </label>
- </div>
</div>
</section>
</if>
diff --git a/chrome/browser/resources/options2/browser_options.js b/chrome/browser/resources/options2/browser_options.js
index a05748f..9d32241 100644
--- a/chrome/browser/resources/options2/browser_options.js
+++ b/chrome/browser/resources/options2/browser_options.js
@@ -218,8 +218,6 @@ cr.define('options', function() {
$('set-as-default-browser').onclick = function(event) {
chrome.send('becomeDefaultBrowser');
};
-
- $('auto-launch').onclick = this.handleAutoLaunchChanged_;
}
// Under the hood section.
@@ -343,16 +341,6 @@ cr.define('options', function() {
},
/**
- * Shows the autoLaunch preference and initializes its checkbox value.
- * @param {bool} enabled Whether autolaunch is enabled or or not.
- * @private
- */
- updateAutoLaunchState_: function(enabled) {
- $('auto-launch-option').hidden = false;
- $('auto-launch').checked = enabled;
- },
-
- /**
* Called when the value of the instant.confirm_dialog_shown preference
* changes. Cache this value.
* @param {Event} event Change event.
@@ -495,14 +483,6 @@ cr.define('options', function() {
},
/**
- * Sets or clear whether Chrome should Auto-launch on computer startup.
- * @private
- */
- handleAutoLaunchChanged_: function() {
- chrome.send('toggleAutoLaunch', [$('auto-launch').checked]);
- },
-
- /**
* Sends an asynchronous request for new autocompletion suggestions for the
* the given query. When new suggestions are available, the C++ handler will
* call updateAutocompleteSuggestions_.
@@ -633,7 +613,6 @@ cr.define('options', function() {
'setThemesResetButtonEnabled',
'updateAccountPicture',
'updateAutocompleteSuggestions',
- 'updateAutoLaunchState',
'updateHomePageLabel',
'updateSearchEngines',
'updateSyncState',
diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc
index e291215..335d301 100644
--- a/chrome/browser/ui/browser_init.cc
+++ b/chrome/browser/ui/browser_init.cc
@@ -143,8 +143,7 @@ static const int kMaxInfobarShown = 5;
class AutolaunchInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
AutolaunchInfoBarDelegate(InfoBarTabHelper* infobar_helper,
- PrefService* prefs,
- Profile* profile);
+ PrefService* prefs);
virtual ~AutolaunchInfoBarDelegate();
private:
@@ -168,9 +167,6 @@ class AutolaunchInfoBarDelegate : public ConfirmInfoBarDelegate {
// Whether the info-bar should be dismissed on the next navigation.
bool should_expire_;
- // Weak pointer to the profile, not owned by us.
- Profile* profile_;
-
// Used to delay the expiration of the info-bar.
base::WeakPtrFactory<AutolaunchInfoBarDelegate> weak_factory_;
@@ -179,13 +175,11 @@ class AutolaunchInfoBarDelegate : public ConfirmInfoBarDelegate {
AutolaunchInfoBarDelegate::AutolaunchInfoBarDelegate(
InfoBarTabHelper* infobar_helper,
- PrefService* prefs,
- Profile* profile)
+ PrefService* prefs)
: ConfirmInfoBarDelegate(infobar_helper),
prefs_(prefs),
action_taken_(false),
should_expire_(false),
- profile_(profile),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
auto_launch_trial::UpdateInfobarShownMetric();
@@ -248,9 +242,7 @@ bool AutolaunchInfoBarDelegate::Cancel() {
content::BrowserThread::PostTask(
content::BrowserThread::FILE, FROM_HERE,
base::Bind(&auto_launch_util::SetWillLaunchAtLogin,
- auto_launch,
- FilePath(),
- profile_->GetPath().BaseName().value()));
+ auto_launch, FilePath()));
return true;
}
@@ -373,7 +365,7 @@ void CheckAutoLaunchCallback() {
infobar_helper->AddInfoBar(
new AutolaunchInfoBarDelegate(infobar_helper,
- tab->profile()->GetPrefs(), tab->profile()));
+ tab->profile()->GetPrefs()));
}
#endif
@@ -1487,21 +1479,12 @@ bool BrowserInit::LaunchWithProfile::CheckIfAutoLaunched(Profile* profile) {
if (!auto_launch_trial::IsInAutoLaunchGroup())
return false;
- // Only supported on the main profile for now.
- if (profile->GetPath().BaseName().value() !=
- ASCIIToUTF16(chrome::kInitialProfile)) {
- return false;
- }
-
int infobar_shown =
profile->GetPrefs()->GetInteger(prefs::kShownAutoLaunchInfobar);
if (infobar_shown >= kMaxInfobarShown)
return false;
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- if (command_line.HasSwitch(switches::kChromeFrame))
- return false;
-
if (command_line.HasSwitch(switches::kAutoLaunchAtStartup) ||
first_run::IsChromeFirstRun()) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc
index 91c6f55..dfebc3c 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.cc
+++ b/chrome/browser/ui/webui/options/browser_options_handler.cc
@@ -7,7 +7,6 @@
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "base/command_line.h"
#include "base/memory/singleton.h"
#include "base/path_service.h"
#include "base/string_number_conversions.h"
@@ -29,9 +28,7 @@
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/webui/favicon_source.h"
-#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_notification_types.h"
-#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
@@ -173,38 +170,26 @@ void BrowserOptionsHandler::Initialize() {
autocomplete_controller_.reset(new AutocompleteController(profile, this));
#if defined(OS_WIN)
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- if (!command_line.HasSwitch(switches::kChromeFrame) &&
- !command_line.HasSwitch(switches::kUserDataDir)) {
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- base::Bind(&BrowserOptionsHandler::CheckAutoLaunch,
- weak_ptr_factory_for_ui_.GetWeakPtr(),
- weak_ptr_factory_for_file_.GetWeakPtr(),
- profile->GetPath()));
- weak_ptr_factory_for_ui_.DetachFromThread();
- }
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
+ base::Bind(&BrowserOptionsHandler::CheckAutoLaunch,
+ weak_ptr_factory_for_ui_.GetWeakPtr(),
+ weak_ptr_factory_for_file_.GetWeakPtr()));
+ weak_ptr_factory_for_ui_.DetachFromThread();
#endif
}
void BrowserOptionsHandler::CheckAutoLaunch(
- base::WeakPtr<BrowserOptionsHandler> weak_this,
- const FilePath& profile_path) {
+ base::WeakPtr<BrowserOptionsHandler> weak_this) {
#if defined(OS_WIN)
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- // Auto-launch is not supported for secondary profiles yet.
- if (profile_path.BaseName().value() != ASCIIToUTF16(chrome::kInitialProfile))
- return;
-
// Pass in weak pointer to this to avoid race if BrowserOptionsHandler is
// deleted.
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&BrowserOptionsHandler::CheckAutoLaunchCallback,
weak_this,
auto_launch_trial::IsInAutoLaunchGroup(),
- auto_launch_util::WillLaunchAtLogin(
- FilePath(),
- profile_path.BaseName().value())));
+ auto_launch_util::WillLaunchAtLogin(FilePath())));
#endif
}
@@ -221,7 +206,7 @@ void BrowserOptionsHandler::CheckAutoLaunchCallback(
base::FundamentalValue enabled(will_launch_at_login);
web_ui()->CallJavascriptFunction("BrowserOptions.updateAutoLaunchState",
- enabled);
+ enabled);
}
#endif
}
@@ -545,11 +530,9 @@ void BrowserOptionsHandler::ToggleAutoLaunch(const ListValue* args) {
// Make sure we keep track of how many disable and how many enable.
auto_launch_trial::UpdateToggleAutoLaunchMetric(enable);
- Profile* profile = Profile::FromWebUI(web_ui());
content::BrowserThread::PostTask(
content::BrowserThread::FILE, FROM_HERE,
- base::Bind(&auto_launch_util::SetWillLaunchAtLogin, enable,
- FilePath(), profile->GetPath().BaseName().value()));
+ base::Bind(&auto_launch_util::SetWillLaunchAtLogin, enable, FilePath()));
#endif // OS_WIN
}
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.h b/chrome/browser/ui/webui/options/browser_options_handler.h
index 902d936..ce64322 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.h
+++ b/chrome/browser/ui/webui/options/browser_options_handler.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -97,10 +97,9 @@ class BrowserOptionsHandler : public OptionsPageUIHandler,
// and whether Chrome is set to auto-launch at login. Gets a reply on the UI
// thread (see CheckAutoLaunchCallback). A weak pointer to this is passed in
// as a parameter to avoid the need to lock between this function and the
- // destructor. |profile_path| is the full path to the current profile.
- void CheckAutoLaunch(base::WeakPtr<BrowserOptionsHandler> weak_this,
- const FilePath& profile_path);
+ // destructor.
+ void CheckAutoLaunch(base::WeakPtr<BrowserOptionsHandler> weak_this);
// Sets up (on the UI thread) the necessary bindings for toggling auto-launch
// (if the user is part of the auto-launch and makes sure the HTML UI knows
// whether Chrome will auto-launch at login.
diff --git a/chrome/browser/ui/webui/options2/browser_options_handler2.cc b/chrome/browser/ui/webui/options2/browser_options_handler2.cc
index 5d557d6..c62604f 100644
--- a/chrome/browser/ui/webui/options2/browser_options_handler2.cc
+++ b/chrome/browser/ui/webui/options2/browser_options_handler2.cc
@@ -41,7 +41,6 @@
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/webui/favicon_source.h"
#include "chrome/browser/ui/webui/web_ui_util.h"
-#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
@@ -336,38 +335,26 @@ void BrowserOptionsHandler::Initialize() {
autocomplete_controller_.reset(new AutocompleteController(profile, this));
#if defined(OS_WIN)
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- if (!command_line.HasSwitch(switches::kChromeFrame) &&
- !command_line.HasSwitch(switches::kUserDataDir)) {
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- base::Bind(&BrowserOptionsHandler::CheckAutoLaunch,
- weak_ptr_factory_for_ui_.GetWeakPtr(),
- weak_ptr_factory_for_file_.GetWeakPtr(),
- profile->GetPath()));
- weak_ptr_factory_for_ui_.DetachFromThread();
- }
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
+ base::Bind(&BrowserOptionsHandler::CheckAutoLaunch,
+ weak_ptr_factory_for_ui_.GetWeakPtr(),
+ weak_ptr_factory_for_file_.GetWeakPtr()));
+ weak_ptr_factory_for_ui_.DetachFromThread();
#endif
}
void BrowserOptionsHandler::CheckAutoLaunch(
- base::WeakPtr<BrowserOptionsHandler> weak_this,
- const FilePath& profile_path) {
+ base::WeakPtr<BrowserOptionsHandler> weak_this) {
#if defined(OS_WIN)
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- // Auto-launch is not supported for secondary profiles yet.
- if (profile_path.BaseName().value() != ASCIIToUTF16(chrome::kInitialProfile))
- return;
-
// Pass in weak pointer to this to avoid race if BrowserOptionsHandler is
// deleted.
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&BrowserOptionsHandler::CheckAutoLaunchCallback,
weak_this,
auto_launch_trial::IsInAutoLaunchGroup(),
- auto_launch_util::WillLaunchAtLogin(
- FilePath(),
- profile_path.BaseName().value())));
+ auto_launch_util::WillLaunchAtLogin(FilePath())));
#endif
}
@@ -384,7 +371,7 @@ void BrowserOptionsHandler::CheckAutoLaunchCallback(
base::FundamentalValue enabled(will_launch_at_login);
web_ui()->CallJavascriptFunction("BrowserOptions.updateAutoLaunchState",
- enabled);
+ enabled);
}
#endif
}
@@ -610,11 +597,9 @@ void BrowserOptionsHandler::ToggleAutoLaunch(const ListValue* args) {
// Make sure we keep track of how many disable and how many enable.
auto_launch_trial::UpdateToggleAutoLaunchMetric(enable);
- Profile* profile = Profile::FromWebUI(web_ui());
content::BrowserThread::PostTask(
content::BrowserThread::FILE, FROM_HERE,
- base::Bind(&auto_launch_util::SetWillLaunchAtLogin, enable,
- FilePath(), profile->GetPath().BaseName().value()));
+ base::Bind(&auto_launch_util::SetWillLaunchAtLogin, enable, FilePath()));
#endif // OS_WIN
}
diff --git a/chrome/browser/ui/webui/options2/browser_options_handler2.h b/chrome/browser/ui/webui/options2/browser_options_handler2.h
index 1b56e66..d267d7c 100644
--- a/chrome/browser/ui/webui/options2/browser_options_handler2.h
+++ b/chrome/browser/ui/webui/options2/browser_options_handler2.h
@@ -81,10 +81,9 @@ class BrowserOptionsHandler
// and whether Chrome is set to auto-launch at login. Gets a reply on the UI
// thread (see CheckAutoLaunchCallback). A weak pointer to this is passed in
// as a parameter to avoid the need to lock between this function and the
- // destructor. |profile_path| is the full path to the current profile.
- void CheckAutoLaunch(base::WeakPtr<BrowserOptionsHandler> weak_this,
- const FilePath& profile_path);
+ // destructor.
+ void CheckAutoLaunch(base::WeakPtr<BrowserOptionsHandler> weak_this);
// Sets up (on the UI thread) the necessary bindings for toggling auto-launch
// (if the user is part of the auto-launch and makes sure the HTML UI knows
// whether Chrome will auto-launch at login.
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc
index 044e83d..464e69c 100644
--- a/chrome/installer/setup/install.cc
+++ b/chrome/installer/setup/install.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -16,7 +16,6 @@
#include "base/path_service.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
-#include "chrome/common/chrome_constants.h"
#include "chrome/installer/setup/setup_constants.h"
#include "chrome/installer/setup/install_worker.h"
#include "chrome/installer/util/auto_launch_util.h"
@@ -424,9 +423,7 @@ InstallStatus InstallOrUpdateProduct(
&auto_launch_chrome);
if (auto_launch_chrome) {
auto_launch_util::SetWillLaunchAtLogin(
- true,
- installer_state.target_path(),
- ASCIIToUTF16(chrome::kInitialProfile));
+ true, installer_state.target_path());
}
}
}
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index 60d5851..9c25fc3 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
//
@@ -738,12 +738,8 @@ InstallStatus UninstallProduct(const InstallationState& original_state,
if (is_chrome) {
ClearRlzProductState();
- if (auto_launch_util::WillLaunchAtLogin(
- installer_state.target_path(),
- ASCIIToUTF16(chrome::kInitialProfile))) {
- auto_launch_util::SetWillLaunchAtLogin(
- false, FilePath(), ASCIIToUTF16(chrome::kInitialProfile));
- }
+ if (auto_launch_util::WillLaunchAtLogin(installer_state.target_path()))
+ auto_launch_util::SetWillLaunchAtLogin(false, FilePath());
}
// First delete shortcuts from Start->Programs, Desktop & Quick Launch.
diff --git a/chrome/installer/util/auto_launch_util.cc b/chrome/installer/util/auto_launch_util.cc
index 1904697..1a80a23 100644
--- a/chrome/installer/util/auto_launch_util.cc
+++ b/chrome/installer/util/auto_launch_util.cc
@@ -1,63 +1,27 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
#include "chrome/installer/util/auto_launch_util.h"
-#include "base/command_line.h"
#include "base/file_path.h"
#include "base/logging.h"
#include "base/path_service.h"
-#include "base/string_number_conversions.h"
+#include "base/string16.h"
#include "base/utf_string_conversions.h"
#include "base/win/win_util.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/chrome_version_info.h"
-#include "chrome/installer/util/browser_distribution.h"
-#include "chrome/installer/util/product.h"
#include "chrome/installer/util/util_constants.h"
-#include "crypto/sha2.h"
namespace auto_launch_util {
-// The prefix of the Chrome Auto-launch key under the Run key.
+// The name of the Chrome Auto-launch key under the Run key.
const wchar_t kAutolaunchKeyValue[] = L"GoogleChromeAutoLaunch";
-// A helper function that takes a |profile_path| and builds a registry key
-// name to use when deciding where to read/write the auto-launch value
-// to/from. It takes into account the name of the profile (so that different
-// installations of Chrome don't conflict, and so the in the future different
-// profiles can be auto-launched (or not) separately).
-string16 ProfileToKeyName(const string16& profile_directory) {
- FilePath path;
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- if (command_line.HasSwitch(switches::kUserDataDir)) {
- path = command_line.GetSwitchValuePath(switches::kUserDataDir);
- } else {
- // Get the path from the same source as the installer, to make sure there
- // are no differences.
- BrowserDistribution* distribution =
- BrowserDistribution::GetSpecificDistribution(
- BrowserDistribution::CHROME_BROWSER);
- installer::Product product(distribution);
- path = product.GetUserDataPath();
- }
- path = path.Append(profile_directory);
-
- std::string input(path.AsUTF8Unsafe());
- uint8 hash[16];
- crypto::SHA256HashString(input, hash, sizeof(hash));
- std::string hash_string = base::HexEncode(hash, sizeof(hash));
- return string16(kAutolaunchKeyValue) +
- ASCIIToWide("_") + ASCIIToWide(hash_string);
-}
-
-bool WillLaunchAtLogin(const FilePath& application_path,
- const string16& profile_directory) {
- string16 key_name(ProfileToKeyName(profile_directory));
+bool WillLaunchAtLogin(const FilePath& application_path) {
string16 autolaunch;
if (!base::win::ReadCommandFromAutoRun(
- HKEY_CURRENT_USER, key_name, &autolaunch)) {
+ HKEY_CURRENT_USER, kAutolaunchKeyValue, &autolaunch)) {
return false;
}
@@ -73,11 +37,7 @@ bool WillLaunchAtLogin(const FilePath& application_path,
return autolaunch.find(chrome_exe.value()) != string16::npos;
}
-void SetWillLaunchAtLogin(bool auto_launch,
- const FilePath& application_path,
- const string16& profile_directory) {
- string16 key_name(ProfileToKeyName(profile_directory));
-
+void SetWillLaunchAtLogin(bool auto_launch, const FilePath& application_path) {
// TODO(finnur): Convert this into a shortcut, instead of using the Run key.
if (auto_launch) {
FilePath path(application_path);
@@ -94,26 +54,10 @@ void SetWillLaunchAtLogin(bool auto_launch,
cmd_line += ASCIIToUTF16("\" --");
cmd_line += ASCIIToUTF16(switches::kAutoLaunchAtStartup);
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- if (command_line.HasSwitch(switches::kUserDataDir)) {
- cmd_line += ASCIIToUTF16(" --");
- cmd_line += ASCIIToUTF16(switches::kUserDataDir);
- cmd_line += ASCIIToUTF16("=\"");
- cmd_line +=
- command_line.GetSwitchValuePath(switches::kUserDataDir).value();
- cmd_line += ASCIIToUTF16("\"");
- }
-
- cmd_line += ASCIIToUTF16(" --");
- cmd_line += ASCIIToUTF16(switches::kProfileDirectory);
- cmd_line += ASCIIToUTF16("=\"");
- cmd_line += profile_directory;
- cmd_line += ASCIIToUTF16("\"");
-
base::win::AddCommandToAutoRun(
- HKEY_CURRENT_USER, key_name, cmd_line);
+ HKEY_CURRENT_USER, kAutolaunchKeyValue, cmd_line);
} else {
- base::win::RemoveCommandFromAutoRun(HKEY_CURRENT_USER, key_name);
+ base::win::RemoveCommandFromAutoRun(HKEY_CURRENT_USER, kAutolaunchKeyValue);
}
}
diff --git a/chrome/installer/util/auto_launch_util.h b/chrome/installer/util/auto_launch_util.h
index bce8abd..3684e8c 100644
--- a/chrome/installer/util/auto_launch_util.h
+++ b/chrome/installer/util/auto_launch_util.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -6,8 +6,6 @@
#define CHROME_INSTALLER_UTIL_AUTO_LAUNCH_UTIL_H_
#pragma once
-#include "base/string16.h"
-
class FilePath;
// A namespace containing the platform specific implementation of setting Chrome
@@ -17,23 +15,16 @@ namespace auto_launch_util {
// Returns whether the Chrome executable specified in |application_path| is set
// to auto-launch at computer startup. NOTE: |application_path| is optional and
// should be blank in most cases (as it will default to the application path of
-// the current executable). |profile_directory| is the name of the directory
-// (leaf, not the full path) that contains the profile that should be opened at
-// computer startup.
-bool WillLaunchAtLogin(const FilePath& application_path,
- const string16& profile_directory);
+// the current executable).
+bool WillLaunchAtLogin(const FilePath& application_path);
// Configures whether the Chrome executable should auto-launch at computer
// startup. |application_path| is needed when |auto_launch| is true AND when
// the caller is not the process being set to auto-launch, ie. the installer.
// This is because |application_path|, if left blank, defaults to the
// application path of the current executable. If |auto_launch| is true, then it
-// will auto-launch, otherwise it will be configured not to. |profile_directory|
-// is the name of the directory (leaf, not the full path) that contains the
-// profile that should be opened at computer startup.
-void SetWillLaunchAtLogin(bool auto_launch,
- const FilePath& application_path,
- const string16& profile_directory);
+// will auto-launch, otherwise it will be configured not to.
+void SetWillLaunchAtLogin(bool auto_launch, const FilePath& application_path);
} // namespace auto_launch_util