| 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 17 matching lines...) Expand all Loading... |
| 28 #include "chrome/browser/gpu/gpu_mode_manager.h" | 28 #include "chrome/browser/gpu/gpu_mode_manager.h" |
| 29 #include "chrome/browser/lifetime/application_lifetime.h" | 29 #include "chrome/browser/lifetime/application_lifetime.h" |
| 30 #include "chrome/browser/net/url_fixer_upper.h" | 30 #include "chrome/browser/net/url_fixer_upper.h" |
| 31 #include "chrome/browser/prefs/session_startup_pref.h" | 31 #include "chrome/browser/prefs/session_startup_pref.h" |
| 32 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 32 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
| 33 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" | 33 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" |
| 34 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" | 34 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
| 35 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
| 36 #include "chrome/browser/profiles/profile_info_cache.h" | 36 #include "chrome/browser/profiles/profile_info_cache.h" |
| 37 #include "chrome/browser/profiles/profile_info_util.h" | 37 #include "chrome/browser/profiles/profile_info_util.h" |
| 38 #include "chrome/browser/profiles/profile_manager_util.h" |
| 38 #include "chrome/browser/profiles/profile_metrics.h" | 39 #include "chrome/browser/profiles/profile_metrics.h" |
| 39 #include "chrome/browser/profiles/profile_shortcut_manager.h" | 40 #include "chrome/browser/profiles/profile_shortcut_manager.h" |
| 40 #include "chrome/browser/search/search.h" | 41 #include "chrome/browser/search/search.h" |
| 41 #include "chrome/browser/search_engines/template_url.h" | 42 #include "chrome/browser/search_engines/template_url.h" |
| 42 #include "chrome/browser/search_engines/template_url_service.h" | 43 #include "chrome/browser/search_engines/template_url_service.h" |
| 43 #include "chrome/browser/search_engines/template_url_service_factory.h" | 44 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 44 #include "chrome/browser/service/service_process_control.h" | 45 #include "chrome/browser/service/service_process_control.h" |
| 45 #include "chrome/browser/signin/signin_manager.h" | 46 #include "chrome/browser/signin/signin_manager.h" |
| 46 #include "chrome/browser/signin/signin_manager_factory.h" | 47 #include "chrome/browser/signin/signin_manager_factory.h" |
| 47 #include "chrome/browser/sync/profile_sync_service.h" | 48 #include "chrome/browser/sync/profile_sync_service.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 126 |
| 126 namespace { | 127 namespace { |
| 127 | 128 |
| 128 bool ShouldShowMultiProfilesUserList(chrome::HostDesktopType desktop_type) { | 129 bool ShouldShowMultiProfilesUserList(chrome::HostDesktopType desktop_type) { |
| 129 #if defined(OS_CHROMEOS) | 130 #if defined(OS_CHROMEOS) |
| 130 // On Chrome OS we use different UI for multi-profiles. | 131 // On Chrome OS we use different UI for multi-profiles. |
| 131 return false; | 132 return false; |
| 132 #else | 133 #else |
| 133 if (desktop_type != chrome::HOST_DESKTOP_TYPE_NATIVE) | 134 if (desktop_type != chrome::HOST_DESKTOP_TYPE_NATIVE) |
| 134 return false; | 135 return false; |
| 135 return ProfileManager::IsMultipleProfilesEnabled(); | 136 return profiles::IsMultipleProfilesEnabled(); |
| 136 #endif | 137 #endif |
| 137 } | 138 } |
| 138 | 139 |
| 139 void CreateDesktopShortcutForProfile(Profile* profile, | 140 void CreateDesktopShortcutForProfile(Profile* profile, |
| 140 Profile::CreateStatus status) { | 141 Profile::CreateStatus status) { |
| 141 ProfileShortcutManager* shortcut_manager = | 142 ProfileShortcutManager* shortcut_manager = |
| 142 g_browser_process->profile_manager()->profile_shortcut_manager(); | 143 g_browser_process->profile_manager()->profile_shortcut_manager(); |
| 143 if (shortcut_manager) | 144 if (shortcut_manager) |
| 144 shortcut_manager->CreateProfileShortcut(profile->GetPath()); | 145 shortcut_manager->CreateProfileShortcut(profile->GetPath()); |
| 145 } | 146 } |
| 146 | 147 |
| 147 void RunProfileCreationCallbacks( | 148 void RunProfileCreationCallbacks( |
| 148 const std::vector<ProfileManager::CreateCallback>& callbacks, | 149 const std::vector<ProfileManager::CreateCallback>& callbacks, |
| 149 Profile* profile, | 150 Profile* profile, |
| 150 Profile::CreateStatus status) { | 151 Profile::CreateStatus status) { |
| 151 std::vector<ProfileManager::CreateCallback>::const_iterator it; | 152 std::vector<ProfileManager::CreateCallback>::const_iterator it; |
| 152 for (it = callbacks.begin(); it != callbacks.end(); ++it) { | 153 for (it = callbacks.begin(); it != callbacks.end(); ++it) { |
| 153 it->Run(profile, status); | 154 it->Run(profile, status); |
| 154 } | 155 } |
| 155 } | 156 } |
| 156 | 157 |
| 157 void OpenNewWindowForProfile( | 158 void OpenNewWindowForProfile( |
| 158 chrome::HostDesktopType desktop_type, | 159 chrome::HostDesktopType desktop_type, |
| 159 Profile* profile, | 160 Profile* profile, |
| 160 Profile::CreateStatus status) { | 161 Profile::CreateStatus status) { |
| 161 if (status != Profile::CREATE_STATUS_INITIALIZED) | 162 if (status != Profile::CREATE_STATUS_INITIALIZED) |
| 162 return; | 163 return; |
| 163 | 164 |
| 164 ProfileManager::FindOrCreateNewWindowForProfile( | 165 profiles::FindOrCreateNewWindowForProfile( |
| 165 profile, | 166 profile, |
| 166 chrome::startup::IS_PROCESS_STARTUP, | 167 chrome::startup::IS_PROCESS_STARTUP, |
| 167 chrome::startup::IS_FIRST_RUN, | 168 chrome::startup::IS_FIRST_RUN, |
| 168 desktop_type, | 169 desktop_type, |
| 169 false); | 170 false); |
| 170 } | 171 } |
| 171 | 172 |
| 172 } // namespace | 173 } // namespace |
| 173 | 174 |
| 174 BrowserOptionsHandler::BrowserOptionsHandler() | 175 BrowserOptionsHandler::BrowserOptionsHandler() |
| (...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 | 1105 |
| 1105 void BrowserOptionsHandler::CreateProfile(const ListValue* args) { | 1106 void BrowserOptionsHandler::CreateProfile(const ListValue* args) { |
| 1106 #if defined(ENABLE_MANAGED_USERS) | 1107 #if defined(ENABLE_MANAGED_USERS) |
| 1107 // This handler could have been called in managed mode, for example because | 1108 // This handler could have been called in managed mode, for example because |
| 1108 // the user fiddled with the web inspector. Silently return in this case. | 1109 // the user fiddled with the web inspector. Silently return in this case. |
| 1109 Profile* current_profile = Profile::FromWebUI(web_ui()); | 1110 Profile* current_profile = Profile::FromWebUI(web_ui()); |
| 1110 if (ManagedUserService::ProfileIsManaged(current_profile)) | 1111 if (ManagedUserService::ProfileIsManaged(current_profile)) |
| 1111 return; | 1112 return; |
| 1112 #endif | 1113 #endif |
| 1113 | 1114 |
| 1114 if (!ProfileManager::IsMultipleProfilesEnabled()) | 1115 if (!profiles::IsMultipleProfilesEnabled()) |
| 1115 return; | 1116 return; |
| 1116 | 1117 |
| 1117 DCHECK(profile_path_being_created_.empty()); | 1118 DCHECK(profile_path_being_created_.empty()); |
| 1118 profile_creation_start_time_ = base::TimeTicks::Now(); | 1119 profile_creation_start_time_ = base::TimeTicks::Now(); |
| 1119 | 1120 |
| 1120 string16 name; | 1121 string16 name; |
| 1121 string16 icon; | 1122 string16 icon; |
| 1122 bool create_shortcut = false; | 1123 bool create_shortcut = false; |
| 1123 bool managed_user = false; | 1124 bool managed_user = false; |
| 1124 if (args->GetString(0, &name) && args->GetString(1, &icon)) { | 1125 if (args->GetString(0, &name) && args->GetString(1, &icon)) { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1258 } | 1259 } |
| 1259 | 1260 |
| 1260 void BrowserOptionsHandler::DeleteProfileAtPath(base::FilePath file_path) { | 1261 void BrowserOptionsHandler::DeleteProfileAtPath(base::FilePath file_path) { |
| 1261 #if defined(ENABLE_MANAGED_USERS) | 1262 #if defined(ENABLE_MANAGED_USERS) |
| 1262 // This handler could have been called in managed mode, for example because | 1263 // This handler could have been called in managed mode, for example because |
| 1263 // the user fiddled with the web inspector. Silently return in this case. | 1264 // the user fiddled with the web inspector. Silently return in this case. |
| 1264 if (ManagedUserService::ProfileIsManaged(Profile::FromWebUI(web_ui()))) | 1265 if (ManagedUserService::ProfileIsManaged(Profile::FromWebUI(web_ui()))) |
| 1265 return; | 1266 return; |
| 1266 #endif | 1267 #endif |
| 1267 | 1268 |
| 1268 if (!ProfileManager::IsMultipleProfilesEnabled()) | 1269 if (!profiles::IsMultipleProfilesEnabled()) |
| 1269 return; | 1270 return; |
| 1270 | 1271 |
| 1271 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::PROFILE_DELETED); | 1272 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::PROFILE_DELETED); |
| 1272 | 1273 |
| 1273 g_browser_process->profile_manager()->ScheduleProfileForDeletion( | 1274 g_browser_process->profile_manager()->ScheduleProfileForDeletion( |
| 1274 file_path, | 1275 file_path, |
| 1275 base::Bind(&OpenNewWindowForProfile, GetDesktopType())); | 1276 base::Bind(&OpenNewWindowForProfile, GetDesktopType())); |
| 1276 } | 1277 } |
| 1277 | 1278 |
| 1278 void BrowserOptionsHandler::HandleCancelProfileCreation(const ListValue* args) { | 1279 void BrowserOptionsHandler::HandleCancelProfileCreation(const ListValue* args) { |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1733 base::FundamentalValue disabled(proxy_config && | 1734 base::FundamentalValue disabled(proxy_config && |
| 1734 !proxy_config->IsUserModifiable()); | 1735 !proxy_config->IsUserModifiable()); |
| 1735 base::FundamentalValue extension_controlled(is_extension_controlled); | 1736 base::FundamentalValue extension_controlled(is_extension_controlled); |
| 1736 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection", | 1737 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection", |
| 1737 disabled, extension_controlled); | 1738 disabled, extension_controlled); |
| 1738 | 1739 |
| 1739 #endif // !defined(OS_CHROMEOS) | 1740 #endif // !defined(OS_CHROMEOS) |
| 1740 } | 1741 } |
| 1741 | 1742 |
| 1742 } // namespace options | 1743 } // namespace options |
| OLD | NEW |