Chromium Code Reviews| Index: chrome/browser/profiles/profile_window.cc |
| diff --git a/chrome/browser/profiles/profile_window.cc b/chrome/browser/profiles/profile_window.cc |
| index 2f09ebd2a892b3f6fffdfe80f04c11568eabff4a..eda2b01dfb771939ba03073c52d4fe9b9dc5d31d 100644 |
| --- a/chrome/browser/profiles/profile_window.cc |
| +++ b/chrome/browser/profiles/profile_window.cc |
| @@ -19,6 +19,7 @@ |
| #include "chrome/browser/signin/account_reconcilor_factory.h" |
| #include "chrome/browser/signin/account_tracker_service_factory.h" |
| #include "chrome/browser/signin/signin_manager_factory.h" |
| +#include "chrome/browser/signin/signin_promo.h" |
| #include "chrome/browser/signin/signin_ui_util.h" |
| #include "chrome/browser/sync/profile_sync_service.h" |
| #include "chrome/browser/sync/profile_sync_service_factory.h" |
| @@ -29,12 +30,14 @@ |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/common/pref_names.h" |
| #include "chrome/common/url_constants.h" |
| +#include "components/guest_view/browser/guest_view_manager.h" |
| #include "components/signin/core/browser/account_reconcilor.h" |
| #include "components/signin/core/browser/account_tracker_service.h" |
| #include "components/signin/core/browser/signin_manager.h" |
| #include "components/signin/core/common/profile_management_switches.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/user_metrics.h" |
| +#include "google_apis/gaia/gaia_urls.h" |
| #if defined(ENABLE_EXTENSIONS) |
| #include "chrome/browser/extensions/extension_service.h" |
| @@ -232,6 +235,12 @@ void UpdateServicesWithNewProfileManagementFlag(Profile* profile, |
| account_reconcilor->OnNewProfileManagementFlagChanged(new_flag_status); |
| } |
| +bool AddToSet(std::set<content::WebContents*>* content_set, |
| + content::WebContents* web_contents) { |
| + content_set->insert(web_contents); |
| + return false; |
| +} |
| + |
| } // namespace |
| namespace profiles { |
| @@ -244,6 +253,44 @@ const char kUserManagerSelectProfileChromeSettings[] = "#chrome-settings"; |
| const char kUserManagerSelectProfileChromeMemory[] = "#chrome-memory"; |
| const char kUserManagerSelectProfileAppLauncher[] = "#app-launcher"; |
| +ReauthDialogObserver::ReauthDialogObserver(content::WebContents* web_contents, |
| + const std::string& email_address) |
| + : web_contents_(web_contents), |
| + email_address_(email_address) {} |
| + |
| +void ReauthDialogObserver::DidStopLoading() { |
| + // If the sign in process reaches the termination URL, close the dialog. |
| + // Make sure to remove any parts of the URL that gaia might append during |
| + // signin. |
| + 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.
|
| + url::Replacements<char> replacements; |
| + replacements.ClearQuery(); |
| + replacements.ClearRef(); |
| + if (url.ReplaceComponents(replacements) == |
| + GaiaUrls::GetInstance()->signin_completed_continue_url()) { |
| + CloseReauthDialog(); |
| + return; |
| + } |
| + |
| + // If still observing the top level web contents, try to find the embedded |
| + // webview and observe it instead. The webview may not be found in the |
| + // initial page load since it loads asynchronously. |
| + if (url.GetOrigin() != |
| + signin::GetReauthURLWithEmail(email_address_).GetOrigin()) { |
| + return; |
| + } |
| + |
| + std::set<content::WebContents*> content_set; |
| + guest_view::GuestViewManager* manager = |
| + guest_view::GuestViewManager::FromBrowserContext( |
| + web_contents_->GetBrowserContext()); |
| + if (manager) |
| + manager->ForEachGuest(web_contents_, base::Bind(&AddToSet, &content_set)); |
| + DCHECK_LE(content_set.size(), 1U); |
| + if (!content_set.empty()) |
| + Observe(*content_set.begin()); |
| +} |
| + |
| base::FilePath GetPathOfProfileWithEmail(ProfileManager* profile_manager, |
| const std::string& email) { |
| base::string16 profile_email = base::UTF8ToUTF16(email); |