summaryrefslogtreecommitdiffstats
path: root/components/ownership
diff options
context:
space:
mode:
authoravi <avi@chromium.org>2014-10-24 12:07:16 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-24 19:07:42 +0000
commit5e64220166aa85f47fa9b8dd5db53254bc95487f (patch)
tree20d19c1193a393fc6ec6fcdbd4e356f53e1a19b3 /components/ownership
parentf27055fc23aee7a2221aa6f4307578f8bbbb8a8d (diff)
downloadchromium_src-5e64220166aa85f47fa9b8dd5db53254bc95487f.zip
chromium_src-5e64220166aa85f47fa9b8dd5db53254bc95487f.tar.gz
chromium_src-5e64220166aa85f47fa9b8dd5db53254bc95487f.tar.bz2
Revert of Implemented OwnerSettingsService::Set() method. (patchset #7 id:160001 of https://codereview.chromium.org/654263003/)
Reason for revert: ASAN bot unhappy http://build.chromium.org/p/chromium.memory/builders/Linux%20Chromium%20OS%20ASan%20LSan%20Tests%20%281%29/builds/3731 Original issue's description: > Implemented OwnerSettingsService::Set() method. > > BUG=230018 > TEST=unit_tests:OwnerSettingsServiceChromeOSTest.* > > Committed: https://crrev.com/5fa0ee22683b92d67e07c060e8c7a3c4cced51ee > Cr-Commit-Position: refs/heads/master@{#301132} TBR=mnissler@chromium.org,pastarmovj@chromium.org,ygorshenin@chromium.org NOTREECHECKS=true NOTRY=true BUG=230018 Review URL: https://codereview.chromium.org/640063008 Cr-Commit-Position: refs/heads/master@{#301161}
Diffstat (limited to 'components/ownership')
-rw-r--r--components/ownership/owner_settings_service.cc57
-rw-r--r--components/ownership/owner_settings_service.h55
2 files changed, 18 insertions, 94 deletions
diff --git a/components/ownership/owner_settings_service.cc b/components/ownership/owner_settings_service.cc
index 204cdd1..56bcbe0 100644
--- a/components/ownership/owner_settings_service.cc
+++ b/components/ownership/owner_settings_service.cc
@@ -12,7 +12,6 @@
#include "base/message_loop/message_loop.h"
#include "base/task_runner.h"
#include "base/task_runner_util.h"
-#include "base/values.h"
#include "components/ownership/owner_key_util.h"
#include "crypto/signature_creator.h"
@@ -22,15 +21,13 @@ namespace ownership {
namespace {
-scoped_ptr<em::PolicyFetchResponse> AssembleAndSignPolicy(
- scoped_ptr<em::PolicyData> policy,
- crypto::RSAPrivateKey* private_key) {
+std::string AssembleAndSignPolicy(scoped_ptr<em::PolicyData> policy,
+ crypto::RSAPrivateKey* private_key) {
// Assemble the policy.
- scoped_ptr<em::PolicyFetchResponse> policy_response(
- new em::PolicyFetchResponse());
- if (!policy->SerializeToString(policy_response->mutable_policy_data())) {
+ em::PolicyFetchResponse policy_response;
+ if (!policy->SerializeToString(policy_response.mutable_policy_data())) {
LOG(ERROR) << "Failed to encode policy payload.";
- return scoped_ptr<em::PolicyFetchResponse>(nullptr).Pass();
+ return std::string();
}
// Generate the signature.
@@ -38,19 +35,19 @@ scoped_ptr<em::PolicyFetchResponse> AssembleAndSignPolicy(
crypto::SignatureCreator::Create(private_key,
crypto::SignatureCreator::SHA1));
signature_creator->Update(
- reinterpret_cast<const uint8*>(policy_response->policy_data().c_str()),
- policy_response->policy_data().size());
+ reinterpret_cast<const uint8*>(policy_response.policy_data().c_str()),
+ policy_response.policy_data().size());
std::vector<uint8> signature_bytes;
std::string policy_blob;
if (!signature_creator->Final(&signature_bytes)) {
LOG(ERROR) << "Failed to create policy signature.";
- return scoped_ptr<em::PolicyFetchResponse>(nullptr).Pass();
+ return std::string();
}
- policy_response->mutable_policy_data_signature()->assign(
+ policy_response.mutable_policy_data_signature()->assign(
reinterpret_cast<const char*>(vector_as_array(&signature_bytes)),
signature_bytes.size());
- return policy_response.Pass();
+ return policy_response.SerializeAsString();
}
} // namepace
@@ -64,15 +61,6 @@ OwnerSettingsService::~OwnerSettingsService() {
DCHECK(thread_checker_.CalledOnValidThread());
}
-void OwnerSettingsService::AddObserver(Observer* observer) {
- if (observer && !observers_.HasObserver(observer))
- observers_.AddObserver(observer);
-}
-
-void OwnerSettingsService::RemoveObserver(Observer* observer) {
- observers_.RemoveObserver(observer);
-}
-
bool OwnerSettingsService::IsOwner() {
DCHECK(thread_checker_.CalledOnValidThread());
return private_key_.get() && private_key_->key();
@@ -103,31 +91,6 @@ bool OwnerSettingsService::AssembleAndSignPolicyAsync(
callback);
}
-bool OwnerSettingsService::SetBoolean(const std::string& setting, bool value) {
- DCHECK(thread_checker_.CalledOnValidThread());
- base::FundamentalValue in_value(value);
- return Set(setting, in_value);
-}
-
-bool OwnerSettingsService::SetInteger(const std::string& setting, int value) {
- DCHECK(thread_checker_.CalledOnValidThread());
- base::FundamentalValue in_value(value);
- return Set(setting, in_value);
-}
-
-bool OwnerSettingsService::SetDouble(const std::string& setting, double value) {
- DCHECK(thread_checker_.CalledOnValidThread());
- base::FundamentalValue in_value(value);
- return Set(setting, in_value);
-}
-
-bool OwnerSettingsService::SetString(const std::string& setting,
- const std::string& value) {
- DCHECK(thread_checker_.CalledOnValidThread());
- base::StringValue in_value(value);
- return Set(setting, in_value);
-}
-
void OwnerSettingsService::ReloadKeypair() {
ReloadKeypairImpl(
base::Bind(&OwnerSettingsService::OnKeypairLoaded, as_weak_ptr()));
diff --git a/components/ownership/owner_settings_service.h b/components/ownership/owner_settings_service.h
index db36595..1961975 100644
--- a/components/ownership/owner_settings_service.h
+++ b/components/ownership/owner_settings_service.h
@@ -13,7 +13,6 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "base/observer_list.h"
#include "base/threading/thread_checker.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/ownership/ownership_export.h"
@@ -21,7 +20,6 @@
namespace base {
class TaskRunner;
-class Value;
}
namespace ownership {
@@ -33,42 +31,19 @@ class PublicKey;
// which deal with ownership, keypairs and owner-related settings.
class OWNERSHIP_EXPORT OwnerSettingsService : public KeyedService {
public:
- class Observer {
- public:
- virtual ~Observer() {}
-
- // Called when signed policy was stored, or when an error happed during
- // policy storage..
- virtual void OnSignedPolicyStored(bool success) {}
-
- // Called when tentative changes were made to policy, but the policy still
- // not signed and stored.
- //
- // TODO (ygorshenin@, crbug.com/230018): get rid of the method
- // since it creates DeviceSettingsService's dependency on
- // OwnerSettingsService.
- virtual void OnTentativeChangesInPolicy(
- const enterprise_management::PolicyData& policy_data) {}
- };
-
- typedef base::Callback<void(
- scoped_ptr<enterprise_management::PolicyFetchResponse> policy_response)>
+ typedef base::Callback<void(std::string policy_blob)>
AssembleAndSignPolicyAsyncCallback;
typedef base::Callback<void(bool is_owner)> IsOwnerCallback;
explicit OwnerSettingsService(
const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util);
- virtual ~OwnerSettingsService();
+ ~OwnerSettingsService() override;
base::WeakPtr<OwnerSettingsService> as_weak_ptr() {
return weak_factory_.GetWeakPtr();
}
- void AddObserver(Observer* observer);
-
- void RemoveObserver(Observer* observer);
-
// Returns whether current user is owner or not. When this method
// is called too early, incorrect result can be returned because
// private key loading may be in progress.
@@ -85,24 +60,12 @@ class OWNERSHIP_EXPORT OwnerSettingsService : public KeyedService {
scoped_ptr<enterprise_management::PolicyData> policy,
const AssembleAndSignPolicyAsyncCallback& callback);
- // Checks whether |setting| is handled by OwnerSettingsService.
- virtual bool HandlesSetting(const std::string& setting) = 0;
-
- // Sets |setting| value to |value|.
- virtual bool Set(const std::string& setting, const base::Value& value) = 0;
-
- // Sets a bunch of device settings accumulated before ownership gets
- // established.
- //
- // TODO (ygorshenin@, crbug.com/230018): that this is a temporary
- // solution and should be removed.
- virtual bool CommitTentativeDeviceSettings(
- scoped_ptr<enterprise_management::PolicyData> policy) = 0;
-
- bool SetBoolean(const std::string& setting, bool value);
- bool SetInteger(const std::string& setting, int value);
- bool SetDouble(const std::string& setting, double value);
- bool SetString(const std::string& setting, const std::string& value);
+ // Signs |settings| with the private half of the owner key and sends
+ // the resulting policy blob for storage. The
+ // result of the operation is reported through |callback|.
+ virtual void SignAndStorePolicyAsync(
+ scoped_ptr<enterprise_management::PolicyData> policy,
+ const base::Closure& callback) = 0;
protected:
void ReloadKeypair();
@@ -126,8 +89,6 @@ class OWNERSHIP_EXPORT OwnerSettingsService : public KeyedService {
std::vector<IsOwnerCallback> pending_is_owner_callbacks_;
- ObserverList<Observer> observers_;
-
base::ThreadChecker thread_checker_;
private: