Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Side by Side Diff: extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc

Issue 1167423002: Use V8 Maybe APIs in extensions/renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_con tainer.h" 5 #include "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_con tainer.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "components/guest_view/common/guest_view_constants.h" 10 #include "components/guest_view/common/guest_view_constants.h"
(...skipping 25 matching lines...) Expand all
36 class ScriptableObject : public gin::Wrappable<ScriptableObject>, 36 class ScriptableObject : public gin::Wrappable<ScriptableObject>,
37 public gin::NamedPropertyInterceptor { 37 public gin::NamedPropertyInterceptor {
38 public: 38 public:
39 static gin::WrapperInfo kWrapperInfo; 39 static gin::WrapperInfo kWrapperInfo;
40 40
41 static v8::Local<v8::Object> Create( 41 static v8::Local<v8::Object> Create(
42 v8::Isolate* isolate, 42 v8::Isolate* isolate,
43 base::WeakPtr<MimeHandlerViewContainer> container) { 43 base::WeakPtr<MimeHandlerViewContainer> container) {
44 ScriptableObject* scriptable_object = 44 ScriptableObject* scriptable_object =
45 new ScriptableObject(isolate, container); 45 new ScriptableObject(isolate, container);
46 return gin::CreateHandle(isolate, scriptable_object).ToV8()->ToObject(); 46 return gin::CreateHandle(isolate, scriptable_object)
47 .ToV8()
48 .As<v8::Object>();
47 } 49 }
48 50
49 // gin::NamedPropertyInterceptor 51 // gin::NamedPropertyInterceptor
50 v8::Local<v8::Value> GetNamedProperty( 52 v8::Local<v8::Value> GetNamedProperty(
51 v8::Isolate* isolate, 53 v8::Isolate* isolate,
52 const std::string& identifier) override { 54 const std::string& identifier) override {
53 if (identifier == kPostMessageName) { 55 if (identifier == kPostMessageName) {
54 if (post_message_function_template_.IsEmpty()) { 56 if (post_message_function_template_.IsEmpty()) {
55 post_message_function_template_.Reset( 57 post_message_function_template_.Reset(
56 isolate, 58 isolate,
57 gin::CreateFunctionTemplate( 59 gin::CreateFunctionTemplate(
58 isolate, base::Bind(&MimeHandlerViewContainer::PostMessage, 60 isolate, base::Bind(&MimeHandlerViewContainer::PostMessage,
59 container_, isolate))); 61 container_, isolate)));
60 } 62 }
61 return v8::Local<v8::FunctionTemplate>::New( 63 v8::Local<v8::FunctionTemplate> function_template =
62 isolate, post_message_function_template_)->GetFunction(); 64 v8::Local<v8::FunctionTemplate>::New(isolate,
65 post_message_function_template_);
66 v8::Local<v8::Function> interceptor;
67 if (function_template->GetFunction(isolate->GetCurrentContext())
68 .ToLocal(&interceptor))
69 return interceptor;
63 } 70 }
64 return v8::Local<v8::Value>(); 71 return v8::Local<v8::Value>();
65 } 72 }
66 73
67 private: 74 private:
68 ScriptableObject(v8::Isolate* isolate, 75 ScriptableObject(v8::Isolate* isolate,
69 base::WeakPtr<MimeHandlerViewContainer> container) 76 base::WeakPtr<MimeHandlerViewContainer> container)
70 : gin::NamedPropertyInterceptor(isolate, this), 77 : gin::NamedPropertyInterceptor(isolate, this),
71 container_(container) {} 78 container_(container) {}
72 79
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 if (!render_frame()) 319 if (!render_frame())
313 return; 320 return;
314 321
315 render_frame()->Send( 322 render_frame()->Send(
316 new ExtensionsGuestViewHostMsg_CreateMimeHandlerViewGuest( 323 new ExtensionsGuestViewHostMsg_CreateMimeHandlerViewGuest(
317 render_frame()->GetRoutingID(), view_id_, element_instance_id(), 324 render_frame()->GetRoutingID(), view_id_, element_instance_id(),
318 element_size_)); 325 element_size_));
319 } 326 }
320 327
321 } // namespace extensions 328 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc ('k') | extensions/renderer/i18n_custom_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698