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

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

Issue 7071025: Use WebFrame::setIsolatedWorldSecurityOrigin to allow cross-origin XHRs in content scripts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweak whitespace. Created 9 years, 7 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_EXTENSIONS_USER_SCRIPT_SLAVE_H_ 5 #ifndef CHROME_RENDERER_EXTENSIONS_USER_SCRIPT_SLAVE_H_
6 #define CHROME_RENDERER_EXTENSIONS_USER_SCRIPT_SLAVE_H_ 6 #define CHROME_RENDERER_EXTENSIONS_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/memory/scoped_ptr.h" 13 #include "base/memory/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 Extension;
20 class ExtensionSet; 21 class ExtensionSet;
21 22
22 namespace WebKit { 23 namespace WebKit {
23 class WebFrame; 24 class WebFrame;
24 } 25 }
25 26
26 using WebKit::WebScriptSource; 27 using WebKit::WebScriptSource;
27 28
28 // Manages installed UserScripts for a render process. 29 // Manages installed UserScripts for a render process.
29 class UserScriptSlave { 30 class UserScriptSlave {
30 public: 31 public:
31 UserScriptSlave(const ExtensionSet* extensions); 32 explicit UserScriptSlave(const ExtensionSet* extensions);
32 ~UserScriptSlave(); 33 ~UserScriptSlave();
33 34
34 // Returns the unique set of extension IDs this UserScriptSlave knows about. 35 // Returns the unique set of extension IDs this UserScriptSlave knows about.
35 void GetActiveExtensions(std::set<std::string>* extension_ids); 36 void GetActiveExtensions(std::set<std::string>* extension_ids);
36 37
37 // Update the parsed scripts from shared memory. 38 // Update the parsed scripts from shared memory.
38 bool UpdateScripts(base::SharedMemoryHandle shared_memory); 39 bool UpdateScripts(base::SharedMemoryHandle shared_memory);
39 40
40 // Inject the appropriate scripts into a frame based on its URL. 41 // Inject the appropriate scripts into a frame based on its URL.
41 // TODO(aa): Extract a UserScriptFrame interface out of this to improve 42 // TODO(aa): Extract a UserScriptFrame interface out of this to improve
42 // testability. 43 // testability.
43 void InjectScripts(WebKit::WebFrame* frame, UserScript::RunLocation location); 44 void InjectScripts(WebKit::WebFrame* frame, UserScript::RunLocation location);
44 45
45 static int GetIsolatedWorldId(const std::string& extension_id); 46 static int GetIsolatedWorldId(const std::string& extension_id);
46 47
47 static void InsertInitExtensionCode(std::vector<WebScriptSource>* sources, 48 static void InsertInitExtensionCode(std::vector<WebScriptSource>* sources,
48 const std::string& extension_id); 49 const std::string& extension_id);
49 private: 50 private:
51 void InitializeIsolatedWorld(WebKit::WebFrame* frame,
52 int isolated_world_id,
53 const Extension* extension) const;
54
50 // Shared memory containing raw script data. 55 // Shared memory containing raw script data.
51 scoped_ptr<base::SharedMemory> shared_memory_; 56 scoped_ptr<base::SharedMemory> shared_memory_;
52 57
53 // Parsed script data. 58 // Parsed script data.
54 std::vector<UserScript*> scripts_; 59 std::vector<UserScript*> scripts_;
55 STLElementDeleter<std::vector<UserScript*> > script_deleter_; 60 STLElementDeleter<std::vector<UserScript*> > script_deleter_;
56 61
57 // Greasemonkey API source that is injected with the scripts. 62 // Greasemonkey API source that is injected with the scripts.
58 base::StringPiece api_js_; 63 base::StringPiece api_js_;
59 64
60 // Extension metadata. 65 // Extension metadata.
61 const ExtensionSet* extensions_; 66 const ExtensionSet* extensions_;
62 67
63 DISALLOW_COPY_AND_ASSIGN(UserScriptSlave); 68 DISALLOW_COPY_AND_ASSIGN(UserScriptSlave);
64 }; 69 };
65 70
66 #endif // CHROME_RENDERER_EXTENSIONS_USER_SCRIPT_SLAVE_H_ 71 #endif // CHROME_RENDERER_EXTENSIONS_USER_SCRIPT_SLAVE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698