| 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/webui/signin/sync_confirmation_handler.h" | 5 #include "chrome/browser/ui/webui/signin/sync_confirmation_handler.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/metrics/user_metrics.h" | 10 #include "base/metrics/user_metrics.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 void SyncConfirmationHandler::HandleUndo(const base::ListValue* args) { | 64 void SyncConfirmationHandler::HandleUndo(const base::ListValue* args) { |
| 65 did_user_explicitly_interact = true; | 65 did_user_explicitly_interact = true; |
| 66 base::RecordAction(base::UserMetricsAction("Signin_Undo_Signin")); | 66 base::RecordAction(base::UserMetricsAction("Signin_Undo_Signin")); |
| 67 Browser* browser = signin::GetDesktopBrowser(web_ui()); | 67 Browser* browser = signin::GetDesktopBrowser(web_ui()); |
| 68 if (browser) { | 68 if (browser) { |
| 69 LoginUIServiceFactory::GetForProfile(browser->profile())-> | 69 LoginUIServiceFactory::GetForProfile(browser->profile())-> |
| 70 SyncConfirmationUIClosed(LoginUIService::ABORT_SIGNIN); | 70 SyncConfirmationUIClosed(LoginUIService::ABORT_SIGNIN); |
| 71 SigninManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()))->SignOut( | 71 SigninManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()))->SignOut( |
| 72 signin_metrics::ABORT_SIGNIN, | 72 signin_metrics::ABORT_SIGNIN, |
| 73 signin_metrics::SignoutDelete::IGNORE_METRIC); | 73 signin_metrics::SignoutDelete::IGNORE_METRIC); |
| 74 browser->CloseModalSigninWindow(); | 74 browser->signin_view_controller()->CloseModalSignin(); |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 void SyncConfirmationHandler::SetUserImageURL(const std::string& picture_url) { | 78 void SyncConfirmationHandler::SetUserImageURL(const std::string& picture_url) { |
| 79 std::string picture_url_to_load; | 79 std::string picture_url_to_load; |
| 80 GURL url; | 80 GURL url; |
| 81 if (picture_url != AccountTrackerService::kNoPictureURLFound && | 81 if (picture_url != AccountTrackerService::kNoPictureURLFound && |
| 82 profiles::GetImageURLWithThumbnailSize(GURL(picture_url), | 82 profiles::GetImageURLWithThumbnailSize(GURL(picture_url), |
| 83 kProfileImageSize, &url)) { | 83 kProfileImageSize, &url)) { |
| 84 picture_url_to_load = url.spec(); | 84 picture_url_to_load = url.spec(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 103 AccountTrackerServiceFactory::GetForProfile(profile)->RemoveObserver(this); | 103 AccountTrackerServiceFactory::GetForProfile(profile)->RemoveObserver(this); |
| 104 SetUserImageURL(info.picture_url); | 104 SetUserImageURL(info.picture_url); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void SyncConfirmationHandler::CloseModalSigninWindow( | 107 void SyncConfirmationHandler::CloseModalSigninWindow( |
| 108 LoginUIService::SyncConfirmationUIClosedResult result) { | 108 LoginUIService::SyncConfirmationUIClosedResult result) { |
| 109 Browser* browser = signin::GetDesktopBrowser(web_ui()); | 109 Browser* browser = signin::GetDesktopBrowser(web_ui()); |
| 110 if (browser) { | 110 if (browser) { |
| 111 LoginUIServiceFactory::GetForProfile(browser->profile())-> | 111 LoginUIServiceFactory::GetForProfile(browser->profile())-> |
| 112 SyncConfirmationUIClosed(result); | 112 SyncConfirmationUIClosed(result); |
| 113 browser->CloseModalSigninWindow(); | 113 browser->signin_view_controller()->CloseModalSignin(); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 void SyncConfirmationHandler::HandleInitializedWithSize( | 117 void SyncConfirmationHandler::HandleInitializedWithSize( |
| 118 const base::ListValue* args) { | 118 const base::ListValue* args) { |
| 119 Browser* browser = signin::GetDesktopBrowser(web_ui()); | 119 Browser* browser = signin::GetDesktopBrowser(web_ui()); |
| 120 if (!browser) | 120 if (!browser) |
| 121 return; | 121 return; |
| 122 | 122 |
| 123 Profile* profile = browser->profile(); | 123 Profile* profile = browser->profile(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 141 | 141 |
| 142 signin::SetInitializedModalHeight(web_ui(), args); | 142 signin::SetInitializedModalHeight(web_ui(), args); |
| 143 | 143 |
| 144 // After the dialog is shown, some platforms might have an element focused. | 144 // After the dialog is shown, some platforms might have an element focused. |
| 145 // To be consistent, clear the focused element on all platforms. | 145 // To be consistent, clear the focused element on all platforms. |
| 146 // TODO(anthonyvd): Figure out why this is needed on Mac and not other | 146 // TODO(anthonyvd): Figure out why this is needed on Mac and not other |
| 147 // platforms and if there's a way to start unfocused while avoiding this | 147 // platforms and if there's a way to start unfocused while avoiding this |
| 148 // workaround. | 148 // workaround. |
| 149 web_ui()->CallJavascriptFunctionUnsafe("sync.confirmation.clearFocus"); | 149 web_ui()->CallJavascriptFunctionUnsafe("sync.confirmation.clearFocus"); |
| 150 } | 150 } |
| OLD | NEW |