[sql] Disable worker-thread code in SQLite.
[chromium-blink-merge.git] / extensions / renderer / user_script_injector.h
blob1ee8fed531f01a1e0565362efaec7ce5b509e4c1
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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_
6 #define EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/scoped_observer.h"
12 #include "extensions/common/user_script.h"
13 #include "extensions/renderer/script_injection.h"
14 #include "extensions/renderer/user_script_set.h"
16 class InjectionHost;
18 namespace blink {
19 class WebLocalFrame;
22 namespace extensions {
24 // A ScriptInjector for UserScripts.
25 class UserScriptInjector : public ScriptInjector,
26 public UserScriptSet::Observer {
27 public:
28 UserScriptInjector(const UserScript* user_script,
29 UserScriptSet* user_script_set,
30 bool is_declarative);
31 ~UserScriptInjector() override;
33 private:
34 // UserScriptSet::Observer implementation.
35 void OnUserScriptsUpdated(const std::set<HostID>& changed_hosts,
36 const std::vector<UserScript*>& scripts) override;
38 // ScriptInjector implementation.
39 UserScript::InjectionType script_type() const override;
40 bool ShouldExecuteInMainWorld() const override;
41 bool IsUserGesture() const override;
42 bool ExpectsResults() const override;
43 bool ShouldInjectJs(UserScript::RunLocation run_location) const override;
44 bool ShouldInjectCss(UserScript::RunLocation run_location) const override;
45 PermissionsData::AccessType CanExecuteOnFrame(
46 const InjectionHost* injection_host,
47 blink::WebLocalFrame* web_frame,
48 int tab_id) const override;
49 std::vector<blink::WebScriptSource> GetJsSources(
50 UserScript::RunLocation run_location) const override;
51 std::vector<std::string> GetCssSources(
52 UserScript::RunLocation run_location) const override;
53 void GetRunInfo(ScriptsRunInfo* scripts_run_info,
54 UserScript::RunLocation run_location) const override;
55 void OnInjectionComplete(scoped_ptr<base::Value> execution_result,
56 UserScript::RunLocation run_location) override;
57 void OnWillNotInject(InjectFailureReason reason) override;
59 // The associated user script. Owned by the UserScriptInjector that created
60 // this object.
61 const UserScript* script_;
63 // The id of the associated user script. We cache this because when we update
64 // the |script_| associated with this injection, the old referance may be
65 // deleted.
66 int script_id_;
68 // The associated host id, preserved for the same reason as |script_id|.
69 HostID host_id_;
71 // Indicates whether or not this script is declarative. This influences which
72 // script permissions are checked before injection.
73 bool is_declarative_;
75 ScopedObserver<UserScriptSet, UserScriptSet::Observer>
76 user_script_set_observer_;
78 DISALLOW_COPY_AND_ASSIGN(UserScriptInjector);
81 } // namespace extensions
83 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_