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

Side by Side Diff: chrome/renderer/extensions/app_window_custom_bindings.cc

Issue 10916291: Only inject the HTML titlebar into toplevel frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/common/extensions/extension_messages.h" 9 #include "chrome/common/extensions/extension_messages.h"
10 #include "chrome/renderer/extensions/chrome_v8_context.h" 10 #include "chrome/renderer/extensions/chrome_v8_context.h"
11 #include "chrome/renderer/extensions/dispatcher.h" 11 #include "chrome/renderer/extensions/dispatcher.h"
12 #include "content/public/renderer/render_thread.h" 12 #include "content/public/renderer/render_thread.h"
13 #include "content/public/renderer/render_view.h" 13 #include "content/public/renderer/render_view.h"
14 #include "content/public/renderer/render_view_observer.h" 14 #include "content/public/renderer/render_view_observer.h"
15 #include "content/public/renderer/render_view_visitor.h" 15 #include "content/public/renderer/render_view_visitor.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
18 #include "v8/include/v8.h" 18 #include "v8/include/v8.h"
19 19
20 namespace extensions { 20 namespace extensions {
21 21
22 class DidCreateDocumentElementObserver : public content::RenderViewObserver { 22 class DidCreateDocumentElementObserver : public content::RenderViewObserver {
23 public: 23 public:
24 DidCreateDocumentElementObserver( 24 DidCreateDocumentElementObserver(
25 content::RenderView* view, Dispatcher* dispatcher) 25 content::RenderView* view, Dispatcher* dispatcher)
26 : content::RenderViewObserver(view), dispatcher_(dispatcher) { 26 : content::RenderViewObserver(view), dispatcher_(dispatcher) {
27 } 27 }
28 28
29 virtual void DidCreateDocumentElement(WebKit::WebFrame* frame) OVERRIDE { 29 virtual void DidCreateDocumentElement(WebKit::WebFrame* frame) OVERRIDE {
30 v8::HandleScope handle_scope;
31 DCHECK(frame); 30 DCHECK(frame);
32 DCHECK(dispatcher_); 31 DCHECK(dispatcher_);
32 // Don't attempt to inject the titlebar into iframes.
33 if (frame->parent())
34 return;
35 v8::HandleScope handle_scope;
33 ChromeV8Context* v8_context = 36 ChromeV8Context* v8_context =
34 dispatcher_->v8_context_set().GetByV8Context( 37 dispatcher_->v8_context_set().GetByV8Context(
35 frame->mainWorldScriptContext()); 38 frame->mainWorldScriptContext());
36 39
37 if (!v8_context) 40 if (!v8_context)
38 return; 41 return;
39 v8::Context::Scope context_scope(v8_context->v8_context()); 42 v8::Context::Scope context_scope(v8_context->v8_context());
40 v8_context->module_system()->CallModuleMethod( 43 v8_context->module_system()->CallModuleMethod(
41 "injectAppTitlebar", "didCreateDocumentElement"); 44 "injectAppTitlebar", "didCreateDocumentElement");
42 } 45 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 WebKit::WebFrame* frame = view->GetWebView()->mainFrame(); 123 WebKit::WebFrame* frame = view->GetWebView()->mainFrame();
121 frame->setOpener(opener); 124 frame->setOpener(opener);
122 content::RenderThread::Get()->Send( 125 content::RenderThread::Get()->Send(
123 new ExtensionHostMsg_ResumeRequests(view->GetRoutingID())); 126 new ExtensionHostMsg_ResumeRequests(view->GetRoutingID()));
124 127
125 v8::Local<v8::Value> window = frame->mainWorldScriptContext()->Global(); 128 v8::Local<v8::Value> window = frame->mainWorldScriptContext()->Global();
126 return window; 129 return window;
127 } 130 }
128 131
129 } // namespace extensions 132 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698