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

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

Issue 2278003002: Stop copying script contents for each RenderFrames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments from Devlin 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>
8 #include <memory> 9 #include <memory>
9 #include <set> 10 #include <set>
10 #include <string> 11 #include <string>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/scoped_vector.h" 15 #include "base/memory/scoped_vector.h"
15 #include "base/memory/shared_memory.h" 16 #include "base/memory/shared_memory.h"
16 #include "base/observer_list.h" 17 #include "base/observer_list.h"
17 #include "extensions/common/user_script.h" 18 #include "extensions/common/user_script.h"
19 #include "third_party/WebKit/public/platform/WebString.h"
18 20
19 class GURL; 21 class GURL;
20 22
21 namespace content { 23 namespace content {
22 class RenderFrame; 24 class RenderFrame;
23 } 25 }
24 26
25 namespace extensions { 27 namespace extensions {
26 class ScriptInjection; 28 class ScriptInjection;
27 29
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 UserScript::RunLocation run_location, 68 UserScript::RunLocation run_location,
67 const GURL& document_url, 69 const GURL& document_url,
68 bool log_activity); 70 bool log_activity);
69 71
70 // Updates scripts given the shared memory region containing user scripts. 72 // Updates scripts given the shared memory region containing user scripts.
71 // Returns true if the scripts were successfully updated. 73 // Returns true if the scripts were successfully updated.
72 bool UpdateUserScripts(base::SharedMemoryHandle shared_memory, 74 bool UpdateUserScripts(base::SharedMemoryHandle shared_memory,
73 const std::set<HostID>& changed_hosts, 75 const std::set<HostID>& changed_hosts,
74 bool whitelisted_only); 76 bool whitelisted_only);
75 77
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
76 private: 84 private:
77 // Returns a new ScriptInjection for the given |script| to execute in the 85 // Returns a new ScriptInjection for the given |script| to execute in the
78 // |render_frame|, or NULL if the script should not execute. 86 // |render_frame|, or NULL if the script should not execute.
79 std::unique_ptr<ScriptInjection> GetInjectionForScript( 87 std::unique_ptr<ScriptInjection> GetInjectionForScript(
80 const UserScript* script, 88 const UserScript* script,
81 content::RenderFrame* render_frame, 89 content::RenderFrame* render_frame,
82 int tab_id, 90 int tab_id,
83 UserScript::RunLocation run_location, 91 UserScript::RunLocation run_location,
84 const GURL& document_url, 92 const GURL& document_url,
85 bool is_declarative, 93 bool is_declarative,
86 bool log_activity); 94 bool log_activity);
87 95
88 // Shared memory containing raw script data. 96 // Shared memory containing raw script data.
89 std::unique_ptr<base::SharedMemory> shared_memory_; 97 std::unique_ptr<base::SharedMemory> shared_memory_;
90 98
91 // The UserScripts this injector manages. 99 // The UserScripts this injector manages.
92 UserScriptList scripts_; 100 UserScriptList scripts_;
93 101
102 // Map of user script file url -> source.
103 std::map<GURL, blink::WebString> script_sources_;
104
94 // The associated observers. 105 // The associated observers.
95 base::ObserverList<Observer> observers_; 106 base::ObserverList<Observer> observers_;
96 107
97 DISALLOW_COPY_AND_ASSIGN(UserScriptSet); 108 DISALLOW_COPY_AND_ASSIGN(UserScriptSet);
98 }; 109 };
99 110
100 } // namespace extensions 111 } // namespace extensions
101 112
102 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ 113 #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