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

Side by Side Diff: chrome/renderer/user_script_slave.h

Issue 6242010: Refactor away most of ExtensionRendererInfo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/render_view.cc ('k') | chrome/renderer/user_script_slave.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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 CHROME_RENDERER_USER_SCRIPT_SLAVE_H_ 5 #ifndef CHROME_RENDERER_USER_SCRIPT_SLAVE_H_
6 #define CHROME_RENDERER_USER_SCRIPT_SLAVE_H_ 6 #define CHROME_RENDERER_USER_SCRIPT_SLAVE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/scoped_ptr.h" 13 #include "base/scoped_ptr.h"
14 #include "base/shared_memory.h" 14 #include "base/shared_memory.h"
15 #include "base/stl_util-inl.h" 15 #include "base/stl_util-inl.h"
16 #include "base/string_piece.h" 16 #include "base/string_piece.h"
17 #include "chrome/common/extensions/user_script.h" 17 #include "chrome/common/extensions/user_script.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h"
19 19
20 class ExtensionRendererInfo;
21
20 namespace WebKit { 22 namespace WebKit {
21 class WebFrame; 23 class WebFrame;
22 } 24 }
23 25
24 using WebKit::WebScriptSource; 26 using WebKit::WebScriptSource;
25 27
26 // Manages installed UserScripts for a render process. 28 // Manages installed UserScripts for a render process.
27 class UserScriptSlave { 29 class UserScriptSlave {
28 public: 30 public:
29 UserScriptSlave(); 31 UserScriptSlave(const ExtensionRendererInfo* extensions);
30 ~UserScriptSlave(); 32 ~UserScriptSlave();
31 33
32 // Returns the unique set of extension IDs this UserScriptSlave knows about. 34 // Returns the unique set of extension IDs this UserScriptSlave knows about.
33 void GetActiveExtensions(std::set<std::string>* extension_ids); 35 void GetActiveExtensions(std::set<std::string>* extension_ids);
34 36
35 // Update the parsed scripts from shared memory. 37 // Update the parsed scripts from shared memory.
36 bool UpdateScripts(base::SharedMemoryHandle shared_memory); 38 bool UpdateScripts(base::SharedMemoryHandle shared_memory);
37 39
38 // Inject the appropriate scripts into a frame based on its URL. 40 // Inject the appropriate scripts into a frame based on its URL.
39 // TODO(aa): Extract a UserScriptFrame interface out of this to improve 41 // TODO(aa): Extract a UserScriptFrame interface out of this to improve
40 // testability. 42 // testability.
41 void InjectScripts(WebKit::WebFrame* frame, UserScript::RunLocation location); 43 void InjectScripts(WebKit::WebFrame* frame, UserScript::RunLocation location);
42 44
43 static int GetIsolatedWorldId(const std::string& extension_id); 45 static int GetIsolatedWorldId(const std::string& extension_id);
44 46
45 static void InsertInitExtensionCode(std::vector<WebScriptSource>* sources, 47 static void InsertInitExtensionCode(std::vector<WebScriptSource>* sources,
46 const std::string& extension_id); 48 const std::string& extension_id);
47 private: 49 private:
48 // Shared memory containing raw script data. 50 // Shared memory containing raw script data.
49 scoped_ptr<base::SharedMemory> shared_memory_; 51 scoped_ptr<base::SharedMemory> shared_memory_;
50 52
51 // Parsed script data. 53 // Parsed script data.
52 std::vector<UserScript*> scripts_; 54 std::vector<UserScript*> scripts_;
53 STLElementDeleter<std::vector<UserScript*> > script_deleter_; 55 STLElementDeleter<std::vector<UserScript*> > script_deleter_;
54 56
55 // Greasemonkey API source that is injected with the scripts. 57 // Greasemonkey API source that is injected with the scripts.
56 base::StringPiece api_js_; 58 base::StringPiece api_js_;
57 59
60 // Extension metadata.
61 const ExtensionRendererInfo* extensions_;
62
58 DISALLOW_COPY_AND_ASSIGN(UserScriptSlave); 63 DISALLOW_COPY_AND_ASSIGN(UserScriptSlave);
59 }; 64 };
60 65
61 #endif // CHROME_RENDERER_USER_SCRIPT_SLAVE_H_ 66 #endif // CHROME_RENDERER_USER_SCRIPT_SLAVE_H_
OLDNEW
« no previous file with comments | « chrome/renderer/render_view.cc ('k') | chrome/renderer/user_script_slave.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698