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/user_manager_screen_handler.h" | 5 #include "chrome/browser/ui/webui/signin/user_manager_screen_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/profiler/scoped_tracker.h" | 9 #include "base/profiler/scoped_tracker.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "chrome/browser/ui/browser_finder.h" | 28 #include "chrome/browser/ui/browser_finder.h" |
29 #include "chrome/browser/ui/browser_list.h" | 29 #include "chrome/browser/ui/browser_list.h" |
30 #include "chrome/browser/ui/browser_list_observer.h" | 30 #include "chrome/browser/ui/browser_list_observer.h" |
31 #include "chrome/browser/ui/chrome_pages.h" | 31 #include "chrome/browser/ui/chrome_pages.h" |
32 #include "chrome/browser/ui/singleton_tabs.h" | 32 #include "chrome/browser/ui/singleton_tabs.h" |
33 #include "chrome/browser/ui/user_manager.h" | 33 #include "chrome/browser/ui/user_manager.h" |
34 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
35 #include "chrome/common/url_constants.h" | 35 #include "chrome/common/url_constants.h" |
36 #include "chrome/grit/chromium_strings.h" | 36 #include "chrome/grit/chromium_strings.h" |
37 #include "chrome/grit/generated_resources.h" | 37 #include "chrome/grit/generated_resources.h" |
| 38 #include "components/signin/core/browser/signin_manager_base.h" |
38 #include "content/public/browser/notification_service.h" | 39 #include "content/public/browser/notification_service.h" |
39 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
40 #include "content/public/browser/web_ui.h" | 41 #include "content/public/browser/web_ui.h" |
41 #include "google_apis/gaia/gaia_auth_fetcher.h" | 42 #include "google_apis/gaia/gaia_auth_fetcher.h" |
42 #include "google_apis/gaia/gaia_constants.h" | 43 #include "google_apis/gaia/gaia_constants.h" |
43 #include "third_party/skia/include/core/SkBitmap.h" | 44 #include "third_party/skia/include/core/SkBitmap.h" |
44 #include "ui/base/l10n/l10n_util.h" | 45 #include "ui/base/l10n/l10n_util.h" |
45 #include "ui/base/resource/resource_bundle.h" | 46 #include "ui/base/resource/resource_bundle.h" |
46 #include "ui/base/webui/web_ui_util.h" | 47 #include "ui/base/webui/web_ui_util.h" |
47 #include "ui/gfx/image/image.h" | 48 #include "ui/gfx/image/image.h" |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 if (it == user_auth_type_map_.end()) | 353 if (it == user_auth_type_map_.end()) |
353 return ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; | 354 return ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; |
354 return it->second; | 355 return it->second; |
355 } | 356 } |
356 | 357 |
357 ScreenlockBridge::LockHandler::ScreenType | 358 ScreenlockBridge::LockHandler::ScreenType |
358 UserManagerScreenHandler::GetScreenType() const { | 359 UserManagerScreenHandler::GetScreenType() const { |
359 return ScreenlockBridge::LockHandler::LOCK_SCREEN; | 360 return ScreenlockBridge::LockHandler::LOCK_SCREEN; |
360 } | 361 } |
361 | 362 |
| 363 void UserManagerScreenHandler::Lock(content::BrowserContext* browser_context) { |
| 364 profiles::LockProfile(Profile::FromBrowserContext(browser_context)); |
| 365 } |
| 366 |
| 367 void UserManagerScreenHandler::Unlock( |
| 368 content::BrowserContext* browser_context) { |
| 369 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 370 SigninManagerBase* signin_manager = |
| 371 SigninManagerFactory::GetForProfile(profile); |
| 372 Unlock(signin_manager->GetAuthenticatedUsername()); |
| 373 } |
| 374 |
362 void UserManagerScreenHandler::Unlock(const std::string& user_email) { | 375 void UserManagerScreenHandler::Unlock(const std::string& user_email) { |
363 const ProfileInfoCache& info_cache = | 376 const ProfileInfoCache& info_cache = |
364 g_browser_process->profile_manager()->GetProfileInfoCache(); | 377 g_browser_process->profile_manager()->GetProfileInfoCache(); |
365 const size_t profile_index = | 378 const size_t profile_index = |
366 GetIndexOfProfileWithEmail(info_cache, user_email); | 379 GetIndexOfProfileWithEmail(info_cache, user_email); |
367 DCHECK_LT(profile_index, info_cache.GetNumberOfProfiles()); | 380 DCHECK_LT(profile_index, info_cache.GetNumberOfProfiles()); |
368 | 381 |
369 authenticating_profile_index_ = profile_index; | 382 authenticating_profile_index_ = profile_index; |
370 ReportAuthenticationResult(true, ProfileMetrics::AUTH_LOCAL); | 383 ReportAuthenticationResult(true, ProfileMetrics::AUTH_LOCAL); |
371 } | 384 } |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 Profile* profile, Profile::CreateStatus profile_create_status) { | 868 Profile* profile, Profile::CreateStatus profile_create_status) { |
856 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_); | 869 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_); |
857 if (browser && browser->window()) { | 870 if (browser && browser->window()) { |
858 OnBrowserWindowReady(browser); | 871 OnBrowserWindowReady(browser); |
859 } else { | 872 } else { |
860 registrar_.Add(this, | 873 registrar_.Add(this, |
861 chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 874 chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
862 content::NotificationService::AllSources()); | 875 content::NotificationService::AllSources()); |
863 } | 876 } |
864 } | 877 } |
OLD | NEW |