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

Unified Diff: components/policy/core/common/cloud/component_cloud_policy_service.cc

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: components/policy/core/common/cloud/component_cloud_policy_service.cc
diff --git a/components/policy/core/common/cloud/component_cloud_policy_service.cc b/components/policy/core/common/cloud/component_cloud_policy_service.cc
index ab519594f740e4ca27bcce0ef671feb612018993..081f3fec45f26e18f937b8b5c42bbd68d940871f 100644
--- a/components/policy/core/common/cloud/component_cloud_policy_service.cc
+++ b/components/policy/core/common/cloud/component_cloud_policy_service.cc
@@ -22,6 +22,7 @@
#include "components/policy/core/common/cloud/resource_cache.h"
#include "components/policy/core/common/schema.h"
#include "components/policy/core/common/schema_map.h"
+#include "components/user_manager/user_id.h"
#include "net/url_request/url_request_context_getter.h"
#include "policy/proto/device_management_backend.pb.h"
@@ -79,8 +80,8 @@ class ComponentCloudPolicyService::Backend
~Backend() override;
- // |username| and |dm_token| will be used to validate the cached policies.
- void SetCredentials(const std::string& username, const std::string& dm_token);
+ // |user_id| and |dm_token| will be used to validate the cached policies.
+ void SetCredentials(const user_manager::UserID& username, const std::string& dm_token);
// Loads the |store_| and starts downloading updates.
void Init(scoped_refptr<SchemaMap> schema_map);
@@ -140,13 +141,13 @@ ComponentCloudPolicyService::Backend::Backend(
ComponentCloudPolicyService::Backend::~Backend() {}
void ComponentCloudPolicyService::Backend::SetCredentials(
- const std::string& username,
+ const user_manager::UserID& user_id,
const std::string& dm_token) {
- if (username.empty() || dm_token.empty()) {
+ if (user_id.empty() || dm_token.empty()) {
// No sign-in credentials, so drop any cached policy.
store_.Clear();
} else {
- store_.SetCredentials(username, dm_token);
+ store_.SetCredentials(user_id, dm_token);
}
}
@@ -302,7 +303,8 @@ void ComponentCloudPolicyService::ClearCache() {
backend_task_runner_->PostTask(FROM_HERE,
base::Bind(&Backend::SetCredentials,
base::Unretained(backend_.get()),
- std::string(), std::string()));
+ user_manager::UserID(std::string(), std::string()),
+ std::string()));
}
void ComponentCloudPolicyService::OnSchemaRegistryReady() {
@@ -377,7 +379,7 @@ void ComponentCloudPolicyService::OnStoreLoaded(CloudPolicyStore* store) {
backend_task_runner_->PostTask(FROM_HERE,
base::Bind(&Backend::SetCredentials,
base::Unretained(backend_.get()),
- username,
+ user_manager::UserID(std::string() /* gaia_id */, username),
request_token));
if (!loaded_initial_policy_) {

Powered by Google App Engine
This is Rietveld 408576698