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