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

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

Issue 885493007: Refactoring: de-couple Extensions from "script injection System" [render side] : 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « extensions/renderer/script_injector.h ('k') | extensions/renderer/user_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_USER_SCRIPT_INJECTOR_H_ 5 #ifndef EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_
6 #define EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_ 6 #define EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/scoped_observer.h" 11 #include "base/scoped_observer.h"
12 #include "extensions/common/user_script.h" 12 #include "extensions/common/user_script.h"
13 #include "extensions/renderer/script_injection.h" 13 #include "extensions/renderer/script_injection.h"
14 #include "extensions/renderer/user_script_set.h" 14 #include "extensions/renderer/user_script_set.h"
15 15
16 class InjectionHost;
17
16 namespace blink { 18 namespace blink {
17 class WebFrame; 19 class WebFrame;
18 } 20 }
19 21
20 namespace extensions { 22 namespace extensions {
21 class Extension;
22 23
23 // A ScriptInjector for UserScripts. 24 // A ScriptInjector for UserScripts.
24 class UserScriptInjector : public ScriptInjector, 25 class UserScriptInjector : public ScriptInjector,
25 public UserScriptSet::Observer { 26 public UserScriptSet::Observer {
26 public: 27 public:
27 UserScriptInjector(const UserScript* user_script, 28 UserScriptInjector(const UserScript* user_script,
28 UserScriptSet* user_script_set, 29 UserScriptSet* user_script_set,
29 bool is_declarative); 30 bool is_declarative);
30 ~UserScriptInjector() override; 31 ~UserScriptInjector() override;
31 32
32 private: 33 private:
33 // UserScriptSet::Observer implementation. 34 // UserScriptSet::Observer implementation.
34 void OnUserScriptsUpdated(const std::set<std::string>& changed_extensions, 35 void OnUserScriptsUpdated(const std::set<std::string>& changed_extensions,
35 const std::vector<UserScript*>& scripts) override; 36 const std::vector<UserScript*>& scripts) override;
36 37
37 // ScriptInjector implementation. 38 // ScriptInjector implementation.
38 UserScript::InjectionType script_type() const override; 39 UserScript::InjectionType script_type() const override;
39 bool ShouldExecuteInChildFrames() const override; 40 bool ShouldExecuteInChildFrames() const override;
40 bool ShouldExecuteInMainWorld() const override; 41 bool ShouldExecuteInMainWorld() const override;
41 bool IsUserGesture() const override; 42 bool IsUserGesture() const override;
42 bool ExpectsResults() const override; 43 bool ExpectsResults() const override;
43 bool ShouldInjectJs(UserScript::RunLocation run_location) const override; 44 bool ShouldInjectJs(UserScript::RunLocation run_location) const override;
44 bool ShouldInjectCss(UserScript::RunLocation run_location) const override; 45 bool ShouldInjectCss(UserScript::RunLocation run_location) const override;
45 PermissionsData::AccessType CanExecuteOnFrame( 46 PermissionsData::AccessType CanExecuteOnFrame(
46 const Extension* extension, 47 const InjectionHost* injection_host,
47 blink::WebFrame* web_frame, 48 blink::WebFrame* web_frame,
48 int tab_id, 49 int tab_id,
49 const GURL& top_url) const override; 50 const GURL& top_url) const override;
50 std::vector<blink::WebScriptSource> GetJsSources( 51 std::vector<blink::WebScriptSource> GetJsSources(
51 UserScript::RunLocation run_location) const override; 52 UserScript::RunLocation run_location) const override;
52 std::vector<std::string> GetCssSources( 53 std::vector<std::string> GetCssSources(
53 UserScript::RunLocation run_location) const override; 54 UserScript::RunLocation run_location) const override;
54 void OnInjectionComplete(scoped_ptr<base::ListValue> execution_results, 55 void OnInjectionComplete(scoped_ptr<base::ListValue> execution_results,
55 ScriptsRunInfo* scripts_run_info, 56 ScriptsRunInfo* scripts_run_info,
56 UserScript::RunLocation run_location) override; 57 UserScript::RunLocation run_location) override;
(...skipping 17 matching lines...) Expand all
74 75
75 ScopedObserver<UserScriptSet, UserScriptSet::Observer> 76 ScopedObserver<UserScriptSet, UserScriptSet::Observer>
76 user_script_set_observer_; 77 user_script_set_observer_;
77 78
78 DISALLOW_COPY_AND_ASSIGN(UserScriptInjector); 79 DISALLOW_COPY_AND_ASSIGN(UserScriptInjector);
79 }; 80 };
80 81
81 } // namespace extensions 82 } // namespace extensions
82 83
83 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_ 84 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_
OLDNEW
« no previous file with comments | « extensions/renderer/script_injector.h ('k') | extensions/renderer/user_script_injector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698