| OLD | NEW |
| 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 Loading... |
| 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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 content::Source<ThemeService>( | 405 content::Source<ThemeService>( |
| 405 ThemeServiceFactory::GetForProfile(profile))); | 406 ThemeServiceFactory::GetForProfile(profile))); |
| 406 | 407 |
| 407 UpdateSearchEngines(); | 408 UpdateSearchEngines(); |
| 408 UpdateHomePageLabel(); | 409 UpdateHomePageLabel(); |
| 409 ObserveThemeChanged(); | 410 ObserveThemeChanged(); |
| 410 | 411 |
| 411 autocomplete_controller_.reset(new AutocompleteController(profile, this)); | 412 autocomplete_controller_.reset(new AutocompleteController(profile, this)); |
| 412 | 413 |
| 413 #if defined(OS_WIN) | 414 #if defined(OS_WIN) |
| 414 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 415 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 415 base::Bind(&BrowserOptionsHandler::CheckAutoLaunch, | 416 if (!command_line.HasSwitch(switches::kChromeFrame) && |
| 416 weak_ptr_factory_for_ui_.GetWeakPtr(), | 417 !command_line.HasSwitch(switches::kUserDataDir)) { |
| 417 weak_ptr_factory_for_file_.GetWeakPtr())); | 418 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 418 weak_ptr_factory_for_ui_.DetachFromThread(); | 419 base::Bind(&BrowserOptionsHandler::CheckAutoLaunch, |
| 420 weak_ptr_factory_for_ui_.GetWeakPtr(), |
| 421 weak_ptr_factory_for_file_.GetWeakPtr(), |
| 422 profile->GetPath())); |
| 423 weak_ptr_factory_for_ui_.DetachFromThread(); |
| 424 } |
| 419 #endif | 425 #endif |
| 420 } | 426 } |
| 421 | 427 |
| 422 void BrowserOptionsHandler::CheckAutoLaunch( | 428 void BrowserOptionsHandler::CheckAutoLaunch( |
| 423 base::WeakPtr<BrowserOptionsHandler> weak_this) { | 429 base::WeakPtr<BrowserOptionsHandler> weak_this, |
| 430 const FilePath& profile_path) { |
| 424 #if defined(OS_WIN) | 431 #if defined(OS_WIN) |
| 425 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 432 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 426 | 433 |
| 434 // Auto-launch is not supported for secondary profiles yet. |
| 435 if (profile_path.BaseName().value() != ASCIIToUTF16(chrome::kInitialProfile)) |
| 436 return; |
| 437 |
| 427 // Pass in weak pointer to this to avoid race if BrowserOptionsHandler is | 438 // Pass in weak pointer to this to avoid race if BrowserOptionsHandler is |
| 428 // deleted. | 439 // deleted. |
| 429 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 440 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 430 base::Bind(&BrowserOptionsHandler::CheckAutoLaunchCallback, | 441 base::Bind(&BrowserOptionsHandler::CheckAutoLaunchCallback, |
| 431 weak_this, | 442 weak_this, |
| 432 auto_launch_trial::IsInAutoLaunchGroup(), | 443 auto_launch_trial::IsInAutoLaunchGroup(), |
| 433 auto_launch_util::WillLaunchAtLogin(FilePath()))); | 444 auto_launch_util::WillLaunchAtLogin( |
| 445 FilePath(), |
| 446 profile_path.BaseName().value()))); |
| 434 #endif | 447 #endif |
| 435 } | 448 } |
| 436 | 449 |
| 437 void BrowserOptionsHandler::CheckAutoLaunchCallback( | 450 void BrowserOptionsHandler::CheckAutoLaunchCallback( |
| 438 bool is_in_auto_launch_group, | 451 bool is_in_auto_launch_group, |
| 439 bool will_launch_at_login) { | 452 bool will_launch_at_login) { |
| 440 #if defined(OS_WIN) | 453 #if defined(OS_WIN) |
| 441 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 454 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 442 | 455 |
| 443 if (is_in_auto_launch_group) { | 456 if (is_in_auto_launch_group) { |
| 444 web_ui()->RegisterMessageCallback("toggleAutoLaunch", | 457 web_ui()->RegisterMessageCallback("toggleAutoLaunch", |
| 445 base::Bind(&BrowserOptionsHandler::ToggleAutoLaunch, | 458 base::Bind(&BrowserOptionsHandler::ToggleAutoLaunch, |
| 446 base::Unretained(this))); | 459 base::Unretained(this))); |
| 447 | 460 |
| 448 base::FundamentalValue enabled(will_launch_at_login); | 461 base::FundamentalValue enabled(will_launch_at_login); |
| 449 web_ui()->CallJavascriptFunction("BrowserOptions.updateAutoLaunchState", | 462 web_ui()->CallJavascriptFunction("BrowserOptions.updateAutoLaunchState", |
| 450 enabled); | 463 enabled); |
| 451 } | 464 } |
| 452 #endif | 465 #endif |
| 453 } | 466 } |
| 454 | 467 |
| 455 void BrowserOptionsHandler::UpdateDefaultBrowserState() { | 468 void BrowserOptionsHandler::UpdateDefaultBrowserState() { |
| 456 // Check for side-by-side first. | 469 // Check for side-by-side first. |
| 457 if (!ShellIntegration::CanSetAsDefaultBrowser()) { | 470 if (!ShellIntegration::CanSetAsDefaultBrowser()) { |
| 458 SetDefaultBrowserUIString(IDS_OPTIONS_DEFAULTBROWSER_SXS); | 471 SetDefaultBrowserUIString(IDS_OPTIONS_DEFAULTBROWSER_SXS); |
| 459 return; | 472 return; |
| 460 } | 473 } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 #if defined(OS_WIN) | 679 #if defined(OS_WIN) |
| 667 if (!auto_launch_trial::IsInAutoLaunchGroup()) | 680 if (!auto_launch_trial::IsInAutoLaunchGroup()) |
| 668 return; | 681 return; |
| 669 | 682 |
| 670 bool enable; | 683 bool enable; |
| 671 CHECK_EQ(args->GetSize(), 1U); | 684 CHECK_EQ(args->GetSize(), 1U); |
| 672 CHECK(args->GetBoolean(0, &enable)); | 685 CHECK(args->GetBoolean(0, &enable)); |
| 673 | 686 |
| 674 // Make sure we keep track of how many disable and how many enable. | 687 // Make sure we keep track of how many disable and how many enable. |
| 675 auto_launch_trial::UpdateToggleAutoLaunchMetric(enable); | 688 auto_launch_trial::UpdateToggleAutoLaunchMetric(enable); |
| 689 Profile* profile = Profile::FromWebUI(web_ui()); |
| 676 content::BrowserThread::PostTask( | 690 content::BrowserThread::PostTask( |
| 677 content::BrowserThread::FILE, FROM_HERE, | 691 content::BrowserThread::FILE, FROM_HERE, |
| 678 base::Bind(&auto_launch_util::SetWillLaunchAtLogin, enable, FilePath())); | 692 base::Bind(&auto_launch_util::SetWillLaunchAtLogin, enable, |
| 693 FilePath(), profile->GetPath().BaseName().value())); |
| 679 #endif // OS_WIN | 694 #endif // OS_WIN |
| 680 } | 695 } |
| 681 | 696 |
| 682 void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) { | 697 void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) { |
| 683 Profile* profile = Profile::FromWebUI(web_ui()); | 698 Profile* profile = Profile::FromWebUI(web_ui()); |
| 684 base::FundamentalValue enabled( | 699 base::FundamentalValue enabled( |
| 685 InstantFieldTrial::IsInstantExperiment(profile) && | 700 InstantFieldTrial::IsInstantExperiment(profile) && |
| 686 !InstantFieldTrial::IsHiddenExperiment(profile)); | 701 !InstantFieldTrial::IsHiddenExperiment(profile)); |
| 687 web_ui()->CallJavascriptFunction("BrowserOptions.setInstantFieldTrialStatus", | 702 web_ui()->CallJavascriptFunction("BrowserOptions.setInstantFieldTrialStatus", |
| 688 enabled); | 703 enabled); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 } | 817 } |
| 803 | 818 |
| 804 void BrowserOptionsHandler::IncreaseScreenBrightnessCallback( | 819 void BrowserOptionsHandler::IncreaseScreenBrightnessCallback( |
| 805 const ListValue* args) { | 820 const ListValue* args) { |
| 806 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 821 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 807 IncreaseScreenBrightness(); | 822 IncreaseScreenBrightness(); |
| 808 } | 823 } |
| 809 #endif | 824 #endif |
| 810 | 825 |
| 811 } // namespace options2 | 826 } // namespace options2 |
| OLD | NEW |