| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/supervised_user/supervised_user_service.h" | 5 #include "chrome/browser/supervised_user/supervised_user_service.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #include "components/signin/core/browser/signin_manager.h" | 40 #include "components/signin/core/browser/signin_manager.h" |
| 41 #include "components/signin/core/browser/signin_manager_base.h" | 41 #include "components/signin/core/browser/signin_manager_base.h" |
| 42 #include "content/public/browser/browser_thread.h" | 42 #include "content/public/browser/browser_thread.h" |
| 43 #include "content/public/browser/user_metrics.h" | 43 #include "content/public/browser/user_metrics.h" |
| 44 #include "google_apis/gaia/google_service_auth_error.h" | 44 #include "google_apis/gaia/google_service_auth_error.h" |
| 45 #include "grit/generated_resources.h" | 45 #include "grit/generated_resources.h" |
| 46 #include "net/base/escape.h" | 46 #include "net/base/escape.h" |
| 47 #include "ui/base/l10n/l10n_util.h" | 47 #include "ui/base/l10n/l10n_util.h" |
| 48 | 48 |
| 49 #if defined(OS_CHROMEOS) | 49 #if defined(OS_CHROMEOS) |
| 50 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
| 50 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 51 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
| 51 #include "chrome/browser/chromeos/login/users/user_manager.h" | 52 #include "components/user_manager/user_manager.h" |
| 52 #endif | 53 #endif |
| 53 | 54 |
| 54 #if defined(ENABLE_EXTENSIONS) | 55 #if defined(ENABLE_EXTENSIONS) |
| 55 #include "chrome/browser/extensions/extension_service.h" | 56 #include "chrome/browser/extensions/extension_service.h" |
| 56 #include "chrome/common/extensions/api/supervised_user_private/supervised_user_h
andler.h" | 57 #include "chrome/common/extensions/api/supervised_user_private/supervised_user_h
andler.h" |
| 57 #include "extensions/browser/extension_registry.h" | 58 #include "extensions/browser/extension_registry.h" |
| 58 #include "extensions/browser/extension_system.h" | 59 #include "extensions/browser/extension_system.h" |
| 59 #include "extensions/common/extension_set.h" | 60 #include "extensions/common/extension_set.h" |
| 60 #endif | 61 #endif |
| 61 | 62 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 return (*sites.begin())->category_id; | 249 return (*sites.begin())->category_id; |
| 249 } | 250 } |
| 250 | 251 |
| 251 // static | 252 // static |
| 252 void SupervisedUserService::GetCategoryNames(CategoryList* list) { | 253 void SupervisedUserService::GetCategoryNames(CategoryList* list) { |
| 253 SupervisedUserSiteList::GetCategoryNames(list); | 254 SupervisedUserSiteList::GetCategoryNames(list); |
| 254 } | 255 } |
| 255 | 256 |
| 256 std::string SupervisedUserService::GetCustodianEmailAddress() const { | 257 std::string SupervisedUserService::GetCustodianEmailAddress() const { |
| 257 #if defined(OS_CHROMEOS) | 258 #if defined(OS_CHROMEOS) |
| 258 return chromeos::UserManager::Get()->GetSupervisedUserManager()-> | 259 return chromeos::ChromeUserManager::Get() |
| 259 GetManagerDisplayEmail( | 260 ->GetSupervisedUserManager() |
| 260 chromeos::UserManager::Get()->GetActiveUser()->email()); | 261 ->GetManagerDisplayEmail( |
| 262 user_manager::UserManager::Get()->GetActiveUser()->email()); |
| 261 #else | 263 #else |
| 262 return profile_->GetPrefs()->GetString(prefs::kSupervisedUserCustodianEmail); | 264 return profile_->GetPrefs()->GetString(prefs::kSupervisedUserCustodianEmail); |
| 263 #endif | 265 #endif |
| 264 } | 266 } |
| 265 | 267 |
| 266 std::string SupervisedUserService::GetCustodianName() const { | 268 std::string SupervisedUserService::GetCustodianName() const { |
| 267 #if defined(OS_CHROMEOS) | 269 #if defined(OS_CHROMEOS) |
| 268 return base::UTF16ToUTF8(chromeos::UserManager::Get()-> | 270 return base::UTF16ToUTF8( |
| 269 GetSupervisedUserManager()->GetManagerDisplayName( | 271 chromeos::ChromeUserManager::Get() |
| 270 chromeos::UserManager::Get()->GetActiveUser()->email())); | 272 ->GetSupervisedUserManager() |
| 273 ->GetManagerDisplayName( |
| 274 user_manager::UserManager::Get()->GetActiveUser()->email())); |
| 271 #else | 275 #else |
| 272 std::string name = profile_->GetPrefs()->GetString( | 276 std::string name = profile_->GetPrefs()->GetString( |
| 273 prefs::kSupervisedUserCustodianName); | 277 prefs::kSupervisedUserCustodianName); |
| 274 return name.empty() ? GetCustodianEmailAddress() : name; | 278 return name.empty() ? GetCustodianEmailAddress() : name; |
| 275 #endif | 279 #endif |
| 276 } | 280 } |
| 277 | 281 |
| 278 void SupervisedUserService::AddNavigationBlockedCallback( | 282 void SupervisedUserService::AddNavigationBlockedCallback( |
| 279 const NavigationBlockedCallback& callback) { | 283 const NavigationBlockedCallback& callback) { |
| 280 navigation_blocked_callbacks_.push_back(callback); | 284 navigation_blocked_callbacks_.push_back(callback); |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 content::RecordAction(UserMetricsAction("ManagedUsers_OpenProfile")); | 814 content::RecordAction(UserMetricsAction("ManagedUsers_OpenProfile")); |
| 811 else if (is_profile_active_ && !profile_became_active) | 815 else if (is_profile_active_ && !profile_became_active) |
| 812 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); | 816 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); |
| 813 | 817 |
| 814 is_profile_active_ = profile_became_active; | 818 is_profile_active_ = profile_became_active; |
| 815 } | 819 } |
| 816 | 820 |
| 817 std::string SupervisedUserService::GetSupervisedUserName() const { | 821 std::string SupervisedUserService::GetSupervisedUserName() const { |
| 818 #if defined(OS_CHROMEOS) | 822 #if defined(OS_CHROMEOS) |
| 819 // The active user can be NULL in unit tests. | 823 // The active user can be NULL in unit tests. |
| 820 if (chromeos::UserManager::Get()->GetActiveUser()) { | 824 if (user_manager::UserManager::Get()->GetActiveUser()) { |
| 821 return UTF16ToUTF8(chromeos::UserManager::Get()->GetUserDisplayName( | 825 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( |
| 822 chromeos::UserManager::Get()->GetActiveUser()->GetUserID())); | 826 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); |
| 823 } | 827 } |
| 824 return std::string(); | 828 return std::string(); |
| 825 #else | 829 #else |
| 826 return profile_->GetPrefs()->GetString(prefs::kProfileName); | 830 return profile_->GetPrefs()->GetString(prefs::kProfileName); |
| 827 #endif | 831 #endif |
| 828 } | 832 } |
| OLD | NEW |