| 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 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 entry->SetString("url", match.destination_url.spec()); | 954 entry->SetString("url", match.destination_url.spec()); |
| 955 suggestions.Append(entry); | 955 suggestions.Append(entry); |
| 956 } | 956 } |
| 957 | 957 |
| 958 web_ui()->CallJavascriptFunction( | 958 web_ui()->CallJavascriptFunction( |
| 959 "BrowserOptions.updateAutocompleteSuggestions", suggestions); | 959 "BrowserOptions.updateAutocompleteSuggestions", suggestions); |
| 960 } | 960 } |
| 961 | 961 |
| 962 void BrowserOptionsHandler::SendProfilesInfo() { | 962 void BrowserOptionsHandler::SendProfilesInfo() { |
| 963 // Set profile creation text and button if multi-profiles switch is on. | 963 // Set profile creation text and button if multi-profiles switch is on. |
| 964 scoped_ptr<Value> visible(Value::CreateBooleanValue(multiprofile_)); | 964 bool profiles_section_visible = multiprofile_ && |
| 965 !g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode); |
| 966 |
| 967 scoped_ptr<Value> visible( |
| 968 Value::CreateBooleanValue(profiles_section_visible)); |
| 965 web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesSectionVisible", | 969 web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesSectionVisible", |
| 966 *visible); | 970 *visible); |
| 967 | 971 |
| 968 if (!multiprofile_) | 972 if (!profiles_section_visible) |
| 969 return; | 973 return; |
| 970 | 974 |
| 971 ProfileInfoCache& cache = | 975 ProfileInfoCache& cache = |
| 972 g_browser_process->profile_manager()->GetProfileInfoCache(); | 976 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 973 ListValue profile_info_list; | 977 ListValue profile_info_list; |
| 974 FilePath current_profile_path = | 978 FilePath current_profile_path = |
| 975 web_ui()->GetWebContents()->GetBrowserContext()->GetPath(); | 979 web_ui()->GetWebContents()->GetBrowserContext()->GetPath(); |
| 976 for (size_t i = 0, e = cache.GetNumberOfProfiles(); i < e; ++i) { | 980 for (size_t i = 0, e = cache.GetNumberOfProfiles(); i < e; ++i) { |
| 977 DictionaryValue* profile_value = new DictionaryValue(); | 981 DictionaryValue* profile_value = new DictionaryValue(); |
| 978 FilePath profile_path = cache.GetPathOfProfileAtIndex(i); | 982 FilePath profile_path = cache.GetPathOfProfileAtIndex(i); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 995 } | 999 } |
| 996 | 1000 |
| 997 profile_info_list.Append(profile_value); | 1001 profile_info_list.Append(profile_value); |
| 998 } | 1002 } |
| 999 | 1003 |
| 1000 web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesInfo", | 1004 web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesInfo", |
| 1001 profile_info_list); | 1005 profile_info_list); |
| 1002 } | 1006 } |
| 1003 | 1007 |
| 1004 void BrowserOptionsHandler::CreateProfile(const ListValue* args) { | 1008 void BrowserOptionsHandler::CreateProfile(const ListValue* args) { |
| 1009 // This handler could have been called in managed mode, for example because |
| 1010 // the user fiddled with the web inspector. Silently return in this case. |
| 1011 if (g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode)) |
| 1012 return; |
| 1005 ProfileManager::CreateMultiProfileAsync(); | 1013 ProfileManager::CreateMultiProfileAsync(); |
| 1006 } | 1014 } |
| 1007 | 1015 |
| 1008 void BrowserOptionsHandler::ObserveThemeChanged() { | 1016 void BrowserOptionsHandler::ObserveThemeChanged() { |
| 1009 Profile* profile = Profile::FromWebUI(web_ui()); | 1017 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1010 #if defined(TOOLKIT_GTK) | 1018 #if defined(TOOLKIT_GTK) |
| 1011 ThemeServiceGtk* theme_service = ThemeServiceGtk::GetFrom(profile); | 1019 ThemeServiceGtk* theme_service = ThemeServiceGtk::GetFrom(profile); |
| 1012 bool is_gtk_theme = theme_service->UsingNativeTheme(); | 1020 bool is_gtk_theme = theme_service->UsingNativeTheme(); |
| 1013 base::FundamentalValue gtk_enabled(!is_gtk_theme); | 1021 base::FundamentalValue gtk_enabled(!is_gtk_theme); |
| 1014 web_ui()->CallJavascriptFunction("BrowserOptions.setGtkThemeButtonEnabled", | 1022 web_ui()->CallJavascriptFunction("BrowserOptions.setGtkThemeButtonEnabled", |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1446 } | 1454 } |
| 1447 | 1455 |
| 1448 void BrowserOptionsHandler::SetupSSLConfigSettings() { | 1456 void BrowserOptionsHandler::SetupSSLConfigSettings() { |
| 1449 base::FundamentalValue checked(rev_checking_enabled_.GetValue()); | 1457 base::FundamentalValue checked(rev_checking_enabled_.GetValue()); |
| 1450 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged()); | 1458 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged()); |
| 1451 web_ui()->CallJavascriptFunction( | 1459 web_ui()->CallJavascriptFunction( |
| 1452 "BrowserOptions.setCheckRevocationCheckboxState", checked, disabled); | 1460 "BrowserOptions.setCheckRevocationCheckboxState", checked, disabled); |
| 1453 } | 1461 } |
| 1454 | 1462 |
| 1455 } // namespace options2 | 1463 } // namespace options2 |
| OLD | NEW |