| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/signin_supervised_user_import_handler.h
" | 5 #include "chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.h
" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_
service_factory.h" | 25 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_
service_factory.h" |
| 26 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service.h" | 26 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service.h" |
| 27 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service_fac
tory.h" | 27 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service_fac
tory.h" |
| 28 #include "chrome/browser/supervised_user/supervised_user_constants.h" | 28 #include "chrome/browser/supervised_user/supervised_user_constants.h" |
| 29 #include "chrome/browser/ui/browser_finder.h" | 29 #include "chrome/browser/ui/browser_finder.h" |
| 30 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 31 #include "chrome/grit/generated_resources.h" | 31 #include "chrome/grit/generated_resources.h" |
| 32 #include "components/prefs/pref_service.h" | 32 #include "components/prefs/pref_service.h" |
| 33 #include "components/signin/core/browser/signin_error_controller.h" | 33 #include "components/signin/core/browser/signin_error_controller.h" |
| 34 #include "components/signin/core/browser/signin_manager.h" | 34 #include "components/signin/core/browser/signin_manager.h" |
| 35 #include "content/public/browser/browser_thread.h" |
| 35 #include "content/public/browser/web_ui.h" | 36 #include "content/public/browser/web_ui.h" |
| 36 #include "content/public/common/referrer.h" | 37 #include "content/public/common/referrer.h" |
| 37 #include "grit/theme_resources.h" | 38 #include "grit/theme_resources.h" |
| 38 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
| 39 #include "url/gurl.h" | 40 #include "url/gurl.h" |
| 40 | 41 |
| 41 | 42 |
| 42 SigninSupervisedUserImportHandler::SigninSupervisedUserImportHandler() | 43 SigninSupervisedUserImportHandler::SigninSupervisedUserImportHandler() |
| 43 : weak_ptr_factory_(this) { | 44 : weak_ptr_factory_(this) { |
| 44 } | 45 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 const base::ListValue* args) { | 87 const base::ListValue* args) { |
| 87 CHECK_EQ(1U, args->GetSize()); | 88 CHECK_EQ(1U, args->GetSize()); |
| 88 std::string url; | 89 std::string url; |
| 89 bool success = args->GetString(0, &url); | 90 bool success = args->GetString(0, &url); |
| 90 DCHECK(success); | 91 DCHECK(success); |
| 91 content::OpenURLParams params(GURL(url), | 92 content::OpenURLParams params(GURL(url), |
| 92 content::Referrer(), | 93 content::Referrer(), |
| 93 NEW_FOREGROUND_TAB, | 94 NEW_FOREGROUND_TAB, |
| 94 ui::PAGE_TRANSITION_LINK, | 95 ui::PAGE_TRANSITION_LINK, |
| 95 false); | 96 false); |
| 96 // Get the browser owned by the last used profile. | 97 // ProfileManager::GetLastUsedProfile() will attempt to load the default |
| 97 Browser* browser = | 98 // profile if there is no last used profile. If the default profile is not |
| 98 chrome::FindLastActiveWithProfile(ProfileManager::GetLastUsedProfile()); | 99 // fully loaded and initialized, it will attempt to do so synchronously. |
| 99 DCHECK(browser); | 100 // Therefore we cannot use that method here. If the last used profile is not |
| 100 if (browser) | 101 // loaded, we do nothing. This is an edge case and should not happen often. |
| 102 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 103 base::FilePath last_used_profile_dir = |
| 104 profile_manager->GetLastUsedProfileDir(profile_manager->user_data_dir()); |
| 105 Profile* last_used_profile = |
| 106 profile_manager->GetProfileByPath(last_used_profile_dir); |
| 107 |
| 108 if (last_used_profile) { |
| 109 // Last used profile may be the Guest Profile. |
| 110 if (ProfileManager::IncognitoModeForced(last_used_profile)) |
| 111 last_used_profile = last_used_profile->GetOffTheRecordProfile(); |
| 112 |
| 113 // Get the browser owned by the last used profile or create a new one if |
| 114 // it doesn't exist. |
| 115 Browser* browser = chrome::FindLastActiveWithProfile(last_used_profile); |
| 116 if (!browser) |
| 117 browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, |
| 118 last_used_profile)); |
| 101 browser->OpenURL(params); | 119 browser->OpenURL(params); |
| 120 } |
| 102 } | 121 } |
| 103 | 122 |
| 104 void SigninSupervisedUserImportHandler::GetExistingSupervisedUsers( | 123 void SigninSupervisedUserImportHandler::GetExistingSupervisedUsers( |
| 105 const base::ListValue* args) { | 124 const base::ListValue* args) { |
| 106 CHECK_EQ(2U, args->GetSize()); | 125 CHECK_EQ(2U, args->GetSize()); |
| 107 AssignWebUICallbackId(args); | 126 AssignWebUICallbackId(args); |
| 108 | 127 |
| 109 base::FilePath custodian_profile_path; | 128 base::FilePath custodian_profile_path; |
| 110 const base::Value* profile_path_value; | 129 const base::Value* profile_path_value; |
| 111 bool success = args->Get(1, &profile_path_value); | 130 bool success = args->Get(1, &profile_path_value); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 283 |
| 265 bool SigninSupervisedUserImportHandler::HasAuthError(Profile* profile) const { | 284 bool SigninSupervisedUserImportHandler::HasAuthError(Profile* profile) const { |
| 266 SigninErrorController* error_controller = | 285 SigninErrorController* error_controller = |
| 267 SigninErrorControllerFactory::GetForProfile(profile); | 286 SigninErrorControllerFactory::GetForProfile(profile); |
| 268 if (!error_controller) | 287 if (!error_controller) |
| 269 return true; | 288 return true; |
| 270 | 289 |
| 271 GoogleServiceAuthError::State state = error_controller->auth_error().state(); | 290 GoogleServiceAuthError::State state = error_controller->auth_error().state(); |
| 272 return state != GoogleServiceAuthError::NONE; | 291 return state != GoogleServiceAuthError::NONE; |
| 273 } | 292 } |
| OLD | NEW |