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

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: Rebase and remove ConsumerInstanceInfo(id). 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 const UserScript::ConsumerInstanceType& consumer_instance_type,
Devlin 2015/02/23 20:15:00 nit: a const& enum is kinda silly.
Xi Han 2015/02/24 16:19:55 Done.
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 30 matching lines...) Expand all
78 80
79 // The injector for this injection. 81 // The injector for this injection.
80 scoped_ptr<ScriptInjector> injector_; 82 scoped_ptr<ScriptInjector> injector_;
81 83
82 // The (main) WebFrame into which this should inject the script. 84 // The (main) WebFrame into which this should inject the script.
83 blink::WebLocalFrame* web_frame_; 85 blink::WebLocalFrame* web_frame_;
84 86
85 // The id of the associated injection_host. 87 // The id of the associated injection_host.
86 HostID host_id_; 88 HostID host_id_;
87 89
90 // The type of the instance on which the host will inject the script.
91 UserScript::ConsumerInstanceType consumer_instance_type_;
92
88 // The location in the document load at which we inject the script. 93 // The location in the document load at which we inject the script.
89 UserScript::RunLocation run_location_; 94 UserScript::RunLocation run_location_;
90 95
91 // The tab id associated with the frame. 96 // The tab id associated with the frame.
92 int tab_id_; 97 int tab_id_;
93 98
94 // This injection's request id. This will be -1 unless the injection is 99 // This injection's request id. This will be -1 unless the injection is
95 // currently waiting on permission. 100 // currently waiting on permission.
96 int64 request_id_; 101 int64 request_id_;
97 102
98 // Whether or not the injection is complete, either via injecting the script 103 // Whether or not the injection is complete, either via injecting the script
99 // or because it will never complete. 104 // or because it will never complete.
100 bool complete_; 105 bool complete_;
101 106
102 DISALLOW_COPY_AND_ASSIGN(ScriptInjection); 107 DISALLOW_COPY_AND_ASSIGN(ScriptInjection);
103 }; 108 };
104 109
105 } // namespace extensions 110 } // namespace extensions
106 111
107 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTION_H_ 112 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698