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