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

Side by Side Diff: Source/WebKit/chromium/src/WebHelperPluginImpl.cpp

Issue 12575006: Merge 145319 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1410/
Patch Set: Created 7 years, 9 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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 22 matching lines...) Expand all
33 33
34 #include "DocumentLoader.h" 34 #include "DocumentLoader.h"
35 #include "EmptyClients.h" 35 #include "EmptyClients.h"
36 #include "FocusController.h" 36 #include "FocusController.h"
37 #include "FrameView.h" 37 #include "FrameView.h"
38 #include "HTMLPlugInElement.h" 38 #include "HTMLPlugInElement.h"
39 #include "NodeList.h" 39 #include "NodeList.h"
40 #include "Page.h" 40 #include "Page.h"
41 #include "PageWidgetDelegate.h" 41 #include "PageWidgetDelegate.h"
42 #include "Settings.h" 42 #include "Settings.h"
43 #include "WebDocument.h"
43 #include "WebFrameImpl.h" 44 #include "WebFrameImpl.h"
44 #include "WebPlugin.h" 45 #include "WebPlugin.h"
45 #include "WebPluginContainerImpl.h" 46 #include "WebPluginContainerImpl.h"
46 #include "WebViewClient.h" 47 #include "WebViewClient.h"
47 #include "WebViewImpl.h" 48 #include "WebViewImpl.h"
48 #include "WebWidgetClient.h" 49 #include "WebWidgetClient.h"
49 50
50 using namespace WebCore; 51 using namespace WebCore;
51 52
52 namespace WebKit { 53 namespace WebKit {
53 54
54 #define addLiteral(literal, writer) writer.addData(literal, sizeof(literal) - 1) 55 #define addLiteral(literal, writer) writer.addData(literal, sizeof(literal) - 1)
55 56
56 static inline void addString(const String& str, DocumentWriter& writer) 57 static inline void addString(const String& str, DocumentWriter& writer)
57 { 58 {
58 CString str8 = str.utf8(); 59 CString str8 = str.utf8();
59 writer.addData(str8.data(), str8.length()); 60 writer.addData(str8.data(), str8.length());
60 } 61 }
61 62
62 void writeDocument(WebCore::DocumentWriter& writer, const String& pluginType) 63 void writeDocument(const String& pluginType, const WebDocument& hostDocument, We bCore::DocumentWriter& writer)
63 { 64 {
65 // Give the new document the same URL as the hose document so that content
66 // settings and other decisions can be made based on the correct origin.
67 const WebURL& url = hostDocument.url();
68
64 writer.setMIMEType("text/html"); 69 writer.setMIMEType("text/html");
65 writer.setEncoding("UTF-8", false); 70 writer.setEncoding("UTF-8", false);
66 writer.begin(); 71 writer.begin(url);
67 72
68 addLiteral("<!DOCTYPE html><head><meta charset='UTF-8'></head><body>\n", wri ter); 73 addLiteral("<!DOCTYPE html><head><meta charset='UTF-8'></head><body>\n", wri ter);
69 String objectTag = "<object type=\"" + pluginType + "\"></object>"; 74 String objectTag = "<object type=\"" + pluginType + "\"></object>";
70 addString(objectTag, writer); 75 addString(objectTag, writer);
71 addLiteral("</body>\n", writer); 76 addLiteral("</body>\n", writer);
72 77
73 writer.end(); 78 writer.end();
74 } 79 }
75 80
76 class HelperPluginChromeClient : public EmptyChromeClient { 81 class HelperPluginChromeClient : public EmptyChromeClient {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 , m_webView(0) 113 , m_webView(0)
109 { 114 {
110 ASSERT(client); 115 ASSERT(client);
111 } 116 }
112 117
113 WebHelperPluginImpl::~WebHelperPluginImpl() 118 WebHelperPluginImpl::~WebHelperPluginImpl()
114 { 119 {
115 ASSERT(!m_page); 120 ASSERT(!m_page);
116 } 121 }
117 122
118 bool WebHelperPluginImpl::initialize(WebViewImpl* webView, const String& pluginT ype) 123 bool WebHelperPluginImpl::initialize(const String& pluginType, const WebDocument & hostDocument, WebViewImpl* webView)
119 { 124 {
120 ASSERT(webView); 125 ASSERT(webView);
121 m_webView = webView; 126 m_webView = webView;
122 127
123 return initializePage(webView, pluginType); 128 return initializePage(pluginType, hostDocument);
124 } 129 }
125 130
126 void WebHelperPluginImpl::closeHelperPlugin() 131 void WebHelperPluginImpl::closeHelperPlugin()
127 { 132 {
128 if (m_page) { 133 if (m_page) {
129 m_page->setGroupName(String()); 134 m_page->setGroupName(String());
130 m_page->mainFrame()->loader()->stopAllLoaders(); 135 m_page->mainFrame()->loader()->stopAllLoaders();
131 m_page->mainFrame()->loader()->stopLoading(UnloadEventPolicyNone); 136 m_page->mainFrame()->loader()->stopLoading(UnloadEventPolicyNone);
132 } 137 }
133 138
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 ASSERT(plugin); 173 ASSERT(plugin);
169 // If the plugin is a placeholder, it is not useful to the caller, and it 174 // If the plugin is a placeholder, it is not useful to the caller, and it
170 // could be replaced at any time. Therefore, do not return it. 175 // could be replaced at any time. Therefore, do not return it.
171 if (plugin->isPlaceholder()) 176 if (plugin->isPlaceholder())
172 return 0; 177 return 0;
173 178
174 // The plugin was instantiated and will outlive this object. 179 // The plugin was instantiated and will outlive this object.
175 return plugin; 180 return plugin;
176 } 181 }
177 182
178 bool WebHelperPluginImpl::initializePage(WebKit::WebViewImpl* webView, const Str ing& pluginType) 183 bool WebHelperPluginImpl::initializePage(const String& pluginType, const WebDocu ment& hostDocument)
179 { 184 {
180 Page::PageClients pageClients; 185 Page::PageClients pageClients;
181 fillWithEmptyClients(pageClients); 186 fillWithEmptyClients(pageClients);
182 m_chromeClient = adoptPtr(new HelperPluginChromeClient(this)); 187 m_chromeClient = adoptPtr(new HelperPluginChromeClient(this));
183 pageClients.chromeClient = m_chromeClient.get(); 188 pageClients.chromeClient = m_chromeClient.get();
184 189
185 m_page = adoptPtr(new Page(pageClients)); 190 m_page = adoptPtr(new Page(pageClients));
186 // Scripting must be enabled in ScriptController::windowScriptNPObject(). 191 // Scripting must be enabled in ScriptController::windowScriptNPObject().
187 m_page->settings()->setScriptEnabled(true); 192 m_page->settings()->setScriptEnabled(true);
188 m_page->settings()->setPluginsEnabled(true); 193 m_page->settings()->setPluginsEnabled(true);
189 194
190 unsigned layoutMilestones = DidFirstLayout | DidFirstVisuallyNonEmptyLayout; 195 unsigned layoutMilestones = DidFirstLayout | DidFirstVisuallyNonEmptyLayout;
191 m_page->addLayoutMilestones(static_cast<LayoutMilestones>(layoutMilestones)) ; 196 m_page->addLayoutMilestones(static_cast<LayoutMilestones>(layoutMilestones)) ;
192 197
193 webView->client()->initializeHelperPluginWebFrame(this); 198 m_webView->client()->initializeHelperPluginWebFrame(this);
194 199
195 // The page's main frame was set in initializeFrame() as a result of the abo ve call. 200 // The page's main frame was set in initializeFrame() as a result of the abo ve call.
196 Frame* frame = m_page->mainFrame(); 201 Frame* frame = m_page->mainFrame();
197 ASSERT(frame); 202 ASSERT(frame);
198 frame->setView(FrameView::create(frame)); 203 frame->setView(FrameView::create(frame));
199 // No need to set a size or make it not transparent. 204 // No need to set a size or make it not transparent.
200 205
201 DocumentWriter* writer = frame->loader()->activeDocumentLoader()->writer(); 206 DocumentWriter* writer = frame->loader()->activeDocumentLoader()->writer();
202 writeDocument(*writer, pluginType); 207 writeDocument(pluginType, hostDocument, *writer);
203 208
204 return true; 209 return true;
205 } 210 }
206 211
207 void WebHelperPluginImpl::destoryPage() 212 void WebHelperPluginImpl::destoryPage()
208 { 213 {
209 if (!m_page) 214 if (!m_page)
210 return; 215 return;
211 216
212 if (m_page->mainFrame()) 217 if (m_page->mainFrame())
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // A WebHelperPluginImpl instance usually has two references. 254 // A WebHelperPluginImpl instance usually has two references.
250 // - One owned by the instance itself. It represents the visible widget. 255 // - One owned by the instance itself. It represents the visible widget.
251 // - One owned by the hosting element. It's released when the hosting 256 // - One owned by the hosting element. It's released when the hosting
252 // element asks the WebHelperPluginImpl to close. 257 // element asks the WebHelperPluginImpl to close.
253 // We need them because the closing operation is asynchronous and the widget 258 // We need them because the closing operation is asynchronous and the widget
254 // can be closed while the hosting element is unaware of it. 259 // can be closed while the hosting element is unaware of it.
255 return adoptRef(new WebHelperPluginImpl(client)).leakRef(); 260 return adoptRef(new WebHelperPluginImpl(client)).leakRef();
256 } 261 }
257 262
258 } // namespace WebKit 263 } // namespace WebKit
OLDNEW
« no previous file with comments | « Source/WebKit/chromium/src/WebHelperPluginImpl.h ('k') | Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698