diff options
author | joaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-21 12:25:38 +0000 |
---|---|---|
committer | joaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-21 12:25:38 +0000 |
commit | f5ba12b0dd9d4c2c8132608352e690abd537de2a (patch) | |
tree | 99ce30e6eba726b8d91ea8781cd1a4fc1ca5f8fd | |
parent | 9932aeb9a62901629ba1caaea9d7aff0a8eeaf3a (diff) | |
download | chromium_src-f5ba12b0dd9d4c2c8132608352e690abd537de2a.zip chromium_src-f5ba12b0dd9d4c2c8132608352e690abd537de2a.tar.gz chromium_src-f5ba12b0dd9d4c2c8132608352e690abd537de2a.tar.bz2 |
Cosmetic cleanups in chrome/browser/policy/
BUG=None
TEST=Everything works as before, compiles cleanly
Review URL: http://codereview.chromium.org/7941008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102100 0039d316-1c4b-4281-b951-d872f2087c98
66 files changed, 277 insertions, 244 deletions
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h index 24ac16b..8e0a00c 100644 --- a/chrome/browser/browser_process_impl.h +++ b/chrome/browser/browser_process_impl.h @@ -166,8 +166,6 @@ class BrowserProcessImpl : public BrowserProcess, void CreateStatusTray(); void CreateBackgroundModeManager(); - bool IsSafeBrowsingDetectionServiceEnabled(); - void ApplyDisabledSchemesPolicy(); void ApplyAllowCrossOriginAuthPromptPolicy(); diff --git a/chrome/browser/policy/asynchronous_policy_loader.h b/chrome/browser/policy/asynchronous_policy_loader.h index fff0c8c..1458d82 100644 --- a/chrome/browser/policy/asynchronous_policy_loader.h +++ b/chrome/browser/policy/asynchronous_policy_loader.h @@ -7,12 +7,16 @@ #pragma once #include "base/memory/ref_counted.h" -#include "base/message_loop.h" +#include "base/memory/scoped_ptr.h" #include "base/observer_list.h" +#include "base/time.h" #include "base/values.h" #include "chrome/browser/policy/asynchronous_policy_provider.h" #include "chrome/browser/policy/configuration_policy_provider.h" +class CancelableTask; +class MessageLoop; + namespace policy { // Used by the implementation of asynchronous policy provider to manage the @@ -20,9 +24,8 @@ namespace policy { class AsynchronousPolicyLoader : public base::RefCountedThreadSafe<AsynchronousPolicyLoader> { public: - explicit AsynchronousPolicyLoader( - AsynchronousPolicyProvider::Delegate* delegate, - int reload_interval_minutes); + AsynchronousPolicyLoader(AsynchronousPolicyProvider::Delegate* delegate, + int reload_interval_minutes); // Triggers initial policy load. virtual void Init(); diff --git a/chrome/browser/policy/asynchronous_policy_provider.h b/chrome/browser/policy/asynchronous_policy_provider.h index 3c15a74..337a4ab 100644 --- a/chrome/browser/policy/asynchronous_policy_provider.h +++ b/chrome/browser/policy/asynchronous_policy_provider.h @@ -7,7 +7,6 @@ #pragma once #include "base/memory/ref_counted.h" -#include "base/memory/weak_ptr.h" #include "base/threading/non_thread_safe.h" #include "chrome/browser/policy/configuration_policy_provider.h" @@ -39,7 +38,7 @@ class AsynchronousPolicyProvider virtual ~AsynchronousPolicyProvider(); // ConfigurationPolicyProvider implementation. - virtual bool Provide(PolicyMap* map); + virtual bool Provide(PolicyMap* map) OVERRIDE; // For tests to trigger reloads. scoped_refptr<AsynchronousPolicyLoader> loader(); @@ -50,8 +49,10 @@ class AsynchronousPolicyProvider private: // ConfigurationPolicyProvider overrides: - virtual void AddObserver(ConfigurationPolicyProvider::Observer* observer); - virtual void RemoveObserver(ConfigurationPolicyProvider::Observer* observer); + virtual void AddObserver(ConfigurationPolicyProvider::Observer* observer) + OVERRIDE; + virtual void RemoveObserver(ConfigurationPolicyProvider::Observer* observer) + OVERRIDE; DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyProvider); }; diff --git a/chrome/browser/policy/asynchronous_policy_provider_unittest.cc b/chrome/browser/policy/asynchronous_policy_provider_unittest.cc index c078bf0..1b7c1e1 100644 --- a/chrome/browser/policy/asynchronous_policy_provider_unittest.cc +++ b/chrome/browser/policy/asynchronous_policy_provider_unittest.cc @@ -6,6 +6,7 @@ #include "chrome/browser/policy/asynchronous_policy_provider.h" #include "chrome/browser/policy/asynchronous_policy_test_base.h" #include "chrome/browser/policy/configuration_policy_pref_store.h" +#include "chrome/browser/policy/policy_map.h" #include "policy/policy_constants.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/policy/asynchronous_policy_test_base.h b/chrome/browser/policy/asynchronous_policy_test_base.h index 4737261..373c5a3 100644 --- a/chrome/browser/policy/asynchronous_policy_test_base.h +++ b/chrome/browser/policy/asynchronous_policy_test_base.h @@ -6,6 +6,7 @@ #define CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_TEST_BASE_H_ #pragma once +#include "base/memory/scoped_ptr.h" #include "base/message_loop.h" #include "chrome/browser/policy/asynchronous_policy_provider.h" #include "content/browser/browser_thread.h" diff --git a/chrome/browser/policy/browser_policy_connector.cc b/chrome/browser/policy/browser_policy_connector.cc index c32f426..0b8f295 100644 --- a/chrome/browser/policy/browser_policy_connector.cc +++ b/chrome/browser/policy/browser_policy_connector.cc @@ -5,9 +5,9 @@ #include "chrome/browser/policy/browser_policy_connector.h" #include "base/command_line.h" +#include "base/file_path.h" #include "base/path_service.h" #include "chrome/browser/net/gaia/token_service.h" -#include "chrome/browser/policy/cloud_policy_data_store.h" #include "chrome/browser/policy/cloud_policy_provider.h" #include "chrome/browser/policy/cloud_policy_provider_impl.h" #include "chrome/browser/policy/cloud_policy_subsystem.h" @@ -425,4 +425,4 @@ ConfigurationPolicyProvider* #endif } -} // namespace +} // namespace policy diff --git a/chrome/browser/policy/browser_policy_connector.h b/chrome/browser/policy/browser_policy_connector.h index 1325493..bcf2de4 100644 --- a/chrome/browser/policy/browser_policy_connector.h +++ b/chrome/browser/policy/browser_policy_connector.h @@ -9,7 +9,6 @@ #include <string> #include "base/basictypes.h" -#include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/task.h" #include "chrome/browser/policy/cloud_policy_data_store.h" @@ -17,13 +16,11 @@ #include "content/common/notification_observer.h" #include "content/common/notification_registrar.h" -class FilePath; class TestingBrowserProcess; class TokenService; namespace policy { -class CloudPolicyDataStore; class CloudPolicyProvider; class CloudPolicySubsystem; class ConfigurationPolicyProvider; diff --git a/chrome/browser/policy/cloud_policy_cache_base.cc b/chrome/browser/policy/cloud_policy_cache_base.cc index b9d4cb8..7fe4ab8 100644 --- a/chrome/browser/policy/cloud_policy_cache_base.cc +++ b/chrome/browser/policy/cloud_policy_cache_base.cc @@ -8,7 +8,6 @@ #include "base/logging.h" #include "base/metrics/histogram.h" -#include "base/values.h" #include "chrome/browser/policy/enterprise_metrics.h" #include "chrome/browser/policy/policy_notifier.h" diff --git a/chrome/browser/policy/cloud_policy_controller.cc b/chrome/browser/policy/cloud_policy_controller.cc index 0d454a6..09371b3 100644 --- a/chrome/browser/policy/cloud_policy_controller.cc +++ b/chrome/browser/policy/cloud_policy_controller.cc @@ -5,21 +5,41 @@ #include "chrome/browser/policy/cloud_policy_controller.h" #include <algorithm> +#include <string> #include "base/bind.h" #include "base/logging.h" #include "base/metrics/histogram.h" #include "base/rand_util.h" #include "base/string_util.h" +#include "base/time.h" #include "chrome/browser/policy/cloud_policy_cache_base.h" #include "chrome/browser/policy/cloud_policy_subsystem.h" +#include "chrome/browser/policy/delayed_work_scheduler.h" #include "chrome/browser/policy/device_management_service.h" +#include "chrome/browser/policy/device_token_fetcher.h" #include "chrome/browser/policy/enterprise_metrics.h" +#include "chrome/browser/policy/policy_notifier.h" #include "chrome/browser/policy/proto/device_management_constants.h" #include "chrome/common/guid.h" namespace { +// The maximum ratio in percent of the policy refresh rate we use for adjusting +// the policy refresh time instant. The rationale is to avoid load spikes from +// many devices that were set up in sync for some reason. +const int kPolicyRefreshDeviationFactorPercent = 10; +// Maximum deviation we are willing to accept. +const int64 kPolicyRefreshDeviationMaxInMilliseconds = 30 * 60 * 1000; + +// These are the base values for delays before retrying after an error. They +// will be doubled each time they are used. +const int64 kPolicyRefreshErrorDelayInMilliseconds = + 5 * 60 * 1000; // 5 minutes. + +// Default value for the policy refresh rate. +const int kPolicyRefreshRateInMilliseconds = 3 * 60 * 60 * 1000; // 3 hours. + // Domain names that are known not to be managed. // We don't register the device when such a user logs in. const char* kNonManagedDomains[] = { @@ -44,28 +64,12 @@ bool CanBeInManagedDomain(const std::string& username) { return true; } -} +} // namespace namespace policy { namespace em = enterprise_management; -// The maximum ratio in percent of the policy refresh rate we use for adjusting -// the policy refresh time instant. The rationale is to avoid load spikes from -// many devices that were set up in sync for some reason. -static const int kPolicyRefreshDeviationFactorPercent = 10; -// Maximum deviation we are willing to accept. -static const int64 kPolicyRefreshDeviationMaxInMilliseconds = 30 * 60 * 1000; - -// These are the base values for delays before retrying after an error. They -// will be doubled each time they are used. -static const int64 kPolicyRefreshErrorDelayInMilliseconds = - 5 * 60 * 1000; // 5 minutes - -// Default value for the policy refresh rate. -static const int kPolicyRefreshRateInMilliseconds = - 3 * 60 * 60 * 1000; // 3 hours. - CloudPolicyController::CloudPolicyController( DeviceManagementService* service, CloudPolicyCacheBase* cache, diff --git a/chrome/browser/policy/cloud_policy_controller.h b/chrome/browser/policy/cloud_policy_controller.h index 3ce708a..c446704 100644 --- a/chrome/browser/policy/cloud_policy_controller.h +++ b/chrome/browser/policy/cloud_policy_controller.h @@ -6,19 +6,18 @@ #define CHROME_BROWSER_POLICY_CLOUD_POLICY_CONTROLLER_H_ #pragma once -#include <string> - #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "chrome/browser/policy/cloud_policy_data_store.h" -#include "chrome/browser/policy/configuration_policy_provider.h" -#include "chrome/browser/policy/delayed_work_scheduler.h" -#include "chrome/browser/policy/device_token_fetcher.h" +#include "chrome/browser/policy/device_management_backend.h" namespace policy { class CloudPolicyCacheBase; -class DeviceManagementBackend; +class DelayedWorkScheduler; +class DeviceManagementService; +class DeviceTokenFetcher; +class PolicyNotifier; // Coordinates the actions of DeviceTokenFetcher, CloudPolicyDataStore, // DeviceManagementBackend, and CloudPolicyCache: calls their methods and diff --git a/chrome/browser/policy/cloud_policy_controller_unittest.cc b/chrome/browser/policy/cloud_policy_controller_unittest.cc index 84071e9..4182195 100644 --- a/chrome/browser/policy/cloud_policy_controller_unittest.cc +++ b/chrome/browser/policy/cloud_policy_controller_unittest.cc @@ -5,6 +5,7 @@ #include "chrome/browser/policy/cloud_policy_controller.h" #include "base/message_loop.h" +#include "base/memory/scoped_ptr.h" #include "base/scoped_temp_dir.h" #include "chrome/browser/policy/cloud_policy_data_store.h" #include "chrome/browser/policy/device_token_fetcher.h" @@ -21,10 +22,7 @@ namespace policy { using ::testing::AnyNumber; -using ::testing::AtLeast; using ::testing::InSequence; -using ::testing::Mock; -using ::testing::Return; using ::testing::_; class MockDeviceTokenFetcher : public DeviceTokenFetcher { @@ -239,4 +237,5 @@ TEST_F(CloudPolicyControllerTest, InvalidSerialNumber) { CreateNewController(); loop_.RunAllPending(); } + } // namespace policy diff --git a/chrome/browser/policy/cloud_policy_provider.h b/chrome/browser/policy/cloud_policy_provider.h index 5fa6d98..7c7228e 100644 --- a/chrome/browser/policy/cloud_policy_provider.h +++ b/chrome/browser/policy/cloud_policy_provider.h @@ -7,11 +7,12 @@ #pragma once #include "base/basictypes.h" -#include "chrome/browser/policy/cloud_policy_cache_base.h" #include "chrome/browser/policy/configuration_policy_provider.h" namespace policy { +class CloudPolicyCacheBase; + // A policy provider having multiple backend caches, combining their relevant // PolicyMaps and keeping the result cached. The underlying caches are kept as // weak references and can be added dynamically. Also the diff --git a/chrome/browser/policy/cloud_policy_provider_impl.cc b/chrome/browser/policy/cloud_policy_provider_impl.cc index ddec786..716b131 100644 --- a/chrome/browser/policy/cloud_policy_provider_impl.cc +++ b/chrome/browser/policy/cloud_policy_provider_impl.cc @@ -4,9 +4,6 @@ #include "chrome/browser/policy/cloud_policy_provider_impl.h" -#include <set> - -#include "base/values.h" #include "chrome/browser/policy/configuration_policy_pref_store.h" namespace policy { diff --git a/chrome/browser/policy/cloud_policy_provider_impl.h b/chrome/browser/policy/cloud_policy_provider_impl.h index ed1d33a..c1ff449 100644 --- a/chrome/browser/policy/cloud_policy_provider_impl.h +++ b/chrome/browser/policy/cloud_policy_provider_impl.h @@ -6,6 +6,8 @@ #define CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_IMPL_H_ #pragma once +#include <vector> + #include "base/observer_list.h" #include "chrome/browser/policy/cloud_policy_cache_base.h" #include "chrome/browser/policy/cloud_policy_provider.h" diff --git a/chrome/browser/policy/cloud_policy_subsystem.h b/chrome/browser/policy/cloud_policy_subsystem.h index fc14bee..2810a81 100644 --- a/chrome/browser/policy/cloud_policy_subsystem.h +++ b/chrome/browser/policy/cloud_policy_subsystem.h @@ -72,9 +72,6 @@ class CloudPolicySubsystem CloudPolicyCacheBase* policy_cache); virtual ~CloudPolicySubsystem(); - // net::NetworkChangeNotifier::IPAddressObserver: - virtual void OnIPAddressChanged() OVERRIDE; - // Initializes the subsystem. The first network request will only be made // after |delay_milliseconds|. It can be scheduled to be happen earlier by // calling |ScheduleInitialization|. @@ -126,7 +123,10 @@ class CloudPolicySubsystem // NotificationObserver overrides. virtual void Observe(int type, const NotificationSource& source, - const NotificationDetails& details); + const NotificationDetails& details) OVERRIDE; + + // net::NetworkChangeNotifier::IPAddressObserver: + virtual void OnIPAddressChanged() OVERRIDE; // Name of the preference to read the refresh rate from. const char* refresh_pref_name_; diff --git a/chrome/browser/policy/config_dir_policy_provider.cc b/chrome/browser/policy/config_dir_policy_provider.cc index b659d6a..41aa8e2 100644 --- a/chrome/browser/policy/config_dir_policy_provider.cc +++ b/chrome/browser/policy/config_dir_policy_provider.cc @@ -1,13 +1,16 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/policy/config_dir_policy_provider.h" +#include <algorithm> #include <set> +#include "base/file_path.h" #include "base/file_util.h" -#include "base/values.h" +#include "base/logging.h" +#include "base/platform_file.h" #include "content/common/json_value_serializer.h" namespace policy { diff --git a/chrome/browser/policy/config_dir_policy_provider.h b/chrome/browser/policy/config_dir_policy_provider.h index 3647489..3535ad9 100644 --- a/chrome/browser/policy/config_dir_policy_provider.h +++ b/chrome/browser/policy/config_dir_policy_provider.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,8 +6,12 @@ #define CHROME_BROWSER_POLICY_CONFIG_DIR_POLICY_PROVIDER_H_ #pragma once +#include "base/time.h" +#include "base/values.h" #include "chrome/browser/policy/file_based_policy_provider.h" +class FilePath; + namespace policy { // Policy provider backed by JSON files in a configuration directory. @@ -32,8 +36,8 @@ class ConfigDirPolicyProviderDelegate explicit ConfigDirPolicyProviderDelegate(const FilePath& config_dir); // FileBasedPolicyProvider::ProviderDelegate implementation. - virtual DictionaryValue* Load(); - virtual base::Time GetLastModification(); + virtual DictionaryValue* Load() OVERRIDE; + virtual base::Time GetLastModification() OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(ConfigDirPolicyProviderDelegate); diff --git a/chrome/browser/policy/config_dir_policy_provider_unittest.cc b/chrome/browser/policy/config_dir_policy_provider_unittest.cc index 0b3b32c..8506c4a 100644 --- a/chrome/browser/policy/config_dir_policy_provider_unittest.cc +++ b/chrome/browser/policy/config_dir_policy_provider_unittest.cc @@ -10,6 +10,7 @@ #include "base/string_number_conversions.h" #include "chrome/browser/policy/config_dir_policy_provider.h" #include "chrome/browser/policy/configuration_policy_pref_store.h" +#include "chrome/browser/policy/policy_map.h" #include "content/browser/browser_thread.h" #include "content/common/json_value_serializer.h" #include "policy/policy_constants.h" diff --git a/chrome/browser/policy/configuration_policy_pref_store.cc b/chrome/browser/policy/configuration_policy_pref_store.cc index 65011dd..79913d9 100644 --- a/chrome/browser/policy/configuration_policy_pref_store.cc +++ b/chrome/browser/policy/configuration_policy_pref_store.cc @@ -5,22 +5,17 @@ #include "chrome/browser/policy/configuration_policy_pref_store.h" #include <map> -#include <set> #include <string> #include <vector> -#include "base/command_line.h" -#include "base/lazy_instance.h" #include "base/logging.h" #include "base/stl_util.h" #include "base/string16.h" #include "base/string_util.h" -#include "base/utf_string_conversions.h" -#include "base/values.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/download/download_util.h" #include "chrome/browser/policy/browser_policy_connector.h" -#include "chrome/browser/policy/configuration_policy_provider.h" +#include "chrome/browser/policy/policy_map.h" #include "chrome/browser/policy/policy_path_parser.h" #include "chrome/browser/prefs/incognito_mode_prefs.h" #include "chrome/browser/prefs/pref_value_map.h" @@ -28,7 +23,6 @@ #include "chrome/browser/search_engines/search_terms_data.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/common/pref_names.h" -#include "content/common/notification_service.h" #include "policy/policy_constants.h" namespace policy { @@ -398,8 +392,7 @@ void ConfigurationPolicyPrefKeeper::Apply(PolicyMap* policies) { ApplyAutofillPolicy(current->first, value) || ApplyDownloadDirPolicy(current->first, value) || ApplyDiskCacheDirPolicy(current->first, value) || - ApplyFileSelectionDialogsPolicy(current->first, - value) || + ApplyFileSelectionDialogsPolicy(current->first, value) || ApplyDefaultSearchPolicy(current->first, value) || ApplyIncognitoModePolicy(current->first, value) || ApplyBookmarksPolicy(current->first, value) || @@ -1254,7 +1247,7 @@ void ConfigurationPolicyPrefStore::Refresh() { new ConfigurationPolicyPrefKeeper(provider_)); std::vector<std::string> changed_prefs; new_keeper->GetDifferingPrefPaths(policy_keeper_.get(), &changed_prefs); - policy_keeper_.reset(new_keeper.release()); + policy_keeper_.swap(new_keeper); // Send out change notifications. for (std::vector<std::string>::const_iterator pref(changed_prefs.begin()); diff --git a/chrome/browser/policy/configuration_policy_pref_store.h b/chrome/browser/policy/configuration_policy_pref_store.h index 1ac47db..fca8ad6 100644 --- a/chrome/browser/policy/configuration_policy_pref_store.h +++ b/chrome/browser/policy/configuration_policy_pref_store.h @@ -6,9 +6,6 @@ #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_H_ #pragma once -#include <set> -#include <string> - #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "base/observer_list.h" diff --git a/chrome/browser/policy/configuration_policy_provider.cc b/chrome/browser/policy/configuration_policy_provider.cc index 1c9e80d..99dd1a6 100644 --- a/chrome/browser/policy/configuration_policy_provider.cc +++ b/chrome/browser/policy/configuration_policy_provider.cc @@ -4,7 +4,6 @@ #include "chrome/browser/policy/configuration_policy_provider.h" -#include "base/values.h" #include "chrome/browser/policy/policy_map.h" namespace policy { diff --git a/chrome/browser/policy/configuration_policy_provider.h b/chrome/browser/policy/configuration_policy_provider.h index 1f21899..202c0d1 100644 --- a/chrome/browser/policy/configuration_policy_provider.h +++ b/chrome/browser/policy/configuration_policy_provider.h @@ -10,9 +10,7 @@ #include <string> #include "base/basictypes.h" -#include "base/memory/scoped_ptr.h" #include "base/values.h" -#include "chrome/browser/policy/policy_map.h" #include "policy/configuration_policy_type.h" namespace policy { diff --git a/chrome/browser/policy/configuration_policy_provider_delegate_win.cc b/chrome/browser/policy/configuration_policy_provider_delegate_win.cc index 7e93486..185c18e 100644 --- a/chrome/browser/policy/configuration_policy_provider_delegate_win.cc +++ b/chrome/browser/policy/configuration_policy_provider_delegate_win.cc @@ -1,11 +1,17 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/policy/configuration_policy_provider_delegate_win.h" +#include <string.h> + +#include "base/basictypes.h" +#include "base/logging.h" +#include "base/memory/scoped_ptr.h" #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" +#include "base/values.h" #include "base/win/registry.h" #include "policy/policy_constants.h" diff --git a/chrome/browser/policy/configuration_policy_provider_delegate_win.h b/chrome/browser/policy/configuration_policy_provider_delegate_win.h index 63d36b2..ac00cca9 100644 --- a/chrome/browser/policy/configuration_policy_provider_delegate_win.h +++ b/chrome/browser/policy/configuration_policy_provider_delegate_win.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,13 +13,13 @@ namespace policy { class ConfigurationPolicyProviderDelegateWin : public AsynchronousPolicyProvider::Delegate { public: - ConfigurationPolicyProviderDelegateWin( + explicit ConfigurationPolicyProviderDelegateWin( const ConfigurationPolicyProvider::PolicyDefinitionList* policy_definition_list); virtual ~ConfigurationPolicyProviderDelegateWin() {} // AsynchronousPolicyProvider::Delegate overrides: - virtual DictionaryValue* Load(); + virtual DictionaryValue* Load() OVERRIDE; private: // Methods to perform type-specific policy lookups in the registry. diff --git a/chrome/browser/policy/configuration_policy_provider_mac.cc b/chrome/browser/policy/configuration_policy_provider_mac.cc index d732ff7..b7e12aa 100644 --- a/chrome/browser/policy/configuration_policy_provider_mac.cc +++ b/chrome/browser/policy/configuration_policy_provider_mac.cc @@ -1,19 +1,23 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/policy/configuration_policy_provider_mac.h" +#include "base/file_path.h" #include "base/file_util.h" -#include "base/logging.h" #include "base/mac/scoped_cftyperef.h" #include "base/path_service.h" +#include "base/platform_file.h" #include "base/sys_string_conversions.h" +#include "chrome/browser/preferences_mac.h" #include "chrome/common/chrome_paths.h" namespace policy { -static FilePath GetManagedPolicyPath() { +namespace { + +FilePath GetManagedPolicyPath() { // This constructs the path to the plist file in which Mac OS X stores the // managed preference for the application. This is undocumented and therefore // fragile, but if it doesn't work out, FileBasedPolicyLoader has a task that @@ -34,6 +38,8 @@ static FilePath GetManagedPolicyPath() { return path.Append(base::SysCFStringRefToUTF8(bundle_id) + ".plist"); } +} // namespace + MacPreferencesPolicyProviderDelegate::MacPreferencesPolicyProviderDelegate( MacPreferences* preferences, const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list) diff --git a/chrome/browser/policy/configuration_policy_provider_mac.h b/chrome/browser/policy/configuration_policy_provider_mac.h index 4f2e35f..531335f 100644 --- a/chrome/browser/policy/configuration_policy_provider_mac.h +++ b/chrome/browser/policy/configuration_policy_provider_mac.h @@ -8,7 +8,8 @@ #include "base/memory/scoped_ptr.h" #include "chrome/browser/policy/file_based_policy_provider.h" -#include "chrome/browser/preferences_mac.h" + +class MacPreferences; namespace policy { @@ -23,8 +24,8 @@ class MacPreferencesPolicyProviderDelegate virtual ~MacPreferencesPolicyProviderDelegate(); // FileBasedPolicyLoader::Delegate implementation. - virtual DictionaryValue* Load(); - virtual base::Time GetLastModification(); + virtual DictionaryValue* Load() OVERRIDE; + virtual base::Time GetLastModification() OVERRIDE; private: // In order to access the application preferences API, the names and values of @@ -41,8 +42,7 @@ class MacPreferencesPolicyProviderDelegate // An implementation of |ConfigurationPolicyProvider| using the mechanism // provided by Mac OS X's managed preferences. -class ConfigurationPolicyProviderMac - : public FileBasedPolicyProvider { +class ConfigurationPolicyProviderMac : public FileBasedPolicyProvider { public: explicit ConfigurationPolicyProviderMac( const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list); diff --git a/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc b/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc index e273f09..6583355 100644 --- a/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc +++ b/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc @@ -9,6 +9,7 @@ #include "base/sys_string_conversions.h" #include "chrome/browser/policy/configuration_policy_pref_store.h" #include "chrome/browser/policy/configuration_policy_provider_mac.h" +#include "chrome/browser/policy/policy_map.h" #include "chrome/browser/preferences_mock_mac.h" #include "policy/policy_constants.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/policy/configuration_policy_provider_win.cc b/chrome/browser/policy/configuration_policy_provider_win.cc index df336d3..bb4b39d 100644 --- a/chrome/browser/policy/configuration_policy_provider_win.cc +++ b/chrome/browser/policy/configuration_policy_provider_win.cc @@ -1,19 +1,22 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/policy/configuration_policy_provider_win.h" -#include "chrome/browser/policy/asynchronous_policy_provider.h" #include "chrome/browser/policy/configuration_policy_loader_win.h" #include "chrome/browser/policy/configuration_policy_provider_delegate_win.h" namespace policy { +namespace { + // Period at which to run the reload task in case the group policy change // watchers fail. const int kReloadIntervalMinutes = 15; +} // namespace + ConfigurationPolicyProviderWin::ConfigurationPolicyProviderWin( const PolicyDefinitionList* policy_list) : AsynchronousPolicyProvider( diff --git a/chrome/browser/policy/configuration_policy_provider_win_unittest.cc b/chrome/browser/policy/configuration_policy_provider_win_unittest.cc index 383d84a..4200430 100644 --- a/chrome/browser/policy/configuration_policy_provider_win_unittest.cc +++ b/chrome/browser/policy/configuration_policy_provider_win_unittest.cc @@ -15,6 +15,7 @@ #include "chrome/browser/policy/asynchronous_policy_loader.h" #include "chrome/browser/policy/configuration_policy_pref_store.h" #include "chrome/browser/policy/configuration_policy_provider_win.h" +#include "chrome/browser/policy/policy_map.h" #include "chrome/common/pref_names.h" #include "content/browser/browser_thread.h" #include "policy/policy_constants.h" diff --git a/chrome/browser/policy/configuration_policy_reader.cc b/chrome/browser/policy/configuration_policy_reader.cc index f9e39b8..9dd1d4a 100644 --- a/chrome/browser/policy/configuration_policy_reader.cc +++ b/chrome/browser/policy/configuration_policy_reader.cc @@ -7,7 +7,9 @@ #include <map> #include <vector> +#include "base/logging.h" #include "base/stl_util.h" +#include "base/string16.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/policy/browser_policy_connector.h" @@ -77,10 +79,7 @@ void ConfigurationPolicyStatusKeeper::GetPoliciesFromProvider( PolicyMap::const_iterator policy = policies->begin(); for ( ; policy != policies->end(); ++policy) { string16 name = PolicyStatus::GetPolicyName(policy->first); - - if (name == string16()) { - NOTREACHED(); - } + DCHECK(!name.empty()); // TODO(simo) actually determine whether the policy is a user or a device // one and whether the policy could be enforced or not once this information @@ -153,7 +152,7 @@ ConfigurationPolicyReader* g_browser_process->browser_policy_connector(); return new ConfigurationPolicyReader( connector->GetRecommendedPlatformProvider(), - PolicyStatusInfo::RECOMMENDED); + PolicyStatusInfo::RECOMMENDED); } // static @@ -180,10 +179,8 @@ void ConfigurationPolicyReader::Refresh() { if (!provider_) return; - // Read policy state into a new keeper and swap out old keeper. - scoped_ptr<ConfigurationPolicyStatusKeeper> new_keeper( + policy_keeper_.reset( new ConfigurationPolicyStatusKeeper(provider_, policy_level_)); - policy_keeper_.reset(new_keeper.release()); FOR_EACH_OBSERVER(Observer, observers_, OnPolicyValuesChanged()); } @@ -250,7 +247,7 @@ ListValue* PolicyStatus::GetPolicyStatusList(bool* any_policies_set) const { string16 PolicyStatus::GetPolicyName(ConfigurationPolicyType policy_type) { static std::map<ConfigurationPolicyType, string16> name_map; static const ConfigurationPolicyProvider::PolicyDefinitionList* - supported_policies; + supported_policies = NULL; if (!supported_policies) { supported_policies = diff --git a/chrome/browser/policy/configuration_policy_reader.h b/chrome/browser/policy/configuration_policy_reader.h index f1eb523..80d9cea 100644 --- a/chrome/browser/policy/configuration_policy_reader.h +++ b/chrome/browser/policy/configuration_policy_reader.h @@ -11,6 +11,7 @@ #include "base/values.h" #include "chrome/browser/policy/configuration_policy_provider.h" #include "chrome/browser/policy/policy_status_info.h" +#include "policy/configuration_policy_type.h" namespace policy { @@ -39,8 +40,8 @@ class ConfigurationPolicyReader : public ConfigurationPolicyProvider::Observer { virtual ~ConfigurationPolicyReader(); // ConfigurationPolicyProvider::Observer methods: - virtual void OnUpdatePolicy(); - virtual void OnProviderGoingAway(); + virtual void OnUpdatePolicy() OVERRIDE; + virtual void OnProviderGoingAway() OVERRIDE; // Methods to handle Observers. |observer| must be non-NULL. void AddObserver(Observer* observer); diff --git a/chrome/browser/policy/delayed_work_scheduler.cc b/chrome/browser/policy/delayed_work_scheduler.cc index 35fd049..8879330 100644 --- a/chrome/browser/policy/delayed_work_scheduler.cc +++ b/chrome/browser/policy/delayed_work_scheduler.cc @@ -4,11 +4,6 @@ #include "chrome/browser/policy/delayed_work_scheduler.h" -#include <algorithm> - -#include "base/logging.h" -#include "base/message_loop.h" - namespace policy { DelayedWorkScheduler::DelayedWorkScheduler() { diff --git a/chrome/browser/policy/delayed_work_scheduler.h b/chrome/browser/policy/delayed_work_scheduler.h index 8dd543e..6e288f9 100644 --- a/chrome/browser/policy/delayed_work_scheduler.h +++ b/chrome/browser/policy/delayed_work_scheduler.h @@ -6,6 +6,7 @@ #define CHROME_BROWSER_POLICY_DELAYED_WORK_SCHEDULER_H_ #pragma once +#include "base/basictypes.h" #include "base/callback.h" #include "base/timer.h" diff --git a/chrome/browser/policy/device_management_backend.h b/chrome/browser/policy/device_management_backend.h index e160f44..9e8ec63 100644 --- a/chrome/browser/policy/device_management_backend.h +++ b/chrome/browser/policy/device_management_backend.h @@ -8,7 +8,6 @@ #include <string> -#include "base/basictypes.h" #include "base/threading/non_thread_safe.h" #include "chrome/browser/policy/cloud_policy_data_store.h" #include "chrome/browser/policy/proto/device_management_backend.pb.h" diff --git a/chrome/browser/policy/device_management_backend_impl.cc b/chrome/browser/policy/device_management_backend_impl.cc index bbac2d6..c111ad3 100644 --- a/chrome/browser/policy/device_management_backend_impl.cc +++ b/chrome/browser/policy/device_management_backend_impl.cc @@ -7,10 +7,6 @@ #include <utility> #include <vector> -#if defined(OS_POSIX) && !defined(OS_MACOSX) -#include <sys/utsname.h> -#endif - #include "base/metrics/histogram.h" #include "base/stringprintf.h" #include "base/sys_info.h" @@ -84,8 +80,6 @@ const char kMachineInfoHWClass[] = "hardware_class"; const char kMachineInfoBoard[] = "CHROMEOS_RELEASE_BOARD"; #endif -} // namespace - // Helper class for URL query parameter encoding/decoding. class URLQueryParameters { public: @@ -124,6 +118,8 @@ std::string URLQueryParameters::Encode() { return result; } +} // namespace + // A base class containing the common code for the jobs created by the backend // implementation. Subclasses provide custom code for handling actual register, // unregister, and policy jobs. @@ -322,7 +318,7 @@ class DeviceManagementRegisterJob : public DeviceManagementJobBase { private: // DeviceManagementJobBase overrides. - virtual void OnError(DeviceManagementBackend::ErrorCode error) { + virtual void OnError(DeviceManagementBackend::ErrorCode error) OVERRIDE { MetricToken sample; switch (error) { case DeviceManagementBackend::kErrorRequestInvalid: @@ -351,7 +347,8 @@ class DeviceManagementRegisterJob : public DeviceManagementJobBase { UMA_HISTOGRAM_ENUMERATION(kMetricToken, sample, kMetricTokenSize); delegate_->OnError(error); } - virtual void OnResponse(const em::DeviceManagementResponse& response) { + virtual void OnResponse( + const em::DeviceManagementResponse& response) OVERRIDE { UMA_HISTOGRAM_ENUMERATION(kMetricToken, kMetricTokenFetchResponseReceived, kMetricTokenSize); delegate_->HandleRegisterResponse(response.register_response()); @@ -385,10 +382,11 @@ class DeviceManagementUnregisterJob : public DeviceManagementJobBase { private: // DeviceManagementJobBase overrides. - virtual void OnError(DeviceManagementBackend::ErrorCode error) { + virtual void OnError(DeviceManagementBackend::ErrorCode error) OVERRIDE { delegate_->OnError(error); } - virtual void OnResponse(const em::DeviceManagementResponse& response) { + virtual void OnResponse( + const em::DeviceManagementResponse& response) OVERRIDE { delegate_->HandleUnregisterResponse(response.unregister_response()); } @@ -423,7 +421,7 @@ class DeviceManagementPolicyJob : public DeviceManagementJobBase { private: // DeviceManagementJobBase overrides. - virtual void OnError(DeviceManagementBackend::ErrorCode error) { + virtual void OnError(DeviceManagementBackend::ErrorCode error) OVERRIDE { MetricPolicy sample; switch (error) { case DeviceManagementBackend::kErrorRequestInvalid: @@ -446,7 +444,8 @@ class DeviceManagementPolicyJob : public DeviceManagementJobBase { UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, sample, kMetricPolicySize); delegate_->OnError(error); } - virtual void OnResponse(const em::DeviceManagementResponse& response) { + virtual void OnResponse( + const em::DeviceManagementResponse& response) OVERRIDE { UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchResponseReceived, kMetricPolicySize); delegate_->HandlePolicyResponse(response.policy_response()); diff --git a/chrome/browser/policy/device_management_service.cc b/chrome/browser/policy/device_management_service.cc index e9b2921..9a51ae7 100644 --- a/chrome/browser/policy/device_management_service.cc +++ b/chrome/browser/policy/device_management_service.cc @@ -4,9 +4,11 @@ #include "chrome/browser/policy/device_management_service.h" +#include "base/message_loop.h" +#include "base/message_loop_proxy.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/io_thread.h" #include "chrome/browser/net/chrome_net_log.h" +#include "chrome/browser/policy/device_management_backend.h" #include "chrome/browser/policy/device_management_backend_impl.h" #include "content/browser/browser_thread.h" #include "net/base/cookie_monster.h" @@ -14,7 +16,6 @@ #include "net/base/load_flags.h" #include "net/base/net_errors.h" #include "net/base/ssl_config_service_defaults.h" -#include "net/http/http_auth_handler_factory.h" #include "net/http/http_network_layer.h" #include "net/proxy/proxy_service.h" #include "net/url_request/url_request_context.h" @@ -36,7 +37,7 @@ class DeviceManagementRequestContext : public net::URLRequestContext { private: // Overridden from net::URLRequestContext: - virtual const std::string& GetUserAgent(const GURL& url) const; + virtual const std::string& GetUserAgent(const GURL& url) const OVERRIDE; }; DeviceManagementRequestContext::DeviceManagementRequestContext( @@ -75,13 +76,14 @@ const std::string& DeviceManagementRequestContext::GetUserAgent( class DeviceManagementRequestContextGetter : public net::URLRequestContextGetter { public: - DeviceManagementRequestContextGetter( + explicit DeviceManagementRequestContextGetter( net::URLRequestContextGetter* base_context_getter) : base_context_getter_(base_context_getter) {} // Overridden from net::URLRequestContextGetter: - virtual net::URLRequestContext* GetURLRequestContext(); - virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const; + virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; + virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() + const OVERRIDE; private: scoped_refptr<net::URLRequestContext> context_; diff --git a/chrome/browser/policy/device_management_service.h b/chrome/browser/policy/device_management_service.h index d2c5122..63bfeee1 100644 --- a/chrome/browser/policy/device_management_service.h +++ b/chrome/browser/policy/device_management_service.h @@ -11,19 +11,18 @@ #include <string> #include "base/basictypes.h" -#include "chrome/browser/policy/device_management_backend.h" +#include "base/memory/ref_counted.h" +#include "base/task.h" #include "content/common/net/url_fetcher.h" #include "googleurl/src/gurl.h" -class Profile; - namespace net { class URLRequestContextGetter; } namespace policy { -class DeviceManagementBackendImpl; +class DeviceManagementBackend; // The device management service is responsible for everything related to // communication with the device management server. It creates the backends @@ -86,7 +85,7 @@ class DeviceManagementService : public URLFetcher::Delegate { const net::URLRequestStatus& status, int response_code, const net::ResponseCookies& cookies, - const std::string& data); + const std::string& data) OVERRIDE; // Does the actual initialization using the request context specified for // |PrepareInitialization|. This will also fire any pending network requests. diff --git a/chrome/browser/policy/device_policy_cache.cc b/chrome/browser/policy/device_policy_cache.cc index 654f5c7..090ad76 100644 --- a/chrome/browser/policy/device_policy_cache.cc +++ b/chrome/browser/policy/device_policy_cache.cc @@ -4,7 +4,9 @@ #include "chrome/browser/policy/device_policy_cache.h" +#include <limits> #include <string> +#include <vector> #include "base/basictypes.h" #include "base/compiler_specific.h" @@ -13,7 +15,6 @@ #include "base/values.h" #include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/cros/update_library.h" -#include "chrome/browser/chromeos/cros_settings_names.h" #include "chrome/browser/chromeos/login/ownership_service.h" #include "chrome/browser/chromeos/user_cros_settings_provider.h" #include "chrome/browser/policy/cloud_policy_data_store.h" diff --git a/chrome/browser/policy/device_policy_cache_unittest.cc b/chrome/browser/policy/device_policy_cache_unittest.cc index 7b706d1..35c3cdc 100644 --- a/chrome/browser/policy/device_policy_cache_unittest.cc +++ b/chrome/browser/policy/device_policy_cache_unittest.cc @@ -20,7 +20,6 @@ namespace { const char kTestUser[] = "test@example.com"; using ::chromeos::SignedSettings; -using ::chromeos::SignedSettingsHelper; using ::testing::_; using ::testing::InSequence; diff --git a/chrome/browser/policy/device_token_fetcher.cc b/chrome/browser/policy/device_token_fetcher.cc index 74ca671..bc565b0 100644 --- a/chrome/browser/policy/device_token_fetcher.cc +++ b/chrome/browser/policy/device_token_fetcher.cc @@ -7,12 +7,14 @@ #include <algorithm> #include "base/bind.h" -#include "base/callback.h" #include "base/metrics/histogram.h" +#include "base/time.h" #include "chrome/browser/policy/cloud_policy_cache_base.h" #include "chrome/browser/policy/cloud_policy_data_store.h" +#include "chrome/browser/policy/delayed_work_scheduler.h" #include "chrome/browser/policy/device_management_service.h" #include "chrome/browser/policy/enterprise_metrics.h" +#include "chrome/browser/policy/policy_notifier.h" #include "chrome/browser/policy/proto/device_management_constants.h" #include "chrome/browser/policy/proto/device_management_local.pb.h" diff --git a/chrome/browser/policy/device_token_fetcher.h b/chrome/browser/policy/device_token_fetcher.h index 2b74193..f446f66 100644 --- a/chrome/browser/policy/device_token_fetcher.h +++ b/chrome/browser/policy/device_token_fetcher.h @@ -7,16 +7,16 @@ #pragma once #include "base/memory/scoped_ptr.h" -#include "chrome/browser/policy/delayed_work_scheduler.h" #include "chrome/browser/policy/device_management_backend.h" -#include "chrome/browser/policy/policy_notifier.h" #include "chrome/browser/policy/proto/device_management_backend.pb.h" namespace policy { class CloudPolicyCacheBase; class CloudPolicyDataStore; +class DelayedWorkScheduler; class DeviceManagementService; +class PolicyNotifier; namespace em = enterprise_management; @@ -124,6 +124,8 @@ class DeviceTokenFetcher CloudPolicyDataStore* data_store_; scoped_ptr<DelayedWorkScheduler> scheduler_; + + DISALLOW_COPY_AND_ASSIGN(DeviceTokenFetcher); }; } // namespace policy diff --git a/chrome/browser/policy/dummy_cloud_policy_provider.h b/chrome/browser/policy/dummy_cloud_policy_provider.h index 3a75069..80cbefc 100644 --- a/chrome/browser/policy/dummy_cloud_policy_provider.h +++ b/chrome/browser/policy/dummy_cloud_policy_provider.h @@ -6,6 +6,7 @@ #define CHROME_BROWSER_POLICY_DUMMY_CLOUD_POLICY_PROVIDER_H_ #pragma once +#include "base/observer_list.h" #include "chrome/browser/policy/cloud_policy_provider.h" namespace policy { diff --git a/chrome/browser/policy/dummy_configuration_policy_provider.h b/chrome/browser/policy/dummy_configuration_policy_provider.h index 5d0a956..77ee8d0 100644 --- a/chrome/browser/policy/dummy_configuration_policy_provider.h +++ b/chrome/browser/policy/dummy_configuration_policy_provider.h @@ -11,15 +11,13 @@ namespace policy { -class ConfigurationPolicyStoreInterface; - class DummyConfigurationPolicyProvider : public ConfigurationPolicyProvider { public: explicit DummyConfigurationPolicyProvider( const PolicyDefinitionList* policy_list); virtual ~DummyConfigurationPolicyProvider(); - virtual bool Provide(PolicyMap* map); + virtual bool Provide(PolicyMap* map) OVERRIDE; private: // ConfigurationPolicyProvider overrides: diff --git a/chrome/browser/policy/enterprise_install_attributes.cc b/chrome/browser/policy/enterprise_install_attributes.cc index 03ebc96..6d89722 100644 --- a/chrome/browser/policy/enterprise_install_attributes.cc +++ b/chrome/browser/policy/enterprise_install_attributes.cc @@ -7,8 +7,12 @@ #include "base/logging.h" #include "chrome/browser/chromeos/cros/cryptohome_library.h" -static const char kAttrEnterpriseOwned[] = "enterprise.owned"; -static const char kAttrEnterpriseUser[] = "enterprise.user"; +namespace { + +const char kAttrEnterpriseOwned[] = "enterprise.owned"; +const char kAttrEnterpriseUser[] = "enterprise.user"; + +} // namespace namespace policy { diff --git a/chrome/browser/policy/file_based_policy_loader.cc b/chrome/browser/policy/file_based_policy_loader.cc index e97d065..46d0439 100644 --- a/chrome/browser/policy/file_based_policy_loader.cc +++ b/chrome/browser/policy/file_based_policy_loader.cc @@ -4,7 +4,9 @@ #include "chrome/browser/policy/file_based_policy_loader.h" -#include "base/compiler_specific.h" +#include "base/files/file_path_watcher.h" +#include "base/memory/ref_counted.h" +#include "base/values.h" #include "content/browser/browser_thread.h" using ::base::files::FilePathWatcher; diff --git a/chrome/browser/policy/file_based_policy_loader.h b/chrome/browser/policy/file_based_policy_loader.h index 4a2919c..e31d72c 100644 --- a/chrome/browser/policy/file_based_policy_loader.h +++ b/chrome/browser/policy/file_based_policy_loader.h @@ -6,10 +6,21 @@ #define CHROME_BROWSER_POLICY_FILE_BASED_POLICY_LOADER_H_ #pragma once -#include "base/files/file_path_watcher.h" +#include "base/compiler_specific.h" +#include "base/file_path.h" +#include "base/memory/scoped_ptr.h" +#include "base/time.h" #include "chrome/browser/policy/asynchronous_policy_loader.h" #include "chrome/browser/policy/file_based_policy_provider.h" +namespace base { +namespace files { + +class FilePathWatcher; + +} // namespace files +} // namespace base + namespace policy { // A customized asynchronous policy loader that handles loading policy from a @@ -18,11 +29,11 @@ namespace policy { // the watched file is in flux. class FileBasedPolicyLoader : public AsynchronousPolicyLoader { public: - FileBasedPolicyLoader( + explicit FileBasedPolicyLoader( FileBasedPolicyProvider::ProviderDelegate* provider_delegate); // AsynchronousPolicyLoader overrides: - virtual void Reload(); + virtual void Reload() OVERRIDE; void OnFilePathChanged(const FilePath& path); void OnFilePathError(const FilePath& path); @@ -39,8 +50,8 @@ class FileBasedPolicyLoader : public AsynchronousPolicyLoader { // Creates the file path watcher and configures it to watch // |config_file_path_|. Must be called on the file thread. - virtual void InitOnFileThread(); - virtual void StopOnFileThread(); + virtual void InitOnFileThread() OVERRIDE; + virtual void StopOnFileThread() OVERRIDE; private: // Checks whether policy information is safe to read. If not, returns false diff --git a/chrome/browser/policy/file_based_policy_provider_unittest.cc b/chrome/browser/policy/file_based_policy_provider_unittest.cc index aee36c7..fd392e5c 100644 --- a/chrome/browser/policy/file_based_policy_provider_unittest.cc +++ b/chrome/browser/policy/file_based_policy_provider_unittest.cc @@ -6,6 +6,7 @@ #include "chrome/browser/policy/asynchronous_policy_test_base.h" #include "chrome/browser/policy/configuration_policy_pref_store.h" #include "chrome/browser/policy/file_based_policy_provider.h" +#include "chrome/browser/policy/policy_map.h" #include "policy/policy_constants.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/policy/logging_work_scheduler.cc b/chrome/browser/policy/logging_work_scheduler.cc index f83c4c9..39292e6 100644 --- a/chrome/browser/policy/logging_work_scheduler.cc +++ b/chrome/browser/policy/logging_work_scheduler.cc @@ -6,7 +6,7 @@ #include <algorithm> -#include "base/compiler_specific.h" +#include "base/message_loop.h" #include "content/browser/browser_thread.h" namespace policy { diff --git a/chrome/browser/policy/logging_work_scheduler.h b/chrome/browser/policy/logging_work_scheduler.h index 9ee4c6b..3dd867b 100644 --- a/chrome/browser/policy/logging_work_scheduler.h +++ b/chrome/browser/policy/logging_work_scheduler.h @@ -10,7 +10,10 @@ #include <vector> #include "base/basictypes.h" +#include "base/callback.h" +#include "base/compiler_specific.h" #include "base/memory/linked_ptr.h" +#include "base/task.h" #include "chrome/browser/policy/delayed_work_scheduler.h" // Utilities for testing users of DelayedWorkScheduler. There are no @@ -108,8 +111,9 @@ class LoggingWorkScheduler : public DelayedWorkScheduler { explicit LoggingWorkScheduler(EventLogger* logger); virtual ~LoggingWorkScheduler(); - virtual void PostDelayedWork(const base::Closure& callback, int64 delay); - virtual void CancelDelayedWork(); + virtual void PostDelayedWork(const base::Closure& callback, int64 delay) + OVERRIDE; + virtual void CancelDelayedWork() OVERRIDE; private: EventLogger* logger_; @@ -125,7 +129,8 @@ class DummyWorkScheduler : public DelayedWorkScheduler { DummyWorkScheduler(); virtual ~DummyWorkScheduler(); - virtual void PostDelayedWork(const base::Closure& callback, int64 delay); + virtual void PostDelayedWork(const base::Closure& callback, int64 delay) + OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(DummyWorkScheduler); diff --git a/chrome/browser/policy/mock_configuration_policy_provider.cc b/chrome/browser/policy/mock_configuration_policy_provider.cc index b659273..c65e583 100644 --- a/chrome/browser/policy/mock_configuration_policy_provider.cc +++ b/chrome/browser/policy/mock_configuration_policy_provider.cc @@ -4,7 +4,6 @@ #include "chrome/browser/policy/mock_configuration_policy_provider.h" -#include "base/stl_util.h" #include "chrome/browser/policy/configuration_policy_pref_store.h" namespace policy { diff --git a/chrome/browser/policy/mock_configuration_policy_provider.h b/chrome/browser/policy/mock_configuration_policy_provider.h index de266dc..bb61215 100644 --- a/chrome/browser/policy/mock_configuration_policy_provider.h +++ b/chrome/browser/policy/mock_configuration_policy_provider.h @@ -6,12 +6,8 @@ #define CHROME_BROWSER_POLICY_MOCK_CONFIGURATION_POLICY_PROVIDER_H_ #pragma once -#include <map> -#include <utility> - #include "chrome/browser/policy/configuration_policy_provider.h" #include "chrome/browser/policy/policy_map.h" -#include "testing/gmock/include/gmock/gmock.h" namespace policy { @@ -28,14 +24,15 @@ class MockConfigurationPolicyProvider : public ConfigurationPolicyProvider { void SetInitializationComplete(bool initialization_complete); // ConfigurationPolicyProvider method overrides. - virtual bool Provide(PolicyMap* policies); - virtual bool IsInitializationComplete() const; + virtual bool Provide(PolicyMap* policies) OVERRIDE; + virtual bool IsInitializationComplete() const OVERRIDE; private: // ConfigurationPolicyProvider overrides: - virtual void AddObserver(ConfigurationPolicyProvider::Observer* observer) {} + virtual void AddObserver( + ConfigurationPolicyProvider::Observer* observer) OVERRIDE {} virtual void RemoveObserver( - ConfigurationPolicyProvider::Observer* observer) {} + ConfigurationPolicyProvider::Observer* observer) OVERRIDE {} PolicyMap policy_map_; bool initialization_complete_; diff --git a/chrome/browser/policy/mock_device_management_backend.h b/chrome/browser/policy/mock_device_management_backend.h index 311d225..4e4a7c2 100644 --- a/chrome/browser/policy/mock_device_management_backend.h +++ b/chrome/browser/policy/mock_device_management_backend.h @@ -6,11 +6,9 @@ #define CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_BACKEND_H_ #pragma once -#include <map> #include <string> #include "base/time.h" -#include "base/values.h" #include "chrome/browser/policy/device_management_backend.h" #include "chrome/browser/policy/proto/cloud_policy.pb.h" #include "chrome/browser/policy/proto/device_management_backend.pb.h" diff --git a/chrome/browser/policy/policy_path_parser_win.cc b/chrome/browser/policy/policy_path_parser_win.cc index 33e8af8..ef13bb1 100644 --- a/chrome/browser/policy/policy_path_parser_win.cc +++ b/chrome/browser/policy/policy_path_parser_win.cc @@ -6,7 +6,6 @@ #include "chrome/browser/policy/policy_path_parser.h" -#include "base/logging.h" #include "base/memory/scoped_ptr.h" namespace policy { diff --git a/chrome/browser/policy/policy_status_info.cc b/chrome/browser/policy/policy_status_info.cc index 5b6131b..2b740df 100644 --- a/chrome/browser/policy/policy_status_info.cc +++ b/chrome/browser/policy/policy_status_info.cc @@ -83,4 +83,4 @@ string16 PolicyStatusInfo::GetPolicyLevelString(PolicyLevel level) { return ASCIIToUTF16(strings[level]); } -} // namespace policy +} // namespace policy diff --git a/chrome/browser/policy/policy_status_info.h b/chrome/browser/policy/policy_status_info.h index 09f68cc..2eecf19 100644 --- a/chrome/browser/policy/policy_status_info.h +++ b/chrome/browser/policy/policy_status_info.h @@ -1,4 +1,4 @@ - // Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,7 +8,6 @@ #include "base/memory/scoped_ptr.h" #include "base/string16.h" #include "base/values.h" -#include "policy/configuration_policy_type.h" namespace policy { @@ -89,6 +88,6 @@ struct PolicyStatusInfo { DISALLOW_COPY_AND_ASSIGN(PolicyStatusInfo); }; -} // namespace policy +} // namespace policy #endif // CHROME_BROWSER_POLICY_POLICY_STATUS_INFO_H_ diff --git a/chrome/browser/policy/testing_cloud_policy_subsystem.h b/chrome/browser/policy/testing_cloud_policy_subsystem.h index fde7cda..6f95e3a 100644 --- a/chrome/browser/policy/testing_cloud_policy_subsystem.h +++ b/chrome/browser/policy/testing_cloud_policy_subsystem.h @@ -10,6 +10,7 @@ namespace policy { +class CloudPolicyCacheBase; class CloudPolicyDataStore; class EventLogger; diff --git a/chrome/browser/policy/testing_policy_url_fetcher_factory.cc b/chrome/browser/policy/testing_policy_url_fetcher_factory.cc index 97feda1..1a2bdff 100644 --- a/chrome/browser/policy/testing_policy_url_fetcher_factory.cc +++ b/chrome/browser/policy/testing_policy_url_fetcher_factory.cc @@ -5,10 +5,11 @@ #include "chrome/browser/policy/testing_policy_url_fetcher_factory.h" #include "base/bind.h" -#include "base/callback.h" #include "chrome/browser/policy/logging_work_scheduler.h" +#include "googleurl/src/gurl.h" #include "googleurl/src/url_parse.h" #include "net/http/http_request_headers.h" +#include "net/url_request/url_request.h" #include "net/url_request/url_request_status.h" namespace { @@ -41,7 +42,7 @@ class TestingPolicyURLFetcher : public URLFetcher { URLFetcher::RequestType request_type, URLFetcher::Delegate* delegate); - virtual void Start(); + virtual void Start() OVERRIDE; void Respond(); private: diff --git a/chrome/browser/policy/testing_policy_url_fetcher_factory.h b/chrome/browser/policy/testing_policy_url_fetcher_factory.h index d109f58..68e1290 100644 --- a/chrome/browser/policy/testing_policy_url_fetcher_factory.h +++ b/chrome/browser/policy/testing_policy_url_fetcher_factory.h @@ -10,14 +10,16 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" -#include "chrome/browser/policy/logging_work_scheduler.h" #include "content/common/net/url_fetcher.h" #include "content/test/test_url_fetcher_factory.h" -#include "googleurl/src/gurl.h" #include "testing/gmock/include/gmock/gmock.h" +class GURL; + namespace policy { +class EventLogger; +class LoggingWorkScheduler; class TestingPolicyURLFetcher; struct TestURLResponse { @@ -37,7 +39,7 @@ class TestingPolicyURLFetcherFactory : public URLFetcher::Factory, int id, const GURL& url, URLFetcher::RequestType request_type, - URLFetcher::Delegate* delegate); + URLFetcher::Delegate* delegate) OVERRIDE; LoggingWorkScheduler* scheduler(); diff --git a/chrome/browser/policy/url_blacklist_manager.cc b/chrome/browser/policy/url_blacklist_manager.cc index c68b774..8cc32c7 100644 --- a/chrome/browser/policy/url_blacklist_manager.cc +++ b/chrome/browser/policy/url_blacklist_manager.cc @@ -7,7 +7,6 @@ #include "base/bind.h" #include "base/stl_util.h" #include "base/string_number_conversions.h" -#include "base/string_util.h" #include "base/values.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/prefs/pref_service.h" @@ -86,60 +85,6 @@ URLBlacklist::~URLBlacklist() { STLDeleteValues(&host_filters_); } -void URLBlacklist::AddFilter(const std::string& filter, bool block) { - std::string scheme; - std::string host; - uint16 port; - std::string path; - SchemeFlag flag; - bool match_subdomains = true; - - if (!FilterToComponents(filter, &scheme, &host, &port, &path)) { - LOG(WARNING) << "Invalid filter, ignoring: " << filter; - return; - } - - if (!SchemeToFlag(scheme, &flag)) { - LOG(WARNING) << "Unsupported scheme in filter, ignoring filter: " << filter; - return; - } - - // Special syntax to disable subdomain matching. - if (!host.empty() && host[0] == '.') { - host.erase(0, 1); - match_subdomains = false; - } - - // Try to find an existing PathFilter with the same path prefix, port and - // match_subdomains value. - PathFilterList* list; - HostFilterTable::iterator host_filter = host_filters_.find(host); - if (host_filter == host_filters_.end()) { - list = new PathFilterList; - host_filters_[host] = list; - } else { - list = host_filter->second; - } - PathFilterList::iterator it; - for (it = list->begin(); it != list->end(); ++it) { - if (it->port == port && it->match_subdomains == match_subdomains && - it->path_prefix == path) - break; - } - PathFilter* path_filter; - if (it == list->end()) { - list->push_back(PathFilter(path, port, match_subdomains)); - path_filter = &list->back(); - } else { - path_filter = &(*it); - } - - if (block) - path_filter->blocked_schemes |= flag; - else - path_filter->allowed_schemes |= flag; -} - void URLBlacklist::Block(const std::string& filter) { AddFilter(filter, true); } @@ -295,6 +240,60 @@ bool URLBlacklist::FilterToComponents(const std::string& filter, return true; } +void URLBlacklist::AddFilter(const std::string& filter, bool block) { + std::string scheme; + std::string host; + uint16 port; + std::string path; + SchemeFlag flag; + bool match_subdomains = true; + + if (!FilterToComponents(filter, &scheme, &host, &port, &path)) { + LOG(WARNING) << "Invalid filter, ignoring: " << filter; + return; + } + + if (!SchemeToFlag(scheme, &flag)) { + LOG(WARNING) << "Unsupported scheme in filter, ignoring filter: " << filter; + return; + } + + // Special syntax to disable subdomain matching. + if (!host.empty() && host[0] == '.') { + host.erase(0, 1); + match_subdomains = false; + } + + // Try to find an existing PathFilter with the same path prefix, port and + // match_subdomains value. + PathFilterList* list; + HostFilterTable::iterator host_filter = host_filters_.find(host); + if (host_filter == host_filters_.end()) { + list = new PathFilterList; + host_filters_[host] = list; + } else { + list = host_filter->second; + } + PathFilterList::iterator it; + for (it = list->begin(); it != list->end(); ++it) { + if (it->port == port && it->match_subdomains == match_subdomains && + it->path_prefix == path) + break; + } + PathFilter* path_filter; + if (it == list->end()) { + list->push_back(PathFilter(path, port, match_subdomains)); + path_filter = &list->back(); + } else { + path_filter = &(*it); + } + + if (block) + path_filter->blocked_schemes |= flag; + else + path_filter->allowed_schemes |= flag; +} + URLBlacklistManager::URLBlacklistManager(PrefService* pref_service) : ALLOW_THIS_IN_INITIALIZER_LIST(ui_method_factory_(this)), pref_service_(pref_service), diff --git a/chrome/browser/policy/url_blacklist_manager.h b/chrome/browser/policy/url_blacklist_manager.h index 1717b20..aa4553f 100644 --- a/chrome/browser/policy/url_blacklist_manager.h +++ b/chrome/browser/policy/url_blacklist_manager.h @@ -23,16 +23,21 @@ class NotificationDetails; class NotificationSource; class PrefService; -namespace base { -class ListValue; -} - namespace policy { // Contains a set of filters to block and allow certain URLs, and matches GURLs // against this set. The filters are currently kept in memory. class URLBlacklist { public: + // A constant mapped to a scheme that can be filtered. + enum SchemeFlag { + SCHEME_HTTP = 1 << 0, + SCHEME_HTTPS = 1 << 1, + SCHEME_FTP = 1 << 2, + + SCHEME_ALL = (1 << 3) - 1, + }; + URLBlacklist(); virtual ~URLBlacklist(); @@ -46,15 +51,6 @@ class URLBlacklist { // Returns true if the URL is blocked. bool IsURLBlocked(const GURL& url) const; - // A constant mapped to a scheme that can be filtered. - enum SchemeFlag { - SCHEME_HTTP = 1 << 0, - SCHEME_HTTPS = 1 << 1, - SCHEME_FTP = 1 << 2, - - SCHEME_ALL = (1 << 3) - 1, - }; - // Returns true if |scheme| is a scheme that can be filtered. Returns true // and sets |flag| to SCHEME_ALL if |scheme| is empty. static bool SchemeToFlag(const std::string& scheme, SchemeFlag* flag); @@ -71,8 +67,6 @@ class URLBlacklist { uint16* port, std::string* path); private: - void AddFilter(const std::string& filter, bool block); - struct PathFilter { explicit PathFilter(const std::string& path, uint16 port, bool match) : path_prefix(path), @@ -91,6 +85,8 @@ class URLBlacklist { typedef std::vector<PathFilter> PathFilterList; typedef base::hash_map<std::string, PathFilterList*> HostFilterTable; + void AddFilter(const std::string& filter, bool block); + HostFilterTable host_filters_; DISALLOW_COPY_AND_ASSIGN(URLBlacklist); diff --git a/chrome/browser/policy/user_policy_cache.cc b/chrome/browser/policy/user_policy_cache.cc index c546600..03f583b 100644 --- a/chrome/browser/policy/user_policy_cache.cc +++ b/chrome/browser/policy/user_policy_cache.cc @@ -8,9 +8,9 @@ #include <string> #include "base/basictypes.h" +#include "base/file_path.h" #include "base/logging.h" #include "base/metrics/histogram.h" -#include "base/values.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/policy/browser_policy_connector.h" #include "chrome/browser/policy/cloud_policy_provider.h" diff --git a/chrome/browser/policy/user_policy_cache.h b/chrome/browser/policy/user_policy_cache.h index f60c82d..a065e19 100644 --- a/chrome/browser/policy/user_policy_cache.h +++ b/chrome/browser/policy/user_policy_cache.h @@ -8,23 +8,29 @@ #include <string> -#include "base/file_path.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" +#include "base/values.h" #include "chrome/browser/policy/cloud_policy_cache_base.h" #include "chrome/browser/policy/user_policy_disk_cache.h" -namespace em = enterprise_management; +class FilePath; namespace enterprise_management { + class CachedCloudPolicyResponse; // <Old-style policy support> (see comment below) class GenericValue; // </Old-style policy support> + } // namespace enterprise_management namespace policy { +namespace em = enterprise_management; + +class PolicyMap; + // CloudPolicyCacheBase implementation that persists policy information // into the file specified by the c'tor parameter |backing_file_path|. class UserPolicyCache : public CloudPolicyCacheBase, diff --git a/chrome/browser/policy/user_policy_cache_unittest.cc b/chrome/browser/policy/user_policy_cache_unittest.cc index eac0ae8..7690879 100644 --- a/chrome/browser/policy/user_policy_cache_unittest.cc +++ b/chrome/browser/policy/user_policy_cache_unittest.cc @@ -11,7 +11,6 @@ #include "base/message_loop.h" #include "base/scoped_temp_dir.h" #include "base/values.h" -#include "chrome/browser/policy/configuration_policy_provider.h" #include "chrome/browser/policy/proto/cloud_policy.pb.h" #include "chrome/browser/policy/proto/device_management_backend.pb.h" #include "chrome/browser/policy/proto/device_management_local.pb.h" diff --git a/chrome/browser/policy/user_policy_disk_cache.cc b/chrome/browser/policy/user_policy_disk_cache.cc index 81d47c6..2c8c5c9 100644 --- a/chrome/browser/policy/user_policy_disk_cache.cc +++ b/chrome/browser/policy/user_policy_disk_cache.cc @@ -2,13 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/browser/policy/user_policy_disk_cache.h" + #include "base/file_util.h" #include "base/logging.h" #include "base/metrics/histogram.h" #include "base/task.h" #include "chrome/browser/policy/enterprise_metrics.h" #include "chrome/browser/policy/proto/device_management_local.pb.h" -#include "chrome/browser/policy/user_policy_disk_cache.h" #include "content/browser/browser_thread.h" namespace { diff --git a/chrome/browser/policy/user_policy_disk_cache.h b/chrome/browser/policy/user_policy_disk_cache.h index 1f7d86b..ee96b96 100644 --- a/chrome/browser/policy/user_policy_disk_cache.h +++ b/chrome/browser/policy/user_policy_disk_cache.h @@ -11,14 +11,16 @@ #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" -namespace em = enterprise_management; - namespace enterprise_management { + class CachedCloudPolicyResponse; + } namespace policy { +namespace em = enterprise_management; + // Handles the on-disk cache file used by UserPolicyCache. This class handles // the necessary thread switching and may outlive the associated UserPolicyCache // instance. diff --git a/chrome/browser/policy/user_policy_token_cache.cc b/chrome/browser/policy/user_policy_token_cache.cc index bea692e..0d5c3c5 100644 --- a/chrome/browser/policy/user_policy_token_cache.cc +++ b/chrome/browser/policy/user_policy_token_cache.cc @@ -6,6 +6,7 @@ #include "base/file_util.h" #include "base/metrics/histogram.h" +#include "base/task.h" #include "chrome/browser/policy/enterprise_metrics.h" #include "chrome/browser/policy/proto/device_management_local.pb.h" #include "content/browser/browser_thread.h" @@ -48,7 +49,7 @@ void UserPolicyTokenLoader::Load() { } void UserPolicyTokenLoader::Store(const std::string& token, - const std::string& device_id) { + const std::string& device_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, |