Index: chrome/browser/ui/webui/options/browser_options_handler.cc |
=================================================================== |
--- chrome/browser/ui/webui/options/browser_options_handler.cc (revision 111708) |
+++ chrome/browser/ui/webui/options/browser_options_handler.cc (working copy) |
@@ -8,9 +8,11 @@ |
#include "base/bind.h" |
#include "base/bind_helpers.h" |
#include "base/memory/singleton.h" |
+#include "base/path_service.h" |
#include "base/string_number_conversions.h" |
#include "base/utf_string_conversions.h" |
#include "base/values.h" |
+#include "chrome/browser/auto_launch_trial.h" |
#include "chrome/browser/autocomplete/autocomplete.h" |
#include "chrome/browser/autocomplete/autocomplete_match.h" |
#include "chrome/browser/browser_process.h" |
@@ -37,6 +39,10 @@ |
#include "grit/generated_resources.h" |
#include "ui/base/l10n/l10n_util.h" |
+#if defined(OS_WIN) |
+#include "chrome/installer/util/auto_launch_util.h" |
+#endif |
+ |
BrowserOptionsHandler::BrowserOptionsHandler() |
: template_url_service_(NULL), startup_custom_pages_table_model_(NULL) { |
#if !defined(OS_MACOSX) |
@@ -90,6 +96,9 @@ |
localized_strings->SetString("defaultBrowserUseAsDefault", |
l10n_util::GetStringFUTF16(IDS_OPTIONS_DEFAULTBROWSER_USEASDEFAULT, |
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
+ localized_strings->SetString("autoLaunchText", |
+ l10n_util::GetStringFUTF16(IDS_AUTOLAUNCH_TEXT, |
+ l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
} |
void BrowserOptionsHandler::RegisterMessages() { |
@@ -126,6 +135,11 @@ |
web_ui_->RegisterMessageCallback("getInstantFieldTrialStatus", |
base::Bind(&BrowserOptionsHandler::GetInstantFieldTrialStatus, |
base::Unretained(this))); |
+ if (auto_launch_trial::IsInAutoLaunchGroup()) { |
+ web_ui_->RegisterMessageCallback("toggleAutoLaunch", |
+ base::Bind(&BrowserOptionsHandler::ToggleAutoLaunch, |
+ base::Unretained(this))); |
+ } |
} |
void BrowserOptionsHandler::Initialize() { |
@@ -152,6 +166,14 @@ |
UpdateSearchEngines(); |
autocomplete_controller_.reset(new AutocompleteController(profile, this)); |
+ |
+#if defined(OS_WIN) |
+ if (auto_launch_trial::IsInAutoLaunchGroup()) { |
+ base::FundamentalValue enabled(auto_launch_util::WillLaunchAtLogin()); |
+ web_ui_->CallJavascriptFunction("BrowserOptions.updateAutoLaunchState", |
+ enabled); |
+ } |
+#endif |
} |
void BrowserOptionsHandler::UpdateDefaultBrowserState() { |
@@ -461,6 +483,26 @@ |
InstantController::Disable(Profile::FromWebUI(web_ui_)); |
} |
+void BrowserOptionsHandler::ToggleAutoLaunch(const ListValue* args) { |
+#if defined(OS_WIN) |
+ if (!auto_launch_trial::IsInAutoLaunchGroup()) |
+ return; |
+ |
+ bool enable; |
+ CHECK_EQ(args->GetSize(), 1U); |
+ CHECK(args->GetBoolean(0, &enable)); |
+ |
+ // Make sure we keep track of how many disable and how many enable. |
grt (UTC plus 2)
2011/12/01 04:45:02
this is almost duplicate code. could it be shared
|
+ auto_launch_trial::UpdateToggleAutoLaunchMetric(enable); |
+ |
+ FilePath chrome_exe; |
grt (UTC plus 2)
2011/12/01 04:45:02
chrome_exe -> chrome_dir, or somesuch
|
+ if (!PathService::Get(base::DIR_EXE, &chrome_exe)) |
stuartmorgan
2011/12/01 10:11:44
Seems a bit odd to me that this code lives here an
|
+ NOTREACHED(); |
+ |
+ auto_launch_util::SetWillLaunchAtLogin(enable, chrome_exe); |
grt (UTC plus 2)
2011/12/01 04:45:02
this will touch the registry. is IO allowed from
|
+#endif // OS_WIN |
+} |
+ |
void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) { |
Profile* profile = Profile::FromWebUI(web_ui_); |
base::FundamentalValue enabled( |