Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/user_manager.h" | 5 #include "chrome/browser/ui/user_manager.h" |
| 6 | 6 |
| 7 #include "chrome/browser/signin/signin_promo.h" | 7 #include "chrome/browser/signin/signin_promo.h" |
| 8 #include "chrome/common/url_constants.h" | |
| 8 #include "components/guest_view/browser/guest_view_manager.h" | 9 #include "components/guest_view/browser/guest_view_manager.h" |
| 9 #include "google_apis/gaia/gaia_urls.h" | 10 #include "google_apis/gaia/gaia_urls.h" |
| 10 | 11 |
| 11 namespace { | 12 namespace { |
| 12 | 13 |
| 13 bool AddToSet(std::set<content::WebContents*>* content_set, | 14 bool AddToSet(std::set<content::WebContents*>* content_set, |
| 14 content::WebContents* web_contents) { | 15 content::WebContents* web_contents) { |
| 15 content_set->insert(web_contents); | 16 content_set->insert(web_contents); |
| 16 return false; | 17 return false; |
| 17 } | 18 } |
| 18 | 19 |
| 19 } // namespace | 20 } // namespace |
| 20 | 21 |
| 21 UserManager::ReauthDialogObserver::ReauthDialogObserver( | 22 UserManager::BaseReauthDialogDelegate::BaseReauthDialogDelegate( |
| 22 content::WebContents* web_contents, const std::string& email_address) | 23 content::WebContents* web_contents) : web_contents_(web_contents) {} |
| 23 : email_address_(email_address) { | 24 |
| 24 // Observe navigations of the web contents so that the dialog can close itself | 25 bool UserManager::BaseReauthDialogDelegate::HandleContextMenu( |
| 25 // when the sign in process is done. | 26 const content::ContextMenuParams& params) { |
| 26 Observe(web_contents); | 27 // Ignores context menu. |
| 28 return true; | |
| 27 } | 29 } |
| 28 | 30 |
| 29 void UserManager::ReauthDialogObserver::DidStopLoading() { | 31 |
| 30 // If the sign in process reaches the termination URL, close the dialog. | 32 void UserManager::BaseReauthDialogDelegate::LoadingStateChanged( |
| 31 // Make sure to remove any parts of the URL that gaia might append during | 33 content::WebContents* source, bool to_different_document) { |
| 32 // signin. | 34 if (source->IsLoading()) |
| 33 GURL url = web_contents()->GetURL(); | |
| 34 url::Replacements<char> replacements; | |
| 35 replacements.ClearQuery(); | |
| 36 replacements.ClearRef(); | |
| 37 if (url.ReplaceComponents(replacements) == | |
| 38 GaiaUrls::GetInstance()->signin_completed_continue_url()) { | |
| 39 CloseReauthDialog(); | |
|
Moe
2016/07/21 15:34:12
The reauth dialog is closed explicitly in InlineLo
| |
| 40 return; | 35 return; |
| 41 } | |
| 42 | 36 |
| 43 // If still observing the top level web contents, try to find the embedded | 37 // If still observing the top level web contents, try to find the embedded |
| 44 // webview and observe it instead. The webview may not be found in the | 38 // webview and observe it instead. The webview may not be found in the |
| 45 // initial page load since it loads asynchronously. | 39 // initial page load since it loads asynchronously. |
| 46 if (url.GetOrigin() != | 40 GURL url = web_contents_->GetURL(); |
| 47 signin::GetReauthURLWithEmail( | 41 if (url.GetOrigin() != GURL(std::string(chrome::kChromeUIChromeSigninURL))) |
| 48 signin_metrics::AccessPoint::ACCESS_POINT_USER_MANAGER, | |
| 49 signin_metrics::Reason::REASON_UNLOCK, email_address_) | |
| 50 .GetOrigin()) { | |
| 51 return; | 42 return; |
| 52 } | |
| 53 | 43 |
| 54 std::set<content::WebContents*> content_set; | 44 std::set<content::WebContents*> content_set; |
| 55 guest_view::GuestViewManager* manager = | 45 guest_view::GuestViewManager* manager = |
| 56 guest_view::GuestViewManager::FromBrowserContext( | 46 guest_view::GuestViewManager::FromBrowserContext( |
| 57 web_contents()->GetBrowserContext()); | 47 web_contents_->GetBrowserContext()); |
| 58 if (manager) | 48 if (manager) |
| 59 manager->ForEachGuest(web_contents(), base::Bind(&AddToSet, &content_set)); | 49 manager->ForEachGuest(web_contents_, base::Bind(&AddToSet, &content_set)); |
| 60 DCHECK_LE(content_set.size(), 1U); | 50 DCHECK_LE(content_set.size(), 1U); |
| 61 if (!content_set.empty()) | 51 if (!content_set.empty()) { |
| 62 Observe(*content_set.begin()); | 52 web_contents_ = *content_set.begin(); |
| 53 web_contents_->SetDelegate(this); | |
| 54 } | |
| 63 } | 55 } |
| OLD | NEW |