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

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: Uploading again post gclient sync (no other changes) 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 UpdateSearchEngines(); 403 UpdateSearchEngines();
404 UpdateHomePageLabel(); 404 UpdateHomePageLabel();
405 ObserveThemeChanged(); 405 ObserveThemeChanged();
406 406
407 autocomplete_controller_.reset(new AutocompleteController(profile, this)); 407 autocomplete_controller_.reset(new AutocompleteController(profile, this));
408 408
409 #if defined(OS_WIN) 409 #if defined(OS_WIN)
410 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 410 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
411 base::Bind(&BrowserOptionsHandler::CheckAutoLaunch, 411 base::Bind(&BrowserOptionsHandler::CheckAutoLaunch,
412 weak_ptr_factory_for_ui_.GetWeakPtr(), 412 weak_ptr_factory_for_ui_.GetWeakPtr(),
413 weak_ptr_factory_for_file_.GetWeakPtr())); 413 weak_ptr_factory_for_file_.GetWeakPtr(),
414 profile->GetPath()));
414 weak_ptr_factory_for_ui_.DetachFromThread(); 415 weak_ptr_factory_for_ui_.DetachFromThread();
415 #endif 416 #endif
416 } 417 }
417 418
418 void BrowserOptionsHandler::CheckAutoLaunch( 419 void BrowserOptionsHandler::CheckAutoLaunch(
419 base::WeakPtr<BrowserOptionsHandler> weak_this) { 420 base::WeakPtr<BrowserOptionsHandler> weak_this,
421 const FilePath& profile_path) {
420 #if defined(OS_WIN) 422 #if defined(OS_WIN)
421 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 423 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
422 424
425 // We don't support this for secondary profiles yet.
426 if (profile_path.BaseName().value() != ASCIIToUTF16("Default"))
427 return;
428
423 // Pass in weak pointer to this to avoid race if BrowserOptionsHandler is 429 // Pass in weak pointer to this to avoid race if BrowserOptionsHandler is
424 // deleted. 430 // deleted.
425 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 431 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
426 base::Bind(&BrowserOptionsHandler::CheckAutoLaunchCallback, 432 base::Bind(&BrowserOptionsHandler::CheckAutoLaunchCallback,
427 weak_this, 433 weak_this,
428 auto_launch_trial::IsInAutoLaunchGroup(), 434 auto_launch_trial::IsInAutoLaunchGroup(),
429 auto_launch_util::WillLaunchAtLogin(FilePath()))); 435 auto_launch_util::WillLaunchAtLogin(FilePath(),
436 profile_path)));
430 #endif 437 #endif
431 } 438 }
432 439
433 void BrowserOptionsHandler::CheckAutoLaunchCallback( 440 void BrowserOptionsHandler::CheckAutoLaunchCallback(
434 bool is_in_auto_launch_group, 441 bool is_in_auto_launch_group,
435 bool will_launch_at_login) { 442 bool will_launch_at_login) {
436 #if defined(OS_WIN) 443 #if defined(OS_WIN)
437 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 444 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
438 445
439 if (is_in_auto_launch_group) { 446 if (is_in_auto_launch_group) {
440 web_ui()->RegisterMessageCallback("toggleAutoLaunch", 447 web_ui()->RegisterMessageCallback("toggleAutoLaunch",
441 base::Bind(&BrowserOptionsHandler::ToggleAutoLaunch, 448 base::Bind(&BrowserOptionsHandler::ToggleAutoLaunch,
442 base::Unretained(this))); 449 base::Unretained(this)));
443 450
444 base::FundamentalValue enabled(will_launch_at_login); 451 base::FundamentalValue enabled(will_launch_at_login);
445 web_ui()->CallJavascriptFunction("BrowserOptions.updateAutoLaunchState", 452 web_ui()->CallJavascriptFunction("BrowserOptions.updateAutoLaunchState",
446 enabled); 453 enabled);
447 } 454 }
448 #endif 455 #endif
449 } 456 }
450 457
451 void BrowserOptionsHandler::UpdateDefaultBrowserState() { 458 void BrowserOptionsHandler::UpdateDefaultBrowserState() {
452 // Check for side-by-side first. 459 // Check for side-by-side first.
453 if (!ShellIntegration::CanSetAsDefaultBrowser()) { 460 if (!ShellIntegration::CanSetAsDefaultBrowser()) {
454 SetDefaultBrowserUIString(IDS_OPTIONS_DEFAULTBROWSER_SXS); 461 SetDefaultBrowserUIString(IDS_OPTIONS_DEFAULTBROWSER_SXS);
455 return; 462 return;
456 } 463 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 #if defined(OS_WIN) 669 #if defined(OS_WIN)
663 if (!auto_launch_trial::IsInAutoLaunchGroup()) 670 if (!auto_launch_trial::IsInAutoLaunchGroup())
664 return; 671 return;
665 672
666 bool enable; 673 bool enable;
667 CHECK_EQ(args->GetSize(), 1U); 674 CHECK_EQ(args->GetSize(), 1U);
668 CHECK(args->GetBoolean(0, &enable)); 675 CHECK(args->GetBoolean(0, &enable));
669 676
670 // Make sure we keep track of how many disable and how many enable. 677 // Make sure we keep track of how many disable and how many enable.
671 auto_launch_trial::UpdateToggleAutoLaunchMetric(enable); 678 auto_launch_trial::UpdateToggleAutoLaunchMetric(enable);
679 Profile* profile = Profile::FromWebUI(web_ui());
672 content::BrowserThread::PostTask( 680 content::BrowserThread::PostTask(
673 content::BrowserThread::FILE, FROM_HERE, 681 content::BrowserThread::FILE, FROM_HERE,
674 base::Bind(&auto_launch_util::SetWillLaunchAtLogin, enable, FilePath())); 682 base::Bind(&auto_launch_util::SetWillLaunchAtLogin, enable,
683 FilePath(), profile->GetPath()));
675 #endif // OS_WIN 684 #endif // OS_WIN
676 } 685 }
677 686
678 void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) { 687 void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) {
679 Profile* profile = Profile::FromWebUI(web_ui()); 688 Profile* profile = Profile::FromWebUI(web_ui());
680 base::FundamentalValue enabled( 689 base::FundamentalValue enabled(
681 InstantFieldTrial::IsInstantExperiment(profile) && 690 InstantFieldTrial::IsInstantExperiment(profile) &&
682 !InstantFieldTrial::IsHiddenExperiment(profile)); 691 !InstantFieldTrial::IsHiddenExperiment(profile));
683 web_ui()->CallJavascriptFunction("BrowserOptions.setInstantFieldTrialStatus", 692 web_ui()->CallJavascriptFunction("BrowserOptions.setInstantFieldTrialStatus",
684 enabled); 693 enabled);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 } 807 }
799 808
800 void BrowserOptionsHandler::IncreaseScreenBrightnessCallback( 809 void BrowserOptionsHandler::IncreaseScreenBrightnessCallback(
801 const ListValue* args) { 810 const ListValue* args) {
802 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 811 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
803 IncreaseScreenBrightness(); 812 IncreaseScreenBrightness();
804 } 813 }
805 #endif 814 #endif
806 815
807 } // namespace options2 816 } // namespace options2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698