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

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: Remove Host::IsEmpty() and move ExtensionConsumer to extensions/renderer. 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_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 Host;
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; 23 class Extension;
Devlin 2015/02/09 17:40:25 Here too
Xi Han 2015/02/09 23:28:12 Done.
22 24
23 // A ScriptInjector for UserScripts. 25 // A ScriptInjector for UserScripts.
24 class UserScriptInjector : public ScriptInjector, 26 class UserScriptInjector : public ScriptInjector,
25 public UserScriptSet::Observer { 27 public UserScriptSet::Observer {
26 public: 28 public:
27 UserScriptInjector(const UserScript* user_script, 29 UserScriptInjector(const UserScript* user_script,
28 UserScriptSet* user_script_set, 30 UserScriptSet* user_script_set,
29 bool is_declarative); 31 bool is_declarative);
30 ~UserScriptInjector() override; 32 ~UserScriptInjector() override;
31 33
32 private: 34 private:
33 // UserScriptSet::Observer implementation. 35 // UserScriptSet::Observer implementation.
34 void OnUserScriptsUpdated(const std::set<std::string>& changed_extensions, 36 void OnUserScriptsUpdated(const std::set<std::string>& changed_extensions,
35 const std::vector<UserScript*>& scripts) override; 37 const std::vector<UserScript*>& scripts) override;
36 38
37 // ScriptInjector implementation. 39 // ScriptInjector implementation.
38 UserScript::InjectionType script_type() const override; 40 UserScript::InjectionType script_type() const override;
39 bool ShouldExecuteInChildFrames() const override; 41 bool ShouldExecuteInChildFrames() const override;
40 bool ShouldExecuteInMainWorld() const override; 42 bool ShouldExecuteInMainWorld() const override;
41 bool IsUserGesture() const override; 43 bool IsUserGesture() const override;
42 bool ExpectsResults() const override; 44 bool ExpectsResults() const override;
43 bool ShouldInjectJs(UserScript::RunLocation run_location) const override; 45 bool ShouldInjectJs(UserScript::RunLocation run_location) const override;
44 bool ShouldInjectCss(UserScript::RunLocation run_location) const override; 46 bool ShouldInjectCss(UserScript::RunLocation run_location) const override;
45 PermissionsData::AccessType CanExecuteOnFrame( 47 PermissionsData::AccessType CanExecuteOnFrame(
46 const Extension* extension, 48 const Host* host,
47 blink::WebFrame* web_frame, 49 blink::WebFrame* web_frame,
48 int tab_id, 50 int tab_id,
49 const GURL& top_url) const override; 51 const GURL& top_url) const override;
50 std::vector<blink::WebScriptSource> GetJsSources( 52 std::vector<blink::WebScriptSource> GetJsSources(
51 UserScript::RunLocation run_location) const override; 53 UserScript::RunLocation run_location) const override;
52 std::vector<std::string> GetCssSources( 54 std::vector<std::string> GetCssSources(
53 UserScript::RunLocation run_location) const override; 55 UserScript::RunLocation run_location) const override;
54 void OnInjectionComplete(scoped_ptr<base::ListValue> execution_results, 56 void OnInjectionComplete(scoped_ptr<base::ListValue> execution_results,
55 ScriptsRunInfo* scripts_run_info, 57 ScriptsRunInfo* scripts_run_info,
56 UserScript::RunLocation run_location) override; 58 UserScript::RunLocation run_location) override;
(...skipping 17 matching lines...) Expand all
74 76
75 ScopedObserver<UserScriptSet, UserScriptSet::Observer> 77 ScopedObserver<UserScriptSet, UserScriptSet::Observer>
76 user_script_set_observer_; 78 user_script_set_observer_;
77 79
78 DISALLOW_COPY_AND_ASSIGN(UserScriptInjector); 80 DISALLOW_COPY_AND_ASSIGN(UserScriptInjector);
79 }; 81 };
80 82
81 } // namespace extensions 83 } // namespace extensions
82 84
83 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_ 85 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698