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

Unified Diff: chrome/browser/ui/webui/options/browser_options_handler.cc

Issue 8729009: Implement an AutoLaunch experiment for Chrome for certain brand codes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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/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(

Powered by Google App Engine
This is Rietveld 408576698