OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/app_window_custom_bindings.h" | 5 #include "extensions/renderer/app_window_custom_bindings.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "content/public/child/v8_value_converter.h" | 8 #include "content/public/child/v8_value_converter.h" |
9 #include "content/public/renderer/render_frame.h" | 9 #include "content/public/renderer/render_frame.h" |
10 #include "content/public/renderer/render_thread.h" | 10 #include "content/public/renderer/render_thread.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 int frame_id = args[0]->Int32Value(); | 43 int frame_id = args[0]->Int32Value(); |
44 | 44 |
45 if (frame_id == MSG_ROUTING_NONE) | 45 if (frame_id == MSG_ROUTING_NONE) |
46 return; | 46 return; |
47 | 47 |
48 content::RenderFrame* app_frame = | 48 content::RenderFrame* app_frame = |
49 content::RenderFrame::FromRoutingID(frame_id); | 49 content::RenderFrame::FromRoutingID(frame_id); |
50 if (!app_frame) | 50 if (!app_frame) |
51 return; | 51 return; |
52 | 52 |
53 // TODO(jeremya): it doesn't really make sense to set the opener here, but we | |
54 // need to make sure the security origin is set up before returning the DOM | |
55 // reference. A better way to do this would be to have the browser pass the | |
56 // opener through so opener_id is set in RenderViewImpl's constructor. | |
57 content::RenderFrame* context_render_frame = context()->GetRenderFrame(); | |
58 if (!context_render_frame) | |
59 return; | |
60 | |
61 blink::WebFrame* opener = context_render_frame->GetWebFrame(); | |
62 blink::WebLocalFrame* app_web_frame = app_frame->GetWebFrame(); | |
63 app_web_frame->setOpener(opener); | |
64 | |
65 content::RenderThread::Get()->Send(new ExtensionHostMsg_AppWindowReady( | 53 content::RenderThread::Get()->Send(new ExtensionHostMsg_AppWindowReady( |
66 app_frame->GetRenderView()->GetRoutingID())); | 54 app_frame->GetRenderView()->GetRoutingID())); |
67 | 55 |
68 v8::Local<v8::Value> window = | 56 v8::Local<v8::Value> window = |
69 app_web_frame->mainWorldScriptContext()->Global(); | 57 app_frame->GetWebFrame()->mainWorldScriptContext()->Global(); |
70 args.GetReturnValue().Set(window); | 58 args.GetReturnValue().Set(window); |
71 } | 59 } |
72 | 60 |
73 void AppWindowCustomBindings::GetWindowControlsHtmlTemplate( | 61 void AppWindowCustomBindings::GetWindowControlsHtmlTemplate( |
74 const v8::FunctionCallbackInfo<v8::Value>& args) { | 62 const v8::FunctionCallbackInfo<v8::Value>& args) { |
75 CHECK_EQ(args.Length(), 0); | 63 CHECK_EQ(args.Length(), 0); |
76 | 64 |
77 v8::Local<v8::Value> result = v8::String::Empty(args.GetIsolate()); | 65 v8::Local<v8::Value> result = v8::String::Empty(args.GetIsolate()); |
78 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 66 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
79 switches::kEnableAppWindowControls)) { | 67 switches::kEnableAppWindowControls)) { |
80 base::StringValue value( | 68 base::StringValue value( |
81 ResourceBundle::GetSharedInstance() | 69 ResourceBundle::GetSharedInstance() |
82 .GetRawDataResource(IDR_WINDOW_CONTROLS_TEMPLATE_HTML) | 70 .GetRawDataResource(IDR_WINDOW_CONTROLS_TEMPLATE_HTML) |
83 .as_string()); | 71 .as_string()); |
84 scoped_ptr<content::V8ValueConverter> converter( | 72 scoped_ptr<content::V8ValueConverter> converter( |
85 content::V8ValueConverter::create()); | 73 content::V8ValueConverter::create()); |
86 result = converter->ToV8Value(&value, context()->v8_context()); | 74 result = converter->ToV8Value(&value, context()->v8_context()); |
87 } | 75 } |
88 args.GetReturnValue().Set(result); | 76 args.GetReturnValue().Set(result); |
89 } | 77 } |
90 | 78 |
91 } // namespace extensions | 79 } // namespace extensions |
OLD | NEW |