OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "chrome/renderer/pepper/pepper_extensions_common_host.h" | 5 #include "chrome/renderer/pepper/pepper_extensions_common_host.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/renderer/extensions/chrome_v8_context.h" | 10 #include "chrome/renderer/extensions/chrome_v8_context.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 if (!dispatcher) | 56 if (!dispatcher) |
57 return NULL; | 57 return NULL; |
58 blink::WebPluginContainer* container = | 58 blink::WebPluginContainer* container = |
59 host->GetContainerForInstance(instance); | 59 host->GetContainerForInstance(instance); |
60 if (!container) | 60 if (!container) |
61 return NULL; | 61 return NULL; |
62 blink::WebFrame* frame = container->element().document().frame(); | 62 blink::WebFrame* frame = container->element().document().frame(); |
63 if (!frame) | 63 if (!frame) |
64 return NULL; | 64 return NULL; |
65 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 65 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 66 // TODO(rockot): Remove this downcast. See http://crbug.com/362616. |
66 extensions::ChromeV8Context* context = | 67 extensions::ChromeV8Context* context = |
67 dispatcher->v8_context_set().GetByV8Context( | 68 static_cast<extensions::ChromeV8Context*>( |
68 frame->mainWorldScriptContext()); | 69 dispatcher->script_context_set().GetByV8Context( |
| 70 frame->mainWorldScriptContext())); |
69 if (!context) | 71 if (!context) |
70 return NULL; | 72 return NULL; |
71 | 73 |
72 return new PepperExtensionsCommonHost( | 74 return new PepperExtensionsCommonHost( |
73 host, instance, resource, context->pepper_request_proxy()); | 75 host, instance, resource, context->pepper_request_proxy()); |
74 } | 76 } |
75 | 77 |
76 int32_t PepperExtensionsCommonHost::OnResourceMessageReceived( | 78 int32_t PepperExtensionsCommonHost::OnResourceMessageReceived( |
77 const IPC::Message& msg, | 79 const IPC::Message& msg, |
78 ppapi::host::HostMessageContext* context) { | 80 ppapi::host::HostMessageContext* context) { |
(...skipping 30 matching lines...) Expand all Loading... |
109 std::string error; | 111 std::string error; |
110 bool success = pepper_request_proxy_->StartRequest( | 112 bool success = pepper_request_proxy_->StartRequest( |
111 base::Bind(&PepperExtensionsCommonHost::OnResponseReceived, | 113 base::Bind(&PepperExtensionsCommonHost::OnResponseReceived, |
112 weak_factory_.GetWeakPtr(), | 114 weak_factory_.GetWeakPtr(), |
113 context->MakeReplyMessageContext()), | 115 context->MakeReplyMessageContext()), |
114 request_name, | 116 request_name, |
115 args, | 117 args, |
116 &error); | 118 &error); |
117 return success ? PP_OK_COMPLETIONPENDING : PP_ERROR_FAILED; | 119 return success ? PP_OK_COMPLETIONPENDING : PP_ERROR_FAILED; |
118 } | 120 } |
OLD | NEW |