OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/manage_profile_handler.h" | 5 #include "chrome/browser/ui/webui/options/manage_profile_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/prefs/scoped_user_pref_update.h" | 11 #include "base/prefs/scoped_user_pref_update.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/value_conversions.h" | 14 #include "base/value_conversions.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| 18 #include "chrome/browser/download/download_service.h" |
| 19 #include "chrome/browser/download/download_service_factory.h" |
18 #include "chrome/browser/profiles/gaia_info_update_service.h" | 20 #include "chrome/browser/profiles/gaia_info_update_service.h" |
19 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/profiles/profile_info_cache.h" | 22 #include "chrome/browser/profiles/profile_info_cache.h" |
21 #include "chrome/browser/profiles/profile_info_util.h" | 23 #include "chrome/browser/profiles/profile_info_util.h" |
22 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
23 #include "chrome/browser/profiles/profile_metrics.h" | 25 #include "chrome/browser/profiles/profile_metrics.h" |
24 #include "chrome/browser/profiles/profile_shortcut_manager.h" | 26 #include "chrome/browser/profiles/profile_shortcut_manager.h" |
25 #include "chrome/browser/profiles/profile_window.h" | 27 #include "chrome/browser/profiles/profile_window.h" |
26 #include "chrome/browser/profiles/profiles_state.h" | 28 #include "chrome/browser/profiles/profiles_state.h" |
27 #include "chrome/browser/signin/signin_manager.h" | 29 #include "chrome/browser/signin/signin_manager.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 IDS_PROFILES_CREATE_MANAGED_NOT_SIGNED_IN_LABEL }, | 96 IDS_PROFILES_CREATE_MANAGED_NOT_SIGNED_IN_LABEL }, |
95 { "manageProfilesManagedAccountDetailsOutOfDate", | 97 { "manageProfilesManagedAccountDetailsOutOfDate", |
96 IDS_PROFILES_CREATE_MANAGED_ACCOUNT_DETAILS_OUT_OF_DATE_LABEL }, | 98 IDS_PROFILES_CREATE_MANAGED_ACCOUNT_DETAILS_OUT_OF_DATE_LABEL }, |
97 { "manageProfilesManagedSignInAgainLink", | 99 { "manageProfilesManagedSignInAgainLink", |
98 IDS_PROFILES_CREATE_MANAGED_ACCOUNT_SIGN_IN_AGAIN_LINK }, | 100 IDS_PROFILES_CREATE_MANAGED_ACCOUNT_SIGN_IN_AGAIN_LINK }, |
99 { "manageProfilesManagedNotSignedInLink", | 101 { "manageProfilesManagedNotSignedInLink", |
100 IDS_PROFILES_CREATE_MANAGED_NOT_SIGNED_IN_LINK }, | 102 IDS_PROFILES_CREATE_MANAGED_NOT_SIGNED_IN_LINK }, |
101 { "deleteProfileTitle", IDS_PROFILES_DELETE_TITLE }, | 103 { "deleteProfileTitle", IDS_PROFILES_DELETE_TITLE }, |
102 { "deleteProfileOK", IDS_PROFILES_DELETE_OK_BUTTON_LABEL }, | 104 { "deleteProfileOK", IDS_PROFILES_DELETE_OK_BUTTON_LABEL }, |
103 { "deleteProfileMessage", IDS_PROFILES_DELETE_MESSAGE }, | 105 { "deleteProfileMessage", IDS_PROFILES_DELETE_MESSAGE }, |
| 106 { "deleteProfileSingleDownloadAddendum", |
| 107 IDS_PROFILES_DELETE_SINGLE_DOWNLOAD_ADDENDUM }, |
| 108 { "deleteProfileMultipleDownloadsAddendum", |
| 109 IDS_PROFILES_DELETE_MULTIPLE_DOWNLOADS_ADDENDUM }, |
104 { "deleteManagedProfileAddendum", IDS_PROFILES_DELETE_MANAGED_ADDENDUM }, | 110 { "deleteManagedProfileAddendum", IDS_PROFILES_DELETE_MANAGED_ADDENDUM }, |
105 { "disconnectManagedProfileTitle", | 111 { "disconnectManagedProfileTitle", |
106 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_TITLE }, | 112 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_TITLE }, |
107 { "disconnectManagedProfileOK", | 113 { "disconnectManagedProfileOK", |
108 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_OK_BUTTON_LABEL }, | 114 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_OK_BUTTON_LABEL }, |
109 { "disconnectManagedProfileText", | 115 { "disconnectManagedProfileText", |
110 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_TEXT }, | 116 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_TEXT }, |
111 { "disconnectManagedProfileLearnMore", | 117 { "disconnectManagedProfileLearnMore", |
112 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_LEARN_MORE }, | 118 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_LEARN_MORE }, |
113 { "createProfileTitle", IDS_PROFILES_CREATE_TITLE }, | 119 { "createProfileTitle", IDS_PROFILES_CREATE_TITLE }, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 web_ui()->RegisterMessageCallback("switchAppListProfile", | 191 web_ui()->RegisterMessageCallback("switchAppListProfile", |
186 base::Bind(&ManageProfileHandler::SwitchAppListProfile, | 192 base::Bind(&ManageProfileHandler::SwitchAppListProfile, |
187 base::Unretained(this))); | 193 base::Unretained(this))); |
188 #endif | 194 #endif |
189 web_ui()->RegisterMessageCallback("addProfileShortcut", | 195 web_ui()->RegisterMessageCallback("addProfileShortcut", |
190 base::Bind(&ManageProfileHandler::AddProfileShortcut, | 196 base::Bind(&ManageProfileHandler::AddProfileShortcut, |
191 base::Unretained(this))); | 197 base::Unretained(this))); |
192 web_ui()->RegisterMessageCallback("removeProfileShortcut", | 198 web_ui()->RegisterMessageCallback("removeProfileShortcut", |
193 base::Bind(&ManageProfileHandler::RemoveProfileShortcut, | 199 base::Bind(&ManageProfileHandler::RemoveProfileShortcut, |
194 base::Unretained(this))); | 200 base::Unretained(this))); |
| 201 web_ui()->RegisterMessageCallback("requestProfileInProgressDownloads", |
| 202 base::Bind(&ManageProfileHandler::RequestProfileInProgressDownloads, |
| 203 base::Unretained(this))); |
195 } | 204 } |
196 | 205 |
197 void ManageProfileHandler::Uninitialize() { | 206 void ManageProfileHandler::Uninitialize() { |
198 registrar_.RemoveAll(); | 207 registrar_.RemoveAll(); |
199 } | 208 } |
200 | 209 |
201 void ManageProfileHandler::Observe( | 210 void ManageProfileHandler::Observe( |
202 int type, | 211 int type, |
203 const content::NotificationSource& source, | 212 const content::NotificationSource& source, |
204 const content::NotificationDetails& details) { | 213 const content::NotificationDetails& details) { |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 ProfileShortcutManager* shortcut_manager = | 484 ProfileShortcutManager* shortcut_manager = |
476 g_browser_process->profile_manager()->profile_shortcut_manager(); | 485 g_browser_process->profile_manager()->profile_shortcut_manager(); |
477 DCHECK(shortcut_manager); | 486 DCHECK(shortcut_manager); |
478 | 487 |
479 shortcut_manager->RemoveProfileShortcuts(profile_file_path); | 488 shortcut_manager->RemoveProfileShortcuts(profile_file_path); |
480 | 489 |
481 // Update the UI buttons. | 490 // Update the UI buttons. |
482 OnHasProfileShortcuts(false); | 491 OnHasProfileShortcuts(false); |
483 } | 492 } |
484 | 493 |
| 494 void ManageProfileHandler::RequestProfileInProgressDownloads( |
| 495 const base::ListValue* args) { |
| 496 base::FilePath profile_file_path; |
| 497 if (!GetProfilePathFromArgs(args, &profile_file_path)) |
| 498 return; |
| 499 |
| 500 int downloads_in_progress = 0; |
| 501 Profile* profile = |
| 502 g_browser_process->profile_manager()->GetProfileByPath(profile_file_path); |
| 503 if (profile) { |
| 504 DownloadService* service = |
| 505 DownloadServiceFactory::GetForBrowserContext(profile); |
| 506 downloads_in_progress = service->NonMaliciousDownloadCount(); |
| 507 } |
| 508 base::FundamentalValue value(downloads_in_progress); |
| 509 web_ui()->CallJavascriptFunction("ManageProfileOverlay.receiveDownloadCount", |
| 510 value); |
| 511 } |
| 512 |
485 } // namespace options | 513 } // namespace options |
OLD | NEW |