OLD | NEW |
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 102 } |
103 | 103 |
104 WebHelperPluginImpl* m_widget; | 104 WebHelperPluginImpl* m_widget; |
105 }; | 105 }; |
106 | 106 |
107 // WebHelperPluginImpl ---------------------------------------------------------
------- | 107 // WebHelperPluginImpl ---------------------------------------------------------
------- |
108 | 108 |
109 WebHelperPluginImpl::WebHelperPluginImpl(WebWidgetClient* client) | 109 WebHelperPluginImpl::WebHelperPluginImpl(WebWidgetClient* client) |
110 : m_widgetClient(client) | 110 : m_widgetClient(client) |
111 , m_webView(0) | 111 , m_webView(0) |
| 112 , m_mainFrame(0) |
112 { | 113 { |
113 ASSERT(client); | 114 ASSERT(client); |
114 } | 115 } |
115 | 116 |
116 WebHelperPluginImpl::~WebHelperPluginImpl() | 117 WebHelperPluginImpl::~WebHelperPluginImpl() |
117 { | 118 { |
118 ASSERT(!m_page); | 119 ASSERT(!m_page); |
119 } | 120 } |
120 | 121 |
121 bool WebHelperPluginImpl::initialize(const String& pluginType, const WebDocument
& hostDocument, WebViewImpl* webView) | 122 bool WebHelperPluginImpl::initialize(const String& pluginType, const WebDocument
& hostDocument, WebViewImpl* webView) |
(...skipping 14 matching lines...) Expand all Loading... |
136 // We must destroy the page now in case the host page is being destroyed, in | 137 // We must destroy the page now in case the host page is being destroyed, in |
137 // which case some of the objects the page depends on may have been | 138 // which case some of the objects the page depends on may have been |
138 // destroyed by the time this->close() is called asynchronously. | 139 // destroyed by the time this->close() is called asynchronously. |
139 destroyPage(); | 140 destroyPage(); |
140 | 141 |
141 // m_widgetClient might be 0 because this widget might be already closed. | 142 // m_widgetClient might be 0 because this widget might be already closed. |
142 if (m_widgetClient) { | 143 if (m_widgetClient) { |
143 // closeWidgetSoon() will call this->close() later. | 144 // closeWidgetSoon() will call this->close() later. |
144 m_widgetClient->closeWidgetSoon(); | 145 m_widgetClient->closeWidgetSoon(); |
145 } | 146 } |
| 147 m_mainFrame->close(); |
146 } | 148 } |
147 | 149 |
148 void WebHelperPluginImpl::initializeFrame(WebFrameClient* client) | 150 void WebHelperPluginImpl::initializeFrame(WebFrameClient* client) |
149 { | 151 { |
150 ASSERT(m_page); | 152 ASSERT(m_page); |
151 RefPtr<WebFrameImpl> frame = WebFrameImpl::create(client); | 153 m_mainFrame = WebFrameImpl::create(client); |
152 frame->initializeAsMainFrame(m_page.get()); | 154 m_mainFrame->initializeAsMainFrame(m_page.get()); |
153 } | 155 } |
154 | 156 |
155 // Returns a pointer to the WebPlugin by finding the single <object> tag in the
page. | 157 // Returns a pointer to the WebPlugin by finding the single <object> tag in the
page. |
156 WebPlugin* WebHelperPluginImpl::getPlugin() | 158 WebPlugin* WebHelperPluginImpl::getPlugin() |
157 { | 159 { |
158 ASSERT(m_page); | 160 ASSERT(m_page); |
159 | 161 |
160 RefPtr<NodeList> objectElements = m_page->mainFrame()->document()->getElemen
tsByTagName(WebCore::HTMLNames::objectTag.localName()); | 162 RefPtr<NodeList> objectElements = m_page->mainFrame()->document()->getElemen
tsByTagName(WebCore::HTMLNames::objectTag.localName()); |
161 ASSERT(objectElements && objectElements->length() == 1); | 163 ASSERT(objectElements && objectElements->length() == 1); |
162 if (!objectElements || objectElements->length() < 1) | 164 if (!objectElements || objectElements->length() < 1) |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 // A WebHelperPluginImpl instance usually has two references. | 243 // A WebHelperPluginImpl instance usually has two references. |
242 // - One owned by the instance itself. It represents the visible widget. | 244 // - One owned by the instance itself. It represents the visible widget. |
243 // - One owned by the hosting element. It's released when the hosting | 245 // - One owned by the hosting element. It's released when the hosting |
244 // element asks the WebHelperPluginImpl to close. | 246 // element asks the WebHelperPluginImpl to close. |
245 // We need them because the closing operation is asynchronous and the widget | 247 // We need them because the closing operation is asynchronous and the widget |
246 // can be closed while the hosting element is unaware of it. | 248 // can be closed while the hosting element is unaware of it. |
247 return adoptRef(new WebHelperPluginImpl(client)).leakRef(); | 249 return adoptRef(new WebHelperPluginImpl(client)).leakRef(); |
248 } | 250 } |
249 | 251 |
250 } // namespace WebKit | 252 } // namespace WebKit |
OLD | NEW |