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

Side by Side Diff: chrome/browser/ui/webui/options2/browser_options_handler2.cc

Issue 9317002: Make the auto-launch experiment profile-aware. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 10 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/options2/browser_options_handler2.h" 5 #include "chrome/browser/ui/webui/options2/browser_options_handler2.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 23 matching lines...) Expand all
34 #include "chrome/browser/search_engines/template_url_service.h" 34 #include "chrome/browser/search_engines/template_url_service.h"
35 #include "chrome/browser/search_engines/template_url_service_factory.h" 35 #include "chrome/browser/search_engines/template_url_service_factory.h"
36 #include "chrome/browser/sync/profile_sync_service.h" 36 #include "chrome/browser/sync/profile_sync_service.h"
37 #include "chrome/browser/sync/profile_sync_service_factory.h" 37 #include "chrome/browser/sync/profile_sync_service_factory.h"
38 #include "chrome/browser/sync/sync_setup_flow.h" 38 #include "chrome/browser/sync/sync_setup_flow.h"
39 #include "chrome/browser/sync/sync_ui_util.h" 39 #include "chrome/browser/sync/sync_ui_util.h"
40 #include "chrome/browser/themes/theme_service.h" 40 #include "chrome/browser/themes/theme_service.h"
41 #include "chrome/browser/themes/theme_service_factory.h" 41 #include "chrome/browser/themes/theme_service_factory.h"
42 #include "chrome/browser/ui/webui/favicon_source.h" 42 #include "chrome/browser/ui/webui/favicon_source.h"
43 #include "chrome/browser/ui/webui/web_ui_util.h" 43 #include "chrome/browser/ui/webui/web_ui_util.h"
44 #include "chrome/common/chrome_constants.h"
44 #include "chrome/common/chrome_notification_types.h" 45 #include "chrome/common/chrome_notification_types.h"
45 #include "chrome/common/chrome_paths.h" 46 #include "chrome/common/chrome_paths.h"
46 #include "chrome/common/chrome_switches.h" 47 #include "chrome/common/chrome_switches.h"
47 #include "chrome/common/net/gaia/google_service_auth_error.h" 48 #include "chrome/common/net/gaia/google_service_auth_error.h"
48 #include "chrome/common/pref_names.h" 49 #include "chrome/common/pref_names.h"
49 #include "chrome/common/url_constants.h" 50 #include "chrome/common/url_constants.h"
50 #include "content/public/browser/browser_thread.h" 51 #include "content/public/browser/browser_thread.h"
51 #include "content/public/browser/navigation_controller.h" 52 #include "content/public/browser/navigation_controller.h"
52 #include "content/public/browser/notification_details.h" 53 #include "content/public/browser/notification_details.h"
53 #include "content/public/browser/notification_service.h" 54 #include "content/public/browser/notification_service.h"
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 UpdateSearchEngines(); 404 UpdateSearchEngines();
404 UpdateHomePageLabel(); 405 UpdateHomePageLabel();
405 ObserveThemeChanged(); 406 ObserveThemeChanged();
406 407
407 autocomplete_controller_.reset(new AutocompleteController(profile, this)); 408 autocomplete_controller_.reset(new AutocompleteController(profile, this));
408 409
409 #if defined(OS_WIN) 410 #if defined(OS_WIN)
410 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 411 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
411 base::Bind(&BrowserOptionsHandler::CheckAutoLaunch, 412 base::Bind(&BrowserOptionsHandler::CheckAutoLaunch,
412 weak_ptr_factory_for_ui_.GetWeakPtr(), 413 weak_ptr_factory_for_ui_.GetWeakPtr(),
413 weak_ptr_factory_for_file_.GetWeakPtr())); 414 weak_ptr_factory_for_file_.GetWeakPtr(),
415 profile->GetPath()));
414 weak_ptr_factory_for_ui_.DetachFromThread(); 416 weak_ptr_factory_for_ui_.DetachFromThread();
415 #endif 417 #endif
416 } 418 }
417 419
418 void BrowserOptionsHandler::CheckAutoLaunch( 420 void BrowserOptionsHandler::CheckAutoLaunch(
419 base::WeakPtr<BrowserOptionsHandler> weak_this) { 421 base::WeakPtr<BrowserOptionsHandler> weak_this,
422 const FilePath& profile_path) {
420 #if defined(OS_WIN) 423 #if defined(OS_WIN)
421 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 424 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
422 425
426 // We don't support this for secondary profiles yet.
427 if (profile_path.BaseName().value() != ASCIIToUTF16(chrome::kInitialProfile))
428 return;
429
423 // Pass in weak pointer to this to avoid race if BrowserOptionsHandler is 430 // Pass in weak pointer to this to avoid race if BrowserOptionsHandler is
424 // deleted. 431 // deleted.
425 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 432 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
426 base::Bind(&BrowserOptionsHandler::CheckAutoLaunchCallback, 433 base::Bind(&BrowserOptionsHandler::CheckAutoLaunchCallback,
427 weak_this, 434 weak_this,
428 auto_launch_trial::IsInAutoLaunchGroup(), 435 auto_launch_trial::IsInAutoLaunchGroup(),
429 auto_launch_util::WillLaunchAtLogin(FilePath()))); 436 auto_launch_util::WillLaunchAtLogin(FilePath(),
437 profile_path)));
430 #endif 438 #endif
431 } 439 }
432 440
433 void BrowserOptionsHandler::CheckAutoLaunchCallback( 441 void BrowserOptionsHandler::CheckAutoLaunchCallback(
434 bool is_in_auto_launch_group, 442 bool is_in_auto_launch_group,
435 bool will_launch_at_login) { 443 bool will_launch_at_login) {
436 #if defined(OS_WIN) 444 #if defined(OS_WIN)
437 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 445 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
438 446
439 if (is_in_auto_launch_group) { 447 if (is_in_auto_launch_group) {
440 web_ui()->RegisterMessageCallback("toggleAutoLaunch", 448 web_ui()->RegisterMessageCallback("toggleAutoLaunch",
441 base::Bind(&BrowserOptionsHandler::ToggleAutoLaunch, 449 base::Bind(&BrowserOptionsHandler::ToggleAutoLaunch,
442 base::Unretained(this))); 450 base::Unretained(this)));
443 451
444 base::FundamentalValue enabled(will_launch_at_login); 452 base::FundamentalValue enabled(will_launch_at_login);
445 web_ui()->CallJavascriptFunction("BrowserOptions.updateAutoLaunchState", 453 web_ui()->CallJavascriptFunction("BrowserOptions.updateAutoLaunchState",
446 enabled); 454 enabled);
447 } 455 }
448 #endif 456 #endif
449 } 457 }
450 458
451 void BrowserOptionsHandler::UpdateDefaultBrowserState() { 459 void BrowserOptionsHandler::UpdateDefaultBrowserState() {
452 // Check for side-by-side first. 460 // Check for side-by-side first.
453 if (!ShellIntegration::CanSetAsDefaultBrowser()) { 461 if (!ShellIntegration::CanSetAsDefaultBrowser()) {
454 SetDefaultBrowserUIString(IDS_OPTIONS_DEFAULTBROWSER_SXS); 462 SetDefaultBrowserUIString(IDS_OPTIONS_DEFAULTBROWSER_SXS);
455 return; 463 return;
456 } 464 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 #if defined(OS_WIN) 670 #if defined(OS_WIN)
663 if (!auto_launch_trial::IsInAutoLaunchGroup()) 671 if (!auto_launch_trial::IsInAutoLaunchGroup())
664 return; 672 return;
665 673
666 bool enable; 674 bool enable;
667 CHECK_EQ(args->GetSize(), 1U); 675 CHECK_EQ(args->GetSize(), 1U);
668 CHECK(args->GetBoolean(0, &enable)); 676 CHECK(args->GetBoolean(0, &enable));
669 677
670 // Make sure we keep track of how many disable and how many enable. 678 // Make sure we keep track of how many disable and how many enable.
671 auto_launch_trial::UpdateToggleAutoLaunchMetric(enable); 679 auto_launch_trial::UpdateToggleAutoLaunchMetric(enable);
680 Profile* profile = Profile::FromWebUI(web_ui());
672 content::BrowserThread::PostTask( 681 content::BrowserThread::PostTask(
673 content::BrowserThread::FILE, FROM_HERE, 682 content::BrowserThread::FILE, FROM_HERE,
674 base::Bind(&auto_launch_util::SetWillLaunchAtLogin, enable, FilePath())); 683 base::Bind(&auto_launch_util::SetWillLaunchAtLogin, enable,
684 FilePath(), profile->GetPath()));
675 #endif // OS_WIN 685 #endif // OS_WIN
676 } 686 }
677 687
678 void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) { 688 void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) {
679 Profile* profile = Profile::FromWebUI(web_ui()); 689 Profile* profile = Profile::FromWebUI(web_ui());
680 base::FundamentalValue enabled( 690 base::FundamentalValue enabled(
681 InstantFieldTrial::IsInstantExperiment(profile) && 691 InstantFieldTrial::IsInstantExperiment(profile) &&
682 !InstantFieldTrial::IsHiddenExperiment(profile)); 692 !InstantFieldTrial::IsHiddenExperiment(profile));
683 web_ui()->CallJavascriptFunction("BrowserOptions.setInstantFieldTrialStatus", 693 web_ui()->CallJavascriptFunction("BrowserOptions.setInstantFieldTrialStatus",
684 enabled); 694 enabled);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 } 808 }
799 809
800 void BrowserOptionsHandler::IncreaseScreenBrightnessCallback( 810 void BrowserOptionsHandler::IncreaseScreenBrightnessCallback(
801 const ListValue* args) { 811 const ListValue* args) {
802 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 812 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
803 IncreaseScreenBrightness(); 813 IncreaseScreenBrightness();
804 } 814 }
805 #endif 815 #endif
806 816
807 } // namespace options2 817 } // namespace options2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698