Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 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_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MASTER_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MASTER_H_ | |
| 7 | |
| 8 #include <set> | |
| 9 | |
| 10 #include "chrome/browser/extensions/user_script_master.h" | |
| 11 #include "extensions/common/extension.h" | |
| 12 | |
| 13 class Profile; | |
| 14 | |
| 15 namespace extensions { | |
| 16 | |
| 17 class DeclarativeUserScriptMaster : public UserScriptMaster { | |
| 18 public: | |
| 19 DeclarativeUserScriptMaster(Profile* profile, | |
| 20 const ExtensionId& extension_id); | |
| 21 virtual ~DeclarativeUserScriptMaster(); | |
| 22 | |
| 23 // Add script to shared memory region. This may not happen right away if a | |
| 24 // script load is in progress. | |
| 25 void AddScript(const UserScript& script); | |
| 26 | |
| 27 // Remove script from shared memory region. This may not happen right away if | |
| 28 // a script load is in progress. | |
| 29 void RemoveScript(const UserScript& script); | |
| 30 | |
| 31 // Remove all scripts from shared memory region. This may not happen right | |
| 32 // away if a script load is in progress. | |
| 33 void ClearScripts(); | |
| 34 | |
| 35 // UserScriptMaster implementation. | |
|
Devlin
2014/07/31 20:32:24
make this private.
| |
| 36 virtual void StartLoad() OVERRIDE; | |
| 37 | |
| 38 protected: | |
| 39 // UserScriptMaster implementation. | |
|
Devlin
2014/07/31 20:32:24
Make all of these private.
| |
| 40 virtual void AcquireUserScripts(scoped_ptr<UserScriptList> scripts) OVERRIDE; | |
| 41 virtual ExtensionsInfo GetExtensionsInfo() OVERRIDE; | |
| 42 virtual std::set<ExtensionId> GetAddedExtensions() OVERRIDE; | |
| 43 virtual std::set<ExtensionId> GetAllManagedExtensions() OVERRIDE; | |
| 44 virtual std::set<ExtensionId> GetChangedExtensions() OVERRIDE; | |
| 45 virtual void ResetChangedExtensions() OVERRIDE; | |
| 46 | |
| 47 private: | |
| 48 // Attempt to initiate a load of scripts. May need to signal a pending load if | |
| 49 // a load is already in progress. | |
| 50 void AttemptLoad(); | |
| 51 | |
| 52 // Reset UserScriptMaster::pending_load_ based on our data. | |
|
Devlin
2014/07/31 20:32:24
Prefer: "Signal a pending load if any scripts have
| |
| 53 void MaybeSignalPendingLoad(); | |
| 54 | |
| 55 bool is_loading() const { | |
| 56 // Ownership of |user_scripts_| is passed to the file thread when loading. | |
| 57 return user_scripts_.get() == NULL; | |
| 58 } | |
| 59 | |
| 60 // List of scripts from currently-installed extensions we should load. | |
| 61 scoped_ptr<UserScriptList> user_scripts_; | |
| 62 | |
| 63 // Set containing only the extension we manage. This is passed to the base | |
| 64 // class in several different contexts. | |
| 65 std::set<ExtensionId> owner_extension_as_set_; | |
| 66 | |
| 67 // Scripts to be added next time the memory region reloads. | |
| 68 std::set<UserScript> scripts_to_add_; | |
| 69 | |
| 70 // Scripts to be removed next time the memory region reloads. | |
| 71 std::set<UserScript> scripts_to_remove_; | |
| 72 | |
| 73 // Indicator variable: clear list of scripts on next reload. | |
| 74 bool clear_scripts_; | |
| 75 | |
| 76 // Maps extension info needed for localization to an extension ID. | |
| 77 ExtensionsInfo extensions_info_; | |
| 78 | |
| 79 DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptMaster); | |
| 80 }; | |
| 81 | |
| 82 } // namespace extensions | |
| 83 | |
| 84 #endif // CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MASTER_H_ | |
| OLD | NEW |