Chromium Code Reviews| OLD | NEW |
|---|---|
| 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, |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 64 UserScript::RunLocation GetRunLocation() const; | 64 UserScript::RunLocation GetRunLocation() const; |
| 65 | 65 |
| 66 // Notify the browser that the script was injected (or never will be), and | 66 // Notify the browser that the script was injected (or never will be), and |
| 67 // send along any results or errors. | 67 // send along any results or errors. |
| 68 void Finish(const std::string& error, content::RenderFrame* render_frame); | 68 void Finish(const std::string& error, content::RenderFrame* render_frame); |
| 69 | 69 |
| 70 // The parameters for injecting the script. | 70 // The parameters for injecting the script. |
| 71 std::unique_ptr<ExtensionMsg_ExecuteCode_Params> params_; | 71 std::unique_ptr<ExtensionMsg_ExecuteCode_Params> params_; |
| 72 | 72 |
| 73 // The url of the frame into which we are injecting. | 73 // The url of the frame into which we are injecting. |
| 74 GURL url_; | 74 mutable GURL url_; |
|
Devlin
2016/11/01 23:39:32
It makes me sad that these are mutable. I think h
jam
2016/11/01 23:47:03
agreed I prefer mutable too, I thought there was a
| |
| 75 | 75 |
| 76 // The serialization of the frame's origin if the frame is an about:-URL. This | 76 // The serialization of the frame's origin if the frame is an about:-URL. This |
| 77 // is used to provide user-friendly messages. | 77 // is used to provide user-friendly messages. |
| 78 std::string origin_for_about_error_; | 78 mutable std::string origin_for_about_error_; |
| 79 | 79 |
| 80 // The results of the script execution. | 80 // The results of the script execution. |
| 81 base::ListValue results_; | 81 base::ListValue results_; |
| 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_ |
| OLD | NEW |