OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/gfx/png_encoder.h" | 12 #include "base/gfx/png_encoder.h" |
| 13 #include "base/gfx/native_widget_types.h" |
13 #include "base/string_piece.h" | 14 #include "base/string_piece.h" |
14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
16 #include "chrome/app/theme/theme_resources.h" | 17 #include "chrome/app/theme/theme_resources.h" |
17 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/gfx/favicon_size.h" | 19 #include "chrome/common/gfx/favicon_size.h" |
19 #include "chrome/common/gfx/color_utils.h" | 20 #include "chrome/common/gfx/color_utils.h" |
20 #include "chrome/common/jstemplate_builder.h" | 21 #include "chrome/common/jstemplate_builder.h" |
21 #include "chrome/common/l10n_util.h" | 22 #include "chrome/common/l10n_util.h" |
22 #include "chrome/common/page_zoom.h" | 23 #include "chrome/common/page_zoom.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 204 |
204 #ifdef CHROME_PERSONALIZATION | 205 #ifdef CHROME_PERSONALIZATION |
205 Personalization::CleanupRendererPersonalization(personalization_); | 206 Personalization::CleanupRendererPersonalization(personalization_); |
206 personalization_ = NULL; | 207 personalization_ = NULL; |
207 #endif | 208 #endif |
208 } | 209 } |
209 | 210 |
210 /*static*/ | 211 /*static*/ |
211 RenderView* RenderView::Create( | 212 RenderView* RenderView::Create( |
212 RenderThreadBase* render_thread, | 213 RenderThreadBase* render_thread, |
213 HWND parent_hwnd, | 214 gfx::NativeViewId parent_hwnd, |
214 base::WaitableEvent* modal_dialog_event, | 215 base::WaitableEvent* modal_dialog_event, |
215 int32 opener_id, | 216 int32 opener_id, |
216 const WebPreferences& webkit_prefs, | 217 const WebPreferences& webkit_prefs, |
217 SharedRenderViewCounter* counter, | 218 SharedRenderViewCounter* counter, |
218 int32 routing_id) { | 219 int32 routing_id) { |
219 DCHECK(routing_id != MSG_ROUTING_NONE); | 220 DCHECK(routing_id != MSG_ROUTING_NONE); |
220 scoped_refptr<RenderView> view = new RenderView(render_thread); | 221 scoped_refptr<RenderView> view = new RenderView(render_thread); |
221 view->Init(parent_hwnd, | 222 view->Init(parent_hwnd, |
222 modal_dialog_event, | 223 modal_dialog_event, |
223 opener_id, | 224 opener_id, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 260 |
260 void RenderView::PluginCrashed(const FilePath& plugin_path) { | 261 void RenderView::PluginCrashed(const FilePath& plugin_path) { |
261 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); | 262 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); |
262 } | 263 } |
263 | 264 |
264 | 265 |
265 void RenderView::JSOutOfMemory() { | 266 void RenderView::JSOutOfMemory() { |
266 Send(new ViewHostMsg_JSOutOfMemory(routing_id_)); | 267 Send(new ViewHostMsg_JSOutOfMemory(routing_id_)); |
267 } | 268 } |
268 | 269 |
269 void RenderView::Init(HWND parent_hwnd, | 270 void RenderView::Init(gfx::NativeViewId parent_hwnd, |
270 base::WaitableEvent* modal_dialog_event, | 271 base::WaitableEvent* modal_dialog_event, |
271 int32 opener_id, | 272 int32 opener_id, |
272 const WebPreferences& webkit_prefs, | 273 const WebPreferences& webkit_prefs, |
273 SharedRenderViewCounter* counter, | 274 SharedRenderViewCounter* counter, |
274 int32 routing_id) { | 275 int32 routing_id) { |
275 DCHECK(!webview()); | 276 DCHECK(!webview()); |
276 | 277 |
277 if (opener_id != MSG_ROUTING_NONE) | 278 if (opener_id != MSG_ROUTING_NONE) |
278 opener_id_ = opener_id; | 279 opener_id_ = opener_id; |
279 | 280 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 IPC_MESSAGE_HANDLER(ViewMsg_PopupNotificationVisiblityChanged, | 419 IPC_MESSAGE_HANDLER(ViewMsg_PopupNotificationVisiblityChanged, |
419 OnPopupNotificationVisiblityChanged) | 420 OnPopupNotificationVisiblityChanged) |
420 | 421 |
421 // Have the super handle all other messages. | 422 // Have the super handle all other messages. |
422 IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message)) | 423 IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message)) |
423 IPC_END_MESSAGE_MAP() | 424 IPC_END_MESSAGE_MAP() |
424 } | 425 } |
425 | 426 |
426 // Got a response from the browser after the renderer decided to create a new | 427 // Got a response from the browser after the renderer decided to create a new |
427 // view. | 428 // view. |
428 void RenderView::OnCreatingNewAck | 429 void RenderView::OnCreatingNewAck(gfx::NativeViewId parent) { |
429 #if defined(OS_WIN) | |
430 (HWND parent) { | |
431 CompleteInit(parent); | 430 CompleteInit(parent); |
432 #else | |
433 () { | |
434 #endif | |
435 | |
436 waiting_for_create_window_ack_ = false; | 431 waiting_for_create_window_ack_ = false; |
437 | 432 |
438 while (!queued_resource_messages_.empty()) { | 433 while (!queued_resource_messages_.empty()) { |
439 IPC::Message* queued_msg = queued_resource_messages_.front(); | 434 IPC::Message* queued_msg = queued_resource_messages_.front(); |
440 queued_resource_messages_.pop(); | 435 queued_resource_messages_.pop(); |
441 resource_dispatcher_->OnMessageReceived(*queued_msg); | 436 resource_dispatcher_->OnMessageReceived(*queued_msg); |
442 delete queued_msg; | 437 delete queued_msg; |
443 } | 438 } |
444 } | 439 } |
445 | 440 |
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1847 // Check to make sure we aren't overloading on popups. | 1842 // Check to make sure we aren't overloading on popups. |
1848 if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups) | 1843 if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups) |
1849 return NULL; | 1844 return NULL; |
1850 | 1845 |
1851 // This window can't be closed from a window.close() call until we receive a | 1846 // This window can't be closed from a window.close() call until we receive a |
1852 // message from the Browser process explicitly allowing it. | 1847 // message from the Browser process explicitly allowing it. |
1853 popup_notification_visible_ = true; | 1848 popup_notification_visible_ = true; |
1854 | 1849 |
1855 int32 routing_id = MSG_ROUTING_NONE; | 1850 int32 routing_id = MSG_ROUTING_NONE; |
1856 | 1851 |
1857 #if defined(OS_WIN) | 1852 ModalDialogEvent modal_dialog_event; |
1858 HANDLE modal_dialog_event = NULL; | |
1859 render_thread_->Send( | 1853 render_thread_->Send( |
1860 new ViewHostMsg_CreateWindow(routing_id_, user_gesture, &routing_id, | 1854 new ViewHostMsg_CreateWindow(routing_id_, user_gesture, &routing_id, |
1861 &modal_dialog_event)); | 1855 &modal_dialog_event)); |
1862 if (routing_id == MSG_ROUTING_NONE) { | 1856 if (routing_id == MSG_ROUTING_NONE) { |
1863 DCHECK(modal_dialog_event == NULL); | |
1864 return NULL; | 1857 return NULL; |
1865 } | 1858 } |
1866 #else // defined(OS_WIN) | |
1867 // On POSIX we don't have a HANDLE parameter as we don't have cross process | |
1868 // events. All platforms should be ported across to this at some point. | |
1869 render_thread_->Send( | |
1870 new ViewHostMsg_CreateWindow(routing_id_, user_gesture, &routing_id)); | |
1871 if (routing_id == MSG_ROUTING_NONE) | |
1872 return NULL; | |
1873 #endif | |
1874 | 1859 |
1875 // The WebView holds a reference to this new RenderView | 1860 // The WebView holds a reference to this new RenderView |
1876 const WebPreferences& prefs = webview->GetPreferences(); | 1861 const WebPreferences& prefs = webview->GetPreferences(); |
1877 base::WaitableEvent* waitable_event = new base::WaitableEvent | 1862 base::WaitableEvent* waitable_event = new base::WaitableEvent |
1878 #if defined(OS_WIN) | 1863 #if defined(OS_WIN) |
1879 (modal_dialog_event); | 1864 (modal_dialog_event.event); |
1880 #else | 1865 #else |
1881 (true, false); | 1866 (true, false); |
1882 #endif | 1867 #endif |
1883 RenderView* view = RenderView::Create(render_thread_, | 1868 RenderView* view = RenderView::Create(render_thread_, |
1884 NULL, waitable_event, routing_id_, | 1869 NULL, waitable_event, routing_id_, |
1885 prefs, shared_popup_counter_, | 1870 prefs, shared_popup_counter_, |
1886 routing_id); | 1871 routing_id); |
1887 view->set_opened_by_user_gesture(user_gesture); | 1872 view->set_opened_by_user_gesture(user_gesture); |
1888 view->set_waiting_for_create_window_ack(true); | 1873 view->set_waiting_for_create_window_ack(true); |
1889 | 1874 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1939 | 1924 |
1940 std::string mime_type_to_use; | 1925 std::string mime_type_to_use; |
1941 if (actual_mime_type && !actual_mime_type->empty()) | 1926 if (actual_mime_type && !actual_mime_type->empty()) |
1942 mime_type_to_use = *actual_mime_type; | 1927 mime_type_to_use = *actual_mime_type; |
1943 else | 1928 else |
1944 mime_type_to_use = mime_type; | 1929 mime_type_to_use = mime_type; |
1945 | 1930 |
1946 if (is_gears) | 1931 if (is_gears) |
1947 ChromePluginLib::Create(path, GetCPBrowserFuncsForRenderer()); | 1932 ChromePluginLib::Create(path, GetCPBrowserFuncsForRenderer()); |
1948 return WebPluginDelegateImpl::Create(path, | 1933 return WebPluginDelegateImpl::Create(path, |
1949 mime_type_to_use, host_window_); | 1934 mime_type_to_use, |
| 1935 gfx::NativeViewFromId(host_window_)); |
1950 } | 1936 } |
1951 | 1937 |
1952 WebPluginDelegateProxy* proxy = | 1938 WebPluginDelegateProxy* proxy = |
1953 WebPluginDelegateProxy::Create(url, mime_type, clsid, this); | 1939 WebPluginDelegateProxy::Create(url, mime_type, clsid, this); |
1954 if (!proxy) | 1940 if (!proxy) |
1955 return NULL; | 1941 return NULL; |
1956 | 1942 |
1957 // We hold onto the proxy so we can poke it when we are painting. See our | 1943 // We hold onto the proxy so we can poke it when we are painting. See our |
1958 // DidPaint implementation below. | 1944 // DidPaint implementation below. |
1959 plugin_delegates_.push_back(proxy); | 1945 plugin_delegates_.push_back(proxy); |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2897 template_resource_id)); | 2883 template_resource_id)); |
2898 | 2884 |
2899 if (template_html.empty()) { | 2885 if (template_html.empty()) { |
2900 NOTREACHED() << "unable to load template. ID: " << template_resource_id; | 2886 NOTREACHED() << "unable to load template. ID: " << template_resource_id; |
2901 return ""; | 2887 return ""; |
2902 } | 2888 } |
2903 // "t" is the id of the templates root node. | 2889 // "t" is the id of the templates root node. |
2904 return jstemplate_builder::GetTemplateHtml( | 2890 return jstemplate_builder::GetTemplateHtml( |
2905 template_html, &error_strings, "t"); | 2891 template_html, &error_strings, "t"); |
2906 } | 2892 } |
OLD | NEW |