OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/profiles/profile_window.h" | 5 #include "chrome/browser/profiles/profile_window.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/about_flags.h" | 12 #include "chrome/browser/about_flags.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/lifetime/application_lifetime.h" | 14 #include "chrome/browser/lifetime/application_lifetime.h" |
15 #include "chrome/browser/pref_service_flags_storage.h" | 15 #include "chrome/browser/pref_service_flags_storage.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 17 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
18 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
19 #include "chrome/browser/signin/account_reconcilor_factory.h" | 19 #include "chrome/browser/signin/account_reconcilor_factory.h" |
20 #include "chrome/browser/signin/account_tracker_service_factory.h" | 20 #include "chrome/browser/signin/account_tracker_service_factory.h" |
21 #include "chrome/browser/signin/signin_manager_factory.h" | 21 #include "chrome/browser/signin/signin_manager_factory.h" |
| 22 #include "chrome/browser/signin/signin_promo.h" |
22 #include "chrome/browser/signin/signin_ui_util.h" | 23 #include "chrome/browser/signin/signin_ui_util.h" |
23 #include "chrome/browser/sync/profile_sync_service.h" | 24 #include "chrome/browser/sync/profile_sync_service.h" |
24 #include "chrome/browser/sync/profile_sync_service_factory.h" | 25 #include "chrome/browser/sync/profile_sync_service_factory.h" |
25 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
26 #include "chrome/browser/ui/browser_dialogs.h" | 27 #include "chrome/browser/ui/browser_dialogs.h" |
27 #include "chrome/browser/ui/profile_chooser_constants.h" | 28 #include "chrome/browser/ui/profile_chooser_constants.h" |
28 #include "chrome/browser/ui/user_manager.h" | 29 #include "chrome/browser/ui/user_manager.h" |
29 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
30 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
31 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
| 33 #include "components/guest_view/browser/guest_view_manager.h" |
32 #include "components/signin/core/browser/account_reconcilor.h" | 34 #include "components/signin/core/browser/account_reconcilor.h" |
33 #include "components/signin/core/browser/account_tracker_service.h" | 35 #include "components/signin/core/browser/account_tracker_service.h" |
34 #include "components/signin/core/browser/signin_manager.h" | 36 #include "components/signin/core/browser/signin_manager.h" |
35 #include "components/signin/core/common/profile_management_switches.h" | 37 #include "components/signin/core/common/profile_management_switches.h" |
36 #include "content/public/browser/browser_thread.h" | 38 #include "content/public/browser/browser_thread.h" |
37 #include "content/public/browser/user_metrics.h" | 39 #include "content/public/browser/user_metrics.h" |
| 40 #include "google_apis/gaia/gaia_urls.h" |
38 | 41 |
39 #if defined(ENABLE_EXTENSIONS) | 42 #if defined(ENABLE_EXTENSIONS) |
40 #include "chrome/browser/extensions/extension_service.h" | 43 #include "chrome/browser/extensions/extension_service.h" |
41 #include "extensions/browser/extension_prefs.h" | 44 #include "extensions/browser/extension_prefs.h" |
42 #include "extensions/browser/extension_registry.h" | 45 #include "extensions/browser/extension_registry.h" |
43 #include "extensions/browser/extension_registry_factory.h" | 46 #include "extensions/browser/extension_registry_factory.h" |
44 #include "extensions/browser/extension_system.h" | 47 #include "extensions/browser/extension_system.h" |
45 #endif // defined(ENABLE_EXTENSIONS) | 48 #endif // defined(ENABLE_EXTENSIONS) |
46 | 49 |
47 #if !defined(OS_IOS) | 50 #if !defined(OS_IOS) |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 228 |
226 // Updates Chrome services that require notification when | 229 // Updates Chrome services that require notification when |
227 // the new_profile_management's status changes. | 230 // the new_profile_management's status changes. |
228 void UpdateServicesWithNewProfileManagementFlag(Profile* profile, | 231 void UpdateServicesWithNewProfileManagementFlag(Profile* profile, |
229 bool new_flag_status) { | 232 bool new_flag_status) { |
230 AccountReconcilor* account_reconcilor = | 233 AccountReconcilor* account_reconcilor = |
231 AccountReconcilorFactory::GetForProfile(profile); | 234 AccountReconcilorFactory::GetForProfile(profile); |
232 account_reconcilor->OnNewProfileManagementFlagChanged(new_flag_status); | 235 account_reconcilor->OnNewProfileManagementFlagChanged(new_flag_status); |
233 } | 236 } |
234 | 237 |
| 238 bool AddToSet(std::set<content::WebContents*>* content_set, |
| 239 content::WebContents* web_contents) { |
| 240 content_set->insert(web_contents); |
| 241 return false; |
| 242 } |
| 243 |
235 } // namespace | 244 } // namespace |
236 | 245 |
237 namespace profiles { | 246 namespace profiles { |
238 | 247 |
239 // User Manager parameters are prefixed with hash. | 248 // User Manager parameters are prefixed with hash. |
240 const char kUserManagerDisplayTutorial[] = "#tutorial"; | 249 const char kUserManagerDisplayTutorial[] = "#tutorial"; |
241 const char kUserManagerSelectProfileTaskManager[] = "#task-manager"; | 250 const char kUserManagerSelectProfileTaskManager[] = "#task-manager"; |
242 const char kUserManagerSelectProfileAboutChrome[] = "#about-chrome"; | 251 const char kUserManagerSelectProfileAboutChrome[] = "#about-chrome"; |
243 const char kUserManagerSelectProfileChromeSettings[] = "#chrome-settings"; | 252 const char kUserManagerSelectProfileChromeSettings[] = "#chrome-settings"; |
244 const char kUserManagerSelectProfileChromeMemory[] = "#chrome-memory"; | 253 const char kUserManagerSelectProfileChromeMemory[] = "#chrome-memory"; |
245 const char kUserManagerSelectProfileAppLauncher[] = "#app-launcher"; | 254 const char kUserManagerSelectProfileAppLauncher[] = "#app-launcher"; |
246 | 255 |
| 256 ReauthDialogObserver::ReauthDialogObserver(content::WebContents* web_contents, |
| 257 const std::string& email_address) |
| 258 : email_address_(email_address) { |
| 259 // Observe navigations of the web contents so that the dialog can close itself |
| 260 // when the sign in process is done. |
| 261 Observe(web_contents); |
| 262 } |
| 263 |
| 264 void ReauthDialogObserver::DidStopLoading() { |
| 265 // If the sign in process reaches the termination URL, close the dialog. |
| 266 // Make sure to remove any parts of the URL that gaia might append during |
| 267 // signin. |
| 268 GURL url = web_contents()->GetURL(); |
| 269 url::Replacements<char> replacements; |
| 270 replacements.ClearQuery(); |
| 271 replacements.ClearRef(); |
| 272 if (url.ReplaceComponents(replacements) == |
| 273 GaiaUrls::GetInstance()->signin_completed_continue_url()) { |
| 274 CloseReauthDialog(); |
| 275 return; |
| 276 } |
| 277 |
| 278 // If still observing the top level web contents, try to find the embedded |
| 279 // webview and observe it instead. The webview may not be found in the |
| 280 // initial page load since it loads asynchronously. |
| 281 if (url.GetOrigin() != |
| 282 signin::GetReauthURLWithEmail(email_address_).GetOrigin()) { |
| 283 return; |
| 284 } |
| 285 |
| 286 std::set<content::WebContents*> content_set; |
| 287 guest_view::GuestViewManager* manager = |
| 288 guest_view::GuestViewManager::FromBrowserContext( |
| 289 web_contents()->GetBrowserContext()); |
| 290 if (manager) |
| 291 manager->ForEachGuest(web_contents(), base::Bind(&AddToSet, &content_set)); |
| 292 DCHECK_LE(content_set.size(), 1U); |
| 293 if (!content_set.empty()) |
| 294 Observe(*content_set.begin()); |
| 295 } |
| 296 |
247 base::FilePath GetPathOfProfileWithEmail(ProfileManager* profile_manager, | 297 base::FilePath GetPathOfProfileWithEmail(ProfileManager* profile_manager, |
248 const std::string& email) { | 298 const std::string& email) { |
249 base::string16 profile_email = base::UTF8ToUTF16(email); | 299 base::string16 profile_email = base::UTF8ToUTF16(email); |
250 std::vector<ProfileAttributesEntry*> entries = | 300 std::vector<ProfileAttributesEntry*> entries = |
251 profile_manager->GetProfileInfoCache().GetAllProfilesAttributes(); | 301 profile_manager->GetProfileInfoCache().GetAllProfilesAttributes(); |
252 for (ProfileAttributesEntry* entry : entries) { | 302 for (ProfileAttributesEntry* entry : entries) { |
253 if (entry->GetUserName() == profile_email) | 303 if (entry->GetUserName() == profile_email) |
254 return entry->GetPath(); | 304 return entry->GetPath(); |
255 } | 305 } |
256 return base::FilePath(); | 306 return base::FilePath(); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 PrefService* local_state = g_browser_process->local_state(); | 604 PrefService* local_state = g_browser_process->local_state(); |
555 const bool dismissed = local_state->GetBoolean( | 605 const bool dismissed = local_state->GetBoolean( |
556 prefs::kProfileAvatarRightClickTutorialDismissed); | 606 prefs::kProfileAvatarRightClickTutorialDismissed); |
557 | 607 |
558 // Don't show the tutorial if it's already been dismissed or if right-clicking | 608 // Don't show the tutorial if it's already been dismissed or if right-clicking |
559 // wouldn't show any targets. | 609 // wouldn't show any targets. |
560 return !dismissed && HasProfileSwitchTargets(profile); | 610 return !dismissed && HasProfileSwitchTargets(profile); |
561 } | 611 } |
562 | 612 |
563 } // namespace profiles | 613 } // namespace profiles |
OLD | NEW |