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

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

Issue 2213603002: Prevent duplicate content script injection defined in manifest.json (reland) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed patch 7 code review comments Created 4 years, 3 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_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 struct ScriptsRunInfo;
22 23
23 // A ScriptInjector to handle tabs.executeScript(). 24 // A ScriptInjector to handle tabs.executeScript().
24 class ProgrammaticScriptInjector : public ScriptInjector { 25 class ProgrammaticScriptInjector : public ScriptInjector {
25 public: 26 public:
26 ProgrammaticScriptInjector(const ExtensionMsg_ExecuteCode_Params& params, 27 ProgrammaticScriptInjector(const ExtensionMsg_ExecuteCode_Params& params,
27 content::RenderFrame* render_frame); 28 content::RenderFrame* render_frame);
28 ~ProgrammaticScriptInjector() override; 29 ~ProgrammaticScriptInjector() override;
29 30
30 private: 31 private:
31 // ScriptInjector implementation. 32 // ScriptInjector implementation.
32 UserScript::InjectionType script_type() const override; 33 UserScript::InjectionType script_type() const override;
33 bool ShouldExecuteInMainWorld() const override; 34 bool ShouldExecuteInMainWorld() const override;
34 bool IsUserGesture() const override; 35 bool IsUserGesture() const override;
35 bool ExpectsResults() const override; 36 bool ExpectsResults() const override;
36 bool ShouldInjectJs(UserScript::RunLocation run_location) const override; 37 bool ShouldInjectJs(UserScript::RunLocation run_location,
37 bool ShouldInjectCss(UserScript::RunLocation run_location) const override; 38 std::map<std::string, std::set<std::string>>&
Devlin 2016/09/06 17:21:13 Remember, chromium style discourages non-const ref
catmullings 2016/09/07 01:00:35 Done.
39 executing_scripts) const override;
40 bool ShouldInjectCss(UserScript::RunLocation run_location,
41 std::map<std::string, std::set<std::string>>&
42 executing_scripts) const override;
38 PermissionsData::AccessType CanExecuteOnFrame( 43 PermissionsData::AccessType CanExecuteOnFrame(
39 const InjectionHost* injection_host, 44 const InjectionHost* injection_host,
40 blink::WebLocalFrame* web_frame, 45 blink::WebLocalFrame* web_frame,
41 int tab_id) const override; 46 int tab_id) const override;
42 std::vector<blink::WebScriptSource> GetJsSources( 47 std::vector<blink::WebScriptSource> GetJsSources(
43 UserScript::RunLocation run_location) const override; 48 UserScript::RunLocation run_location,
49 std::map<std::string, std::set<std::string>>* executing_scripts,
50 size_t* num_injected_js_scripts) const override;
44 std::vector<blink::WebString> GetCssSources( 51 std::vector<blink::WebString> GetCssSources(
45 UserScript::RunLocation run_location) const override; 52 UserScript::RunLocation run_location,
46 void GetRunInfo(ScriptsRunInfo* scripts_run_info, 53 std::map<std::string, std::set<std::string>>* executing_scripts,
47 UserScript::RunLocation run_location) const override; 54 size_t* num_injected_css_scripts) const override;
48 void OnInjectionComplete(std::unique_ptr<base::Value> execution_result, 55 void OnInjectionComplete(std::unique_ptr<base::Value> execution_result,
49 UserScript::RunLocation run_location, 56 UserScript::RunLocation run_location,
50 content::RenderFrame* render_frame) override; 57 content::RenderFrame* render_frame) override;
51 void OnWillNotInject(InjectFailureReason reason, 58 void OnWillNotInject(InjectFailureReason reason,
52 content::RenderFrame* render_frame) override; 59 content::RenderFrame* render_frame) override;
53 60
54 // Whether it is safe to include information about the URL in error messages. 61 // Whether it is safe to include information about the URL in error messages.
55 bool CanShowUrlInError() const; 62 bool CanShowUrlInError() const;
56 63
57 // Return the run location for this injector. 64 // Return the run location for this injector.
(...skipping 18 matching lines...) Expand all
76 83
77 // Whether or not this script injection has finished. 84 // Whether or not this script injection has finished.
78 bool finished_; 85 bool finished_;
79 86
80 DISALLOW_COPY_AND_ASSIGN(ProgrammaticScriptInjector); 87 DISALLOW_COPY_AND_ASSIGN(ProgrammaticScriptInjector);
81 }; 88 };
82 89
83 } // namespace extensions 90 } // namespace extensions
84 91
85 #endif // EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_ 92 #endif // EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698