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

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

Powered by Google App Engine
This is Rietveld 408576698