diff options
Diffstat (limited to 'chrome/renderer/extensions')
7 files changed, 1 insertions, 231 deletions
diff --git a/chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc b/chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc index 8ea9568..671566b 100644 --- a/chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc +++ b/chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc @@ -22,7 +22,6 @@ #include "chrome/renderer/extensions/notifications_native_handler.h" #include "chrome/renderer/extensions/page_actions_custom_bindings.h" #include "chrome/renderer/extensions/page_capture_custom_bindings.h" -#include "chrome/renderer/extensions/pepper_request_natives.h" #include "chrome/renderer/extensions/sync_file_system_custom_bindings.h" #include "chrome/renderer/extensions/tab_finder.h" #include "chrome/renderer/extensions/tabs_custom_bindings.h" @@ -127,9 +126,6 @@ void ChromeExtensionsDispatcherDelegate::RegisterNativeHandlers( scoped_ptr<NativeHandler>( new extensions::PageCaptureCustomBindings(context))); module_system->RegisterNativeHandler( - "pepper_request_natives", - scoped_ptr<NativeHandler>(new extensions::PepperRequestNatives(context))); - module_system->RegisterNativeHandler( "tabs", scoped_ptr<NativeHandler>(new extensions::TabsCustomBindings(context))); module_system->RegisterNativeHandler( @@ -149,9 +145,6 @@ void ChromeExtensionsDispatcherDelegate::RegisterNativeHandlers( void ChromeExtensionsDispatcherDelegate::PopulateSourceMap( extensions::ResourceBundleSourceMap* source_map) { - // Libraries. - source_map->RegisterSource("pepper_request", IDR_PEPPER_REQUEST_JS); - // Custom bindings. source_map->RegisterSource("app", IDR_APP_CUSTOM_BINDINGS_JS); source_map->RegisterSource("app.window", IDR_APP_WINDOW_CUSTOM_BINDINGS_JS); diff --git a/chrome/renderer/extensions/chrome_v8_context.cc b/chrome/renderer/extensions/chrome_v8_context.cc index 8d58f70..ca68bb1 100644 --- a/chrome/renderer/extensions/chrome_v8_context.cc +++ b/chrome/renderer/extensions/chrome_v8_context.cc @@ -21,8 +21,7 @@ ChromeV8Context::ChromeV8Context(const v8::Handle<v8::Context>& v8_context, blink::WebFrame* web_frame, const Extension* extension, Feature::Context context_type) - : ScriptContext(v8_context, web_frame, extension, context_type), - pepper_request_proxy_(this) { + : ScriptContext(v8_context, web_frame, extension, context_type) { } } // namespace extensions diff --git a/chrome/renderer/extensions/chrome_v8_context.h b/chrome/renderer/extensions/chrome_v8_context.h index d4779db..1b74453 100644 --- a/chrome/renderer/extensions/chrome_v8_context.h +++ b/chrome/renderer/extensions/chrome_v8_context.h @@ -9,7 +9,6 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" -#include "chrome/renderer/extensions/pepper_request_proxy.h" #include "extensions/common/features/feature.h" #include "extensions/renderer/module_system.h" #include "extensions/renderer/request_sender.h" @@ -37,14 +36,7 @@ class ChromeV8Context : public ScriptContext { const Extension* extension, Feature::Context context_type); - PepperRequestProxy* pepper_request_proxy() { - return &pepper_request_proxy_; - } - private: - // The proxy for this context for making API calls from Pepper via Javascript. - PepperRequestProxy pepper_request_proxy_; - DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); }; diff --git a/chrome/renderer/extensions/pepper_request_natives.cc b/chrome/renderer/extensions/pepper_request_natives.cc deleted file mode 100644 index 75bc5b4..0000000 --- a/chrome/renderer/extensions/pepper_request_natives.cc +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/renderer/extensions/pepper_request_natives.h" - -#include <string> - -#include "base/logging.h" -#include "base/values.h" -#include "chrome/renderer/extensions/chrome_v8_context.h" -#include "content/public/renderer/v8_value_converter.h" - -namespace extensions { - -PepperRequestNatives::PepperRequestNatives(ScriptContext* context) - : ObjectBackedNativeHandler(context) { - RouteFunction( - "SendResponse", - base::Bind(&PepperRequestNatives::SendResponse, base::Unretained(this))); -} - -void PepperRequestNatives::SendResponse( - const v8::FunctionCallbackInfo<v8::Value>& args) { - DCHECK_EQ(3, args.Length()); - DCHECK(args[0]->IsInt32()); - DCHECK(args[1]->IsArray()); - int request_id = args[0]->Int32Value(); - - // TODO(rockot): This downcast should be eliminated. - // See http://crbug.com/362616. - ChromeV8Context* chrome_context = static_cast<ChromeV8Context*>(context()); - if (args[2]->IsString()) { - chrome_context->pepper_request_proxy()->OnResponseReceived( - request_id, false, base::ListValue(), *v8::String::Utf8Value(args[2])); - return; - } - - scoped_ptr<content::V8ValueConverter> converter( - content::V8ValueConverter::create()); - scoped_ptr<const base::Value> result( - converter->FromV8Value(args[1], chrome_context->v8_context())); - DCHECK(result); - const base::ListValue* result_list = NULL; - CHECK(result->GetAsList(&result_list)); - chrome_context->pepper_request_proxy()->OnResponseReceived( - request_id, true, *result_list, ""); -} - -} // namespace extensions diff --git a/chrome/renderer/extensions/pepper_request_natives.h b/chrome/renderer/extensions/pepper_request_natives.h deleted file mode 100644 index c1b1add..0000000 --- a/chrome/renderer/extensions/pepper_request_natives.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_NATIVES_H_ -#define CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_NATIVES_H_ - -#include "base/compiler_specific.h" -#include "extensions/renderer/object_backed_native_handler.h" - -namespace base { -class Value; -} - -namespace extensions { - -// Custom bindings for handling API calls from pepper plugins. -class PepperRequestNatives : public ObjectBackedNativeHandler { - public: - explicit PepperRequestNatives(ScriptContext* context); - - private: - // Sends a response to an API call to the pepper plugin which made the call. - // |args| should contain: - // |request_id|: An int containing the id of the request. - // |response|: An array containing the response. - // |error|: A string containing the error message if an error occurred or - // null if the call was successful. - void SendResponse(const v8::FunctionCallbackInfo<v8::Value>& args); - - DISALLOW_COPY_AND_ASSIGN(PepperRequestNatives); -}; - -} // namespace extensions - -#endif // CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_NATIVES_H_ diff --git a/chrome/renderer/extensions/pepper_request_proxy.cc b/chrome/renderer/extensions/pepper_request_proxy.cc deleted file mode 100644 index c3936fd..0000000 --- a/chrome/renderer/extensions/pepper_request_proxy.cc +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/renderer/extensions/pepper_request_proxy.h" - -#include "base/values.h" -#include "chrome/renderer/extensions/chrome_v8_context.h" -#include "content/public/renderer/v8_value_converter.h" - -namespace extensions { - -PepperRequestProxy::PepperRequestProxy(ChromeV8Context* context) - : context_(context), - isolate_(context->v8_context()->GetIsolate()), - next_request_id_(0) {} - -PepperRequestProxy::~PepperRequestProxy() {} - -bool PepperRequestProxy::StartRequest(const ResponseCallback& callback, - const std::string& request_name, - const base::ListValue& args, - std::string* error) { - int request_id = next_request_id_++; - pending_request_map_[request_id] = callback; - - // TODO(sammc): Converting from base::Value to v8::Value and then back to - // base::Value is not optimal. For most API calls the JS code doesn't do much. - // http://crbug.com/324115. - v8::HandleScope scope(isolate_); - scoped_ptr<content::V8ValueConverter> converter( - content::V8ValueConverter::create()); - std::vector<v8::Handle<v8::Value> > v8_args; - v8_args.push_back(v8::String::NewFromUtf8(isolate_, request_name.c_str())); - v8_args.push_back(v8::Integer::New(isolate_, request_id)); - for (base::ListValue::const_iterator it = args.begin(); it != args.end(); - ++it) { - v8_args.push_back(converter->ToV8Value(*it, context_->v8_context())); - } - v8::Handle<v8::Value> v8_error = context_->module_system()->CallModuleMethod( - "pepper_request", "startRequest", &v8_args); - if (v8_error->IsString()) { - if (error) { - *error = *v8::String::Utf8Value(v8_error); - pending_request_map_.erase(request_id); - } - return false; - } - - return true; -} - -void PepperRequestProxy::OnResponseReceived(int request_id, - bool success, - const base::ListValue& args, - const std::string& error) { - PendingRequestMap::iterator it = pending_request_map_.find(request_id); - DCHECK(it != pending_request_map_.end()); - it->second.Run(success, args, error); - pending_request_map_.erase(it); -} - -} // namespace extensions diff --git a/chrome/renderer/extensions/pepper_request_proxy.h b/chrome/renderer/extensions/pepper_request_proxy.h deleted file mode 100644 index 8c05c85..0000000 --- a/chrome/renderer/extensions/pepper_request_proxy.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_PROXY_H_ -#define CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_PROXY_H_ - -#include <map> -#include <string> - -#include "base/callback.h" - -namespace base { -class ListValue; -} - -namespace v8 { -class Isolate; -} - -namespace extensions { - -class ChromeV8Context; - -// A proxy that forwards pepper apps API calls through the Javascript API -// bindings. -class PepperRequestProxy { - public: - // A callback to be called with the result of an API call. If |success| is - // true, |response| will contain the response value. Otherwise, |error| will - // contain the error message. - typedef base::Callback<void(bool success, - const base::ListValue& response, - const std::string& error)> ResponseCallback; - - explicit PepperRequestProxy(ChromeV8Context* context); - ~PepperRequestProxy(); - - // Starts an API request. Returns whether the call was successful. On failure, - // |error| will contain the error message. |callback| will only be called on - // success. - bool StartRequest(const ResponseCallback& callback, - const std::string& request_name, - const base::ListValue& args, - std::string* error); - - void OnResponseReceived(int request_id, - bool success, - const base::ListValue& args, - const std::string& error); - - private: - typedef std::map<int, ResponseCallback> PendingRequestMap; - - // Non-owning pointer. - ChromeV8Context* context_; - // Non-owning pointer. - v8::Isolate* isolate_; - PendingRequestMap pending_request_map_; - int next_request_id_; -}; - -} // namespace extensions - -#endif // CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_PROXY_H_ |