Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: chrome/browser/profiles/profile_window.cc

Issue 1261433013: Implement online reauth UI for Locked Profiles on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix views code Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 : web_contents_(web_contents),
259 email_address_(email_address) {}
260
261 void ReauthDialogObserver::DidStopLoading() {
262 // If the sign in process reaches the termination URL, close the dialog.
263 // Make sure to remove any parts of the URL that gaia might append during
264 // signin.
265 GURL url = web_contents_->GetURL();
Roger Tawa OOO till Jul 10th 2015/08/05 13:36:05 I don't believe this is correct. It should be |we
anthonyvd 2015/08/05 18:20:44 Done.
266 url::Replacements<char> replacements;
267 replacements.ClearQuery();
268 replacements.ClearRef();
269 if (url.ReplaceComponents(replacements) ==
270 GaiaUrls::GetInstance()->signin_completed_continue_url()) {
271 CloseReauthDialog();
272 return;
273 }
274
275 // If still observing the top level web contents, try to find the embedded
276 // webview and observe it instead. The webview may not be found in the
277 // initial page load since it loads asynchronously.
278 if (url.GetOrigin() !=
279 signin::GetReauthURLWithEmail(email_address_).GetOrigin()) {
280 return;
281 }
282
283 std::set<content::WebContents*> content_set;
284 guest_view::GuestViewManager* manager =
285 guest_view::GuestViewManager::FromBrowserContext(
286 web_contents_->GetBrowserContext());
287 if (manager)
288 manager->ForEachGuest(web_contents_, base::Bind(&AddToSet, &content_set));
289 DCHECK_LE(content_set.size(), 1U);
290 if (!content_set.empty())
291 Observe(*content_set.begin());
292 }
293
247 base::FilePath GetPathOfProfileWithEmail(ProfileManager* profile_manager, 294 base::FilePath GetPathOfProfileWithEmail(ProfileManager* profile_manager,
248 const std::string& email) { 295 const std::string& email) {
249 base::string16 profile_email = base::UTF8ToUTF16(email); 296 base::string16 profile_email = base::UTF8ToUTF16(email);
250 std::vector<ProfileAttributesEntry*> entries = 297 std::vector<ProfileAttributesEntry*> entries =
251 profile_manager->GetProfileInfoCache().GetAllProfilesAttributes(); 298 profile_manager->GetProfileInfoCache().GetAllProfilesAttributes();
252 for (ProfileAttributesEntry* entry : entries) { 299 for (ProfileAttributesEntry* entry : entries) {
253 if (entry->GetUserName() == profile_email) 300 if (entry->GetUserName() == profile_email)
254 return entry->GetPath(); 301 return entry->GetPath();
255 } 302 }
256 return base::FilePath(); 303 return base::FilePath();
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 PrefService* local_state = g_browser_process->local_state(); 601 PrefService* local_state = g_browser_process->local_state();
555 const bool dismissed = local_state->GetBoolean( 602 const bool dismissed = local_state->GetBoolean(
556 prefs::kProfileAvatarRightClickTutorialDismissed); 603 prefs::kProfileAvatarRightClickTutorialDismissed);
557 604
558 // Don't show the tutorial if it's already been dismissed or if right-clicking 605 // Don't show the tutorial if it's already been dismissed or if right-clicking
559 // wouldn't show any targets. 606 // wouldn't show any targets.
560 return !dismissed && HasProfileSwitchTargets(profile); 607 return !dismissed && HasProfileSwitchTargets(profile);
561 } 608 }
562 609
563 } // namespace profiles 610 } // namespace profiles
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698