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

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

Issue 906493004: Refactoring: de-couple Extensions from "script injection System" [render side]:2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@decouple_brower_isolated_world_1
Patch Set: Devlin's comments and rebase. Created 5 years, 10 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
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_SCRIPT_INJECTION_H_ 5 #ifndef EXTENSIONS_RENDERER_SCRIPT_INJECTION_H_
6 #define EXTENSIONS_RENDERER_SCRIPT_INJECTION_H_ 6 #define EXTENSIONS_RENDERER_SCRIPT_INJECTION_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "extensions/common/user_script.h" 10 #include "extensions/common/user_script.h"
(...skipping 12 matching lines...) Expand all
23 // A script wrapper which is aware of whether or not it is allowed to execute, 23 // A script wrapper which is aware of whether or not it is allowed to execute,
24 // and contains the implementation to do so. 24 // and contains the implementation to do so.
25 class ScriptInjection { 25 class ScriptInjection {
26 public: 26 public:
27 // Return the id of the injection host associated with the given world. 27 // Return the id of the injection host associated with the given world.
28 static std::string GetHostIdForIsolatedWorld(int world_id); 28 static std::string GetHostIdForIsolatedWorld(int world_id);
29 29
30 // Remove the isolated world associated with the given injection host. 30 // Remove the isolated world associated with the given injection host.
31 static void RemoveIsolatedWorld(const std::string& host_id); 31 static void RemoveIsolatedWorld(const std::string& host_id);
32 32
33 ScriptInjection(scoped_ptr<ScriptInjector> injector, 33 ScriptInjection(
34 blink::WebLocalFrame* web_frame, 34 scoped_ptr<ScriptInjector> injector,
35 const HostID& host_id, 35 blink::WebLocalFrame* web_frame,
36 UserScript::RunLocation run_location, 36 const HostID& host_id,
37 int tab_id); 37 UserScript::ConsumerInstanceType consumer_instance_type,
38 UserScript::RunLocation run_location,
39 int tab_id);
38 ~ScriptInjection(); 40 ~ScriptInjection();
39 41
40 // Try to inject the script at the |current_location|. This returns true if 42 // Try to inject the script at the |current_location|. This returns true if
41 // the script has either injected or will never inject (i.e., if the object 43 // the script has either injected or will never inject (i.e., if the object
42 // is done), and false if injection is delayed (either for permission purposes 44 // is done), and false if injection is delayed (either for permission purposes
43 // or because |current_location| is not the designated |run_location_|). 45 // or because |current_location| is not the designated |run_location_|).
44 // NOTE: |injection_host| may be NULL, if the injection_host is removed! 46 // NOTE: |injection_host| may be NULL, if the injection_host is removed!
45 bool TryToInject(UserScript::RunLocation current_location, 47 bool TryToInject(UserScript::RunLocation current_location,
46 const InjectionHost* injection_host, 48 const InjectionHost* injection_host,
47 ScriptsRunInfo* scripts_run_info); 49 ScriptsRunInfo* scripts_run_info);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 81
80 // The injector for this injection. 82 // The injector for this injection.
81 scoped_ptr<ScriptInjector> injector_; 83 scoped_ptr<ScriptInjector> injector_;
82 84
83 // The (main) WebFrame into which this should inject the script. 85 // The (main) WebFrame into which this should inject the script.
84 blink::WebLocalFrame* web_frame_; 86 blink::WebLocalFrame* web_frame_;
85 87
86 // The id of the associated injection_host. 88 // The id of the associated injection_host.
87 HostID host_id_; 89 HostID host_id_;
88 90
91 // The type of the instance on which the host will inject the script.
92 UserScript::ConsumerInstanceType consumer_instance_type_;
93
Devlin 2015/02/25 17:14:38 When is this used?
Xi Han 2015/02/27 19:36:19 The get function consumer_instance_type() is used
Devlin 2015/02/27 21:52:42 Doesn't that check UserScript::consumer_instance_t
Xi Han 2015/02/27 22:10:02 Oh, you are absolutely right. I took it as the one
89 // The location in the document load at which we inject the script. 94 // The location in the document load at which we inject the script.
90 UserScript::RunLocation run_location_; 95 UserScript::RunLocation run_location_;
91 96
92 // The tab id associated with the frame. 97 // The tab id associated with the frame.
93 int tab_id_; 98 int tab_id_;
94 99
95 // This injection's request id. This will be -1 unless the injection is 100 // This injection's request id. This will be -1 unless the injection is
96 // currently waiting on permission. 101 // currently waiting on permission.
97 int64 request_id_; 102 int64 request_id_;
98 103
99 // Whether or not the injection is complete, either via injecting the script 104 // Whether or not the injection is complete, either via injecting the script
100 // or because it will never complete. 105 // or because it will never complete.
101 bool complete_; 106 bool complete_;
102 107
103 DISALLOW_COPY_AND_ASSIGN(ScriptInjection); 108 DISALLOW_COPY_AND_ASSIGN(ScriptInjection);
104 }; 109 };
105 110
106 } // namespace extensions 111 } // namespace extensions
107 112
108 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTION_H_ 113 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTION_H_
OLDNEW
« no previous file with comments | « extensions/renderer/extension_injection_host.cc ('k') | extensions/renderer/script_injection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698