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 "chrome/renderer/extensions/app_window_custom_bindings.h" | 5 #include "chrome/renderer/extensions/app_window_custom_bindings.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 namespace extensions { | 26 namespace extensions { |
27 | 27 |
28 class DidCreateDocumentElementObserver : public content::RenderViewObserver { | 28 class DidCreateDocumentElementObserver : public content::RenderViewObserver { |
29 public: | 29 public: |
30 DidCreateDocumentElementObserver( | 30 DidCreateDocumentElementObserver( |
31 content::RenderView* view, Dispatcher* dispatcher) | 31 content::RenderView* view, Dispatcher* dispatcher) |
32 : content::RenderViewObserver(view), dispatcher_(dispatcher) { | 32 : content::RenderViewObserver(view), dispatcher_(dispatcher) { |
33 } | 33 } |
34 | 34 |
35 virtual void DidCreateDocumentElement(WebKit::WebFrame* frame) OVERRIDE { | 35 virtual void DidCreateDocumentElement(blink::WebFrame* frame) OVERRIDE { |
36 DCHECK(frame); | 36 DCHECK(frame); |
37 DCHECK(dispatcher_); | 37 DCHECK(dispatcher_); |
38 // Don't attempt to inject the titlebar into iframes. | 38 // Don't attempt to inject the titlebar into iframes. |
39 if (frame->parent()) | 39 if (frame->parent()) |
40 return; | 40 return; |
41 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 41 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
42 ChromeV8Context* v8_context = | 42 ChromeV8Context* v8_context = |
43 dispatcher_->v8_context_set().GetByV8Context( | 43 dispatcher_->v8_context_set().GetByV8Context( |
44 frame->mainWorldScriptContext()); | 44 frame->mainWorldScriptContext()); |
45 | 45 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 if (inject_titlebar) | 93 if (inject_titlebar) |
94 new DidCreateDocumentElementObserver(view, dispatcher()); | 94 new DidCreateDocumentElementObserver(view, dispatcher()); |
95 | 95 |
96 // TODO(jeremya): it doesn't really make sense to set the opener here, but we | 96 // TODO(jeremya): it doesn't really make sense to set the opener here, but we |
97 // need to make sure the security origin is set up before returning the DOM | 97 // need to make sure the security origin is set up before returning the DOM |
98 // reference. A better way to do this would be to have the browser pass the | 98 // reference. A better way to do this would be to have the browser pass the |
99 // opener through so opener_id is set in RenderViewImpl's constructor. | 99 // opener through so opener_id is set in RenderViewImpl's constructor. |
100 content::RenderView* render_view = GetRenderView(); | 100 content::RenderView* render_view = GetRenderView(); |
101 if (!render_view) | 101 if (!render_view) |
102 return; | 102 return; |
103 WebKit::WebFrame* opener = render_view->GetWebView()->mainFrame(); | 103 blink::WebFrame* opener = render_view->GetWebView()->mainFrame(); |
104 WebKit::WebFrame* frame = view->GetWebView()->mainFrame(); | 104 blink::WebFrame* frame = view->GetWebView()->mainFrame(); |
105 frame->setOpener(opener); | 105 frame->setOpener(opener); |
106 content::RenderThread::Get()->Send( | 106 content::RenderThread::Get()->Send( |
107 new ExtensionHostMsg_ResumeRequests(view->GetRoutingID())); | 107 new ExtensionHostMsg_ResumeRequests(view->GetRoutingID())); |
108 | 108 |
109 v8::Local<v8::Value> window = frame->mainWorldScriptContext()->Global(); | 109 v8::Local<v8::Value> window = frame->mainWorldScriptContext()->Global(); |
110 args.GetReturnValue().Set(window); | 110 args.GetReturnValue().Set(window); |
111 } | 111 } |
112 | 112 |
113 void AppWindowCustomBindings::GetWindowControlsHtmlTemplate( | 113 void AppWindowCustomBindings::GetWindowControlsHtmlTemplate( |
114 const v8::FunctionCallbackInfo<v8::Value>& args) { | 114 const v8::FunctionCallbackInfo<v8::Value>& args) { |
115 CHECK_EQ(args.Length(), 0); | 115 CHECK_EQ(args.Length(), 0); |
116 | 116 |
117 v8::Handle<v8::Value> result = v8::String::Empty(); | 117 v8::Handle<v8::Value> result = v8::String::Empty(); |
118 if (CommandLine::ForCurrentProcess()->HasSwitch( | 118 if (CommandLine::ForCurrentProcess()->HasSwitch( |
119 switches::kEnableAppWindowControls)) { | 119 switches::kEnableAppWindowControls)) { |
120 base::Value* value = base::Value::CreateStringValue( | 120 base::Value* value = base::Value::CreateStringValue( |
121 ResourceBundle::GetSharedInstance().GetRawDataResource( | 121 ResourceBundle::GetSharedInstance().GetRawDataResource( |
122 IDR_WINDOW_CONTROLS_TEMPLATE_HTML).as_string()); | 122 IDR_WINDOW_CONTROLS_TEMPLATE_HTML).as_string()); |
123 scoped_ptr<content::V8ValueConverter> converter( | 123 scoped_ptr<content::V8ValueConverter> converter( |
124 content::V8ValueConverter::create()); | 124 content::V8ValueConverter::create()); |
125 result = converter->ToV8Value(value, context()->v8_context()); | 125 result = converter->ToV8Value(value, context()->v8_context()); |
126 } | 126 } |
127 args.GetReturnValue().Set(result); | 127 args.GetReturnValue().Set(result); |
128 } | 128 } |
129 | 129 |
130 } // namespace extensions | 130 } // namespace extensions |
OLD | NEW |