| 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 "apps/app_window.h" | 10 #include "apps/app_window.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 using base::UserMetricsAction; | 130 using base::UserMetricsAction; |
| 131 using content::BrowserContext; | 131 using content::BrowserContext; |
| 132 using content::BrowserThread; | 132 using content::BrowserThread; |
| 133 using content::DownloadManager; | 133 using content::DownloadManager; |
| 134 using content::OpenURLParams; | 134 using content::OpenURLParams; |
| 135 using content::Referrer; | 135 using content::Referrer; |
| 136 | 136 |
| 137 namespace options { | 137 namespace options { |
| 138 | 138 |
| 139 namespace { | |
| 140 | |
| 141 bool ShouldShowMultiProfilesUserList(chrome::HostDesktopType desktop_type) { | |
| 142 #if defined(OS_CHROMEOS) | |
| 143 // On Chrome OS we use different UI for multi-profiles. | |
| 144 return false; | |
| 145 #else | |
| 146 if (desktop_type != chrome::HOST_DESKTOP_TYPE_NATIVE) | |
| 147 return false; | |
| 148 return profiles::IsMultipleProfilesEnabled(); | |
| 149 #endif | |
| 150 } | |
| 151 | |
| 152 } // namespace | |
| 153 | |
| 154 BrowserOptionsHandler::BrowserOptionsHandler() | 139 BrowserOptionsHandler::BrowserOptionsHandler() |
| 155 : page_initialized_(false), | 140 : page_initialized_(false), |
| 156 template_url_service_(NULL), | 141 template_url_service_(NULL), |
| 157 cloud_print_mdns_ui_enabled_(false), | 142 cloud_print_mdns_ui_enabled_(false), |
| 158 weak_ptr_factory_(this) { | 143 weak_ptr_factory_(this) { |
| 159 #if !defined(OS_MACOSX) | 144 #if !defined(OS_MACOSX) |
| 160 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this); | 145 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this); |
| 161 #endif | 146 #endif |
| 162 | 147 |
| 163 #if defined(ENABLE_FULL_PRINTING) | 148 #if defined(ENABLE_FULL_PRINTING) |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 "shouldShowAppListHotword", should_show_app_list_hotword.release()); | 541 "shouldShowAppListHotword", should_show_app_list_hotword.release()); |
| 557 #endif | 542 #endif |
| 558 | 543 |
| 559 #if defined(OS_MACOSX) | 544 #if defined(OS_MACOSX) |
| 560 values->SetString("macPasswordsWarning", | 545 values->SetString("macPasswordsWarning", |
| 561 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_MAC_WARNING)); | 546 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_MAC_WARNING)); |
| 562 values->SetBoolean("multiple_profiles", | 547 values->SetBoolean("multiple_profiles", |
| 563 g_browser_process->profile_manager()->GetNumberOfProfiles() > 1); | 548 g_browser_process->profile_manager()->GetNumberOfProfiles() > 1); |
| 564 #endif | 549 #endif |
| 565 | 550 |
| 566 if (ShouldShowMultiProfilesUserList(helper::GetDesktopType(web_ui()))) | 551 if (ShouldShowMultiProfilesUserList()) |
| 567 values->Set("profilesInfo", GetProfilesInfoList().release()); | 552 values->Set("profilesInfo", GetProfilesInfoList().release()); |
| 568 | 553 |
| 569 values->SetBoolean("profileIsManaged", | 554 values->SetBoolean("profileIsManaged", |
| 570 Profile::FromWebUI(web_ui())->IsManaged()); | 555 Profile::FromWebUI(web_ui())->IsManaged()); |
| 571 | 556 |
| 572 #if !defined(OS_CHROMEOS) | 557 #if !defined(OS_CHROMEOS) |
| 573 values->SetBoolean( | 558 values->SetBoolean( |
| 574 "gpuEnabledAtStart", | 559 "gpuEnabledAtStart", |
| 575 g_browser_process->gpu_mode_manager()->initial_gpu_mode_pref()); | 560 g_browser_process->gpu_mode_manager()->initial_gpu_mode_pref()); |
| 576 #endif | 561 #endif |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 bool BrowserOptionsHandler::ShouldShowSetDefaultBrowser() { | 919 bool BrowserOptionsHandler::ShouldShowSetDefaultBrowser() { |
| 935 #if defined(OS_CHROMEOS) | 920 #if defined(OS_CHROMEOS) |
| 936 // We're always the default browser on ChromeOS. | 921 // We're always the default browser on ChromeOS. |
| 937 return false; | 922 return false; |
| 938 #else | 923 #else |
| 939 Profile* profile = Profile::FromWebUI(web_ui()); | 924 Profile* profile = Profile::FromWebUI(web_ui()); |
| 940 return !profile->IsGuestSession(); | 925 return !profile->IsGuestSession(); |
| 941 #endif | 926 #endif |
| 942 } | 927 } |
| 943 | 928 |
| 929 bool BrowserOptionsHandler::ShouldShowMultiProfilesUserList() { |
| 930 #if defined(OS_CHROMEOS) |
| 931 // On Chrome OS we use different UI for multi-profiles. |
| 932 return false; |
| 933 #else |
| 934 if (helper::GetDesktopType(web_ui()) != chrome::HOST_DESKTOP_TYPE_NATIVE) |
| 935 return false; |
| 936 Profile* profile = Profile::FromWebUI(web_ui()); |
| 937 if (profile->IsGuestSession()) |
| 938 return false; |
| 939 return profiles::IsMultipleProfilesEnabled(); |
| 940 #endif |
| 941 } |
| 942 |
| 944 void BrowserOptionsHandler::UpdateDefaultBrowserState() { | 943 void BrowserOptionsHandler::UpdateDefaultBrowserState() { |
| 945 #if defined(OS_MACOSX) | 944 #if defined(OS_MACOSX) |
| 946 ShellIntegration::DefaultWebClientState state = | 945 ShellIntegration::DefaultWebClientState state = |
| 947 ShellIntegration::GetDefaultBrowser(); | 946 ShellIntegration::GetDefaultBrowser(); |
| 948 int status_string_id; | 947 int status_string_id; |
| 949 if (state == ShellIntegration::IS_DEFAULT) | 948 if (state == ShellIntegration::IS_DEFAULT) |
| 950 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_DEFAULT; | 949 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_DEFAULT; |
| 951 else if (state == ShellIntegration::NOT_DEFAULT) | 950 else if (state == ShellIntegration::NOT_DEFAULT) |
| 952 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT; | 951 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT; |
| 953 else | 952 else |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 cache.GetDefaultAvatarIconUrl(icon_index)); | 1181 cache.GetDefaultAvatarIconUrl(icon_index)); |
| 1183 } | 1182 } |
| 1184 | 1183 |
| 1185 profile_info_list->Append(profile_value); | 1184 profile_info_list->Append(profile_value); |
| 1186 } | 1185 } |
| 1187 | 1186 |
| 1188 return profile_info_list.Pass(); | 1187 return profile_info_list.Pass(); |
| 1189 } | 1188 } |
| 1190 | 1189 |
| 1191 void BrowserOptionsHandler::SendProfilesInfo() { | 1190 void BrowserOptionsHandler::SendProfilesInfo() { |
| 1192 if (!ShouldShowMultiProfilesUserList(helper::GetDesktopType(web_ui()))) | 1191 if (!ShouldShowMultiProfilesUserList()) |
| 1193 return; | 1192 return; |
| 1194 web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesInfo", | 1193 web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesInfo", |
| 1195 *GetProfilesInfoList()); | 1194 *GetProfilesInfoList()); |
| 1196 } | 1195 } |
| 1197 | 1196 |
| 1198 void BrowserOptionsHandler::DeleteProfile(const base::ListValue* args) { | 1197 void BrowserOptionsHandler::DeleteProfile(const base::ListValue* args) { |
| 1199 DCHECK(args); | 1198 DCHECK(args); |
| 1200 const base::Value* file_path_value; | 1199 const base::Value* file_path_value; |
| 1201 if (!args->Get(0, &file_path_value)) | 1200 if (!args->Get(0, &file_path_value)) |
| 1202 return; | 1201 return; |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1725 void BrowserOptionsHandler::SetupManagingSupervisedUsers() { | 1724 void BrowserOptionsHandler::SetupManagingSupervisedUsers() { |
| 1726 bool has_users = !Profile::FromWebUI(web_ui())-> | 1725 bool has_users = !Profile::FromWebUI(web_ui())-> |
| 1727 GetPrefs()->GetDictionary(prefs::kManagedUsers)->empty(); | 1726 GetPrefs()->GetDictionary(prefs::kManagedUsers)->empty(); |
| 1728 base::FundamentalValue has_users_value(has_users); | 1727 base::FundamentalValue has_users_value(has_users); |
| 1729 web_ui()->CallJavascriptFunction( | 1728 web_ui()->CallJavascriptFunction( |
| 1730 "BrowserOptions.updateManagesSupervisedUsers", | 1729 "BrowserOptions.updateManagesSupervisedUsers", |
| 1731 has_users_value); | 1730 has_users_value); |
| 1732 } | 1731 } |
| 1733 | 1732 |
| 1734 } // namespace options | 1733 } // namespace options |
| OLD | NEW |