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.
5 #ifndef EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MASTER_H_
6 #define EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MASTER_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/scoped_observer.h"
12 #include "extensions/common/host_id.h"
18 namespace extensions
{
21 class UserScriptLoader
;
23 // Manages declarative user scripts for a single extension. Owns a
24 // UserScriptLoader to which file loading and shared memory management
25 // operations are delegated, and provides an interface for adding, removing,
26 // and clearing scripts.
27 class DeclarativeUserScriptMaster
{
29 DeclarativeUserScriptMaster(content::BrowserContext
* browser_context
,
30 const HostID
& host_id
);
31 ~DeclarativeUserScriptMaster();
33 // Adds script to shared memory region. This may not happen right away if a
34 // script load is in progress.
35 void AddScript(const UserScript
& script
);
37 // Adds a set of scripts to shared meomory region. The fetch of the content
38 // of the script on WebUI requires to start URL request to the associated
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
,
45 // Removes script from shared memory region. This may not happen right away if
46 // a script load is in progress.
47 void RemoveScript(const UserScript
& script
);
49 // Removes a set of scripts from shared memory region. This may not happen
50 // right away if a script load is in progress.
51 void RemoveScripts(const std::set
<UserScript
>& scripts
);
53 // Removes all scripts from shared memory region. This may not happen right
54 // away if a script load is in progress.
57 const HostID
& host_id() const { return host_id_
; }
59 UserScriptLoader
* loader() { return loader_
.get(); }
62 // ID of host that owns scripts that this component manages.
65 // Script loader that handles loading contents of scripts into shared memory
66 // and notifying renderers of script updates.
67 scoped_ptr
<UserScriptLoader
> loader_
;
69 DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptMaster
);
72 } // namespace extensions
74 #endif // EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MASTER_H_