Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: chrome/browser/supervised_user/supervised_user_service.cc

Issue 614053002: Supervised Users: Add tests for PermissionRequestCreatorApiary. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 SupervisedUserSettingsService* settings_service = GetSettingsService(); 746 SupervisedUserSettingsService* settings_service = GetSettingsService();
747 settings_service->SetActive(active_); 747 settings_service->SetActive(active_);
748 748
749 #if defined(ENABLE_EXTENSIONS) 749 #if defined(ENABLE_EXTENSIONS)
750 SetExtensionsActive(); 750 SetExtensionsActive();
751 #endif 751 #endif
752 752
753 if (active_) { 753 if (active_) {
754 if (CommandLine::ForCurrentProcess()->HasSwitch( 754 if (CommandLine::ForCurrentProcess()->HasSwitch(
755 switches::kPermissionRequestApiUrl)) { 755 switches::kPermissionRequestApiUrl)) {
756 permissions_creator_ = 756 std::string value = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
757 PermissionRequestCreatorApiary::CreateWithProfile(profile_); 757 switches::kPermissionRequestApiUrl);
758 } else { 758 GURL url(value);
Bernhard Bauer 2014/09/30 15:01:08 You could probably inline |value|.
Marc Treib 2014/09/30 15:28:46 Done.
759 if (url.is_valid()) {
760 permissions_creator_ =
761 PermissionRequestCreatorApiary::CreateWithProfile(url, profile_);
762 } else {
763 LOG(WARNING) << "Got invalid URL for "
764 << switches::kPermissionRequestApiUrl
765 << ", falling back to PermissionRequestCreatorSync";
766 }
767 }
768 if (!permissions_creator_) {
759 PrefService* pref_service = profile_->GetPrefs(); 769 PrefService* pref_service = profile_->GetPrefs();
760 permissions_creator_.reset(new PermissionRequestCreatorSync( 770 permissions_creator_.reset(new PermissionRequestCreatorSync(
761 settings_service, 771 settings_service,
762 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext( 772 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(
763 profile_), 773 profile_),
764 GetSupervisedUserName(), 774 GetSupervisedUserName(),
765 pref_service->GetString(prefs::kSupervisedUserId))); 775 pref_service->GetString(prefs::kSupervisedUserId)));
766 } 776 }
767 777
768 pref_change_registrar_.Add( 778 pref_change_registrar_.Add(
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 // The active user can be NULL in unit tests. 957 // The active user can be NULL in unit tests.
948 if (user_manager::UserManager::Get()->GetActiveUser()) { 958 if (user_manager::UserManager::Get()->GetActiveUser()) {
949 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( 959 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName(
950 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); 960 user_manager::UserManager::Get()->GetActiveUser()->GetUserID()));
951 } 961 }
952 return std::string(); 962 return std::string();
953 #else 963 #else
954 return profile_->GetPrefs()->GetString(prefs::kProfileName); 964 return profile_->GetPrefs()->GetString(prefs::kProfileName);
955 #endif 965 #endif
956 } 966 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698