diff options
author | sreeram@chromium.org <sreeram@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-19 19:28:44 +0000 |
---|---|---|
committer | sreeram@chromium.org <sreeram@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-19 19:28:44 +0000 |
commit | 350928d345250305e13e1dec5d30d76ff119badd (patch) | |
tree | 77c62c856a1aea6737b8881c469508569ee36229 | |
parent | a6f8cb73534952d34e66001f09443e6955b7302b (diff) | |
download | chromium_src-350928d345250305e13e1dec5d30d76ff119badd.zip chromium_src-350928d345250305e13e1dec5d30d76ff119badd.tar.gz chromium_src-350928d345250305e13e1dec5d30d76ff119badd.tar.bz2 |
Revert 168563 - Wire up local account policy DBus calls in SessionManagerClient.
BUG=chromium-os:35715
TEST=None
Review URL: https://chromiumcodereview.appspot.com/11360191
You had a green linux_chromeos try run, but unfortunately, clang is pickier:
http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20%28Clang%20dbg%29/builds/24522
TBR=mnissler@chromium.org
Review URL: https://codereview.chromium.org/11308106
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168567 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/settings/device_settings_test_helper.cc | 74 | ||||
-rw-r--r-- | chrome/browser/chromeos/settings/device_settings_test_helper.h | 54 | ||||
-rw-r--r-- | chromeos/dbus/mock_session_manager_client.h | 17 | ||||
-rw-r--r-- | chromeos/dbus/session_manager_client.cc | 51 | ||||
-rw-r--r-- | chromeos/dbus/session_manager_client.h | 25 |
5 files changed, 29 insertions, 192 deletions
diff --git a/chrome/browser/chromeos/settings/device_settings_test_helper.cc b/chrome/browser/chromeos/settings/device_settings_test_helper.cc index d1951e8..eb6c889 100644 --- a/chrome/browser/chromeos/settings/device_settings_test_helper.cc +++ b/chrome/browser/chromeos/settings/device_settings_test_helper.cc @@ -12,7 +12,8 @@ namespace chromeos { -DeviceSettingsTestHelper::DeviceSettingsTestHelper() {} +DeviceSettingsTestHelper::DeviceSettingsTestHelper() + : store_result_(true) {} DeviceSettingsTestHelper::~DeviceSettingsTestHelper() {} @@ -29,41 +30,19 @@ void DeviceSettingsTestHelper::FlushLoops() { void DeviceSettingsTestHelper::FlushStore() { std::vector<StorePolicyCallback> callbacks; - callbacks.swap(device_policy_.store_callbacks_); + callbacks.swap(store_callbacks_); for (std::vector<StorePolicyCallback>::iterator cb(callbacks.begin()); cb != callbacks.end(); ++cb) { - cb->Run(device_policy_.store_result_); - } - - std::map<std::string, PolicyState>::iterator device_local_account_state; - for (device_local_account_state = device_local_account_policy_.begin(); - device_local_account_state != device_local_account_policy_.end(); - ++device_local_account_state) { - callbacks.swap(device_local_account_state->second.store_callbacks_); - for (std::vector<StorePolicyCallback>::iterator cb(callbacks.begin()); - cb != callbacks.end(); ++cb) { - cb->Run(device_local_account_state->second.store_result_); - } + cb->Run(store_result_); } } void DeviceSettingsTestHelper::FlushRetrieve() { std::vector<RetrievePolicyCallback> callbacks; - callbacks.swap(device_policy_.retrieve_callbacks_); + callbacks.swap(retrieve_callbacks_); for (std::vector<RetrievePolicyCallback>::iterator cb(callbacks.begin()); cb != callbacks.end(); ++cb) { - cb->Run(device_policy_.policy_blob_); - } - - std::map<std::string, PolicyState>::iterator device_local_account_state; - for (device_local_account_state = device_local_account_policy_.begin(); - device_local_account_state != device_local_account_policy_.end(); - ++device_local_account_state) { - callbacks.swap(device_local_account_state->second.retrieve_callbacks_); - for (std::vector<RetrievePolicyCallback>::iterator cb(callbacks.begin()); - cb != callbacks.end(); ++cb) { - cb->Run(device_local_account_state->second.policy_blob_); - } + cb->Run(policy_blob_); } } @@ -74,22 +53,7 @@ void DeviceSettingsTestHelper::Flush() { FlushLoops(); FlushRetrieve(); FlushLoops(); - } while (HasPendingOperations()); -} - -bool DeviceSettingsTestHelper::HasPendingOperations() const { - if (device_policy_.HasPendingOperations()) - return true; - - std::map<std::string, PolicyState>::const_iterator device_local_account_state; - for (device_local_account_state = device_local_account_policy_.begin(); - device_local_account_state != device_local_account_policy_.end(); - ++device_local_account_state) { - if (device_local_account_state->second.HasPendingOperations()) - return true; - } - - return false; + } while (!store_callbacks_.empty() || !retrieve_callbacks_.empty()); } void DeviceSettingsTestHelper::AddObserver(Observer* observer) {} @@ -129,39 +93,23 @@ bool DeviceSettingsTestHelper::GetIsScreenLocked() { void DeviceSettingsTestHelper::RetrieveDevicePolicy( const RetrievePolicyCallback& callback) { - device_policy_.retrieve_callbacks_.push_back(callback); + retrieve_callbacks_.push_back(callback); } void DeviceSettingsTestHelper::RetrieveUserPolicy( const RetrievePolicyCallback& callback) { } -void DeviceSettingsTestHelper::RetrieveDeviceLocalAccountPolicy( - const std::string& account_id, - const RetrievePolicyCallback& callback) { - device_local_account_policy_[account_id].retrieve_callbacks_.push_back( - callback); -} - void DeviceSettingsTestHelper::StoreDevicePolicy( const std::string& policy_blob, const StorePolicyCallback& callback) { - device_policy_.policy_blob_ = policy_blob; - device_policy_.store_callbacks_.push_back(callback); + policy_blob_ = policy_blob; + store_callbacks_.push_back(callback); } void DeviceSettingsTestHelper::StoreUserPolicy( const std::string& policy_blob, - const StorePolicyCallback& callback) { -} - -void DeviceSettingsTestHelper::StoreDeviceLocalAccountPolicy( - const std::string& account_id, - const std::string& policy_blob, - const StorePolicyCallback& callback) { - device_local_account_policy_[account_id].policy_blob_ = policy_blob; - device_local_account_policy_[account_id].store_callbacks_.push_back(callback); -} + const StorePolicyCallback& callback) {} ScopedDeviceSettingsTestHelper::ScopedDeviceSettingsTestHelper() { DeviceSettingsService::Get()->Initialize(this, new MockOwnerKeyUtil()); diff --git a/chrome/browser/chromeos/settings/device_settings_test_helper.h b/chrome/browser/chromeos/settings/device_settings_test_helper.h index e641f28..3fd8394 100644 --- a/chrome/browser/chromeos/settings/device_settings_test_helper.h +++ b/chrome/browser/chromeos/settings/device_settings_test_helper.h @@ -5,13 +5,11 @@ #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_TEST_HELPER_H_ #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_TEST_HELPER_H_ -#include <map> #include <string> #include <vector> #include "base/basictypes.h" #include "base/compiler_specific.h" -#include "base/string_util.h" #include "chromeos/dbus/session_manager_client.h" namespace chromeos { @@ -39,34 +37,18 @@ class DeviceSettingsTestHelper : public SessionManagerClient { // Flushes all pending operations. void Flush(); - // Checks whether any asynchronous Store/Retrieve operations are pending. - bool HasPendingOperations() const; - bool store_result() { - return device_policy_.store_result_; + return store_result_; } void set_store_result(bool store_result) { - device_policy_.store_result_ = store_result; + store_result_ = store_result; } const std::string& policy_blob() { - return device_policy_.policy_blob_; + return policy_blob_; } void set_policy_blob(const std::string& policy_blob) { - device_policy_.policy_blob_ = policy_blob; - } - - const std::string& device_local_account_policy_blob( - const std::string& id) const { - const std::map<std::string, PolicyState>::const_iterator entry = - device_local_account_policy_.find(id); - return entry == device_local_account_policy_.end() ? - EmptyString() : entry->second.policy_blob_; - } - - void set_device_local_account_policy_blob(const std::string& id, - const std::string& policy_blob) { - device_local_account_policy_[id].policy_blob_ = policy_blob; + policy_blob_ = policy_blob; } // SessionManagerClient: @@ -89,35 +71,17 @@ class DeviceSettingsTestHelper : public SessionManagerClient { const RetrievePolicyCallback& callback) OVERRIDE; virtual void RetrieveUserPolicy( const RetrievePolicyCallback& callback) OVERRIDE; - virtual void RetrieveDeviceLocalAccountPolicy( - const std::string& account_id, - const RetrievePolicyCallback& callback) OVERRIDE; virtual void StoreDevicePolicy(const std::string& policy_blob, const StorePolicyCallback& callback) OVERRIDE; virtual void StoreUserPolicy(const std::string& policy_blob, const StorePolicyCallback& callback) OVERRIDE; - virtual void StoreDeviceLocalAccountPolicy( - const std::string& account_id, - const std::string& policy_blob, - const StorePolicyCallback& callback) OVERRIDE; private: - struct PolicyState { - bool store_result_; - std::string policy_blob_; - std::vector<StorePolicyCallback> store_callbacks_; - std::vector<RetrievePolicyCallback> retrieve_callbacks_; - - PolicyState() - : store_result_(true) {} - - bool HasPendingOperations() const { - return !store_callbacks_.empty() || !retrieve_callbacks_.empty(); - } - }; - - PolicyState device_policy_; - std::map<std::string, PolicyState> device_local_account_policy_; + bool store_result_; + std::string policy_blob_; + + std::vector<StorePolicyCallback> store_callbacks_; + std::vector<RetrievePolicyCallback> retrieve_callbacks_; DISALLOW_COPY_AND_ASSIGN(DeviceSettingsTestHelper); }; diff --git a/chromeos/dbus/mock_session_manager_client.h b/chromeos/dbus/mock_session_manager_client.h index 2841439..25ce152 100644 --- a/chromeos/dbus/mock_session_manager_client.h +++ b/chromeos/dbus/mock_session_manager_client.h @@ -34,19 +34,10 @@ class MockSessionManagerClient : public SessionManagerClient { MOCK_METHOD0(GetIsScreenLocked, bool(void)); MOCK_METHOD1(RetrieveDevicePolicy, void(const RetrievePolicyCallback&)); MOCK_METHOD1(RetrieveUserPolicy, void(const RetrievePolicyCallback&)); - MOCK_METHOD2(RetrieveDeviceLocalAccountPolicy, - void(const std::string&, - const RetrievePolicyCallback&)); - MOCK_METHOD2(StoreDevicePolicy, - void(const std::string&, - const StorePolicyCallback&)); - MOCK_METHOD2(StoreUserPolicy, - void(const std::string&, - const StorePolicyCallback&)); - MOCK_METHOD3(StoreDeviceLocalAccountPolicy, - void(const std::string&, - const std::string&, - const StorePolicyCallback&)); + MOCK_METHOD2(StoreDevicePolicy, void(const std::string&, + const StorePolicyCallback&)); + MOCK_METHOD2(StoreUserPolicy, void(const std::string&, + const StorePolicyCallback&)); }; } // namespace chromeos diff --git a/chromeos/dbus/session_manager_client.cc b/chromeos/dbus/session_manager_client.cc index ff11e1a..67c517c 100644 --- a/chromeos/dbus/session_manager_client.cc +++ b/chromeos/dbus/session_manager_client.cc @@ -180,24 +180,6 @@ class SessionManagerClientImpl : public SessionManagerClient { callback); } - virtual void RetrieveDeviceLocalAccountPolicy( - const std::string& account_name, - const RetrievePolicyCallback& callback) { - dbus::MethodCall method_call( - login_manager::kSessionManagerInterface, - login_manager::kSessionManagerRetrieveDeviceLocalAccountPolicy); - dbus::MessageWriter writer(&method_call); - writer.AppendString(account_name); - session_manager_proxy_->CallMethod( - &method_call, - dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, - base::Bind( - &SessionManagerClientImpl::OnRetrievePolicy, - weak_ptr_factory_.GetWeakPtr(), - login_manager::kSessionManagerRetrieveDeviceLocalAccountPolicy, - callback)); - } - virtual void StoreDevicePolicy(const std::string& policy_blob, const StorePolicyCallback& callback) OVERRIDE { CallStorePolicy(login_manager::kSessionManagerStorePolicy, @@ -210,28 +192,6 @@ class SessionManagerClientImpl : public SessionManagerClient { policy_blob, callback); } - virtual void StoreDeviceLocalAccountPolicy( - const std::string& account_name, - const std::string& policy_blob, - const StorePolicyCallback& callback) OVERRIDE { - dbus::MethodCall method_call( - login_manager::kSessionManagerInterface, - login_manager::kSessionManagerStoreDeviceLocalAccountPolicy); - dbus::MessageWriter writer(&method_call); - writer.AppendString(account_name); - // static_cast does not work due to signedness. - writer.AppendArrayOfBytes( - reinterpret_cast<const uint8*>(policy_blob.data()), policy_blob.size()); - session_manager_proxy_->CallMethod( - &method_call, - dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, - base::Bind( - &SessionManagerClientImpl::OnStorePolicy, - weak_ptr_factory_.GetWeakPtr(), - login_manager::kSessionManagerStoreDeviceLocalAccountPolicy, - callback)); - } - private: // Makes a method call to the session manager with no arguments and no // response. @@ -444,11 +404,6 @@ class SessionManagerClientStubImpl : public SessionManagerClient { const RetrievePolicyCallback& callback) OVERRIDE { callback.Run(""); } - virtual void RetrieveDeviceLocalAccountPolicy( - const std::string& account_name, - const RetrievePolicyCallback& callback) OVERRIDE { - callback.Run(""); - } virtual void StoreDevicePolicy(const std::string& policy_blob, const StorePolicyCallback& callback) OVERRIDE { callback.Run(true); @@ -457,12 +412,6 @@ class SessionManagerClientStubImpl : public SessionManagerClient { const StorePolicyCallback& callback) OVERRIDE { callback.Run(true); } - virtual void StoreDeviceLocalAccountPolicy( - const std::string& account_name, - const std::string& policy_blob, - const StorePolicyCallback& callback) OVERRIDE { - callback.Run(true); - } private: ObserverList<Observer> observers_; diff --git a/chromeos/dbus/session_manager_client.h b/chromeos/dbus/session_manager_client.h index d7b91d4..ff38e8c 100644 --- a/chromeos/dbus/session_manager_client.h +++ b/chromeos/dbus/session_manager_client.h @@ -82,10 +82,9 @@ class CHROMEOS_EXPORT SessionManagerClient { // need to know the current screen lock state when they are added. virtual bool GetIsScreenLocked() = 0; - // Used for RetrieveDevicePolicy, RetrieveUserPolicy and - // RetrieveDeviceLocalAccountPolicy. Takes a serialized protocol buffer as - // string. Upon success, we will pass a protobuf to the callback. On - // failure, we will pass "". + // Used for RetrieveDevicePolicy and RetrieveUserPolicy. Takes a serialized + // protocol buffer as string. Upon success, we will pass a protobuf to the + // callback. On failure, we will pass "". typedef base::Callback<void(const std::string&)> RetrievePolicyCallback; // Fetches the device policy blob stored by the session manager. Upon @@ -97,15 +96,8 @@ class CHROMEOS_EXPORT SessionManagerClient { // call the provided callback. virtual void RetrieveUserPolicy(const RetrievePolicyCallback& callback) = 0; - // Fetches the policy blob associated with the specified device-local account - // from session manager. |callback| is invoked up on completion. - virtual void RetrieveDeviceLocalAccountPolicy( - const std::string& account_id, - const RetrievePolicyCallback& callback) = 0; - - // Used for StoreDevicePolicy, StoreUserPolicy and - // StoreDeviceLocalAccountPolicy. Takes a boolean indicating whether the - // operation was successful or not. + // Used for StoreDevicePolicy and StoreUserPolicy. Takes a boolean indicating + // whether the operation was successful or not. typedef base::Callback<void(bool)> StorePolicyCallback; // Attempts to asynchronously store |policy_blob| as device policy. Upon @@ -119,13 +111,6 @@ class CHROMEOS_EXPORT SessionManagerClient { virtual void StoreUserPolicy(const std::string& policy_blob, const StorePolicyCallback& callback) = 0; - // Sends a request to store a policy blob for the specified device-local - // account. The result of the operation is reported through |callback|. - virtual void StoreDeviceLocalAccountPolicy( - const std::string& account_id, - const std::string& policy_blob, - const StorePolicyCallback& callback) = 0; - // Creates the instance. static SessionManagerClient* Create(DBusClientImplementationType type, dbus::Bus* bus); |