| Index: extensions/renderer/script_context.h
|
| diff --git a/chrome/renderer/extensions/chrome_v8_context.h b/extensions/renderer/script_context.h
|
| similarity index 70%
|
| copy from chrome/renderer/extensions/chrome_v8_context.h
|
| copy to extensions/renderer/script_context.h
|
| index da08b8c72ba4fc7c92f470e19b486e02f3e8ef18..cf360e3116845a11d15e419dd5a5c5536314b55b 100644
|
| --- a/chrome/renderer/extensions/chrome_v8_context.h
|
| +++ b/extensions/renderer/script_context.h
|
| @@ -2,18 +2,17 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_
|
| -#define CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_
|
| +#ifndef EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_
|
| +#define EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_
|
|
|
| #include <string>
|
|
|
| #include "base/basictypes.h"
|
| #include "base/compiler_specific.h"
|
| -#include "chrome/renderer/extensions/module_system.h"
|
| -#include "chrome/renderer/extensions/pepper_request_proxy.h"
|
| -#include "chrome/renderer/extensions/request_sender.h"
|
| -#include "chrome/renderer/extensions/safe_builtins.h"
|
| #include "extensions/common/features/feature.h"
|
| +#include "extensions/renderer/module_system.h"
|
| +#include "extensions/renderer/request_sender.h"
|
| +#include "extensions/renderer/safe_builtins.h"
|
| #include "extensions/renderer/scoped_persistent.h"
|
| #include "v8/include/v8.h"
|
|
|
| @@ -28,14 +27,14 @@ class RenderView;
|
| namespace extensions {
|
| class Extension;
|
|
|
| -// Chrome's wrapper for a v8 context.
|
| -class ChromeV8Context : public RequestSender::Source {
|
| +// Extensions wrapper for a v8 context.
|
| +class ScriptContext : public RequestSender::Source {
|
| public:
|
| - ChromeV8Context(v8::Handle<v8::Context> context,
|
| - blink::WebFrame* frame,
|
| - const Extension* extension,
|
| - Feature::Context context_type);
|
| - virtual ~ChromeV8Context();
|
| + ScriptContext(v8::Handle<v8::Context> context,
|
| + blink::WebFrame* frame,
|
| + const Extension* extension,
|
| + Feature::Context context_type);
|
| + virtual ~ScriptContext();
|
|
|
| // Clears the WebFrame for this contexts and invalidates the associated
|
| // ModuleSystem.
|
| @@ -43,25 +42,17 @@ class ChromeV8Context : public RequestSender::Source {
|
|
|
| // Returns true if this context is still valid, false if it isn't.
|
| // A context becomes invalid via Invalidate().
|
| - bool is_valid() const {
|
| - return !v8_context_.IsEmpty();
|
| - }
|
| + bool is_valid() const { return !v8_context_.IsEmpty(); }
|
|
|
| v8::Handle<v8::Context> v8_context() const {
|
| return v8_context_.NewHandle(v8::Isolate::GetCurrent());
|
| }
|
|
|
| - const Extension* extension() const {
|
| - return extension_.get();
|
| - }
|
| + const Extension* extension() const { return extension_.get(); }
|
|
|
| - blink::WebFrame* web_frame() const {
|
| - return web_frame_;
|
| - }
|
| + blink::WebFrame* web_frame() const { return web_frame_; }
|
|
|
| - Feature::Context context_type() const {
|
| - return context_type_;
|
| - }
|
| + Feature::Context context_type() const { return context_type_; }
|
|
|
| void set_module_system(scoped_ptr<ModuleSystem> module_system) {
|
| module_system_ = module_system.Pass();
|
| @@ -69,16 +60,9 @@ class ChromeV8Context : public RequestSender::Source {
|
|
|
| ModuleSystem* module_system() { return module_system_.get(); }
|
|
|
| - SafeBuiltins* safe_builtins() {
|
| - return &safe_builtins_;
|
| - }
|
| - const SafeBuiltins* safe_builtins() const {
|
| - return &safe_builtins_;
|
| - }
|
| + SafeBuiltins* safe_builtins() { return &safe_builtins_; }
|
|
|
| - PepperRequestProxy* pepper_request_proxy() {
|
| - return &pepper_request_proxy_;
|
| - }
|
| + const SafeBuiltins* safe_builtins() const { return &safe_builtins_; }
|
|
|
| // Returns the ID of the extension associated with this context, or empty
|
| // string if there is no such extension.
|
| @@ -88,9 +72,6 @@ class ChromeV8Context : public RequestSender::Source {
|
| // context is in the process of being destroyed.
|
| content::RenderView* GetRenderView() const;
|
|
|
| - // Get the URL of this context's web frame.
|
| - GURL GetURL() const;
|
| -
|
| // Runs |function| with appropriate scopes. Doesn't catch exceptions, callers
|
| // must do that if they want.
|
| //
|
| @@ -107,30 +88,36 @@ class ChromeV8Context : public RequestSender::Source {
|
| // Returns the availability of the API |api_name|.
|
| Feature::Availability GetAvailability(const std::string& api_name);
|
|
|
| + // Returns a string description of the type of context this is.
|
| + std::string GetContextTypeDescription();
|
| +
|
| + v8::Isolate* isolate() const { return isolate_; }
|
| +
|
| + // Get the URL of this context's web frame.
|
| + GURL GetURL() const;
|
| +
|
| // Returns whether the API |api| or any part of the API could be
|
| // available in this context without taking into account the context's
|
| // extension.
|
| bool IsAnyFeatureAvailableToContext(const extensions::Feature& api);
|
|
|
| - // Returns a string description of the type of context this is.
|
| - std::string GetContextTypeDescription();
|
| + // Utility to get the URL we will match against for a frame. If the frame has
|
| + // committed, this is the commited URL. Otherwise it is the provisional URL.
|
| + static GURL GetDataSourceURLForFrame(const blink::WebFrame* frame);
|
|
|
| // RequestSender::Source implementation.
|
| - virtual ChromeV8Context* GetContext() OVERRIDE;
|
| + virtual ScriptContext* GetContext() OVERRIDE;
|
| virtual void OnResponseReceived(const std::string& name,
|
| int request_id,
|
| bool success,
|
| const base::ListValue& response,
|
| const std::string& error) OVERRIDE;
|
|
|
| - v8::Isolate* isolate() const {
|
| - return isolate_;
|
| - }
|
| -
|
| - private:
|
| + protected:
|
| // The v8 context the bindings are accessible to.
|
| ScopedPersistent<v8::Context> v8_context_;
|
|
|
| + private:
|
| // The WebFrame associated with this context. This can be NULL because this
|
| // object can outlive is destroyed asynchronously.
|
| blink::WebFrame* web_frame_;
|
| @@ -148,14 +135,11 @@ class ChromeV8Context : public RequestSender::Source {
|
| // Contains safe copies of builtin objects like Function.prototype.
|
| SafeBuiltins safe_builtins_;
|
|
|
| - // The proxy for this context for making API calls from Pepper via Javascript.
|
| - PepperRequestProxy pepper_request_proxy_;
|
| -
|
| v8::Isolate* isolate_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(ChromeV8Context);
|
| + DISALLOW_COPY_AND_ASSIGN(ScriptContext);
|
| };
|
|
|
| } // namespace extensions
|
|
|
| -#endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_
|
| +#endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_
|
|
|