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 // Returns true if |profile| is a system profile or created from one. |
| 73 bool IsSystemProfile(Profile* profile) { |
| 74 return profile->GetOriginalProfile()->IsSystemProfile(); |
| 75 } |
| 76 |
72 void RedirectToNtpOrAppsPage(content::WebContents* contents, | 77 void RedirectToNtpOrAppsPage(content::WebContents* contents, |
73 signin_metrics::Source source) { | 78 signin_metrics::Source source) { |
74 // Do nothing if a navigation is pending, since this call can be triggered | 79 // 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 | 80 // from DidStartLoading. This avoids deleting the pending entry while we are |
76 // still navigating to it. See crbug/346632. | 81 // still navigating to it. See crbug/346632. |
77 if (contents->GetController().GetPendingEntry()) | 82 if (contents->GetController().GetPendingEntry()) |
78 return; | 83 return; |
79 | 84 |
80 VLOG(1) << "RedirectToNtpOrAppsPage"; | 85 VLOG(1) << "RedirectToNtpOrAppsPage"; |
81 // Redirect to NTP/Apps page and display a confirmation bubble | 86 // Redirect to NTP/Apps page and display a confirmation bubble |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 } | 597 } |
593 } | 598 } |
594 } | 599 } |
595 | 600 |
596 return true; | 601 return true; |
597 } | 602 } |
598 | 603 |
599 void InlineLoginHandlerImpl::SetExtraInitParams(base::DictionaryValue& params) { | 604 void InlineLoginHandlerImpl::SetExtraInitParams(base::DictionaryValue& params) { |
600 params.SetString("service", "chromiumsync"); | 605 params.SetString("service", "chromiumsync"); |
601 | 606 |
| 607 // If this was called from the user manager to reauthenticate the profile, |
| 608 // make sure the webui is aware. |
| 609 Profile* profile = Profile::FromWebUI(web_ui()); |
| 610 if (IsSystemProfile(profile)) |
| 611 params.SetBoolean("dontResizeNonEmbeddedPages", true); |
| 612 |
602 content::WebContents* contents = web_ui()->GetWebContents(); | 613 content::WebContents* contents = web_ui()->GetWebContents(); |
603 content::WebContentsObserver::Observe(contents); | 614 content::WebContentsObserver::Observe(contents); |
604 LogHistogramValue(signin_metrics::HISTOGRAM_SHOWN); | 615 LogHistogramValue(signin_metrics::HISTOGRAM_SHOWN); |
605 } | 616 } |
606 | 617 |
607 void InlineLoginHandlerImpl::CompleteLogin(const base::ListValue* args) { | 618 void InlineLoginHandlerImpl::CompleteLogin(const base::ListValue* args) { |
608 content::WebContents* contents = web_ui()->GetWebContents(); | 619 content::WebContents* contents = web_ui()->GetWebContents(); |
609 const GURL& current_url = contents->GetURL(); | 620 const GURL& current_url = contents->GetURL(); |
610 | 621 |
611 const base::DictionaryValue* dict = NULL; | 622 const base::DictionaryValue* dict = NULL; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 | 659 |
649 content::StoragePartition* partition = | 660 content::StoragePartition* partition = |
650 content::BrowserContext::GetStoragePartitionForSite( | 661 content::BrowserContext::GetStoragePartitionForSite( |
651 contents->GetBrowserContext(), signin::GetSigninPartitionURL()); | 662 contents->GetBrowserContext(), signin::GetSigninPartitionURL()); |
652 | 663 |
653 // If this was called from the user manager to reauthenticate the profile, | 664 // 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 | 665 // 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 | 666 // find the right profile to reauthenticate. Otherwise the profile can be |
656 // taken from web_ui(). | 667 // taken from web_ui(). |
657 Profile* profile = Profile::FromWebUI(web_ui()); | 668 Profile* profile = Profile::FromWebUI(web_ui()); |
658 if (profile->GetOriginalProfile()->IsSystemProfile()) { | 669 if (IsSystemProfile(profile)) { |
659 // Switch to the profile and finish the login. Don't pass a handler pointer | 670 // Switch to the profile and finish the login. Don't pass a handler pointer |
660 // since it will be destroyed before the callback runs. | 671 // since it will be destroyed before the callback runs. |
661 ProfileManager* manager = g_browser_process->profile_manager(); | 672 ProfileManager* manager = g_browser_process->profile_manager(); |
662 base::FilePath path = profiles::GetPathOfProfileWithEmail(manager, email); | 673 base::FilePath path = profiles::GetPathOfProfileWithEmail(manager, email); |
663 if (!path.empty()) { | 674 if (!path.empty()) { |
664 FinishCompleteLoginParams params(nullptr, partition, current_url, path, | 675 FinishCompleteLoginParams params(nullptr, partition, current_url, path, |
665 confirm_untrusted_signin_, email, | 676 confirm_untrusted_signin_, email, |
666 gaia_id, password, session_index, | 677 gaia_id, password, session_index, |
667 choose_what_to_sync); | 678 choose_what_to_sync); |
668 ProfileManager::CreateCallback callback = base::Bind( | 679 ProfileManager::CreateCallback callback = base::Bind( |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 } | 879 } |
869 } | 880 } |
870 | 881 |
871 if (show_account_management) { | 882 if (show_account_management) { |
872 browser->window()->ShowAvatarBubbleFromAvatarButton( | 883 browser->window()->ShowAvatarBubbleFromAvatarButton( |
873 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, | 884 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, |
874 signin::ManageAccountsParams()); | 885 signin::ManageAccountsParams()); |
875 } | 886 } |
876 } | 887 } |
877 } | 888 } |
OLD | NEW |