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

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

Issue 2471553003: Fix content script injection not working with PlzNavigate because of different navigation timings. (Closed)
Patch Set: review comments Created 4 years, 1 month 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 | « no previous file | extensions/renderer/programmatic_script_injector.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_PROGRAMMATIC_SCRIPT_INJECTOR_H_ 5 #ifndef EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_
6 #define EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_ 6 #define EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "extensions/renderer/script_injection.h" 12 #include "extensions/renderer/script_injection.h"
13 #include "url/gurl.h" 13 #include "url/gurl.h"
14 14
15 struct ExtensionMsg_ExecuteCode_Params; 15 struct ExtensionMsg_ExecuteCode_Params;
16 16
17 namespace content { 17 namespace content {
18 class RenderFrame; 18 class RenderFrame;
19 } 19 }
20 20
21 namespace extensions { 21 namespace extensions {
22 22
23 // A ScriptInjector to handle tabs.executeScript(). 23 // A ScriptInjector to handle tabs.executeScript().
24 class ProgrammaticScriptInjector : public ScriptInjector { 24 class ProgrammaticScriptInjector : public ScriptInjector {
25 public: 25 public:
26 ProgrammaticScriptInjector(const ExtensionMsg_ExecuteCode_Params& params, 26 explicit ProgrammaticScriptInjector(
27 content::RenderFrame* render_frame); 27 const ExtensionMsg_ExecuteCode_Params& params);
28 ~ProgrammaticScriptInjector() override; 28 ~ProgrammaticScriptInjector() override;
29 29
30 private: 30 private:
31 // ScriptInjector implementation. 31 // ScriptInjector implementation.
32 UserScript::InjectionType script_type() const override; 32 UserScript::InjectionType script_type() const override;
33 bool ShouldExecuteInMainWorld() const override; 33 bool ShouldExecuteInMainWorld() const override;
34 bool IsUserGesture() const override; 34 bool IsUserGesture() const override;
35 bool ExpectsResults() const override; 35 bool ExpectsResults() const override;
36 bool ShouldInjectJs( 36 bool ShouldInjectJs(
37 UserScript::RunLocation run_location, 37 UserScript::RunLocation run_location,
38 const std::set<std::string>& executing_scripts) const override; 38 const std::set<std::string>& executing_scripts) const override;
39 bool ShouldInjectCss( 39 bool ShouldInjectCss(
40 UserScript::RunLocation run_location, 40 UserScript::RunLocation run_location,
41 const std::set<std::string>& injected_stylesheets) const override; 41 const std::set<std::string>& injected_stylesheets) const override;
42 PermissionsData::AccessType CanExecuteOnFrame( 42 PermissionsData::AccessType CanExecuteOnFrame(
43 const InjectionHost* injection_host, 43 const InjectionHost* injection_host,
44 blink::WebLocalFrame* web_frame, 44 blink::WebLocalFrame* web_frame,
45 int tab_id) const override; 45 int tab_id) override;
46 std::vector<blink::WebScriptSource> GetJsSources( 46 std::vector<blink::WebScriptSource> GetJsSources(
47 UserScript::RunLocation run_location, 47 UserScript::RunLocation run_location,
48 std::set<std::string>* executing_scripts, 48 std::set<std::string>* executing_scripts,
49 size_t* num_injected_js_scripts) const override; 49 size_t* num_injected_js_scripts) const override;
50 std::vector<blink::WebString> GetCssSources( 50 std::vector<blink::WebString> GetCssSources(
51 UserScript::RunLocation run_location, 51 UserScript::RunLocation run_location,
52 std::set<std::string>* injected_stylesheets, 52 std::set<std::string>* injected_stylesheets,
53 size_t* num_injected_stylesheets) const override; 53 size_t* num_injected_stylesheets) const override;
54 void OnInjectionComplete(std::unique_ptr<base::Value> execution_result, 54 void OnInjectionComplete(std::unique_ptr<base::Value> execution_result,
55 UserScript::RunLocation run_location, 55 UserScript::RunLocation run_location,
(...skipping 26 matching lines...) Expand all
82 82
83 // Whether or not this script injection has finished. 83 // Whether or not this script injection has finished.
84 bool finished_; 84 bool finished_;
85 85
86 DISALLOW_COPY_AND_ASSIGN(ProgrammaticScriptInjector); 86 DISALLOW_COPY_AND_ASSIGN(ProgrammaticScriptInjector);
87 }; 87 };
88 88
89 } // namespace extensions 89 } // namespace extensions
90 90
91 #endif // EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_ 91 #endif // EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_
OLDNEW
« no previous file with comments | « no previous file | extensions/renderer/programmatic_script_injector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698