| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MASTER_H_ | 5 #ifndef EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MASTER_H_ |
| 6 #define EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MASTER_H_ | 6 #define EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MASTER_H_ |
| 7 | 7 |
| 8 #include <set> |
| 9 |
| 10 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/scoped_observer.h" | 11 #include "base/scoped_observer.h" |
| 9 #include "extensions/browser/extension_user_script_loader.h" | 12 #include "extensions/common/host_id.h" |
| 10 | 13 |
| 11 namespace content { | 14 namespace content { |
| 12 class BrowserContext; | 15 class BrowserContext; |
| 13 } | 16 } |
| 14 | 17 |
| 15 namespace extensions { | 18 namespace extensions { |
| 16 | 19 |
| 17 class UserScript; | 20 class UserScript; |
| 21 class UserScriptLoader; |
| 18 | 22 |
| 19 // Manages declarative user scripts for a single extension. Owns a | 23 // Manages declarative user scripts for a single extension. Owns a |
| 20 // UserScriptLoader to which file loading and shared memory management | 24 // UserScriptLoader to which file loading and shared memory management |
| 21 // operations are delegated, and provides an interface for adding, removing, | 25 // operations are delegated, and provides an interface for adding, removing, |
| 22 // and clearing scripts. | 26 // and clearing scripts. |
| 23 class DeclarativeUserScriptMaster { | 27 class DeclarativeUserScriptMaster { |
| 24 public: | 28 public: |
| 25 DeclarativeUserScriptMaster(content::BrowserContext* browser_context, | 29 DeclarativeUserScriptMaster(content::BrowserContext* browser_context, |
| 26 const HostID& host_id); | 30 const HostID& host_id); |
| 27 ~DeclarativeUserScriptMaster(); | 31 ~DeclarativeUserScriptMaster(); |
| 28 | 32 |
| 29 // Adds script to shared memory region. This may not happen right away if a | 33 // Adds script to shared memory region. This may not happen right away if a |
| 30 // script load is in progress. | 34 // script load is in progress. |
| 31 void AddScript(const UserScript& script); | 35 void AddScript(const UserScript& script); |
| 32 | 36 |
| 33 // Adds a set of scripts to shared memory region. This may not happen right | 37 // Adds a set of scripts to shared meomory region. The fetch of the content |
| 34 // away if a script load is in progress. | 38 // of the script on WebUI requires to start URL request to the associated |
| 35 void AddScripts(const std::set<UserScript>& scripts); | 39 // render specified by |render_process_id, render_view_id|. |
| 40 // This may not happen right away if a script load is in progress. |
| 41 void AddScripts(const std::set<UserScript>& scripts, |
| 42 int render_process_id, |
| 43 int render_view_id); |
| 36 | 44 |
| 37 // Removes script from shared memory region. This may not happen right away if | 45 // Removes script from shared memory region. This may not happen right away if |
| 38 // a script load is in progress. | 46 // a script load is in progress. |
| 39 void RemoveScript(const UserScript& script); | 47 void RemoveScript(const UserScript& script); |
| 40 | 48 |
| 41 // Removes a set of scripts from shared memory region. This may not happen | 49 // Removes a set of scripts from shared memory region. This may not happen |
| 42 // right away if a script load is in progress. | 50 // right away if a script load is in progress. |
| 43 void RemoveScripts(const std::set<UserScript>& scripts); | 51 void RemoveScripts(const std::set<UserScript>& scripts); |
| 44 | 52 |
| 45 // Removes all scripts from shared memory region. This may not happen right | 53 // Removes all scripts from shared memory region. This may not happen right |
| 46 // away if a script load is in progress. | 54 // away if a script load is in progress. |
| 47 void ClearScripts(); | 55 void ClearScripts(); |
| 48 | 56 |
| 49 const HostID& host_id() const { return host_id_; } | 57 const HostID& host_id() const { return host_id_; } |
| 50 | 58 |
| 51 private: | 59 private: |
| 52 // ID of host that owns scripts that this component manages. | 60 // ID of host that owns scripts that this component manages. |
| 53 HostID host_id_; | 61 HostID host_id_; |
| 54 | 62 |
| 55 // Script loader that handles loading contents of scripts into shared memory | 63 // Script loader that handles loading contents of scripts into shared memory |
| 56 // and notifying renderers of script updates. | 64 // and notifying renderers of script updates. |
| 57 ExtensionUserScriptLoader loader_; | 65 scoped_ptr<UserScriptLoader> loader_; |
| 58 | 66 |
| 59 DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptMaster); | 67 DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptMaster); |
| 60 }; | 68 }; |
| 61 | 69 |
| 62 } // namespace extensions | 70 } // namespace extensions |
| 63 | 71 |
| 64 #endif // EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MASTER_H_ | 72 #endif // EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MASTER_H_ |
| OLD | NEW |