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/ui/webui/signin/inline_login_handler_impl.h" | 5 #include "chrome/browser/ui/webui/signin/inline_login_handler_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 #include "net/base/url_util.h" | 62 #include "net/base/url_util.h" |
63 #include "ui/base/l10n/l10n_util.h" | 63 #include "ui/base/l10n/l10n_util.h" |
64 | 64 |
65 namespace { | 65 namespace { |
66 | 66 |
67 void LogHistogramValue(int action) { | 67 void LogHistogramValue(int action) { |
68 UMA_HISTOGRAM_ENUMERATION("Signin.AllAccessPointActions", action, | 68 UMA_HISTOGRAM_ENUMERATION("Signin.AllAccessPointActions", action, |
69 signin_metrics::HISTOGRAM_MAX); | 69 signin_metrics::HISTOGRAM_MAX); |
70 } | 70 } |
71 | 71 |
72 bool IsUserManagerReauthenticatingProfile(Profile* profile) { | |
achuithb
2015/09/28 20:11:48
Could you please add a function comment?
Does it
Roger Tawa OOO till Jul 10th
2015/09/28 20:57:11
Done.
| |
73 return profile->GetOriginalProfile()->IsSystemProfile(); | |
74 } | |
75 | |
72 void RedirectToNtpOrAppsPage(content::WebContents* contents, | 76 void RedirectToNtpOrAppsPage(content::WebContents* contents, |
73 signin_metrics::Source source) { | 77 signin_metrics::Source source) { |
74 // Do nothing if a navigation is pending, since this call can be triggered | 78 // Do nothing if a navigation is pending, since this call can be triggered |
75 // from DidStartLoading. This avoids deleting the pending entry while we are | 79 // from DidStartLoading. This avoids deleting the pending entry while we are |
76 // still navigating to it. See crbug/346632. | 80 // still navigating to it. See crbug/346632. |
77 if (contents->GetController().GetPendingEntry()) | 81 if (contents->GetController().GetPendingEntry()) |
78 return; | 82 return; |
79 | 83 |
80 VLOG(1) << "RedirectToNtpOrAppsPage"; | 84 VLOG(1) << "RedirectToNtpOrAppsPage"; |
81 // Redirect to NTP/Apps page and display a confirmation bubble | 85 // Redirect to NTP/Apps page and display a confirmation bubble |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
592 } | 596 } |
593 } | 597 } |
594 } | 598 } |
595 | 599 |
596 return true; | 600 return true; |
597 } | 601 } |
598 | 602 |
599 void InlineLoginHandlerImpl::SetExtraInitParams(base::DictionaryValue& params) { | 603 void InlineLoginHandlerImpl::SetExtraInitParams(base::DictionaryValue& params) { |
600 params.SetString("service", "chromiumsync"); | 604 params.SetString("service", "chromiumsync"); |
601 | 605 |
606 // If this was called from the user manager to reauthenticate the profile, | |
607 // make sure the webui is aware. | |
608 Profile* profile = Profile::FromWebUI(web_ui()); | |
609 if (IsUserManagerReauthenticatingProfile(profile)) | |
610 params.SetBoolean("dontResizeNonEmbeddedPages", true); | |
611 | |
602 content::WebContents* contents = web_ui()->GetWebContents(); | 612 content::WebContents* contents = web_ui()->GetWebContents(); |
603 content::WebContentsObserver::Observe(contents); | 613 content::WebContentsObserver::Observe(contents); |
604 LogHistogramValue(signin_metrics::HISTOGRAM_SHOWN); | 614 LogHistogramValue(signin_metrics::HISTOGRAM_SHOWN); |
605 } | 615 } |
606 | 616 |
607 void InlineLoginHandlerImpl::CompleteLogin(const base::ListValue* args) { | 617 void InlineLoginHandlerImpl::CompleteLogin(const base::ListValue* args) { |
608 content::WebContents* contents = web_ui()->GetWebContents(); | 618 content::WebContents* contents = web_ui()->GetWebContents(); |
609 const GURL& current_url = contents->GetURL(); | 619 const GURL& current_url = contents->GetURL(); |
610 | 620 |
611 const base::DictionaryValue* dict = NULL; | 621 const base::DictionaryValue* dict = NULL; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
648 | 658 |
649 content::StoragePartition* partition = | 659 content::StoragePartition* partition = |
650 content::BrowserContext::GetStoragePartitionForSite( | 660 content::BrowserContext::GetStoragePartitionForSite( |
651 contents->GetBrowserContext(), signin::GetSigninPartitionURL()); | 661 contents->GetBrowserContext(), signin::GetSigninPartitionURL()); |
652 | 662 |
653 // If this was called from the user manager to reauthenticate the profile, | 663 // If this was called from the user manager to reauthenticate the profile, |
654 // the current profile is the system profile. In this case, use the email to | 664 // the current profile is the system profile. In this case, use the email to |
655 // find the right profile to reauthenticate. Otherwise the profile can be | 665 // find the right profile to reauthenticate. Otherwise the profile can be |
656 // taken from web_ui(). | 666 // taken from web_ui(). |
657 Profile* profile = Profile::FromWebUI(web_ui()); | 667 Profile* profile = Profile::FromWebUI(web_ui()); |
658 if (profile->GetOriginalProfile()->IsSystemProfile()) { | 668 if (IsUserManagerReauthenticatingProfile(profile)) { |
659 // Switch to the profile and finish the login. Don't pass a handler pointer | 669 // Switch to the profile and finish the login. Don't pass a handler pointer |
660 // since it will be destroyed before the callback runs. | 670 // since it will be destroyed before the callback runs. |
661 ProfileManager* manager = g_browser_process->profile_manager(); | 671 ProfileManager* manager = g_browser_process->profile_manager(); |
662 base::FilePath path = profiles::GetPathOfProfileWithEmail(manager, email); | 672 base::FilePath path = profiles::GetPathOfProfileWithEmail(manager, email); |
663 if (!path.empty()) { | 673 if (!path.empty()) { |
664 FinishCompleteLoginParams params(nullptr, partition, current_url, path, | 674 FinishCompleteLoginParams params(nullptr, partition, current_url, path, |
665 confirm_untrusted_signin_, email, | 675 confirm_untrusted_signin_, email, |
666 gaia_id, password, session_index, | 676 gaia_id, password, session_index, |
667 choose_what_to_sync); | 677 choose_what_to_sync); |
668 ProfileManager::CreateCallback callback = base::Bind( | 678 ProfileManager::CreateCallback callback = base::Bind( |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
868 } | 878 } |
869 } | 879 } |
870 | 880 |
871 if (show_account_management) { | 881 if (show_account_management) { |
872 browser->window()->ShowAvatarBubbleFromAvatarButton( | 882 browser->window()->ShowAvatarBubbleFromAvatarButton( |
873 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, | 883 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, |
874 signin::ManageAccountsParams()); | 884 signin::ManageAccountsParams()); |
875 } | 885 } |
876 } | 886 } |
877 } | 887 } |
OLD | NEW |