| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 devtools_agent_(NULL), | 185 devtools_agent_(NULL), |
| 186 devtools_client_(NULL), | 186 devtools_client_(NULL), |
| 187 history_back_list_count_(0), | 187 history_back_list_count_(0), |
| 188 history_forward_list_count_(0), | 188 history_forward_list_count_(0), |
| 189 has_unload_listener_(false), | 189 has_unload_listener_(false), |
| 190 decrement_shared_popup_at_destruction_(false), | 190 decrement_shared_popup_at_destruction_(false), |
| 191 form_field_autofill_request_id_(0), | 191 form_field_autofill_request_id_(0), |
| 192 popup_notification_visible_(false), | 192 popup_notification_visible_(false), |
| 193 delay_seconds_for_form_state_sync_(kDefaultDelaySecondsForFormStateSync), | 193 delay_seconds_for_form_state_sync_(kDefaultDelaySecondsForFormStateSync), |
| 194 preferred_width_(0), | 194 preferred_width_(0), |
| 195 send_preferred_width_changes_(false) { | 195 send_preferred_width_changes_(false), |
| 196 determine_page_text_after_loading_stops_(false) { |
| 196 } | 197 } |
| 197 | 198 |
| 198 RenderView::~RenderView() { | 199 RenderView::~RenderView() { |
| 199 if (decrement_shared_popup_at_destruction_) | 200 if (decrement_shared_popup_at_destruction_) |
| 200 shared_popup_counter_->data--; | 201 shared_popup_counter_->data--; |
| 201 | 202 |
| 202 // Clear any back-pointers that might still be held by plugins. | 203 // Clear any back-pointers that might still be held by plugins. |
| 203 PluginDelegateList::iterator it = plugin_delegates_.begin(); | 204 PluginDelegateList::iterator it = plugin_delegates_.begin(); |
| 204 while (it != plugin_delegates_.end()) { | 205 while (it != plugin_delegates_.end()) { |
| 205 (*it)->DropRenderView(); | 206 (*it)->DropRenderView(); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) | 349 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) |
| 349 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) | 350 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) |
| 350 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste) | 351 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste) |
| 351 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace) | 352 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace) |
| 352 IPC_MESSAGE_HANDLER(ViewMsg_ToggleSpellCheck, OnToggleSpellCheck) | 353 IPC_MESSAGE_HANDLER(ViewMsg_ToggleSpellCheck, OnToggleSpellCheck) |
| 353 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) | 354 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) |
| 354 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) | 355 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) |
| 355 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) | 356 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) |
| 356 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) | 357 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) |
| 357 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) | 358 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) |
| 359 IPC_MESSAGE_HANDLER(ViewMsg_DeterminePageText, OnDeterminePageText) |
| 358 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) | 360 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
| 359 IPC_MESSAGE_HANDLER(ViewMsg_InsertText, OnInsertText) | 361 IPC_MESSAGE_HANDLER(ViewMsg_InsertText, OnInsertText) |
| 360 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) | 362 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) |
| 361 IPC_MESSAGE_HANDLER(ViewMsg_SetupDevToolsClient, OnSetupDevToolsClient) | 363 IPC_MESSAGE_HANDLER(ViewMsg_SetupDevToolsClient, OnSetupDevToolsClient) |
| 362 IPC_MESSAGE_HANDLER(ViewMsg_DownloadFavIcon, OnDownloadFavIcon) | 364 IPC_MESSAGE_HANDLER(ViewMsg_DownloadFavIcon, OnDownloadFavIcon) |
| 363 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) | 365 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) |
| 364 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) | 366 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) |
| 365 IPC_MESSAGE_HANDLER(ViewMsg_AddMessageToConsole, OnAddMessageToConsole) | 367 IPC_MESSAGE_HANDLER(ViewMsg_AddMessageToConsole, OnAddMessageToConsole) |
| 366 IPC_MESSAGE_HANDLER(ViewMsg_ReservePageIDRange, OnReservePageIDRange) | 368 IPC_MESSAGE_HANDLER(ViewMsg_ReservePageIDRange, OnReservePageIDRange) |
| 367 IPC_MESSAGE_HANDLER(ViewMsg_UploadFile, OnUploadFileRequest) | 369 IPC_MESSAGE_HANDLER(ViewMsg_UploadFile, OnUploadFileRequest) |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 return; | 492 return; |
| 491 | 493 |
| 492 // full text | 494 // full text |
| 493 std::wstring contents; | 495 std::wstring contents; |
| 494 CaptureText(main_frame, &contents); | 496 CaptureText(main_frame, &contents); |
| 495 if (contents.size()) { | 497 if (contents.size()) { |
| 496 // Send the text to the browser for indexing. | 498 // Send the text to the browser for indexing. |
| 497 Send(new ViewHostMsg_PageContents(url, load_id, contents)); | 499 Send(new ViewHostMsg_PageContents(url, load_id, contents)); |
| 498 } | 500 } |
| 499 | 501 |
| 502 // Send over text content of this page to the browser. |
| 503 if (determine_page_text_after_loading_stops_) { |
| 504 determine_page_text_after_loading_stops_ = false; |
| 505 Send(new ViewMsg_DeterminePageText_Reply(routing_id_, contents)); |
| 506 } |
| 507 |
| 500 // thumbnail | 508 // thumbnail |
| 501 SendThumbnail(); | 509 SendThumbnail(); |
| 502 } | 510 } |
| 503 | 511 |
| 504 void RenderView::CaptureText(WebFrame* frame, std::wstring* contents) { | 512 void RenderView::CaptureText(WebFrame* frame, std::wstring* contents) { |
| 505 contents->clear(); | 513 contents->clear(); |
| 506 if (!frame) | 514 if (!frame) |
| 507 return; | 515 return; |
| 508 | 516 |
| 509 // Don't index any https pages. People generally don't want their bank | 517 // Don't index any https pages. People generally don't want their bank |
| (...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2192 true); // reset the tickmarks | 2200 true); // reset the tickmarks |
| 2193 } | 2201 } |
| 2194 | 2202 |
| 2195 // Iterate to the next frame. The frame will not necessarily scope, for | 2203 // Iterate to the next frame. The frame will not necessarily scope, for |
| 2196 // example if it is not visible. | 2204 // example if it is not visible. |
| 2197 search_frame = webview()->GetNextFrameAfter(search_frame, true); | 2205 search_frame = webview()->GetNextFrameAfter(search_frame, true); |
| 2198 } while (search_frame != main_frame); | 2206 } while (search_frame != main_frame); |
| 2199 } | 2207 } |
| 2200 } | 2208 } |
| 2201 | 2209 |
| 2210 void RenderView::OnDeterminePageText() { |
| 2211 if (!is_loading_) { |
| 2212 if (!webview()) |
| 2213 return; |
| 2214 WebFrame* main_frame = webview()->GetMainFrame(); |
| 2215 std::wstring contents; |
| 2216 CaptureText(main_frame, &contents); |
| 2217 Send(new ViewMsg_DeterminePageText_Reply(routing_id_, contents)); |
| 2218 determine_page_text_after_loading_stops_ = false; |
| 2219 return; |
| 2220 } |
| 2221 |
| 2222 // We set |determine_page_text_after_loading_stops_| true here so that, |
| 2223 // after page has been loaded completely, the text in the page is captured. |
| 2224 determine_page_text_after_loading_stops_ = true; |
| 2225 } |
| 2226 |
| 2202 void RenderView::ReportFindInPageMatchCount(int count, int request_id, | 2227 void RenderView::ReportFindInPageMatchCount(int count, int request_id, |
| 2203 bool final_update) { | 2228 bool final_update) { |
| 2204 // If we have a message that has been queued up, then we should just replace | 2229 // If we have a message that has been queued up, then we should just replace |
| 2205 // it. The ACK from the browser will make sure it gets sent when the browser | 2230 // it. The ACK from the browser will make sure it gets sent when the browser |
| 2206 // wants it. | 2231 // wants it. |
| 2207 if (queued_find_reply_message_.get()) { | 2232 if (queued_find_reply_message_.get()) { |
| 2208 IPC::Message* msg = new ViewHostMsg_Find_Reply( | 2233 IPC::Message* msg = new ViewHostMsg_Find_Reply( |
| 2209 routing_id_, | 2234 routing_id_, |
| 2210 request_id, | 2235 request_id, |
| 2211 count, | 2236 count, |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2988 Send(new ViewHostMsg_PasswordFormsSeen(routing_id_, password_forms)); | 3013 Send(new ViewHostMsg_PasswordFormsSeen(routing_id_, password_forms)); |
| 2989 } | 3014 } |
| 2990 | 3015 |
| 2991 void RenderView::Print(WebFrame* frame, bool script_initiated) { | 3016 void RenderView::Print(WebFrame* frame, bool script_initiated) { |
| 2992 DCHECK(frame); | 3017 DCHECK(frame); |
| 2993 if (print_helper_.get() == NULL) { | 3018 if (print_helper_.get() == NULL) { |
| 2994 print_helper_.reset(new PrintWebViewHelper(this)); | 3019 print_helper_.reset(new PrintWebViewHelper(this)); |
| 2995 } | 3020 } |
| 2996 print_helper_->Print(frame, script_initiated); | 3021 print_helper_->Print(frame, script_initiated); |
| 2997 } | 3022 } |
| OLD | NEW |