| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_LOADER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_LOADER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_LOADER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_LOADER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/file_path.h" |
| 9 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| 10 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 11 | 12 |
| 12 class DictionaryValue; | 13 class DictionaryValue; |
| 13 class ExternalExtensionProviderImpl; | 14 class ExternalExtensionProviderImpl; |
| 14 | 15 |
| 15 // Base class for gathering a list of external extensions. Subclasses | 16 // Base class for gathering a list of external extensions. Subclasses |
| 16 // implement loading from registry, JSON file, policy. | 17 // implement loading from registry, JSON file, policy. |
| 17 // Instances are owned by ExternalExtensionProviderImpl objects. | 18 // Instances are owned by ExternalExtensionProviderImpl objects. |
| 18 // Instances are created on the UI thread and expect public method calls from | 19 // Instances are created on the UI thread and expect public method calls from |
| (...skipping 15 matching lines...) Expand all Loading... |
| 34 // Called by the owner before it gets deleted. | 35 // Called by the owner before it gets deleted. |
| 35 void OwnerShutdown(); | 36 void OwnerShutdown(); |
| 36 | 37 |
| 37 // Initiates the possibly asynchronous loading of extension list. | 38 // Initiates the possibly asynchronous loading of extension list. |
| 38 // It is the responsibility of the caller to ensure that calls to | 39 // It is the responsibility of the caller to ensure that calls to |
| 39 // this method do not overlap with each other. | 40 // this method do not overlap with each other. |
| 40 // Implementations of this method should save the loaded results | 41 // Implementations of this method should save the loaded results |
| 41 // in prefs_ and then call LoadFinished. | 42 // in prefs_ and then call LoadFinished. |
| 42 virtual void StartLoading() = 0; | 43 virtual void StartLoading() = 0; |
| 43 | 44 |
| 45 // Some external providers allow relative file paths to local CRX files. |
| 46 // Subclasses that want this behavior should override this method to |
| 47 // return the absolute path from which relative paths should be resolved. |
| 48 // By default, return an empty path, which indicates that relative paths |
| 49 // are not allowed. |
| 50 virtual const FilePath GetBaseCrxFilePath(); |
| 51 |
| 44 protected: | 52 protected: |
| 45 virtual ~ExternalExtensionLoader() {} | 53 virtual ~ExternalExtensionLoader() {} |
| 46 | 54 |
| 47 // Notifies the provider that the list of extensions has been loaded. | 55 // Notifies the provider that the list of extensions has been loaded. |
| 48 void LoadFinished(); | 56 void LoadFinished(); |
| 49 | 57 |
| 50 // Used for passing the list of extensions from the method that loads them | 58 // Used for passing the list of extensions from the method that loads them |
| 51 // to |LoadFinished|. To ensure thread safety, the rules are the following: | 59 // to |LoadFinished|. To ensure thread safety, the rules are the following: |
| 52 // if this value is written on another thread than the UI, then it should | 60 // if this value is written on another thread than the UI, then it should |
| 53 // only be written in a task that was posted from |StartLoading|. After that, | 61 // only be written in a task that was posted from |StartLoading|. After that, |
| 54 // this task should invoke |LoadFinished| with a PostTask. This scheme of | 62 // this task should invoke |LoadFinished| with a PostTask. This scheme of |
| 55 // posting tasks will avoid concurrent access and imply the necessary memory | 63 // posting tasks will avoid concurrent access and imply the necessary memory |
| 56 // barriers. | 64 // barriers. |
| 57 scoped_ptr<DictionaryValue> prefs_; | 65 scoped_ptr<DictionaryValue> prefs_; |
| 58 | 66 |
| 59 private: | 67 private: |
| 60 friend class base::RefCountedThreadSafe<ExternalExtensionLoader>; | 68 friend class base::RefCountedThreadSafe<ExternalExtensionLoader>; |
| 61 | 69 |
| 62 ExternalExtensionProviderImpl* owner_; // weak | 70 ExternalExtensionProviderImpl* owner_; // weak |
| 63 | 71 |
| 64 // Set to true if loading the extensions is already running. New requests | 72 // Set to true if loading the extensions is already running. New requests |
| 65 // are ignored while this is set true. | 73 // are ignored while this is set true. |
| 66 bool running_; | 74 bool running_; |
| 67 | 75 |
| 68 DISALLOW_COPY_AND_ASSIGN(ExternalExtensionLoader); | 76 DISALLOW_COPY_AND_ASSIGN(ExternalExtensionLoader); |
| 69 }; | 77 }; |
| 70 | 78 |
| 71 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_LOADER_H_ | 79 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_LOADER_H_ |
| OLD | NEW |