Home | History | Annotate | Download | only in policy
      1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_POLICY_FILE_BASED_POLICY_PROVIDER_H_
      6 #define CHROME_BROWSER_POLICY_FILE_BASED_POLICY_PROVIDER_H_
      7 #pragma once
      8 
      9 #include "base/file_path.h"
     10 #include "base/time.h"
     11 #include "chrome/browser/policy/asynchronous_policy_provider.h"
     12 
     13 namespace policy {
     14 
     15 // File based policy provider that coordinates watching and reloading policy
     16 // information from the configuration path. Actual logic for loading policy
     17 // information is handled by a delegate passed at construction time.
     18 class FileBasedPolicyProvider : public AsynchronousPolicyProvider {
     19  public:
     20 
     21   // Delegate interface for actual policy loading from the system.
     22   class ProviderDelegate : public AsynchronousPolicyProvider::Delegate {
     23    public:
     24     explicit ProviderDelegate(const FilePath& config_file_path);
     25     virtual ~ProviderDelegate();
     26 
     27     // AsynchronousPolicyProvider::Delegate implementation:
     28     virtual DictionaryValue* Load() = 0;
     29 
     30     // Gets the last modification timestamp for the policy information from the
     31     // filesystem. Returns base::Time() if the information is not present, in
     32     // which case Load() should return an empty dictionary.
     33     virtual base::Time GetLastModification() = 0;
     34 
     35     const FilePath& config_file_path() { return config_file_path_; }
     36 
     37    private:
     38     const FilePath config_file_path_;
     39 
     40     DISALLOW_COPY_AND_ASSIGN(ProviderDelegate);
     41   };
     42 
     43   // Assumes ownership of |delegate|.
     44   FileBasedPolicyProvider(const PolicyDefinitionList* policy_list,
     45                           ProviderDelegate* delegate);
     46   virtual ~FileBasedPolicyProvider() {}
     47 
     48  private:
     49   DISALLOW_COPY_AND_ASSIGN(FileBasedPolicyProvider);
     50 };
     51 
     52 }  // namespace policy
     53 
     54 #endif  // CHROME_BROWSER_POLICY_FILE_BASED_POLICY_PROVIDER_H_
     55