Chromium Code Reviews| 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 static_cast<chromeos::options2::SystemSettingsProvider*>( | 384 static_cast<chromeos::options2::SystemSettingsProvider*>( |
| 385 chromeos::CrosSettings::Get()->GetProvider( | 385 chromeos::CrosSettings::Get()->GetProvider( |
| 386 chromeos::kSystemTimezone))->GetTimezoneList()); | 386 chromeos::kSystemTimezone))->GetTimezoneList()); |
| 387 #endif | 387 #endif |
| 388 #if defined(OS_MACOSX) | 388 #if defined(OS_MACOSX) |
| 389 values->SetString("macPasswordsWarning", | 389 values->SetString("macPasswordsWarning", |
| 390 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_MAC_WARNING)); | 390 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_MAC_WARNING)); |
| 391 values->SetBoolean("multiple_profiles", | 391 values->SetBoolean("multiple_profiles", |
| 392 g_browser_process->profile_manager()->GetNumberOfProfiles() > 1); | 392 g_browser_process->profile_manager()->GetNumberOfProfiles() > 1); |
| 393 #endif | 393 #endif |
| 394 | |
| 395 if (multiprofile_) | |
| 396 values->Set("profilesInfo", GetProfilesInfoList()); | |
| 394 } | 397 } |
| 395 | 398 |
| 396 void BrowserOptionsHandler::RegisterCloudPrintValues(DictionaryValue* values) { | 399 void BrowserOptionsHandler::RegisterCloudPrintValues(DictionaryValue* values) { |
| 397 #if defined(OS_CHROMEOS) | 400 #if defined(OS_CHROMEOS) |
| 398 values->SetString("cloudPrintChromeosOptionLabel", | 401 values->SetString("cloudPrintChromeosOptionLabel", |
| 399 l10n_util::GetStringFUTF16( | 402 l10n_util::GetStringFUTF16( |
| 400 IDS_CLOUD_PRINT_CHROMEOS_OPTION_LABEL, | 403 IDS_CLOUD_PRINT_CHROMEOS_OPTION_LABEL, |
| 401 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT))); | 404 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT))); |
| 402 values->SetString("cloudPrintChromeosOptionButton", | 405 values->SetString("cloudPrintChromeosOptionButton", |
| 403 l10n_util::GetStringFUTF16( | 406 l10n_util::GetStringFUTF16( |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 603 #if !defined(OS_CHROMEOS) | 606 #if !defined(OS_CHROMEOS) |
| 604 proxy_prefs_.reset( | 607 proxy_prefs_.reset( |
| 605 PrefSetObserver::CreateProxyPrefSetObserver(prefs, this)); | 608 PrefSetObserver::CreateProxyPrefSetObserver(prefs, this)); |
| 606 #endif // !defined(OS_CHROMEOS) | 609 #endif // !defined(OS_CHROMEOS) |
| 607 } | 610 } |
| 608 | 611 |
| 609 void BrowserOptionsHandler::InitializePage() { | 612 void BrowserOptionsHandler::InitializePage() { |
| 610 OnTemplateURLServiceChanged(); | 613 OnTemplateURLServiceChanged(); |
| 611 ObserveThemeChanged(); | 614 ObserveThemeChanged(); |
| 612 | 615 |
| 613 if (multiprofile_) | |
| 614 SendProfilesInfo(); | |
| 615 | |
| 616 SetupMetricsReportingCheckbox(); | 616 SetupMetricsReportingCheckbox(); |
| 617 SetupMetricsReportingSettingVisibility(); | 617 SetupMetricsReportingSettingVisibility(); |
| 618 SetupFontSizeSelector(); | 618 SetupFontSizeSelector(); |
| 619 SetupPageZoomSelector(); | 619 SetupPageZoomSelector(); |
| 620 SetupAutoOpenFileTypes(); | 620 SetupAutoOpenFileTypes(); |
| 621 SetupProxySettingsSection(); | 621 SetupProxySettingsSection(); |
| 622 SetupSSLConfigSettings(); | 622 SetupSSLConfigSettings(); |
| 623 #if !defined(OS_CHROMEOS) | 623 #if !defined(OS_CHROMEOS) |
| 624 if (cloud_print_connector_ui_enabled_) { | 624 if (cloud_print_connector_ui_enabled_) { |
| 625 SetupCloudPrintConnectorSection(); | 625 SetupCloudPrintConnectorSection(); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 894 | 894 |
| 895 void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) { | 895 void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) { |
| 896 Profile* profile = Profile::FromWebUI(web_ui()); | 896 Profile* profile = Profile::FromWebUI(web_ui()); |
| 897 base::FundamentalValue enabled( | 897 base::FundamentalValue enabled( |
| 898 InstantFieldTrial::IsInstantExperiment(profile) && | 898 InstantFieldTrial::IsInstantExperiment(profile) && |
| 899 !InstantFieldTrial::IsHiddenExperiment(profile)); | 899 !InstantFieldTrial::IsHiddenExperiment(profile)); |
| 900 web_ui()->CallJavascriptFunction("BrowserOptions.setInstantFieldTrialStatus", | 900 web_ui()->CallJavascriptFunction("BrowserOptions.setInstantFieldTrialStatus", |
| 901 enabled); | 901 enabled); |
| 902 } | 902 } |
| 903 | 903 |
| 904 void BrowserOptionsHandler::SendProfilesInfo() { | 904 ListValue* BrowserOptionsHandler::GetProfilesInfoList() { |
| 905 // Set profile creation text and button if multi-profiles switch is on. | |
| 906 scoped_ptr<Value> visible(Value::CreateBooleanValue(multiprofile_)); | |
| 907 web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesSectionVisible", | |
| 908 *visible); | |
| 909 | |
| 910 if (!multiprofile_) | |
| 911 return; | |
| 912 | |
| 913 ProfileInfoCache& cache = | 905 ProfileInfoCache& cache = |
| 914 g_browser_process->profile_manager()->GetProfileInfoCache(); | 906 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 915 ListValue profile_info_list; | 907 ListValue* profile_info_list = new ListValue; |
|
sail
2012/04/23 15:44:53
Maybe make this a scoped_ptr and do a release at t
Evan Stade
2012/04/23 20:19:02
that would delete the object
Evan Stade
2012/04/23 21:55:47
Done.
| |
| 916 FilePath current_profile_path = | 908 FilePath current_profile_path = |
| 917 web_ui()->GetWebContents()->GetBrowserContext()->GetPath(); | 909 web_ui()->GetWebContents()->GetBrowserContext()->GetPath(); |
| 910 | |
| 918 for (size_t i = 0, e = cache.GetNumberOfProfiles(); i < e; ++i) { | 911 for (size_t i = 0, e = cache.GetNumberOfProfiles(); i < e; ++i) { |
| 919 DictionaryValue* profile_value = new DictionaryValue(); | 912 DictionaryValue* profile_value = new DictionaryValue(); |
| 920 FilePath profile_path = cache.GetPathOfProfileAtIndex(i); | 913 FilePath profile_path = cache.GetPathOfProfileAtIndex(i); |
| 921 profile_value->SetString("name", cache.GetNameOfProfileAtIndex(i)); | 914 profile_value->SetString("name", cache.GetNameOfProfileAtIndex(i)); |
| 922 profile_value->Set("filePath", base::CreateFilePathValue(profile_path)); | 915 profile_value->Set("filePath", base::CreateFilePathValue(profile_path)); |
| 923 profile_value->SetBoolean("isCurrentProfile", | 916 profile_value->SetBoolean("isCurrentProfile", |
| 924 profile_path == current_profile_path); | 917 profile_path == current_profile_path); |
| 925 | 918 |
| 926 bool is_gaia_picture = | 919 bool is_gaia_picture = |
| 927 cache.IsUsingGAIAPictureOfProfileAtIndex(i) && | 920 cache.IsUsingGAIAPictureOfProfileAtIndex(i) && |
| 928 cache.GetGAIAPictureOfProfileAtIndex(i); | 921 cache.GetGAIAPictureOfProfileAtIndex(i); |
| 929 if (is_gaia_picture) { | 922 if (is_gaia_picture) { |
| 930 gfx::Image icon = profiles::GetAvatarIconForWebUI( | 923 gfx::Image icon = profiles::GetAvatarIconForWebUI( |
| 931 cache.GetAvatarIconOfProfileAtIndex(i), true); | 924 cache.GetAvatarIconOfProfileAtIndex(i), true); |
| 932 profile_value->SetString("iconURL", | 925 profile_value->SetString("iconURL", |
| 933 web_ui_util::GetImageDataUrl(*icon.ToSkBitmap())); | 926 web_ui_util::GetImageDataUrl(*icon.ToSkBitmap())); |
| 934 } else { | 927 } else { |
| 935 size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(i); | 928 size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(i); |
| 936 profile_value->SetString("iconURL", | 929 profile_value->SetString("iconURL", |
| 937 cache.GetDefaultAvatarIconUrl(icon_index)); | 930 cache.GetDefaultAvatarIconUrl(icon_index)); |
| 938 } | 931 } |
| 939 | 932 |
| 940 profile_info_list.Append(profile_value); | 933 profile_info_list->Append(profile_value); |
| 941 } | 934 } |
| 942 | 935 |
| 936 return profile_info_list; | |
| 937 } | |
| 938 | |
| 939 void BrowserOptionsHandler::SendProfilesInfo() { | |
| 940 scoped_ptr<ListValue> profile_info_list(GetProfilesInfoList()); | |
| 943 web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesInfo", | 941 web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesInfo", |
| 944 profile_info_list); | 942 *profile_info_list); |
| 945 } | 943 } |
| 946 | 944 |
| 947 void BrowserOptionsHandler::CreateProfile(const ListValue* args) { | 945 void BrowserOptionsHandler::CreateProfile(const ListValue* args) { |
| 948 // This handler could have been called in managed mode, for example because | 946 // This handler could have been called in managed mode, for example because |
| 949 // the user fiddled with the web inspector. Silently return in this case. | 947 // the user fiddled with the web inspector. Silently return in this case. |
| 950 if (!ProfileManager::IsMultipleProfilesEnabled()) | 948 if (!ProfileManager::IsMultipleProfilesEnabled()) |
| 951 return; | 949 return; |
| 952 ProfileManager::CreateMultiProfileAsync(); | 950 ProfileManager::CreateMultiProfileAsync(); |
| 953 } | 951 } |
| 954 | 952 |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1412 } | 1410 } |
| 1413 | 1411 |
| 1414 void BrowserOptionsHandler::SetupSSLConfigSettings() { | 1412 void BrowserOptionsHandler::SetupSSLConfigSettings() { |
| 1415 base::FundamentalValue checked(rev_checking_enabled_.GetValue()); | 1413 base::FundamentalValue checked(rev_checking_enabled_.GetValue()); |
| 1416 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged()); | 1414 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged()); |
| 1417 web_ui()->CallJavascriptFunction( | 1415 web_ui()->CallJavascriptFunction( |
| 1418 "BrowserOptions.setCheckRevocationCheckboxState", checked, disabled); | 1416 "BrowserOptions.setCheckRevocationCheckboxState", checked, disabled); |
| 1419 } | 1417 } |
| 1420 | 1418 |
| 1421 } // namespace options2 | 1419 } // namespace options2 |
| OLD | NEW |