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