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

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 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
« no previous file with comments | « chrome/browser/ui/webui/options/browser_options_handler.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/options/browser_options_handler.cc
===================================================================
--- chrome/browser/ui/webui/options/browser_options_handler.cc (revision 114230)
+++ 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,8 +39,17 @@
#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
+
+using content::BrowserThread;
+
BrowserOptionsHandler::BrowserOptionsHandler()
- : template_url_service_(NULL), startup_custom_pages_table_model_(NULL) {
+ : template_url_service_(NULL),
+ startup_custom_pages_table_model_(NULL),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_file_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_ui_(this)) {
#if !defined(OS_MACOSX)
default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this);
#endif
@@ -90,6 +101,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() {
@@ -152,8 +166,49 @@
UpdateSearchEngines();
autocomplete_controller_.reset(new AutocompleteController(profile, this));
+
+#if defined(OS_WIN)
+ 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) {
+#if defined(OS_WIN)
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+
+ // 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())));
+#endif
+}
+
+void BrowserOptionsHandler::CheckAutoLaunchCallback(
+ bool is_in_auto_launch_group,
+ bool will_launch_at_login) {
+#if defined(OS_WIN)
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (is_in_auto_launch_group) {
+ web_ui_->RegisterMessageCallback("toggleAutoLaunch",
+ base::Bind(&BrowserOptionsHandler::ToggleAutoLaunch,
+ base::Unretained(this)));
+
+ base::FundamentalValue enabled(will_launch_at_login);
+ web_ui_->CallJavascriptFunction("BrowserOptions.updateAutoLaunchState",
+ enabled);
+ }
+#endif
+}
+
void BrowserOptionsHandler::UpdateDefaultBrowserState() {
// Check for side-by-side first.
if (!ShellIntegration::CanSetAsDefaultBrowser()) {
@@ -461,6 +516,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(
« no previous file with comments | « chrome/browser/ui/webui/options/browser_options_handler.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698