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/options/browser_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/browser_options_handler.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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 return; // Still processing. | 776 return; // Still processing. |
777 | 777 |
778 SetDefaultBrowserUIString(status_string_id); | 778 SetDefaultBrowserUIString(status_string_id); |
779 } | 779 } |
780 | 780 |
781 bool BrowserOptionsHandler::IsInteractiveSetDefaultPermitted() { | 781 bool BrowserOptionsHandler::IsInteractiveSetDefaultPermitted() { |
782 return true; // This is UI so we can allow it. | 782 return true; // This is UI so we can allow it. |
783 } | 783 } |
784 | 784 |
785 void BrowserOptionsHandler::SetDefaultBrowserUIString(int status_string_id) { | 785 void BrowserOptionsHandler::SetDefaultBrowserUIString(int status_string_id) { |
786 scoped_ptr<Value> status_string(Value::CreateStringValue( | 786 base::StringValue status_string( |
787 l10n_util::GetStringFUTF16(status_string_id, | 787 l10n_util::GetStringFUTF16(status_string_id, |
788 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)))); | 788 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
789 | 789 |
790 scoped_ptr<Value> is_default(Value::CreateBooleanValue( | 790 base::FundamentalValue is_default( |
791 status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT)); | 791 status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT); |
792 | 792 |
793 scoped_ptr<Value> can_be_default(Value::CreateBooleanValue( | 793 base::FundamentalValue can_be_default( |
794 !default_browser_policy_.IsManaged() && | 794 !default_browser_policy_.IsManaged() && |
795 (status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT || | 795 (status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT || |
796 status_string_id == IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT))); | 796 status_string_id == IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT)); |
797 | 797 |
798 web_ui()->CallJavascriptFunction( | 798 web_ui()->CallJavascriptFunction( |
799 "BrowserOptions.updateDefaultBrowserState", | 799 "BrowserOptions.updateDefaultBrowserState", |
800 *status_string, *is_default, *can_be_default); | 800 status_string, is_default, can_be_default); |
801 } | 801 } |
802 | 802 |
803 void BrowserOptionsHandler::OnTemplateURLServiceChanged() { | 803 void BrowserOptionsHandler::OnTemplateURLServiceChanged() { |
804 if (!template_url_service_ || !template_url_service_->loaded()) | 804 if (!template_url_service_ || !template_url_service_->loaded()) |
805 return; | 805 return; |
806 | 806 |
807 const TemplateURL* default_url = | 807 const TemplateURL* default_url = |
808 template_url_service_->GetDefaultSearchProvider(); | 808 template_url_service_->GetDefaultSearchProvider(); |
809 | 809 |
810 int default_index = -1; | 810 int default_index = -1; |
811 ListValue search_engines; | 811 ListValue search_engines; |
812 TemplateURLService::TemplateURLVector model_urls( | 812 TemplateURLService::TemplateURLVector model_urls( |
813 template_url_service_->GetTemplateURLs()); | 813 template_url_service_->GetTemplateURLs()); |
814 for (size_t i = 0; i < model_urls.size(); ++i) { | 814 for (size_t i = 0; i < model_urls.size(); ++i) { |
815 if (!model_urls[i]->ShowInDefaultList()) | 815 if (!model_urls[i]->ShowInDefaultList()) |
816 continue; | 816 continue; |
817 | 817 |
818 DictionaryValue* entry = new DictionaryValue(); | 818 DictionaryValue* entry = new DictionaryValue(); |
819 entry->SetString("name", model_urls[i]->short_name()); | 819 entry->SetString("name", model_urls[i]->short_name()); |
820 entry->SetInteger("index", i); | 820 entry->SetInteger("index", i); |
821 search_engines.Append(entry); | 821 search_engines.Append(entry); |
822 if (model_urls[i] == default_url) | 822 if (model_urls[i] == default_url) |
823 default_index = i; | 823 default_index = i; |
824 } | 824 } |
825 | 825 |
826 scoped_ptr<Value> default_value(Value::CreateIntegerValue(default_index)); | 826 web_ui()->CallJavascriptFunction( |
827 scoped_ptr<Value> default_managed(Value::CreateBooleanValue( | 827 "BrowserOptions.updateSearchEngines", |
828 template_url_service_->is_default_search_managed())); | 828 search_engines, |
829 | 829 base::FundamentalValue(default_index), |
830 web_ui()->CallJavascriptFunction("BrowserOptions.updateSearchEngines", | 830 base::FundamentalValue( |
831 search_engines, *default_value, | 831 template_url_service_->is_default_search_managed())); |
832 *default_managed); | |
833 } | 832 } |
834 | 833 |
835 // static | 834 // static |
836 void BrowserOptionsHandler::CreateDesktopShortcutForProfile( | 835 void BrowserOptionsHandler::CreateDesktopShortcutForProfile( |
837 Profile* profile, Profile::CreateStatus status) { | 836 Profile* profile, Profile::CreateStatus status) { |
838 ProfileShortcutManager* shortcut_manager = | 837 ProfileShortcutManager* shortcut_manager = |
839 g_browser_process->profile_manager()->profile_shortcut_manager(); | 838 g_browser_process->profile_manager()->profile_shortcut_manager(); |
840 if (shortcut_manager) | 839 if (shortcut_manager) |
841 shortcut_manager->CreateProfileShortcut(profile->GetPath()); | 840 shortcut_manager->CreateProfileShortcut(profile->GetPath()); |
842 } | 841 } |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1369 // Each item in the list has the following parameters: | 1368 // Each item in the list has the following parameters: |
1370 // 1. Title (string). | 1369 // 1. Title (string). |
1371 // 2. Value (double). | 1370 // 2. Value (double). |
1372 // 3. Is selected? (bool). | 1371 // 3. Is selected? (bool). |
1373 ListValue zoom_factors_value; | 1372 ListValue zoom_factors_value; |
1374 for (std::vector<double>::const_iterator i = zoom_factors.begin(); | 1373 for (std::vector<double>::const_iterator i = zoom_factors.begin(); |
1375 i != zoom_factors.end(); ++i) { | 1374 i != zoom_factors.end(); ++i) { |
1376 ListValue* option = new ListValue(); | 1375 ListValue* option = new ListValue(); |
1377 double factor = *i; | 1376 double factor = *i; |
1378 int percent = static_cast<int>(factor * 100 + 0.5); | 1377 int percent = static_cast<int>(factor * 100 + 0.5); |
1379 option->Append(Value::CreateStringValue( | 1378 option->Append(new base::StringValue( |
1380 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, percent))); | 1379 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, percent))); |
1381 option->Append(Value::CreateDoubleValue(factor)); | 1380 option->Append(new base::FundamentalValue(factor)); |
1382 bool selected = content::ZoomValuesEqual(factor, default_zoom_factor); | 1381 bool selected = content::ZoomValuesEqual(factor, default_zoom_factor); |
1383 option->Append(Value::CreateBooleanValue(selected)); | 1382 option->Append(new base::FundamentalValue(selected)); |
1384 zoom_factors_value.Append(option); | 1383 zoom_factors_value.Append(option); |
1385 } | 1384 } |
1386 | 1385 |
1387 web_ui()->CallJavascriptFunction( | 1386 web_ui()->CallJavascriptFunction( |
1388 "BrowserOptions.setupPageZoomSelector", zoom_factors_value); | 1387 "BrowserOptions.setupPageZoomSelector", zoom_factors_value); |
1389 } | 1388 } |
1390 | 1389 |
1391 void BrowserOptionsHandler::SetupAutoOpenFileTypes() { | 1390 void BrowserOptionsHandler::SetupAutoOpenFileTypes() { |
1392 // Set the hidden state for the AutoOpenFileTypesResetToDefault button. | 1391 // Set the hidden state for the AutoOpenFileTypesResetToDefault button. |
1393 // We show the button if the user has any auto-open file types registered. | 1392 // We show the button if the user has any auto-open file types registered. |
(...skipping 28 matching lines...) Expand all Loading... |
1422 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 1421 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
1423 } | 1422 } |
1424 StringValue label(label_str); | 1423 StringValue label(label_str); |
1425 | 1424 |
1426 web_ui()->CallJavascriptFunction( | 1425 web_ui()->CallJavascriptFunction( |
1427 "BrowserOptions.setupProxySettingsSection", disabled, label); | 1426 "BrowserOptions.setupProxySettingsSection", disabled, label); |
1428 #endif // !defined(OS_CHROMEOS) | 1427 #endif // !defined(OS_CHROMEOS) |
1429 } | 1428 } |
1430 | 1429 |
1431 } // namespace options | 1430 } // namespace options |
OLD | NEW |