| 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 |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 decrement_shared_popup_at_destruction_ = true; | 290 decrement_shared_popup_at_destruction_ = true; |
| 291 } else { | 291 } else { |
| 292 shared_popup_counter_ = new SharedRenderViewCounter(0); | 292 shared_popup_counter_ = new SharedRenderViewCounter(0); |
| 293 decrement_shared_popup_at_destruction_ = false; | 293 decrement_shared_popup_at_destruction_ = false; |
| 294 } | 294 } |
| 295 | 295 |
| 296 devtools_agent_ = new DevToolsAgent(routing_id, this, | 296 devtools_agent_ = new DevToolsAgent(routing_id, this, |
| 297 MessageLoop::current()); | 297 MessageLoop::current()); |
| 298 webwidget_ = WebView::Create(this, webkit_prefs); | 298 webwidget_ = WebView::Create(this, webkit_prefs); |
| 299 | 299 |
| 300 #if defined(OS_LINUX) |
| 301 // We have to enable ourselves as the editor delegate on linux so we can copy |
| 302 // text selections to the X clipboard. |
| 303 webview()->SetUseEditorDelegate(true); |
| 304 #endif |
| 305 |
| 300 // Don't let WebCore keep a B/F list - we have our own. | 306 // Don't let WebCore keep a B/F list - we have our own. |
| 301 // We let it keep 1 entry because FrameLoader::goToItem expects an item in the | 307 // We let it keep 1 entry because FrameLoader::goToItem expects an item in the |
| 302 // backForwardList, which is used only in ASSERTs. | 308 // backForwardList, which is used only in ASSERTs. |
| 303 webview()->SetBackForwardListSize(1); | 309 webview()->SetBackForwardListSize(1); |
| 304 | 310 |
| 305 routing_id_ = routing_id; | 311 routing_id_ = routing_id; |
| 306 render_thread_->AddRoute(routing_id_, this); | 312 render_thread_->AddRoute(routing_id_, this); |
| 307 // Take a reference on behalf of the RenderThread. This will be balanced | 313 // Take a reference on behalf of the RenderThread. This will be balanced |
| 308 // when we receive ViewMsg_Close. | 314 // when we receive ViewMsg_Close. |
| 309 AddRef(); | 315 AddRef(); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 OnPopupNotificationVisiblityChanged) | 424 OnPopupNotificationVisiblityChanged) |
| 419 IPC_MESSAGE_HANDLER(ViewMsg_RequestAudioPacket, OnRequestAudioPacket) | 425 IPC_MESSAGE_HANDLER(ViewMsg_RequestAudioPacket, OnRequestAudioPacket) |
| 420 IPC_MESSAGE_HANDLER(ViewMsg_NotifyAudioStreamCreated, OnAudioStreamCreated) | 426 IPC_MESSAGE_HANDLER(ViewMsg_NotifyAudioStreamCreated, OnAudioStreamCreated) |
| 421 IPC_MESSAGE_HANDLER(ViewMsg_NotifyAudioStreamStateChanged, | 427 IPC_MESSAGE_HANDLER(ViewMsg_NotifyAudioStreamStateChanged, |
| 422 OnAudioStreamStateChanged) | 428 OnAudioStreamStateChanged) |
| 423 IPC_MESSAGE_HANDLER(ViewMsg_NotifyAudioStreamVolume, OnAudioStreamVolume) | 429 IPC_MESSAGE_HANDLER(ViewMsg_NotifyAudioStreamVolume, OnAudioStreamVolume) |
| 424 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) | 430 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) |
| 425 IPC_MESSAGE_HANDLER(ViewMsg_HandleExtensionMessage, | 431 IPC_MESSAGE_HANDLER(ViewMsg_HandleExtensionMessage, |
| 426 OnHandleExtensionMessage) | 432 OnHandleExtensionMessage) |
| 427 IPC_MESSAGE_HANDLER(ViewMsg_ExtensionResponse, OnExtensionResponse) | 433 IPC_MESSAGE_HANDLER(ViewMsg_ExtensionResponse, OnExtensionResponse) |
| 434 IPC_MESSAGE_HANDLER(ViewMsg_RequestSelectionText, OnRequestSelectionText) |
| 428 | 435 |
| 429 // Have the super handle all other messages. | 436 // Have the super handle all other messages. |
| 430 IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message)) | 437 IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message)) |
| 431 IPC_END_MESSAGE_MAP() | 438 IPC_END_MESSAGE_MAP() |
| 432 } | 439 } |
| 433 | 440 |
| 434 void RenderView::SendThumbnail() { | 441 void RenderView::SendThumbnail() { |
| 435 WebFrame* main_frame = webview()->GetMainFrame(); | 442 WebFrame* main_frame = webview()->GetMainFrame(); |
| 436 if (!main_frame) | 443 if (!main_frame) |
| 437 return; | 444 return; |
| 438 | 445 |
| 439 // get the URL for this page | 446 // get the URL for this page |
| 440 GURL url(main_frame->GetURL()); | 447 GURL url(main_frame->GetURL()); |
| 441 if (url.is_empty()) | 448 if (url.is_empty()) |
| 442 return; | 449 return; |
| 443 | 450 |
| 444 if (size_.IsEmpty()) | 451 if (size_.IsEmpty()) |
| 445 return; // Don't create an empty thumbnail! | 452 return; // Don't create an empty thumbnail! |
| 446 | 453 |
| 447 ThumbnailScore score; | 454 ThumbnailScore score; |
| 448 SkBitmap thumbnail; | 455 SkBitmap thumbnail; |
| 449 if (!CaptureThumbnail(main_frame, kThumbnailWidth, kThumbnailHeight, | 456 if (!CaptureThumbnail(main_frame, kThumbnailWidth, kThumbnailHeight, |
| 450 &thumbnail, &score)) | 457 &thumbnail, &score)) |
| 451 return; | 458 return; |
| 452 | 459 |
| 453 // send the thumbnail message to the browser process | 460 // send the thumbnail message to the browser process |
| 454 Send(new ViewHostMsg_Thumbnail(routing_id_, url, score, thumbnail)); | 461 Send(new ViewHostMsg_Thumbnail(routing_id_, url, score, thumbnail)); |
| 455 } | 462 } |
| 456 | 463 |
| 464 void RenderView::OnRequestSelectionText() { |
| 465 Send(new ViewHostMsg_SetSelectionText(routing_id_, selection_text_)); |
| 466 } |
| 467 |
| 457 void RenderView::PrintPage(const ViewMsg_PrintPage_Params& params, | 468 void RenderView::PrintPage(const ViewMsg_PrintPage_Params& params, |
| 458 const gfx::Size& canvas_size, | 469 const gfx::Size& canvas_size, |
| 459 WebFrame* frame) { | 470 WebFrame* frame) { |
| 460 #if defined(OS_WIN) | 471 #if defined(OS_WIN) |
| 461 // Generate a memory-based EMF file. The EMF will use the current screen's | 472 // Generate a memory-based EMF file. The EMF will use the current screen's |
| 462 // DPI. | 473 // DPI. |
| 463 gfx::Emf emf; | 474 gfx::Emf emf; |
| 464 | 475 |
| 465 emf.CreateDc(NULL, NULL); | 476 emf.CreateDc(NULL, NULL); |
| 466 HDC hdc = emf.hdc(); | 477 HDC hdc = emf.hdc(); |
| (...skipping 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2415 TimeDelta::FromSeconds(delay_seconds_for_form_state_sync_), this, | 2426 TimeDelta::FromSeconds(delay_seconds_for_form_state_sync_), this, |
| 2416 &RenderView::SyncNavigationState); | 2427 &RenderView::SyncNavigationState); |
| 2417 } | 2428 } |
| 2418 } | 2429 } |
| 2419 | 2430 |
| 2420 void RenderView::SetTooltipText(WebView* webview, | 2431 void RenderView::SetTooltipText(WebView* webview, |
| 2421 const std::wstring& tooltip_text) { | 2432 const std::wstring& tooltip_text) { |
| 2422 Send(new ViewHostMsg_SetTooltipText(routing_id_, tooltip_text)); | 2433 Send(new ViewHostMsg_SetTooltipText(routing_id_, tooltip_text)); |
| 2423 } | 2434 } |
| 2424 | 2435 |
| 2436 void RenderView::DidChangeSelection(bool is_empty_selection) { |
| 2437 #if defined(OS_LINUX) |
| 2438 if (!is_empty_selection) { |
| 2439 // TODO(estade): find a way to incrementally update the selection text. |
| 2440 selection_text_ = webview()->GetMainFrame()->GetSelection(false); |
| 2441 Send(new ViewHostMsg_SelectionChanged(routing_id_)); |
| 2442 } |
| 2443 #endif |
| 2444 } |
| 2445 |
| 2446 |
| 2425 void RenderView::DownloadUrl(const GURL& url, const GURL& referrer) { | 2447 void RenderView::DownloadUrl(const GURL& url, const GURL& referrer) { |
| 2426 Send(new ViewHostMsg_DownloadUrl(routing_id_, url, referrer)); | 2448 Send(new ViewHostMsg_DownloadUrl(routing_id_, url, referrer)); |
| 2427 } | 2449 } |
| 2428 | 2450 |
| 2429 WebDevToolsAgentDelegate* RenderView::GetWebDevToolsAgentDelegate() { | 2451 WebDevToolsAgentDelegate* RenderView::GetWebDevToolsAgentDelegate() { |
| 2430 return devtools_agent_; | 2452 return devtools_agent_; |
| 2431 } | 2453 } |
| 2432 | 2454 |
| 2433 void RenderView::PasteFromSelectionClipboard() { | 2455 void RenderView::PasteFromSelectionClipboard() { |
| 2434 Send(new ViewHostMsg_PasteFromSelectionClipboard(routing_id_)); | 2456 Send(new ViewHostMsg_PasteFromSelectionClipboard(routing_id_)); |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2969 void RenderView::OnExtensionResponse(int callback_id, | 2991 void RenderView::OnExtensionResponse(int callback_id, |
| 2970 const std::string& response) { | 2992 const std::string& response) { |
| 2971 WebFrame* web_frame = pending_extension_callbacks_.Lookup(callback_id); | 2993 WebFrame* web_frame = pending_extension_callbacks_.Lookup(callback_id); |
| 2972 if (!web_frame) | 2994 if (!web_frame) |
| 2973 return; // The frame went away. | 2995 return; // The frame went away. |
| 2974 | 2996 |
| 2975 extensions_v8::ExtensionProcessBindings::ExecuteCallbackInFrame( | 2997 extensions_v8::ExtensionProcessBindings::ExecuteCallbackInFrame( |
| 2976 web_frame, callback_id, response); | 2998 web_frame, callback_id, response); |
| 2977 pending_extension_callbacks_.Remove(callback_id); | 2999 pending_extension_callbacks_.Remove(callback_id); |
| 2978 } | 3000 } |
| OLD | NEW |