Chromium Code Reviews| 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()); |
|
grt (UTC plus 2)
2011/12/03 04:43:38
i can't remember if i remarked that this will hit
Finnur
2011/12/13 15:53:24
It does. I just didn't see it because I built mini
|
| + web_ui_->CallJavascriptFunction("BrowserOptions.updateAutoLaunchState", |
| + enabled); |
| + } |
| +#endif |
| } |
| void BrowserOptionsHandler::UpdateDefaultBrowserState() { |
| @@ -461,6 +483,23 @@ |
| 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. |
| + auto_launch_trial::UpdateToggleAutoLaunchMetric(enable); |
| + content::BrowserThread::PostTask( |
| + content::BrowserThread::FILE, FROM_HERE, |
| + base::Bind(&auto_launch_util::SetWillLaunchAtLogin, enable, FilePath())); |
| +#endif // OS_WIN |
| +} |
| + |
| void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) { |
| Profile* profile = Profile::FromWebUI(web_ui_); |
| base::FundamentalValue enabled( |