Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1062)

Side by Side Diff: extensions/renderer/user_script_set.h

Issue 2325053002: Revert of Stop copying script contents for each RenderFrames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/renderer/user_script_injector.cc ('k') | extensions/renderer/user_script_set.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_RENDERER_USER_SCRIPT_SET_H_ 5 #ifndef EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_
6 #define EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ 6 #define EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_
7 7
8 #include <map>
9 #include <memory> 8 #include <memory>
10 #include <set> 9 #include <set>
11 #include <string> 10 #include <string>
12 #include <vector> 11 #include <vector>
13 12
14 #include "base/macros.h" 13 #include "base/macros.h"
15 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
16 #include "base/memory/shared_memory.h" 15 #include "base/memory/shared_memory.h"
17 #include "base/observer_list.h" 16 #include "base/observer_list.h"
18 #include "extensions/common/user_script.h" 17 #include "extensions/common/user_script.h"
19 #include "third_party/WebKit/public/platform/WebString.h"
20 18
21 class GURL; 19 class GURL;
22 20
23 namespace content { 21 namespace content {
24 class RenderFrame; 22 class RenderFrame;
25 } 23 }
26 24
27 namespace extensions { 25 namespace extensions {
28 class ScriptInjection; 26 class ScriptInjection;
29 27
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 UserScript::RunLocation run_location, 66 UserScript::RunLocation run_location,
69 const GURL& document_url, 67 const GURL& document_url,
70 bool log_activity); 68 bool log_activity);
71 69
72 // Updates scripts given the shared memory region containing user scripts. 70 // Updates scripts given the shared memory region containing user scripts.
73 // Returns true if the scripts were successfully updated. 71 // Returns true if the scripts were successfully updated.
74 bool UpdateUserScripts(base::SharedMemoryHandle shared_memory, 72 bool UpdateUserScripts(base::SharedMemoryHandle shared_memory,
75 const std::set<HostID>& changed_hosts, 73 const std::set<HostID>& changed_hosts,
76 bool whitelisted_only); 74 bool whitelisted_only);
77 75
78 // Returns the contents of a script file.
79 // Note that copying is cheap as this uses WebString.
80 blink::WebString GetJsSource(const UserScript::File& file,
81 bool emulate_greasemonkey);
82 blink::WebString GetCssSource(const UserScript::File& file);
83
84 private: 76 private:
85 // Returns a new ScriptInjection for the given |script| to execute in the 77 // Returns a new ScriptInjection for the given |script| to execute in the
86 // |render_frame|, or NULL if the script should not execute. 78 // |render_frame|, or NULL if the script should not execute.
87 std::unique_ptr<ScriptInjection> GetInjectionForScript( 79 std::unique_ptr<ScriptInjection> GetInjectionForScript(
88 const UserScript* script, 80 const UserScript* script,
89 content::RenderFrame* render_frame, 81 content::RenderFrame* render_frame,
90 int tab_id, 82 int tab_id,
91 UserScript::RunLocation run_location, 83 UserScript::RunLocation run_location,
92 const GURL& document_url, 84 const GURL& document_url,
93 bool is_declarative, 85 bool is_declarative,
94 bool log_activity); 86 bool log_activity);
95 87
96 // Shared memory containing raw script data. 88 // Shared memory containing raw script data.
97 std::unique_ptr<base::SharedMemory> shared_memory_; 89 std::unique_ptr<base::SharedMemory> shared_memory_;
98 90
99 // The UserScripts this injector manages. 91 // The UserScripts this injector manages.
100 UserScriptList scripts_; 92 UserScriptList scripts_;
101 93
102 // Map of user script file url -> source.
103 std::map<GURL, blink::WebString> script_sources_;
104
105 // The associated observers. 94 // The associated observers.
106 base::ObserverList<Observer> observers_; 95 base::ObserverList<Observer> observers_;
107 96
108 DISALLOW_COPY_AND_ASSIGN(UserScriptSet); 97 DISALLOW_COPY_AND_ASSIGN(UserScriptSet);
109 }; 98 };
110 99
111 } // namespace extensions 100 } // namespace extensions
112 101
113 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ 102 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_
OLDNEW
« no previous file with comments | « extensions/renderer/user_script_injector.cc ('k') | extensions/renderer/user_script_set.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698