| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include "grit/generated_resources.h" | 51 #include "grit/generated_resources.h" |
| 52 #include "grit/renderer_resources.h" | 52 #include "grit/renderer_resources.h" |
| 53 #include "net/base/data_url.h" | 53 #include "net/base/data_url.h" |
| 54 #include "net/base/escape.h" | 54 #include "net/base/escape.h" |
| 55 #include "net/base/net_errors.h" | 55 #include "net/base/net_errors.h" |
| 56 #include "skia/ext/bitmap_platform_device.h" | 56 #include "skia/ext/bitmap_platform_device.h" |
| 57 #include "skia/ext/image_operations.h" | 57 #include "skia/ext/image_operations.h" |
| 58 #include "webkit/api/public/WebDataSource.h" | 58 #include "webkit/api/public/WebDataSource.h" |
| 59 #include "webkit/api/public/WebDragData.h" | 59 #include "webkit/api/public/WebDragData.h" |
| 60 #include "webkit/api/public/WebForm.h" | 60 #include "webkit/api/public/WebForm.h" |
| 61 #include "webkit/api/public/WebFrame.h" |
| 61 #include "webkit/api/public/WebHistoryItem.h" | 62 #include "webkit/api/public/WebHistoryItem.h" |
| 62 #include "webkit/api/public/WebNode.h" | 63 #include "webkit/api/public/WebNode.h" |
| 63 #include "webkit/api/public/WebPoint.h" | 64 #include "webkit/api/public/WebPoint.h" |
| 64 #include "webkit/api/public/WebRect.h" | 65 #include "webkit/api/public/WebRect.h" |
| 65 #include "webkit/api/public/WebScriptSource.h" | 66 #include "webkit/api/public/WebScriptSource.h" |
| 66 #include "webkit/api/public/WebSize.h" | 67 #include "webkit/api/public/WebSize.h" |
| 67 #include "webkit/api/public/WebURL.h" | 68 #include "webkit/api/public/WebURL.h" |
| 68 #include "webkit/api/public/WebURLError.h" | 69 #include "webkit/api/public/WebURLError.h" |
| 69 #include "webkit/api/public/WebURLRequest.h" | 70 #include "webkit/api/public/WebURLRequest.h" |
| 70 #include "webkit/api/public/WebURLResponse.h" | 71 #include "webkit/api/public/WebURLResponse.h" |
| 71 #include "webkit/api/public/WebVector.h" | 72 #include "webkit/api/public/WebVector.h" |
| 72 #include "webkit/default_plugin/default_plugin_shared.h" | 73 #include "webkit/default_plugin/default_plugin_shared.h" |
| 73 #include "webkit/glue/glue_serialize.h" | 74 #include "webkit/glue/glue_serialize.h" |
| 74 #include "webkit/glue/dom_operations.h" | 75 #include "webkit/glue/dom_operations.h" |
| 75 #include "webkit/glue/dom_serializer.h" | 76 #include "webkit/glue/dom_serializer.h" |
| 76 #include "webkit/glue/image_decoder.h" | 77 #include "webkit/glue/image_decoder.h" |
| 77 #include "webkit/glue/media/buffered_data_source.h" | 78 #include "webkit/glue/media/buffered_data_source.h" |
| 78 #include "webkit/glue/media/simple_data_source.h" | 79 #include "webkit/glue/media/simple_data_source.h" |
| 79 #include "webkit/glue/password_form.h" | 80 #include "webkit/glue/password_form.h" |
| 80 #include "webkit/glue/plugins/plugin_list.h" | 81 #include "webkit/glue/plugins/plugin_list.h" |
| 81 #include "webkit/glue/searchable_form_data.h" | 82 #include "webkit/glue/searchable_form_data.h" |
| 82 #include "webkit/glue/webaccessibilitymanager_impl.h" | 83 #include "webkit/glue/webaccessibilitymanager_impl.h" |
| 83 #include "webkit/glue/webdevtoolsagent_delegate.h" | 84 #include "webkit/glue/webdevtoolsagent_delegate.h" |
| 84 #include "webkit/glue/webdropdata.h" | 85 #include "webkit/glue/webdropdata.h" |
| 85 #include "webkit/glue/webframe.h" | |
| 86 #include "webkit/glue/webkit_glue.h" | 86 #include "webkit/glue/webkit_glue.h" |
| 87 #include "webkit/glue/webmediaplayer_impl.h" | 87 #include "webkit/glue/webmediaplayer_impl.h" |
| 88 #include "webkit/glue/webpreferences.h" | 88 #include "webkit/glue/webpreferences.h" |
| 89 #include "webkit/glue/webplugin_delegate.h" | 89 #include "webkit/glue/webplugin_delegate.h" |
| 90 #include "webkit/glue/webtextinput.h" | |
| 91 #include "webkit/glue/webview.h" | 90 #include "webkit/glue/webview.h" |
| 92 | 91 |
| 93 #if defined(OS_WIN) | 92 #if defined(OS_WIN) |
| 94 // TODO(port): these files are currently Windows only because they concern: | 93 // TODO(port): these files are currently Windows only because they concern: |
| 95 // * theming | 94 // * theming |
| 96 #include "base/gfx/native_theme.h" | 95 #include "base/gfx/native_theme.h" |
| 97 #endif | 96 #endif |
| 98 | 97 |
| 99 using base::Time; | 98 using base::Time; |
| 100 using base::TimeDelta; | 99 using base::TimeDelta; |
| 101 using webkit_glue::AltErrorPageResourceFetcher; | 100 using webkit_glue::AltErrorPageResourceFetcher; |
| 102 using webkit_glue::AutofillForm; | 101 using webkit_glue::AutofillForm; |
| 103 using webkit_glue::PasswordForm; | 102 using webkit_glue::PasswordForm; |
| 104 using webkit_glue::PasswordFormDomManager; | 103 using webkit_glue::PasswordFormDomManager; |
| 105 using webkit_glue::SearchableFormData; | 104 using webkit_glue::SearchableFormData; |
| 106 using WebKit::WebConsoleMessage; | 105 using WebKit::WebConsoleMessage; |
| 107 using WebKit::WebData; | 106 using WebKit::WebData; |
| 108 using WebKit::WebDataSource; | 107 using WebKit::WebDataSource; |
| 109 using WebKit::WebDragData; | 108 using WebKit::WebDragData; |
| 110 using WebKit::WebForm; | 109 using WebKit::WebForm; |
| 110 using WebKit::WebFrame; |
| 111 using WebKit::WebHistoryItem; | 111 using WebKit::WebHistoryItem; |
| 112 using WebKit::WebNavigationPolicy; | 112 using WebKit::WebNavigationPolicy; |
| 113 using WebKit::WebNavigationType; | 113 using WebKit::WebNavigationType; |
| 114 using WebKit::WebPopupMenuInfo; | 114 using WebKit::WebPopupMenuInfo; |
| 115 using WebKit::WebRect; | 115 using WebKit::WebRect; |
| 116 using WebKit::WebScriptSource; | 116 using WebKit::WebScriptSource; |
| 117 using WebKit::WebSize; | 117 using WebKit::WebSize; |
| 118 using WebKit::WebString; | 118 using WebKit::WebString; |
| 119 using WebKit::WebTextDirection; | 119 using WebKit::WebTextDirection; |
| 120 using WebKit::WebURL; | 120 using WebKit::WebURL; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 if (command_line.HasSwitch(switches::kDomAutomationController)) | 330 if (command_line.HasSwitch(switches::kDomAutomationController)) |
| 331 enabled_bindings_ |= BindingsPolicy::DOM_AUTOMATION; | 331 enabled_bindings_ |= BindingsPolicy::DOM_AUTOMATION; |
| 332 | 332 |
| 333 audio_message_filter_ = new AudioMessageFilter(routing_id_); | 333 audio_message_filter_ = new AudioMessageFilter(routing_id_); |
| 334 render_thread_->AddFilter(audio_message_filter_); | 334 render_thread_->AddFilter(audio_message_filter_); |
| 335 } | 335 } |
| 336 | 336 |
| 337 void RenderView::OnMessageReceived(const IPC::Message& message) { | 337 void RenderView::OnMessageReceived(const IPC::Message& message) { |
| 338 WebFrame* main_frame = webview() ? webview()->GetMainFrame() : NULL; | 338 WebFrame* main_frame = webview() ? webview()->GetMainFrame() : NULL; |
| 339 child_process_logging::ScopedActiveURLSetter url_setter( | 339 child_process_logging::ScopedActiveURLSetter url_setter( |
| 340 main_frame ? main_frame->GetURL() : GURL()); | 340 main_frame ? main_frame->url() : WebURL()); |
| 341 | 341 |
| 342 // If this is developer tools renderer intercept tools messages first. | 342 // If this is developer tools renderer intercept tools messages first. |
| 343 if (devtools_client_.get() && devtools_client_->OnMessageReceived(message)) | 343 if (devtools_client_.get() && devtools_client_->OnMessageReceived(message)) |
| 344 return; | 344 return; |
| 345 if (devtools_agent_.get() && devtools_agent_->OnMessageReceived(message)) | 345 if (devtools_agent_.get() && devtools_agent_->OnMessageReceived(message)) |
| 346 return; | 346 return; |
| 347 | 347 |
| 348 IPC_BEGIN_MESSAGE_MAP(RenderView, message) | 348 IPC_BEGIN_MESSAGE_MAP(RenderView, message) |
| 349 IPC_MESSAGE_HANDLER(ViewMsg_CaptureThumbnail, SendThumbnail) | 349 IPC_MESSAGE_HANDLER(ViewMsg_CaptureThumbnail, SendThumbnail) |
| 350 IPC_MESSAGE_HANDLER(ViewMsg_PrintPages, OnPrintPages) | 350 IPC_MESSAGE_HANDLER(ViewMsg_PrintPages, OnPrintPages) |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message)) | 434 IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message)) |
| 435 IPC_END_MESSAGE_MAP() | 435 IPC_END_MESSAGE_MAP() |
| 436 } | 436 } |
| 437 | 437 |
| 438 void RenderView::SendThumbnail() { | 438 void RenderView::SendThumbnail() { |
| 439 WebFrame* main_frame = webview()->GetMainFrame(); | 439 WebFrame* main_frame = webview()->GetMainFrame(); |
| 440 if (!main_frame) | 440 if (!main_frame) |
| 441 return; | 441 return; |
| 442 | 442 |
| 443 // get the URL for this page | 443 // get the URL for this page |
| 444 GURL url(main_frame->GetURL()); | 444 GURL url(main_frame->url()); |
| 445 if (url.is_empty()) | 445 if (url.is_empty()) |
| 446 return; | 446 return; |
| 447 | 447 |
| 448 if (size_.IsEmpty()) | 448 if (size_.IsEmpty()) |
| 449 return; // Don't create an empty thumbnail! | 449 return; // Don't create an empty thumbnail! |
| 450 | 450 |
| 451 ThumbnailScore score; | 451 ThumbnailScore score; |
| 452 SkBitmap thumbnail; | 452 SkBitmap thumbnail; |
| 453 if (!CaptureThumbnail(webview(), kThumbnailWidth, kThumbnailHeight, | 453 if (!CaptureThumbnail(webview(), kThumbnailWidth, kThumbnailHeight, |
| 454 &thumbnail, &score)) | 454 &thumbnail, &score)) |
| 455 return; | 455 return; |
| 456 | 456 |
| 457 // send the thumbnail message to the browser process | 457 // send the thumbnail message to the browser process |
| 458 Send(new ViewHostMsg_Thumbnail(routing_id_, url, score, thumbnail)); | 458 Send(new ViewHostMsg_Thumbnail(routing_id_, url, score, thumbnail)); |
| 459 } | 459 } |
| 460 | 460 |
| 461 void RenderView::OnPrintPages() { | 461 void RenderView::OnPrintPages() { |
| 462 DCHECK(webview()); | 462 DCHECK(webview()); |
| 463 if (webview()) { | 463 if (webview()) { |
| 464 // If the user has selected text in the currently focused frame we print | 464 // If the user has selected text in the currently focused frame we print |
| 465 // only that frame (this makes print selection work for multiple frames). | 465 // only that frame (this makes print selection work for multiple frames). |
| 466 if (webview()->GetFocusedFrame()->HasSelection()) | 466 if (webview()->GetFocusedFrame()->hasSelection()) |
| 467 Print(webview()->GetFocusedFrame(), false); | 467 Print(webview()->GetFocusedFrame(), false); |
| 468 else | 468 else |
| 469 Print(webview()->GetMainFrame(), false); | 469 Print(webview()->GetMainFrame(), false); |
| 470 } | 470 } |
| 471 } | 471 } |
| 472 | 472 |
| 473 void RenderView::OnPrintingDone(int document_cookie, bool success) { | 473 void RenderView::OnPrintingDone(int document_cookie, bool success) { |
| 474 // Ignoring document cookie here since only one print job can be outstanding | 474 // Ignoring document cookie here since only one print job can be outstanding |
| 475 // per renderer and document_cookie is 0 when printing is successful. | 475 // per renderer and document_cookie is 0 when printing is successful. |
| 476 DCHECK(print_helper_.get()); | 476 DCHECK(print_helper_.get()); |
| 477 if (print_helper_.get() != NULL) { | 477 if (print_helper_.get() != NULL) { |
| 478 print_helper_->DidFinishPrinting(success); | 478 print_helper_->DidFinishPrinting(success); |
| 479 } | 479 } |
| 480 } | 480 } |
| 481 | 481 |
| 482 void RenderView::CapturePageInfo(int load_id, bool preliminary_capture) { | 482 void RenderView::CapturePageInfo(int load_id, bool preliminary_capture) { |
| 483 if (load_id != page_id_) | 483 if (load_id != page_id_) |
| 484 return; // this capture call is no longer relevant due to navigation | 484 return; // this capture call is no longer relevant due to navigation |
| 485 if (load_id == last_indexed_page_id_) | 485 if (load_id == last_indexed_page_id_) |
| 486 return; // we already indexed this page | 486 return; // we already indexed this page |
| 487 | 487 |
| 488 if (!webview()) | 488 if (!webview()) |
| 489 return; | 489 return; |
| 490 | 490 |
| 491 WebFrame* main_frame = webview()->GetMainFrame(); | 491 WebFrame* main_frame = webview()->GetMainFrame(); |
| 492 if (!main_frame) | 492 if (!main_frame) |
| 493 return; | 493 return; |
| 494 | 494 |
| 495 // Don't index/capture pages that are in view source mode. | 495 // Don't index/capture pages that are in view source mode. |
| 496 if (main_frame->GetInViewSourceMode()) | 496 if (main_frame->isViewSourceModeEnabled()) |
| 497 return; | 497 return; |
| 498 | 498 |
| 499 // Don't index/capture pages that failed to load. This only checks the top | 499 // Don't index/capture pages that failed to load. This only checks the top |
| 500 // level frame so the thumbnail may contain a frame that failed to load. | 500 // level frame so the thumbnail may contain a frame that failed to load. |
| 501 WebDataSource* ds = main_frame->GetDataSource(); | 501 WebDataSource* ds = main_frame->dataSource(); |
| 502 if (ds && ds->hasUnreachableURL()) | 502 if (ds && ds->hasUnreachableURL()) |
| 503 return; | 503 return; |
| 504 | 504 |
| 505 if (!preliminary_capture) | 505 if (!preliminary_capture) |
| 506 last_indexed_page_id_ = load_id; | 506 last_indexed_page_id_ = load_id; |
| 507 | 507 |
| 508 // get the URL for this page | 508 // get the URL for this page |
| 509 GURL url(main_frame->GetURL()); | 509 GURL url(main_frame->url()); |
| 510 if (url.is_empty()) | 510 if (url.is_empty()) |
| 511 return; | 511 return; |
| 512 | 512 |
| 513 // full text | 513 // full text |
| 514 std::wstring contents; | 514 std::wstring contents; |
| 515 CaptureText(main_frame, &contents); | 515 CaptureText(main_frame, &contents); |
| 516 if (contents.size()) { | 516 if (contents.size()) { |
| 517 // Send the text to the browser for indexing. | 517 // Send the text to the browser for indexing. |
| 518 Send(new ViewHostMsg_PageContents(url, load_id, contents)); | 518 Send(new ViewHostMsg_PageContents(url, load_id, contents)); |
| 519 } | 519 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 532 contents->clear(); | 532 contents->clear(); |
| 533 if (!frame) | 533 if (!frame) |
| 534 return; | 534 return; |
| 535 | 535 |
| 536 // Don't index any https pages. People generally don't want their bank | 536 // Don't index any https pages. People generally don't want their bank |
| 537 // accounts, etc. indexed on their computer, especially since some of these | 537 // accounts, etc. indexed on their computer, especially since some of these |
| 538 // things are not marked cachable. | 538 // things are not marked cachable. |
| 539 // TODO(brettw) we may want to consider more elaborate heuristics such as | 539 // TODO(brettw) we may want to consider more elaborate heuristics such as |
| 540 // the cachability of the page. We may also want to consider subframes (this | 540 // the cachability of the page. We may also want to consider subframes (this |
| 541 // test will still index subframes if the subframe is SSL). | 541 // test will still index subframes if the subframe is SSL). |
| 542 if (frame->GetURL().SchemeIsSecure()) | 542 if (GURL(frame->url()).SchemeIsSecure()) |
| 543 return; | 543 return; |
| 544 | 544 |
| 545 #ifdef TIME_TEXT_RETRIEVAL | 545 #ifdef TIME_TEXT_RETRIEVAL |
| 546 double begin = time_util::GetHighResolutionTimeNow(); | 546 double begin = time_util::GetHighResolutionTimeNow(); |
| 547 #endif | 547 #endif |
| 548 | 548 |
| 549 // get the contents of the frame | 549 // get the contents of the frame |
| 550 frame->GetContentAsPlainText(kMaxIndexChars, contents); | 550 *contents = UTF16ToWideHack(frame->contentAsText(kMaxIndexChars)); |
| 551 | 551 |
| 552 #ifdef TIME_TEXT_RETRIEVAL | 552 #ifdef TIME_TEXT_RETRIEVAL |
| 553 double end = time_util::GetHighResolutionTimeNow(); | 553 double end = time_util::GetHighResolutionTimeNow(); |
| 554 char buf[128]; | 554 char buf[128]; |
| 555 sprintf_s(buf, "%d chars retrieved for indexing in %gms\n", | 555 sprintf_s(buf, "%d chars retrieved for indexing in %gms\n", |
| 556 contents.size(), (end - begin)*1000); | 556 contents.size(), (end - begin)*1000); |
| 557 OutputDebugStringA(buf); | 557 OutputDebugStringA(buf); |
| 558 #endif | 558 #endif |
| 559 | 559 |
| 560 // When the contents are clipped to the maximum, we don't want to have a | 560 // When the contents are clipped to the maximum, we don't want to have a |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 S16CPU x_offset = (src_bmp.width() - new_width) / 2; | 614 S16CPU x_offset = (src_bmp.width() - new_width) / 2; |
| 615 src_rect.set(x_offset, 0, new_width + x_offset, src_bmp.height()); | 615 src_rect.set(x_offset, 0, new_width + x_offset, src_bmp.height()); |
| 616 score->good_clipping = false; | 616 score->good_clipping = false; |
| 617 } else { | 617 } else { |
| 618 src_rect.set(0, 0, src_bmp.width(), | 618 src_rect.set(0, 0, src_bmp.width(), |
| 619 static_cast<S16CPU>(src_bmp.width() / dest_aspect)); | 619 static_cast<S16CPU>(src_bmp.width() / dest_aspect)); |
| 620 score->good_clipping = true; | 620 score->good_clipping = true; |
| 621 } | 621 } |
| 622 } | 622 } |
| 623 | 623 |
| 624 score->at_top = (view->GetMainFrame()->ScrollOffset().height == 0); | 624 score->at_top = (view->GetMainFrame()->scrollOffset().height == 0); |
| 625 | 625 |
| 626 SkBitmap subset; | 626 SkBitmap subset; |
| 627 device.accessBitmap(false).extractSubset(&subset, src_rect); | 627 device.accessBitmap(false).extractSubset(&subset, src_rect); |
| 628 | 628 |
| 629 // Resample the subset that we want to get it the right size. | 629 // Resample the subset that we want to get it the right size. |
| 630 *thumbnail = skia::ImageOperations::Resize( | 630 *thumbnail = skia::ImageOperations::Resize( |
| 631 subset, skia::ImageOperations::RESIZE_LANCZOS3, w, h); | 631 subset, skia::ImageOperations::RESIZE_LANCZOS3, w, h); |
| 632 | 632 |
| 633 score->boring_score = CalculateBoringScore(thumbnail); | 633 score->boring_score = CalculateBoringScore(thumbnail); |
| 634 | 634 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 657 if (devtools_agent_.get()) | 657 if (devtools_agent_.get()) |
| 658 devtools_agent_->OnNavigate(); | 658 devtools_agent_->OnNavigate(); |
| 659 | 659 |
| 660 child_process_logging::ScopedActiveURLSetter url_setter(params.url); | 660 child_process_logging::ScopedActiveURLSetter url_setter(params.url); |
| 661 | 661 |
| 662 AboutHandler::MaybeHandle(params.url); | 662 AboutHandler::MaybeHandle(params.url); |
| 663 | 663 |
| 664 bool is_reload = params.reload; | 664 bool is_reload = params.reload; |
| 665 | 665 |
| 666 WebFrame* main_frame = webview()->GetMainFrame(); | 666 WebFrame* main_frame = webview()->GetMainFrame(); |
| 667 if (is_reload && main_frame->GetCurrentHistoryItem().isNull()) { | 667 if (is_reload && main_frame->currentHistoryItem().isNull()) { |
| 668 // We cannot reload if we do not have any history state. This happens, for | 668 // We cannot reload if we do not have any history state. This happens, for |
| 669 // example, when recovering from a crash. Our workaround here is a bit of | 669 // example, when recovering from a crash. Our workaround here is a bit of |
| 670 // a hack since it means that reload after a crashed tab does not cause an | 670 // a hack since it means that reload after a crashed tab does not cause an |
| 671 // end-to-end cache validation. | 671 // end-to-end cache validation. |
| 672 is_reload = false; | 672 is_reload = false; |
| 673 } | 673 } |
| 674 | 674 |
| 675 // A navigation resulting from loading a javascript URL should not be treated | 675 // A navigation resulting from loading a javascript URL should not be treated |
| 676 // as a browser initiated event. Instead, we want it to look as if the page | 676 // as a browser initiated event. Instead, we want it to look as if the page |
| 677 // initiated any load resulting from JS execution. | 677 // initiated any load resulting from JS execution. |
| 678 if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) { | 678 if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) { |
| 679 pending_navigation_state_.reset(NavigationState::CreateBrowserInitiated( | 679 pending_navigation_state_.reset(NavigationState::CreateBrowserInitiated( |
| 680 params.page_id, params.transition, params.request_time)); | 680 params.page_id, params.transition, params.request_time)); |
| 681 } | 681 } |
| 682 | 682 |
| 683 // If we are reloading, then WebKit will use the history state of the current | 683 // If we are reloading, then WebKit will use the history state of the current |
| 684 // page, so we should just ignore any given history state. Otherwise, if we | 684 // page, so we should just ignore any given history state. Otherwise, if we |
| 685 // have history state, then we need to navigate to it, which corresponds to a | 685 // have history state, then we need to navigate to it, which corresponds to a |
| 686 // back/forward navigation event. | 686 // back/forward navigation event. |
| 687 if (is_reload) { | 687 if (is_reload) { |
| 688 main_frame->Reload(); | 688 main_frame->reload(); |
| 689 } else if (!params.state.empty()) { | 689 } else if (!params.state.empty()) { |
| 690 // We must know the page ID of the page we are navigating back to. | 690 // We must know the page ID of the page we are navigating back to. |
| 691 DCHECK_NE(params.page_id, -1); | 691 DCHECK_NE(params.page_id, -1); |
| 692 main_frame->LoadHistoryItem( | 692 main_frame->loadHistoryItem( |
| 693 webkit_glue::HistoryItemFromString(params.state)); | 693 webkit_glue::HistoryItemFromString(params.state)); |
| 694 } else { | 694 } else { |
| 695 // Navigate to the given URL. | 695 // Navigate to the given URL. |
| 696 WebURLRequest request(params.url); | 696 WebURLRequest request(params.url); |
| 697 | 697 |
| 698 // A session history navigation should have been accompanied by state. | 698 // A session history navigation should have been accompanied by state. |
| 699 DCHECK_EQ(params.page_id, -1); | 699 DCHECK_EQ(params.page_id, -1); |
| 700 | 700 |
| 701 if (main_frame->GetInViewSourceMode()) | 701 if (main_frame->isViewSourceModeEnabled()) |
| 702 request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); | 702 request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); |
| 703 | 703 |
| 704 if (params.referrer.is_valid()) { | 704 if (params.referrer.is_valid()) { |
| 705 request.setHTTPHeaderField(WebString::fromUTF8("Referer"), | 705 request.setHTTPHeaderField(WebString::fromUTF8("Referer"), |
| 706 WebString::fromUTF8(params.referrer.spec())); | 706 WebString::fromUTF8(params.referrer.spec())); |
| 707 } | 707 } |
| 708 | 708 |
| 709 main_frame->LoadRequest(request); | 709 main_frame->loadRequest(request); |
| 710 } | 710 } |
| 711 | 711 |
| 712 // In case LoadRequest failed before DidCreateDataSource was called. | 712 // In case LoadRequest failed before DidCreateDataSource was called. |
| 713 pending_navigation_state_.reset(); | 713 pending_navigation_state_.reset(); |
| 714 } | 714 } |
| 715 | 715 |
| 716 // Stop loading the current page | 716 // Stop loading the current page |
| 717 void RenderView::OnStop() { | 717 void RenderView::OnStop() { |
| 718 if (webview()) | 718 if (webview()) |
| 719 webview()->StopLoading(); | 719 webview()->StopLoading(); |
| 720 } | 720 } |
| 721 | 721 |
| 722 void RenderView::OnLoadAlternateHTMLText(const std::string& html, | 722 void RenderView::OnLoadAlternateHTMLText(const std::string& html, |
| 723 bool new_navigation, | 723 bool new_navigation, |
| 724 const GURL& display_url, | 724 const GURL& display_url, |
| 725 const std::string& security_info) { | 725 const std::string& security_info) { |
| 726 if (!webview()) | 726 if (!webview()) |
| 727 return; | 727 return; |
| 728 | 728 |
| 729 pending_navigation_state_.reset(NavigationState::CreateBrowserInitiated( | 729 pending_navigation_state_.reset(NavigationState::CreateBrowserInitiated( |
| 730 new_navigation ? -1 : page_id_, PageTransition::LINK, Time::Now())); | 730 new_navigation ? -1 : page_id_, PageTransition::LINK, Time::Now())); |
| 731 pending_navigation_state_->set_security_info(security_info); | 731 pending_navigation_state_->set_security_info(security_info); |
| 732 | 732 |
| 733 webview()->GetMainFrame()->LoadHTMLString(html, | 733 webview()->GetMainFrame()->loadHTMLString(html, |
| 734 GURL(kUnreachableWebDataURL), | 734 GURL(kUnreachableWebDataURL), |
| 735 display_url, | 735 display_url, |
| 736 !new_navigation); | 736 !new_navigation); |
| 737 | 737 |
| 738 pending_navigation_state_.reset(); | 738 pending_navigation_state_.reset(); |
| 739 } | 739 } |
| 740 | 740 |
| 741 void RenderView::OnCopyImageAt(int x, int y) { | 741 void RenderView::OnCopyImageAt(int x, int y) { |
| 742 webview()->CopyImageAt(x, y); | 742 webview()->CopyImageAt(x, y); |
| 743 } | 743 } |
| 744 | 744 |
| 745 void RenderView::OnExecuteEditCommand(const std::string& name, | 745 void RenderView::OnExecuteEditCommand(const std::string& name, |
| 746 const std::string& value) { | 746 const std::string& value) { |
| 747 if (!webview() || !webview()->GetFocusedFrame()) | 747 if (!webview() || !webview()->GetFocusedFrame()) |
| 748 return; | 748 return; |
| 749 | 749 |
| 750 webview()->GetFocusedFrame()->ExecuteEditCommandByName(name, value); | 750 webview()->GetFocusedFrame()->executeCommand( |
| 751 WebString::fromUTF8(name), WebString::fromUTF8(value)); |
| 751 } | 752 } |
| 752 | 753 |
| 753 void RenderView::OnSetupDevToolsClient() { | 754 void RenderView::OnSetupDevToolsClient() { |
| 754 DCHECK(!devtools_client_.get()); | 755 DCHECK(!devtools_client_.get()); |
| 755 devtools_client_.reset(new DevToolsClient(this)); | 756 devtools_client_.reset(new DevToolsClient(this)); |
| 756 } | 757 } |
| 757 | 758 |
| 758 void RenderView::OnStopFinding(bool clear_selection) { | 759 void RenderView::OnStopFinding(bool clear_selection) { |
| 759 WebView* view = webview(); | 760 WebView* view = webview(); |
| 760 if (!view) | 761 if (!view) |
| 761 return; | 762 return; |
| 762 | 763 |
| 763 if (clear_selection) | 764 if (clear_selection) |
| 764 view->GetFocusedFrame()->ClearSelection(); | 765 view->GetFocusedFrame()->clearSelection(); |
| 765 | 766 |
| 766 WebFrame* frame = view->GetMainFrame(); | 767 WebFrame* frame = view->GetMainFrame(); |
| 767 while (frame) { | 768 while (frame) { |
| 768 frame->StopFinding(clear_selection); | 769 frame->stopFinding(clear_selection); |
| 769 frame = view->GetNextFrameAfter(frame, false); | 770 frame = view->GetNextFrameAfter(frame, false); |
| 770 } | 771 } |
| 771 } | 772 } |
| 772 | 773 |
| 773 void RenderView::OnFindReplyAck() { | 774 void RenderView::OnFindReplyAck() { |
| 774 // Check if there is any queued up request waiting to be sent. | 775 // Check if there is any queued up request waiting to be sent. |
| 775 if (queued_find_reply_message_.get()) { | 776 if (queued_find_reply_message_.get()) { |
| 776 // Send the search result over to the browser process. | 777 // Send the search result over to the browser process. |
| 777 Send(queued_find_reply_message_.get()); | 778 Send(queued_find_reply_message_.get()); |
| 778 queued_find_reply_message_.release(); | 779 queued_find_reply_message_.release(); |
| 779 } | 780 } |
| 780 } | 781 } |
| 781 | 782 |
| 782 void RenderView::OnUpdateTargetURLAck() { | 783 void RenderView::OnUpdateTargetURLAck() { |
| 783 // Check if there is a targeturl waiting to be sent. | 784 // Check if there is a targeturl waiting to be sent. |
| 784 if (target_url_status_ == TARGET_PENDING) { | 785 if (target_url_status_ == TARGET_PENDING) { |
| 785 Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, | 786 Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, |
| 786 pending_target_url_)); | 787 pending_target_url_)); |
| 787 } | 788 } |
| 788 | 789 |
| 789 target_url_status_ = TARGET_NONE; | 790 target_url_status_ = TARGET_NONE; |
| 790 } | 791 } |
| 791 | 792 |
| 792 void RenderView::OnUndo() { | 793 void RenderView::OnUndo() { |
| 793 if (!webview()) | 794 if (!webview()) |
| 794 return; | 795 return; |
| 795 | 796 |
| 796 webview()->GetFocusedFrame()->Undo(); | 797 webview()->GetFocusedFrame()->executeCommand(WebString::fromUTF8("Undo")); |
| 798 UserMetricsRecordAction(L"Undo"); |
| 797 } | 799 } |
| 798 | 800 |
| 799 void RenderView::OnRedo() { | 801 void RenderView::OnRedo() { |
| 800 if (!webview()) | 802 if (!webview()) |
| 801 return; | 803 return; |
| 802 | 804 |
| 803 webview()->GetFocusedFrame()->Redo(); | 805 webview()->GetFocusedFrame()->executeCommand(WebString::fromUTF8("Redo")); |
| 806 UserMetricsRecordAction(L"Redo"); |
| 804 } | 807 } |
| 805 | 808 |
| 806 void RenderView::OnCut() { | 809 void RenderView::OnCut() { |
| 807 if (!webview()) | 810 if (!webview()) |
| 808 return; | 811 return; |
| 809 | 812 |
| 810 webview()->GetFocusedFrame()->Cut(); | 813 webview()->GetFocusedFrame()->executeCommand(WebString::fromUTF8("Cut")); |
| 814 UserMetricsRecordAction(L"Cut"); |
| 811 } | 815 } |
| 812 | 816 |
| 813 void RenderView::OnCopy() { | 817 void RenderView::OnCopy() { |
| 814 if (!webview()) | 818 if (!webview()) |
| 815 return; | 819 return; |
| 816 | 820 |
| 817 webview()->GetFocusedFrame()->Copy(); | 821 webview()->GetFocusedFrame()->executeCommand(WebString::fromUTF8("Copy")); |
| 822 UserMetricsRecordAction(L"Copy"); |
| 818 } | 823 } |
| 819 | 824 |
| 820 void RenderView::OnPaste() { | 825 void RenderView::OnPaste() { |
| 821 if (!webview()) | 826 if (!webview()) |
| 822 return; | 827 return; |
| 823 | 828 |
| 824 webview()->GetFocusedFrame()->Paste(); | 829 webview()->GetFocusedFrame()->executeCommand(WebString::fromUTF8("Paste")); |
| 830 UserMetricsRecordAction(L"Paste"); |
| 825 } | 831 } |
| 826 | 832 |
| 827 void RenderView::OnReplace(const std::wstring& text) { | 833 void RenderView::OnReplace(const std::wstring& text) { |
| 828 if (!webview()) | 834 if (!webview()) |
| 829 return; | 835 return; |
| 830 | 836 |
| 831 webview()->GetFocusedFrame()->Replace(text); | 837 webview()->GetFocusedFrame()->replaceSelection(WideToUTF16Hack(text)); |
| 832 } | 838 } |
| 833 | 839 |
| 834 void RenderView::OnToggleSpellCheck() { | 840 void RenderView::OnToggleSpellCheck() { |
| 835 if (!webview()) | 841 if (!webview()) |
| 836 return; | 842 return; |
| 837 | 843 |
| 838 webview()->GetFocusedFrame()->ToggleSpellCheck(); | 844 WebFrame* frame = webview()->GetFocusedFrame(); |
| 845 frame->enableContinuousSpellChecking( |
| 846 !frame->isContinuousSpellCheckingEnabled()); |
| 839 } | 847 } |
| 840 | 848 |
| 841 void RenderView::OnDelete() { | 849 void RenderView::OnDelete() { |
| 842 if (!webview()) | 850 if (!webview()) |
| 843 return; | 851 return; |
| 844 | 852 |
| 845 webview()->GetFocusedFrame()->Delete(); | 853 webview()->GetFocusedFrame()->executeCommand(WebString::fromUTF8("Delete")); |
| 854 UserMetricsRecordAction(L"DeleteSelection"); |
| 846 } | 855 } |
| 847 | 856 |
| 848 void RenderView::OnSelectAll() { | 857 void RenderView::OnSelectAll() { |
| 849 if (!webview()) | 858 if (!webview()) |
| 850 return; | 859 return; |
| 851 | 860 |
| 852 webview()->GetFocusedFrame()->SelectAll(); | 861 webview()->GetFocusedFrame()->selectAll(); |
| 853 } | 862 } |
| 854 | 863 |
| 855 void RenderView::OnSetInitialFocus(bool reverse) { | 864 void RenderView::OnSetInitialFocus(bool reverse) { |
| 856 if (!webview()) | 865 if (!webview()) |
| 857 return; | 866 return; |
| 858 webview()->SetInitialFocus(reverse); | 867 webview()->SetInitialFocus(reverse); |
| 859 } | 868 } |
| 860 | 869 |
| 861 /////////////////////////////////////////////////////////////////////////////// | 870 /////////////////////////////////////////////////////////////////////////////// |
| 862 | 871 |
| 863 // Tell the embedding application that the URL of the active page has changed | 872 // Tell the embedding application that the URL of the active page has changed |
| 864 void RenderView::UpdateURL(WebFrame* frame) { | 873 void RenderView::UpdateURL(WebFrame* frame) { |
| 865 WebDataSource* ds = frame->GetDataSource(); | 874 WebDataSource* ds = frame->dataSource(); |
| 866 DCHECK(ds); | 875 DCHECK(ds); |
| 867 | 876 |
| 868 const WebURLRequest& request = ds->request(); | 877 const WebURLRequest& request = ds->request(); |
| 869 const WebURLRequest& original_request = ds->originalRequest(); | 878 const WebURLRequest& original_request = ds->originalRequest(); |
| 870 const WebURLResponse& response = ds->response(); | 879 const WebURLResponse& response = ds->response(); |
| 871 | 880 |
| 872 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 881 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
| 873 DCHECK(navigation_state); | 882 DCHECK(navigation_state); |
| 874 | 883 |
| 875 ViewHostMsg_FrameNavigate_Params params; | 884 ViewHostMsg_FrameNavigate_Params params; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 } | 916 } |
| 908 | 917 |
| 909 const PasswordForm* password_form_data = | 918 const PasswordForm* password_form_data = |
| 910 navigation_state->password_form_data(); | 919 navigation_state->password_form_data(); |
| 911 if (password_form_data) | 920 if (password_form_data) |
| 912 params.password_form = *password_form_data; | 921 params.password_form = *password_form_data; |
| 913 | 922 |
| 914 params.gesture = navigation_gesture_; | 923 params.gesture = navigation_gesture_; |
| 915 navigation_gesture_ = NavigationGestureUnknown; | 924 navigation_gesture_ = NavigationGestureUnknown; |
| 916 | 925 |
| 917 if (!frame->GetParent()) { | 926 if (!frame->parent()) { |
| 918 // Top-level navigation. | 927 // Top-level navigation. |
| 919 | 928 |
| 920 // Update contents MIME type for main frame. | 929 // Update contents MIME type for main frame. |
| 921 params.contents_mime_type = UTF16ToUTF8(ds->response().mimeType()); | 930 params.contents_mime_type = UTF16ToUTF8(ds->response().mimeType()); |
| 922 | 931 |
| 923 params.transition = navigation_state->transition_type(); | 932 params.transition = navigation_state->transition_type(); |
| 924 if (!PageTransition::IsMainFrame(params.transition)) { | 933 if (!PageTransition::IsMainFrame(params.transition)) { |
| 925 // If the main frame does a load, it should not be reported as a subframe | 934 // If the main frame does a load, it should not be reported as a subframe |
| 926 // navigation. This can occur in the following case: | 935 // navigation. This can occur in the following case: |
| 927 // 1. You're on a site with frames. | 936 // 1. You're on a site with frames. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 // before we navigate to a new page. This must be called *before* the page ID | 1024 // before we navigate to a new page. This must be called *before* the page ID |
| 1016 // has been updated so we know what it was. | 1025 // has been updated so we know what it was. |
| 1017 void RenderView::UpdateSessionHistory(WebFrame* frame) { | 1026 void RenderView::UpdateSessionHistory(WebFrame* frame) { |
| 1018 // If we have a valid page ID at this point, then it corresponds to the page | 1027 // If we have a valid page ID at this point, then it corresponds to the page |
| 1019 // we are navigating away from. Otherwise, this is the first navigation, so | 1028 // we are navigating away from. Otherwise, this is the first navigation, so |
| 1020 // there is no past session history to record. | 1029 // there is no past session history to record. |
| 1021 if (page_id_ == -1) | 1030 if (page_id_ == -1) |
| 1022 return; | 1031 return; |
| 1023 | 1032 |
| 1024 const WebHistoryItem& item = | 1033 const WebHistoryItem& item = |
| 1025 webview()->GetMainFrame()->GetPreviousHistoryItem(); | 1034 webview()->GetMainFrame()->previousHistoryItem(); |
| 1026 if (item.isNull()) | 1035 if (item.isNull()) |
| 1027 return; | 1036 return; |
| 1028 | 1037 |
| 1029 Send(new ViewHostMsg_UpdateState( | 1038 Send(new ViewHostMsg_UpdateState( |
| 1030 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); | 1039 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); |
| 1031 } | 1040 } |
| 1032 | 1041 |
| 1033 /////////////////////////////////////////////////////////////////////////////// | 1042 /////////////////////////////////////////////////////////////////////////////// |
| 1034 // WebViewDelegate | 1043 // WebViewDelegate |
| 1035 | 1044 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1057 return; | 1066 return; |
| 1058 } | 1067 } |
| 1059 | 1068 |
| 1060 is_loading_ = false; | 1069 is_loading_ = false; |
| 1061 | 1070 |
| 1062 // NOTE: For now we're doing the safest thing, and sending out notification | 1071 // NOTE: For now we're doing the safest thing, and sending out notification |
| 1063 // when done loading. This currently isn't an issue as the favicon is only | 1072 // when done loading. This currently isn't an issue as the favicon is only |
| 1064 // displayed when done loading. Ideally we would send notification when | 1073 // displayed when done loading. Ideally we would send notification when |
| 1065 // finished parsing the head, but webkit doesn't support that yet. | 1074 // finished parsing the head, but webkit doesn't support that yet. |
| 1066 // The feed discovery code would also benefit from access to the head. | 1075 // The feed discovery code would also benefit from access to the head. |
| 1067 GURL favicon_url(webview->GetMainFrame()->GetFavIconURL()); | 1076 GURL favicon_url(webview->GetMainFrame()->favIconURL()); |
| 1068 if (!favicon_url.is_empty()) | 1077 if (!favicon_url.is_empty()) |
| 1069 Send(new ViewHostMsg_UpdateFavIconURL(routing_id_, page_id_, favicon_url)); | 1078 Send(new ViewHostMsg_UpdateFavIconURL(routing_id_, page_id_, favicon_url)); |
| 1070 | 1079 |
| 1071 AddGURLSearchProvider(webview->GetMainFrame()->GetOSDDURL(), | 1080 AddGURLSearchProvider(webview->GetMainFrame()->openSearchDescriptionURL(), |
| 1072 true); // autodetected | 1081 true); // autodetected |
| 1073 | 1082 |
| 1074 Send(new ViewHostMsg_DidStopLoading(routing_id_)); | 1083 Send(new ViewHostMsg_DidStopLoading(routing_id_)); |
| 1075 | 1084 |
| 1076 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 1085 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 1077 method_factory_.NewRunnableMethod(&RenderView::CapturePageInfo, page_id_, | 1086 method_factory_.NewRunnableMethod(&RenderView::CapturePageInfo, page_id_, |
| 1078 false), | 1087 false), |
| 1079 kDelayForCaptureMs); | 1088 kDelayForCaptureMs); |
| 1080 | 1089 |
| 1081 // The page is loaded. Try to process the file we need to upload if any. | 1090 // The page is loaded. Try to process the file we need to upload if any. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1092 if (pending_navigation_state_.get()) { | 1101 if (pending_navigation_state_.get()) { |
| 1093 ds->setExtraData(pending_navigation_state_.release()); | 1102 ds->setExtraData(pending_navigation_state_.release()); |
| 1094 } else { | 1103 } else { |
| 1095 ds->setExtraData(NavigationState::CreateContentInitiated()); | 1104 ds->setExtraData(NavigationState::CreateContentInitiated()); |
| 1096 } | 1105 } |
| 1097 } | 1106 } |
| 1098 | 1107 |
| 1099 void RenderView::DidPaint() { | 1108 void RenderView::DidPaint() { |
| 1100 WebFrame* main_frame = webview()->GetMainFrame(); | 1109 WebFrame* main_frame = webview()->GetMainFrame(); |
| 1101 | 1110 |
| 1102 if (main_frame->GetProvisionalDataSource()) { | 1111 if (main_frame->provisionalDataSource()) { |
| 1103 // If we have a provisional frame we are between the start | 1112 // If we have a provisional frame we are between the start |
| 1104 // and commit stages of loading...ignore this paint. | 1113 // and commit stages of loading...ignore this paint. |
| 1105 return; | 1114 return; |
| 1106 } | 1115 } |
| 1107 | 1116 |
| 1108 WebDataSource* ds = main_frame->GetDataSource(); | 1117 WebDataSource* ds = main_frame->dataSource(); |
| 1109 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 1118 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
| 1110 DCHECK(navigation_state); | 1119 DCHECK(navigation_state); |
| 1111 | 1120 |
| 1112 Time now = Time::Now(); | 1121 Time now = Time::Now(); |
| 1113 if (navigation_state->first_paint_time().is_null()) { | 1122 if (navigation_state->first_paint_time().is_null()) { |
| 1114 navigation_state->set_first_paint_time(now); | 1123 navigation_state->set_first_paint_time(now); |
| 1115 } | 1124 } |
| 1116 if (navigation_state->first_paint_after_load_time().is_null() && | 1125 if (navigation_state->first_paint_after_load_time().is_null() && |
| 1117 !navigation_state->finish_load_time().is_null()) { | 1126 !navigation_state->finish_load_time().is_null()) { |
| 1118 navigation_state->set_first_paint_after_load_time(now); | 1127 navigation_state->set_first_paint_after_load_time(now); |
| 1119 } | 1128 } |
| 1120 } | 1129 } |
| 1121 | 1130 |
| 1122 void RenderView::DidStartProvisionalLoadForFrame( | 1131 void RenderView::DidStartProvisionalLoadForFrame( |
| 1123 WebView* webview, | 1132 WebView* webview, |
| 1124 WebFrame* frame, | 1133 WebFrame* frame, |
| 1125 NavigationGesture gesture) { | 1134 NavigationGesture gesture) { |
| 1126 WebDataSource* ds = frame->GetProvisionalDataSource(); | 1135 WebDataSource* ds = frame->provisionalDataSource(); |
| 1127 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 1136 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
| 1128 | 1137 |
| 1129 navigation_state->set_start_load_time(Time::Now()); | 1138 navigation_state->set_start_load_time(Time::Now()); |
| 1130 | 1139 |
| 1131 // Update the request time if WebKit has better knowledge of it. | 1140 // Update the request time if WebKit has better knowledge of it. |
| 1132 if (navigation_state->request_time().is_null()) { | 1141 if (navigation_state->request_time().is_null()) { |
| 1133 double event_time = ds->triggeringEventTime(); | 1142 double event_time = ds->triggeringEventTime(); |
| 1134 if (event_time != 0.0) | 1143 if (event_time != 0.0) |
| 1135 navigation_state->set_request_time(Time::FromDoubleT(event_time)); | 1144 navigation_state->set_request_time(Time::FromDoubleT(event_time)); |
| 1136 } | 1145 } |
| 1137 | 1146 |
| 1138 bool is_top_most = !frame->GetParent(); | 1147 bool is_top_most = !frame->parent(); |
| 1139 if (is_top_most) { | 1148 if (is_top_most) { |
| 1140 navigation_gesture_ = gesture; | 1149 navigation_gesture_ = gesture; |
| 1141 | 1150 |
| 1142 // Make sure redirect tracking state is clear for the new load. | 1151 // Make sure redirect tracking state is clear for the new load. |
| 1143 completed_client_redirect_src_ = GURL(); | 1152 completed_client_redirect_src_ = GURL(); |
| 1144 } else if (frame->GetParent()->IsLoading()) { | 1153 } else if (frame->parent()->isLoading()) { |
| 1145 // Take note of AUTO_SUBFRAME loads here, so that we can know how to | 1154 // Take note of AUTO_SUBFRAME loads here, so that we can know how to |
| 1146 // load an error page. See DidFailProvisionalLoadWithError. | 1155 // load an error page. See DidFailProvisionalLoadWithError. |
| 1147 navigation_state->set_transition_type(PageTransition::AUTO_SUBFRAME); | 1156 navigation_state->set_transition_type(PageTransition::AUTO_SUBFRAME); |
| 1148 } | 1157 } |
| 1149 | 1158 |
| 1150 Send(new ViewHostMsg_DidStartProvisionalLoadForFrame( | 1159 Send(new ViewHostMsg_DidStartProvisionalLoadForFrame( |
| 1151 routing_id_, is_top_most, ds->request().url())); | 1160 routing_id_, is_top_most, ds->request().url())); |
| 1152 } | 1161 } |
| 1153 | 1162 |
| 1154 bool RenderView::DidLoadResourceFromMemoryCache(WebView* webview, | 1163 bool RenderView::DidLoadResourceFromMemoryCache(WebView* webview, |
| 1155 const WebURLRequest& request, | 1164 const WebURLRequest& request, |
| 1156 const WebURLResponse& response, | 1165 const WebURLResponse& response, |
| 1157 WebFrame* frame) { | 1166 WebFrame* frame) { |
| 1158 // Let the browser know we loaded a resource from the memory cache. This | 1167 // Let the browser know we loaded a resource from the memory cache. This |
| 1159 // message is needed to display the correct SSL indicators. | 1168 // message is needed to display the correct SSL indicators. |
| 1160 Send(new ViewHostMsg_DidLoadResourceFromMemoryCache(routing_id_, | 1169 Send(new ViewHostMsg_DidLoadResourceFromMemoryCache( |
| 1161 request.url(), frame->GetSecurityOrigin(), | 1170 routing_id_, |
| 1162 frame->GetTop()->GetSecurityOrigin(), | 1171 request.url(), |
| 1172 frame->securityOrigin().utf8(), |
| 1173 frame->top()->securityOrigin().utf8(), |
| 1163 response.securityInfo())); | 1174 response.securityInfo())); |
| 1164 | 1175 |
| 1165 return false; | 1176 return false; |
| 1166 } | 1177 } |
| 1167 | 1178 |
| 1168 void RenderView::DidReceiveProvisionalLoadServerRedirect(WebView* webview, | 1179 void RenderView::DidReceiveProvisionalLoadServerRedirect(WebView* webview, |
| 1169 WebFrame* frame) { | 1180 WebFrame* frame) { |
| 1170 if (frame == webview->GetMainFrame()) { | 1181 if (frame == webview->GetMainFrame()) { |
| 1171 // Received a redirect on the main frame. | 1182 // Received a redirect on the main frame. |
| 1172 WebDataSource* data_source = | 1183 WebDataSource* data_source = |
| 1173 webview->GetMainFrame()->GetProvisionalDataSource(); | 1184 webview->GetMainFrame()->provisionalDataSource(); |
| 1174 if (!data_source) { | 1185 if (!data_source) { |
| 1175 // Should only be invoked when we have a data source. | 1186 // Should only be invoked when we have a data source. |
| 1176 NOTREACHED(); | 1187 NOTREACHED(); |
| 1177 return; | 1188 return; |
| 1178 } | 1189 } |
| 1179 std::vector<GURL> redirects; | 1190 std::vector<GURL> redirects; |
| 1180 GetRedirectChain(data_source, &redirects); | 1191 GetRedirectChain(data_source, &redirects); |
| 1181 if (redirects.size() >= 2) { | 1192 if (redirects.size() >= 2) { |
| 1182 Send(new ViewHostMsg_DidRedirectProvisionalLoad( | 1193 Send(new ViewHostMsg_DidRedirectProvisionalLoad( |
| 1183 routing_id_, page_id_, redirects[redirects.size() - 2], | 1194 routing_id_, page_id_, redirects[redirects.size() - 2], |
| 1184 redirects[redirects.size() - 1])); | 1195 redirects[redirects.size() - 1])); |
| 1185 } | 1196 } |
| 1186 } | 1197 } |
| 1187 } | 1198 } |
| 1188 | 1199 |
| 1189 void RenderView::DidFailProvisionalLoadWithError(WebView* webview, | 1200 void RenderView::DidFailProvisionalLoadWithError(WebView* webview, |
| 1190 const WebURLError& error, | 1201 const WebURLError& error, |
| 1191 WebFrame* frame) { | 1202 WebFrame* frame) { |
| 1192 // Notify the browser that we failed a provisional load with an error. | 1203 // Notify the browser that we failed a provisional load with an error. |
| 1193 // | 1204 // |
| 1194 // Note: It is important this notification occur before DidStopLoading so the | 1205 // Note: It is important this notification occur before DidStopLoading so the |
| 1195 // SSL manager can react to the provisional load failure before being | 1206 // SSL manager can react to the provisional load failure before being |
| 1196 // notified the load stopped. | 1207 // notified the load stopped. |
| 1197 // | 1208 // |
| 1198 WebDataSource* ds = frame->GetProvisionalDataSource(); | 1209 WebDataSource* ds = frame->provisionalDataSource(); |
| 1199 DCHECK(ds); | 1210 DCHECK(ds); |
| 1200 | 1211 |
| 1201 const WebURLRequest& failed_request = ds->request(); | 1212 const WebURLRequest& failed_request = ds->request(); |
| 1202 | 1213 |
| 1203 bool show_repost_interstitial = | 1214 bool show_repost_interstitial = |
| 1204 (error.reason == net::ERR_CACHE_MISS && | 1215 (error.reason == net::ERR_CACHE_MISS && |
| 1205 EqualsASCII(failed_request.httpMethod(), "POST")); | 1216 EqualsASCII(failed_request.httpMethod(), "POST")); |
| 1206 Send(new ViewHostMsg_DidFailProvisionalLoadWithError( | 1217 Send(new ViewHostMsg_DidFailProvisionalLoadWithError( |
| 1207 routing_id_, !frame->GetParent(), | 1218 routing_id_, !frame->parent(), error.reason, error.unreachableURL, |
| 1208 error.reason, error.unreachableURL, | |
| 1209 show_repost_interstitial)); | 1219 show_repost_interstitial)); |
| 1210 | 1220 |
| 1211 // Don't display an error page if this is simply a cancelled load. Aside | 1221 // Don't display an error page if this is simply a cancelled load. Aside |
| 1212 // from being dumb, WebCore doesn't expect it and it will cause a crash. | 1222 // from being dumb, WebCore doesn't expect it and it will cause a crash. |
| 1213 if (error.reason == net::ERR_ABORTED) | 1223 if (error.reason == net::ERR_ABORTED) |
| 1214 return; | 1224 return; |
| 1215 | 1225 |
| 1216 // Make sure we never show errors in view source mode. | 1226 // Make sure we never show errors in view source mode. |
| 1217 frame->SetInViewSourceMode(false); | 1227 frame->enableViewSourceMode(false); |
| 1218 | 1228 |
| 1219 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 1229 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
| 1220 | 1230 |
| 1221 // If this is a failed back/forward/reload navigation, then we need to do a | 1231 // If this is a failed back/forward/reload navigation, then we need to do a |
| 1222 // 'replace' load. This is necessary to avoid messing up session history. | 1232 // 'replace' load. This is necessary to avoid messing up session history. |
| 1223 // Otherwise, we do a normal load, which simulates a 'go' navigation as far | 1233 // Otherwise, we do a normal load, which simulates a 'go' navigation as far |
| 1224 // as session history is concerned. | 1234 // as session history is concerned. |
| 1225 // | 1235 // |
| 1226 // AUTO_SUBFRAME loads should always be treated as loads that do not advance | 1236 // AUTO_SUBFRAME loads should always be treated as loads that do not advance |
| 1227 // the page id. | 1237 // the page id. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 } | 1280 } |
| 1271 error_strings.SetString(L"textdirection", | 1281 error_strings.SetString(L"textdirection", |
| 1272 (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? | 1282 (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? |
| 1273 L"rtl" : L"ltr"); | 1283 L"rtl" : L"ltr"); |
| 1274 | 1284 |
| 1275 alt_html = GetAltHTMLForTemplate(error_strings, resource_id); | 1285 alt_html = GetAltHTMLForTemplate(error_strings, resource_id); |
| 1276 } else { | 1286 } else { |
| 1277 alt_html = html; | 1287 alt_html = html; |
| 1278 } | 1288 } |
| 1279 | 1289 |
| 1280 frame->LoadHTMLString(alt_html, | 1290 frame->loadHTMLString(alt_html, |
| 1281 GURL(kUnreachableWebDataURL), | 1291 GURL(kUnreachableWebDataURL), |
| 1282 failed_url, | 1292 failed_url, |
| 1283 replace); | 1293 replace); |
| 1284 } | 1294 } |
| 1285 | 1295 |
| 1286 void RenderView::DidReceiveDocumentData(WebFrame* frame, const char* data, | 1296 void RenderView::DidReceiveDocumentData(WebFrame* frame, const char* data, |
| 1287 size_t data_len) { | 1297 size_t data_len) { |
| 1288 NavigationState* navigation_state = | 1298 NavigationState* navigation_state = |
| 1289 NavigationState::FromDataSource(frame->GetDataSource()); | 1299 NavigationState::FromDataSource(frame->dataSource()); |
| 1290 if (!navigation_state->postpone_loading_data()) { | 1300 if (!navigation_state->postpone_loading_data()) { |
| 1291 frame->CommitDocumentData(data, data_len); | 1301 frame->commitDocumentData(data, data_len); |
| 1292 return; | 1302 return; |
| 1293 } | 1303 } |
| 1294 | 1304 |
| 1295 // Continue buffering the response data for the original 404 page. If it | 1305 // Continue buffering the response data for the original 404 page. If it |
| 1296 // grows too large, then we'll just let it through. | 1306 // grows too large, then we'll just let it through. |
| 1297 navigation_state->append_postponed_data(data, data_len); | 1307 navigation_state->append_postponed_data(data, data_len); |
| 1298 if (navigation_state->postponed_data().size() >= 512) { | 1308 if (navigation_state->postponed_data().size() >= 512) { |
| 1299 navigation_state->set_postpone_loading_data(false); | 1309 navigation_state->set_postpone_loading_data(false); |
| 1300 frame->CommitDocumentData(navigation_state->postponed_data().data(), | 1310 frame->commitDocumentData(navigation_state->postponed_data().data(), |
| 1301 navigation_state->postponed_data().size()); | 1311 navigation_state->postponed_data().size()); |
| 1302 navigation_state->clear_postponed_data(); | 1312 navigation_state->clear_postponed_data(); |
| 1303 } | 1313 } |
| 1304 } | 1314 } |
| 1305 | 1315 |
| 1306 void RenderView::DidCommitLoadForFrame(WebView *webview, WebFrame* frame, | 1316 void RenderView::DidCommitLoadForFrame(WebView *webview, WebFrame* frame, |
| 1307 bool is_new_navigation) { | 1317 bool is_new_navigation) { |
| 1308 NavigationState* navigation_state = | 1318 NavigationState* navigation_state = |
| 1309 NavigationState::FromDataSource(frame->GetDataSource()); | 1319 NavigationState::FromDataSource(frame->dataSource()); |
| 1310 | 1320 |
| 1311 navigation_state->set_commit_load_time(Time::Now()); | 1321 navigation_state->set_commit_load_time(Time::Now()); |
| 1312 if (is_new_navigation) { | 1322 if (is_new_navigation) { |
| 1313 // When we perform a new navigation, we need to update the previous session | 1323 // When we perform a new navigation, we need to update the previous session |
| 1314 // history entry with state for the page we are leaving. | 1324 // history entry with state for the page we are leaving. |
| 1315 UpdateSessionHistory(frame); | 1325 UpdateSessionHistory(frame); |
| 1316 | 1326 |
| 1317 // We bump our Page ID to correspond with the new session history entry. | 1327 // We bump our Page ID to correspond with the new session history entry. |
| 1318 page_id_ = next_page_id_++; | 1328 page_id_ = next_page_id_++; |
| 1319 | 1329 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 void RenderView::DidReceiveTitle(WebView* webview, | 1371 void RenderView::DidReceiveTitle(WebView* webview, |
| 1362 const std::wstring& title, | 1372 const std::wstring& title, |
| 1363 WebFrame* frame) { | 1373 WebFrame* frame) { |
| 1364 UpdateTitle(frame, title); | 1374 UpdateTitle(frame, title); |
| 1365 | 1375 |
| 1366 // Also check whether we have new encoding name. | 1376 // Also check whether we have new encoding name. |
| 1367 UpdateEncoding(frame, webview->GetMainFrameEncodingName()); | 1377 UpdateEncoding(frame, webview->GetMainFrameEncodingName()); |
| 1368 } | 1378 } |
| 1369 | 1379 |
| 1370 void RenderView::DidFinishLoadForFrame(WebView* webview, WebFrame* frame) { | 1380 void RenderView::DidFinishLoadForFrame(WebView* webview, WebFrame* frame) { |
| 1371 WebDataSource* ds = frame->GetDataSource(); | 1381 WebDataSource* ds = frame->dataSource(); |
| 1372 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 1382 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
| 1373 DCHECK(navigation_state); | 1383 DCHECK(navigation_state); |
| 1374 navigation_state->set_finish_load_time(Time::Now()); | 1384 navigation_state->set_finish_load_time(Time::Now()); |
| 1375 } | 1385 } |
| 1376 | 1386 |
| 1377 void RenderView::DidFailLoadWithError(WebView* webview, | 1387 void RenderView::DidFailLoadWithError(WebView* webview, |
| 1378 const WebURLError& error, | 1388 const WebURLError& error, |
| 1379 WebFrame* frame) { | 1389 WebFrame* frame) { |
| 1380 // Currently this function is empty. When you implement something here and it | 1390 // Currently this function is empty. When you implement something here and it |
| 1381 // will display any error messages in HTML, please make sure to call | 1391 // will display any error messages in HTML, please make sure to call |
| 1382 // frame->SetInViewSourceMode(false) not to show them in view source mode. | 1392 // frame->SetInViewSourceMode(false) not to show them in view source mode. |
| 1383 } | 1393 } |
| 1384 | 1394 |
| 1385 void RenderView::DidFinishDocumentLoadForFrame(WebView* webview, | 1395 void RenderView::DidFinishDocumentLoadForFrame(WebView* webview, |
| 1386 WebFrame* frame) { | 1396 WebFrame* frame) { |
| 1387 WebDataSource* ds = frame->GetDataSource(); | 1397 WebDataSource* ds = frame->dataSource(); |
| 1388 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 1398 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
| 1389 DCHECK(navigation_state); | 1399 DCHECK(navigation_state); |
| 1390 navigation_state->set_finish_document_load_time(Time::Now()); | 1400 navigation_state->set_finish_document_load_time(Time::Now()); |
| 1391 | 1401 |
| 1392 Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_)); | 1402 Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_)); |
| 1393 | 1403 |
| 1394 // The document has now been fully loaded. Scan for password forms to be | 1404 // The document has now been fully loaded. Scan for password forms to be |
| 1395 // sent up to the browser. | 1405 // sent up to the browser. |
| 1396 SendPasswordForms(frame); | 1406 SendPasswordForms(frame); |
| 1397 | 1407 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1410 void RenderView::DidChangeLocationWithinPageForFrame(WebView* webview, | 1420 void RenderView::DidChangeLocationWithinPageForFrame(WebView* webview, |
| 1411 WebFrame* frame, | 1421 WebFrame* frame, |
| 1412 bool is_new_navigation) { | 1422 bool is_new_navigation) { |
| 1413 // If this was a reference fragment navigation that we initiated, then we | 1423 // If this was a reference fragment navigation that we initiated, then we |
| 1414 // could end up having a non-null pending navigation state. We just need to | 1424 // could end up having a non-null pending navigation state. We just need to |
| 1415 // update the ExtraData on the datasource so that others who read the | 1425 // update the ExtraData on the datasource so that others who read the |
| 1416 // ExtraData will get the new NavigationState. Similarly, if we did not | 1426 // ExtraData will get the new NavigationState. Similarly, if we did not |
| 1417 // initiate this navigation, then we need to take care to reset any pre- | 1427 // initiate this navigation, then we need to take care to reset any pre- |
| 1418 // existing navigation state to a content-initiated navigation state. | 1428 // existing navigation state to a content-initiated navigation state. |
| 1419 // DidCreateDataSource conveniently takes care of this for us. | 1429 // DidCreateDataSource conveniently takes care of this for us. |
| 1420 DidCreateDataSource(frame, frame->GetDataSource()); | 1430 DidCreateDataSource(frame, frame->dataSource()); |
| 1421 | 1431 |
| 1422 DidCommitLoadForFrame(webview, frame, is_new_navigation); | 1432 DidCommitLoadForFrame(webview, frame, is_new_navigation); |
| 1423 | 1433 |
| 1424 const string16& title = | 1434 const string16& title = |
| 1425 webview->GetMainFrame()->GetDataSource()->pageTitle(); | 1435 webview->GetMainFrame()->dataSource()->pageTitle(); |
| 1426 UpdateTitle(frame, UTF16ToWideHack(title)); | 1436 UpdateTitle(frame, UTF16ToWideHack(title)); |
| 1427 } | 1437 } |
| 1428 | 1438 |
| 1429 void RenderView::DidCompleteClientRedirect(WebView* webview, | 1439 void RenderView::DidCompleteClientRedirect(WebView* webview, |
| 1430 WebFrame* frame, | 1440 WebFrame* frame, |
| 1431 const GURL& source) { | 1441 const GURL& source) { |
| 1432 if (webview->GetMainFrame() == frame) | 1442 if (webview->GetMainFrame() == frame) |
| 1433 completed_client_redirect_src_ = source; | 1443 completed_client_redirect_src_ = source; |
| 1434 } | 1444 } |
| 1435 | 1445 |
| 1436 void RenderView::WillCloseFrame(WebView* webview, WebFrame* frame) { | 1446 void RenderView::WillCloseFrame(WebView* webview, WebFrame* frame) { |
| 1437 if (!frame->GetParent()) { | 1447 if (!frame->parent()) { |
| 1438 const GURL& url = frame->GetURL(); | 1448 const GURL& url = frame->url(); |
| 1439 if (url.SchemeIs("http") || url.SchemeIs("https")) | 1449 if (url.SchemeIs("http") || url.SchemeIs("https")) |
| 1440 DumpLoadHistograms(); | 1450 DumpLoadHistograms(); |
| 1441 } | 1451 } |
| 1442 } | 1452 } |
| 1443 | 1453 |
| 1444 void RenderView::WillSubmitForm(WebView* webview, WebFrame* frame, | 1454 void RenderView::WillSubmitForm(WebView* webview, WebFrame* frame, |
| 1445 const WebForm& form) { | 1455 const WebForm& form) { |
| 1446 NavigationState* navigation_state = | 1456 NavigationState* navigation_state = |
| 1447 NavigationState::FromDataSource(frame->GetProvisionalDataSource()); | 1457 NavigationState::FromDataSource(frame->provisionalDataSource()); |
| 1448 | 1458 |
| 1449 if (navigation_state->transition_type() == PageTransition::LINK) | 1459 if (navigation_state->transition_type() == PageTransition::LINK) |
| 1450 navigation_state->set_transition_type(PageTransition::FORM_SUBMIT); | 1460 navigation_state->set_transition_type(PageTransition::FORM_SUBMIT); |
| 1451 | 1461 |
| 1452 // Save these to be processed when the ensuing navigation is committed. | 1462 // Save these to be processed when the ensuing navigation is committed. |
| 1453 navigation_state->set_searchable_form_data( | 1463 navigation_state->set_searchable_form_data( |
| 1454 SearchableFormData::Create(form)); | 1464 SearchableFormData::Create(form)); |
| 1455 navigation_state->set_password_form_data( | 1465 navigation_state->set_password_form_data( |
| 1456 PasswordFormDomManager::CreatePasswordForm(form)); | 1466 PasswordFormDomManager::CreatePasswordForm(form)); |
| 1457 | 1467 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1471 void RenderView::DidReceiveResponse(WebFrame* frame, uint32 identifier, | 1481 void RenderView::DidReceiveResponse(WebFrame* frame, uint32 identifier, |
| 1472 const WebURLResponse& response) { | 1482 const WebURLResponse& response) { |
| 1473 // Consider loading an alternate error page for 404 responses. | 1483 // Consider loading an alternate error page for 404 responses. |
| 1474 if (response.httpStatusCode() != 404) | 1484 if (response.httpStatusCode() != 404) |
| 1475 return; | 1485 return; |
| 1476 | 1486 |
| 1477 // Only do this for responses that correspond to a provisional data source | 1487 // Only do this for responses that correspond to a provisional data source |
| 1478 // of the top-most frame. If we have a provisional data source, then we | 1488 // of the top-most frame. If we have a provisional data source, then we |
| 1479 // can't have any sub-resources yet, so we know that this response must | 1489 // can't have any sub-resources yet, so we know that this response must |
| 1480 // correspond to a frame load. | 1490 // correspond to a frame load. |
| 1481 if (!frame->GetProvisionalDataSource() || frame->GetParent()) | 1491 if (!frame->provisionalDataSource() || frame->parent()) |
| 1482 return; | 1492 return; |
| 1483 | 1493 |
| 1484 // If we are in view source mode, then just let the user see the source of | 1494 // If we are in view source mode, then just let the user see the source of |
| 1485 // the server's 404 error page. | 1495 // the server's 404 error page. |
| 1486 if (frame->GetInViewSourceMode()) | 1496 if (frame->isViewSourceModeEnabled()) |
| 1487 return; | 1497 return; |
| 1488 | 1498 |
| 1489 // Can we even load an alternate error page for this URL? | 1499 // Can we even load an alternate error page for this URL? |
| 1490 if (!GetAlternateErrorPageURL(response.url(), HTTP_404).is_valid()) | 1500 if (!GetAlternateErrorPageURL(response.url(), HTTP_404).is_valid()) |
| 1491 return; | 1501 return; |
| 1492 | 1502 |
| 1493 NavigationState* navigation_state = | 1503 NavigationState* navigation_state = |
| 1494 NavigationState::FromDataSource(frame->GetProvisionalDataSource()); | 1504 NavigationState::FromDataSource(frame->provisionalDataSource()); |
| 1495 navigation_state->set_postpone_loading_data(true); | 1505 navigation_state->set_postpone_loading_data(true); |
| 1496 navigation_state->clear_postponed_data(); | 1506 navigation_state->clear_postponed_data(); |
| 1497 } | 1507 } |
| 1498 | 1508 |
| 1499 void RenderView::DidFinishLoading(WebFrame* frame, uint32 identifier) { | 1509 void RenderView::DidFinishLoading(WebFrame* frame, uint32 identifier) { |
| 1500 NavigationState* navigation_state = | 1510 NavigationState* navigation_state = |
| 1501 NavigationState::FromDataSource(frame->GetDataSource()); | 1511 NavigationState::FromDataSource(frame->dataSource()); |
| 1502 if (!navigation_state->postpone_loading_data()) | 1512 if (!navigation_state->postpone_loading_data()) |
| 1503 return; | 1513 return; |
| 1504 | 1514 |
| 1505 // The server returned a 404 and the content was < 512 bytes (which we | 1515 // The server returned a 404 and the content was < 512 bytes (which we |
| 1506 // suppressed). Go ahead and fetch the alternate page content. | 1516 // suppressed). Go ahead and fetch the alternate page content. |
| 1507 | 1517 |
| 1508 const GURL& frame_url = frame->GetURL(); | 1518 const GURL& frame_url = frame->url(); |
| 1509 | 1519 |
| 1510 const GURL& error_page_url = GetAlternateErrorPageURL(frame_url, HTTP_404); | 1520 const GURL& error_page_url = GetAlternateErrorPageURL(frame_url, HTTP_404); |
| 1511 DCHECK(error_page_url.is_valid()); | 1521 DCHECK(error_page_url.is_valid()); |
| 1512 | 1522 |
| 1513 WebURLError original_error; | 1523 WebURLError original_error; |
| 1514 original_error.unreachableURL = frame_url; | 1524 original_error.unreachableURL = frame_url; |
| 1515 | 1525 |
| 1516 navigation_state->set_alt_error_page_fetcher( | 1526 navigation_state->set_alt_error_page_fetcher( |
| 1517 new AltErrorPageResourceFetcher( | 1527 new AltErrorPageResourceFetcher( |
| 1518 error_page_url, frame, original_error, | 1528 error_page_url, frame, original_error, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1539 external_host_bindings_.set_routing_id(routing_id_); | 1549 external_host_bindings_.set_routing_id(routing_id_); |
| 1540 external_host_bindings_.BindToJavascript(frame, L"externalHost"); | 1550 external_host_bindings_.BindToJavascript(frame, L"externalHost"); |
| 1541 } | 1551 } |
| 1542 } | 1552 } |
| 1543 | 1553 |
| 1544 void RenderView::DocumentElementAvailable(WebFrame* frame) { | 1554 void RenderView::DocumentElementAvailable(WebFrame* frame) { |
| 1545 // TODO(mpcomplete): remove this before Chrome extensions ship. | 1555 // TODO(mpcomplete): remove this before Chrome extensions ship. |
| 1546 // HACK. This is a temporary workaround to allow cross-origin XHR for Chrome | 1556 // HACK. This is a temporary workaround to allow cross-origin XHR for Chrome |
| 1547 // extensions. It grants full access to every origin, when we really want | 1557 // extensions. It grants full access to every origin, when we really want |
| 1548 // to be able to restrict them more specifically. | 1558 // to be able to restrict them more specifically. |
| 1549 GURL url = frame->GetURL(); | 1559 GURL url = frame->url(); |
| 1550 if (url.SchemeIs(chrome::kExtensionScheme)) | 1560 if (url.SchemeIs(chrome::kExtensionScheme)) |
| 1551 frame->GrantUniversalAccess(); | 1561 frame->grantUniversalAccess(); |
| 1552 | 1562 |
| 1553 if (RenderThread::current()) // Will be NULL during unit tests. | 1563 if (RenderThread::current()) // Will be NULL during unit tests. |
| 1554 RenderThread::current()->user_script_slave()->InjectScripts( | 1564 RenderThread::current()->user_script_slave()->InjectScripts( |
| 1555 frame, UserScript::DOCUMENT_START); | 1565 frame, UserScript::DOCUMENT_START); |
| 1556 | 1566 |
| 1557 // Notify the browser about non-blank documents loading in the top frame. | 1567 // Notify the browser about non-blank documents loading in the top frame. |
| 1558 if (url.is_valid() && url.spec() != "about:blank") { | 1568 if (url.is_valid() && url.spec() != "about:blank") { |
| 1559 if (frame == webview()->GetMainFrame()) | 1569 if (frame == webview()->GetMainFrame()) |
| 1560 Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_)); | 1570 Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_)); |
| 1561 } | 1571 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1586 const GURL& url = request.url(); | 1596 const GURL& url = request.url(); |
| 1587 | 1597 |
| 1588 // If the browser is interested, then give it a chance to look at top level | 1598 // If the browser is interested, then give it a chance to look at top level |
| 1589 // navigations | 1599 // navigations |
| 1590 if (renderer_preferences_.browser_handles_top_level_requests && | 1600 if (renderer_preferences_.browser_handles_top_level_requests && |
| 1591 // Only send once. | 1601 // Only send once. |
| 1592 last_top_level_navigation_page_id_ != page_id_ && | 1602 last_top_level_navigation_page_id_ != page_id_ && |
| 1593 // Not interested in reloads. | 1603 // Not interested in reloads. |
| 1594 type != WebKit::WebNavigationTypeReload && | 1604 type != WebKit::WebNavigationTypeReload && |
| 1595 // Must be a top level frame. | 1605 // Must be a top level frame. |
| 1596 frame->GetParent() == NULL) { | 1606 frame->parent() == NULL) { |
| 1597 // Skip if navigation is on the same page (using '#'). | 1607 // Skip if navigation is on the same page (using '#'). |
| 1598 GURL frame_origin = frame->GetURL().GetOrigin(); | 1608 GURL frame_origin = GURL(frame->url()).GetOrigin(); |
| 1599 if (url.GetOrigin() != frame_origin || url.ref().empty()) { | 1609 if (url.GetOrigin() != frame_origin || url.ref().empty()) { |
| 1600 last_top_level_navigation_page_id_ = page_id_; | 1610 last_top_level_navigation_page_id_ = page_id_; |
| 1601 OpenURL(webview, url, GURL(), default_policy); | 1611 OpenURL(webview, url, GURL(), default_policy); |
| 1602 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. | 1612 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
| 1603 } | 1613 } |
| 1604 } | 1614 } |
| 1605 | 1615 |
| 1606 // A content initiated navigation may have originated from a link-click, | 1616 // A content initiated navigation may have originated from a link-click, |
| 1607 // script, drag-n-drop operation, etc. | 1617 // script, drag-n-drop operation, etc. |
| 1608 bool is_content_initiated = | 1618 bool is_content_initiated = |
| 1609 NavigationState::FromDataSource(frame->GetProvisionalDataSource())-> | 1619 NavigationState::FromDataSource(frame->provisionalDataSource())-> |
| 1610 is_content_initiated(); | 1620 is_content_initiated(); |
| 1611 | 1621 |
| 1612 // We only care about navigations that are within the current tab (as opposed | 1622 // We only care about navigations that are within the current tab (as opposed |
| 1613 // to, for example, opening a new window). | 1623 // to, for example, opening a new window). |
| 1614 // But we sometimes navigate to about:blank to clear a tab, and we want to | 1624 // But we sometimes navigate to about:blank to clear a tab, and we want to |
| 1615 // still allow that. | 1625 // still allow that. |
| 1616 if (default_policy == WebKit::WebNavigationPolicyCurrentTab && | 1626 if (default_policy == WebKit::WebNavigationPolicyCurrentTab && |
| 1617 is_content_initiated && frame->GetParent() == NULL && | 1627 is_content_initiated && frame->parent() == NULL && |
| 1618 !url.SchemeIs(chrome::kAboutScheme)) { | 1628 !url.SchemeIs(chrome::kAboutScheme)) { |
| 1619 // When we received such unsolicited navigations, we sometimes want to | 1629 // When we received such unsolicited navigations, we sometimes want to |
| 1620 // punt them up to the browser to handle. | 1630 // punt them up to the browser to handle. |
| 1621 if (BindingsPolicy::is_dom_ui_enabled(enabled_bindings_) || | 1631 if (BindingsPolicy::is_dom_ui_enabled(enabled_bindings_) || |
| 1622 BindingsPolicy::is_extension_enabled(enabled_bindings_) || | 1632 BindingsPolicy::is_extension_enabled(enabled_bindings_) || |
| 1623 frame->GetInViewSourceMode() || | 1633 frame->isViewSourceModeEnabled() || |
| 1624 url.SchemeIs(chrome::kViewSourceScheme) || | 1634 url.SchemeIs(chrome::kViewSourceScheme) || |
| 1625 url.SchemeIs(chrome::kPrintScheme)) { | 1635 url.SchemeIs(chrome::kPrintScheme)) { |
| 1626 OpenURL(webview, url, GURL(), default_policy); | 1636 OpenURL(webview, url, GURL(), default_policy); |
| 1627 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. | 1637 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
| 1628 } | 1638 } |
| 1629 } | 1639 } |
| 1630 | 1640 |
| 1631 // Detect when a page is "forking" a new tab that can be safely rendered in | 1641 // Detect when a page is "forking" a new tab that can be safely rendered in |
| 1632 // its own process. This is done by sites like Gmail that try to open links | 1642 // its own process. This is done by sites like Gmail that try to open links |
| 1633 // in new windows without script connections back to the original page. We | 1643 // in new windows without script connections back to the original page. We |
| 1634 // treat such cases as browser navigations (in which we will create a new | 1644 // treat such cases as browser navigations (in which we will create a new |
| 1635 // renderer for a cross-site navigation), rather than WebKit navigations. | 1645 // renderer for a cross-site navigation), rather than WebKit navigations. |
| 1636 // | 1646 // |
| 1637 // We use the following heuristic to decide whether to fork a new page in its | 1647 // We use the following heuristic to decide whether to fork a new page in its |
| 1638 // own process: | 1648 // own process: |
| 1639 // The parent page must open a new tab to about:blank, set the new tab's | 1649 // The parent page must open a new tab to about:blank, set the new tab's |
| 1640 // window.opener to null, and then redirect the tab to a cross-site URL using | 1650 // window.opener to null, and then redirect the tab to a cross-site URL using |
| 1641 // JavaScript. | 1651 // JavaScript. |
| 1642 bool is_fork = | 1652 bool is_fork = |
| 1643 // Must start from a tab showing about:blank, which is later redirected. | 1653 // Must start from a tab showing about:blank, which is later redirected. |
| 1644 frame->GetURL() == GURL("about:blank") && | 1654 GURL(frame->url()) == GURL("about:blank") && |
| 1645 // Must be the first real navigation of the tab. | 1655 // Must be the first real navigation of the tab. |
| 1646 GetHistoryBackListCount() < 1 && | 1656 GetHistoryBackListCount() < 1 && |
| 1647 GetHistoryForwardListCount() < 1 && | 1657 GetHistoryForwardListCount() < 1 && |
| 1648 // The parent page must have set the child's window.opener to null before | 1658 // The parent page must have set the child's window.opener to null before |
| 1649 // redirecting to the desired URL. | 1659 // redirecting to the desired URL. |
| 1650 frame->GetOpener() == NULL && | 1660 frame->opener() == NULL && |
| 1651 // Must be a top-level frame. | 1661 // Must be a top-level frame. |
| 1652 frame->GetParent() == NULL && | 1662 frame->parent() == NULL && |
| 1653 // Must not have issued the request from this page. | 1663 // Must not have issued the request from this page. |
| 1654 is_content_initiated && | 1664 is_content_initiated && |
| 1655 // Must be targeted at the current tab. | 1665 // Must be targeted at the current tab. |
| 1656 default_policy == WebKit::WebNavigationPolicyCurrentTab && | 1666 default_policy == WebKit::WebNavigationPolicyCurrentTab && |
| 1657 // Must be a JavaScript navigation, which appears as "other". | 1667 // Must be a JavaScript navigation, which appears as "other". |
| 1658 type == WebKit::WebNavigationTypeOther; | 1668 type == WebKit::WebNavigationTypeOther; |
| 1659 if (is_fork) { | 1669 if (is_fork) { |
| 1660 // Open the URL via the browser, not via WebKit. | 1670 // Open the URL via the browser, not via WebKit. |
| 1661 OpenURL(webview, url, GURL(), default_policy); | 1671 OpenURL(webview, url, GURL(), default_policy); |
| 1662 return WebKit::WebNavigationPolicyIgnore; | 1672 return WebKit::WebNavigationPolicyIgnore; |
| 1663 } | 1673 } |
| 1664 | 1674 |
| 1665 return default_policy; | 1675 return default_policy; |
| 1666 } | 1676 } |
| 1667 | 1677 |
| 1668 void RenderView::RunJavaScriptAlert(WebFrame* webframe, | 1678 void RenderView::RunJavaScriptAlert(WebFrame* webframe, |
| 1669 const std::wstring& message) { | 1679 const std::wstring& message) { |
| 1670 RunJavaScriptMessage(MessageBoxFlags::kIsJavascriptAlert, | 1680 RunJavaScriptMessage(MessageBoxFlags::kIsJavascriptAlert, |
| 1671 message, | 1681 message, |
| 1672 std::wstring(), | 1682 std::wstring(), |
| 1673 webframe->GetURL(), | 1683 webframe->url(), |
| 1674 NULL); | 1684 NULL); |
| 1675 } | 1685 } |
| 1676 | 1686 |
| 1677 bool RenderView::RunJavaScriptConfirm(WebFrame* webframe, | 1687 bool RenderView::RunJavaScriptConfirm(WebFrame* webframe, |
| 1678 const std::wstring& message) { | 1688 const std::wstring& message) { |
| 1679 return RunJavaScriptMessage(MessageBoxFlags::kIsJavascriptConfirm, | 1689 return RunJavaScriptMessage(MessageBoxFlags::kIsJavascriptConfirm, |
| 1680 message, | 1690 message, |
| 1681 std::wstring(), | 1691 std::wstring(), |
| 1682 webframe->GetURL(), | 1692 webframe->url(), |
| 1683 NULL); | 1693 NULL); |
| 1684 } | 1694 } |
| 1685 | 1695 |
| 1686 bool RenderView::RunJavaScriptPrompt(WebFrame* webframe, | 1696 bool RenderView::RunJavaScriptPrompt(WebFrame* webframe, |
| 1687 const std::wstring& message, | 1697 const std::wstring& message, |
| 1688 const std::wstring& default_value, | 1698 const std::wstring& default_value, |
| 1689 std::wstring* result) { | 1699 std::wstring* result) { |
| 1690 return RunJavaScriptMessage(MessageBoxFlags::kIsJavascriptPrompt, | 1700 return RunJavaScriptMessage(MessageBoxFlags::kIsJavascriptPrompt, |
| 1691 message, | 1701 message, |
| 1692 default_value, | 1702 default_value, |
| 1693 webframe->GetURL(), | 1703 webframe->url(), |
| 1694 result); | 1704 result); |
| 1695 } | 1705 } |
| 1696 | 1706 |
| 1697 bool RenderView::RunJavaScriptMessage(int type, | 1707 bool RenderView::RunJavaScriptMessage(int type, |
| 1698 const std::wstring& message, | 1708 const std::wstring& message, |
| 1699 const std::wstring& default_value, | 1709 const std::wstring& default_value, |
| 1700 const GURL& frame_url, | 1710 const GURL& frame_url, |
| 1701 std::wstring* result) { | 1711 std::wstring* result) { |
| 1702 bool success = false; | 1712 bool success = false; |
| 1703 std::wstring result_temp; | 1713 std::wstring result_temp; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1718 autodetected)); | 1728 autodetected)); |
| 1719 } | 1729 } |
| 1720 | 1730 |
| 1721 bool RenderView::RunBeforeUnloadConfirm(WebFrame* webframe, | 1731 bool RenderView::RunBeforeUnloadConfirm(WebFrame* webframe, |
| 1722 const std::wstring& message) { | 1732 const std::wstring& message) { |
| 1723 bool success = false; | 1733 bool success = false; |
| 1724 // This is an ignored return value, but is included so we can accept the same | 1734 // This is an ignored return value, but is included so we can accept the same |
| 1725 // response as RunJavaScriptMessage. | 1735 // response as RunJavaScriptMessage. |
| 1726 std::wstring ignored_result; | 1736 std::wstring ignored_result; |
| 1727 IPC::SyncMessage* msg = new ViewHostMsg_RunBeforeUnloadConfirm( | 1737 IPC::SyncMessage* msg = new ViewHostMsg_RunBeforeUnloadConfirm( |
| 1728 routing_id_, webframe->GetURL(), message, &success, &ignored_result); | 1738 routing_id_, webframe->url(), message, &success, &ignored_result); |
| 1729 | 1739 |
| 1730 msg->set_pump_messages_event(modal_dialog_event_.get()); | 1740 msg->set_pump_messages_event(modal_dialog_event_.get()); |
| 1731 Send(msg); | 1741 Send(msg); |
| 1732 | 1742 |
| 1733 return success; | 1743 return success; |
| 1734 } | 1744 } |
| 1735 | 1745 |
| 1736 void RenderView::QueryFormFieldAutofill(const std::wstring& field_name, | 1746 void RenderView::QueryFormFieldAutofill(const std::wstring& field_name, |
| 1737 const std::wstring& text, | 1747 const std::wstring& text, |
| 1738 int64 node_id) { | 1748 int64 node_id) { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1896 WebView* webview, | 1906 WebView* webview, |
| 1897 const GURL& url, | 1907 const GURL& url, |
| 1898 const std::string& mime_type, | 1908 const std::string& mime_type, |
| 1899 const std::string& clsid, | 1909 const std::string& clsid, |
| 1900 std::string* actual_mime_type) { | 1910 std::string* actual_mime_type) { |
| 1901 if (!PluginChannelHost::IsListening()) | 1911 if (!PluginChannelHost::IsListening()) |
| 1902 return NULL; | 1912 return NULL; |
| 1903 | 1913 |
| 1904 GURL policy_url; | 1914 GURL policy_url; |
| 1905 if (webview->GetMainFrame()) | 1915 if (webview->GetMainFrame()) |
| 1906 policy_url = webview->GetMainFrame()->GetURL(); | 1916 policy_url = webview->GetMainFrame()->url(); |
| 1907 | 1917 |
| 1908 FilePath path; | 1918 FilePath path; |
| 1909 render_thread_->Send( | 1919 render_thread_->Send( |
| 1910 new ViewHostMsg_GetPluginPath(url, policy_url, mime_type, clsid, &path, | 1920 new ViewHostMsg_GetPluginPath(url, policy_url, mime_type, clsid, &path, |
| 1911 actual_mime_type)); | 1921 actual_mime_type)); |
| 1912 if (path.value().empty()) | 1922 if (path.value().empty()) |
| 1913 return NULL; | 1923 return NULL; |
| 1914 | 1924 |
| 1915 std::string mime_type_to_use; | 1925 std::string mime_type_to_use; |
| 1916 if (!actual_mime_type->empty()) | 1926 if (!actual_mime_type->empty()) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2015 // message. | 2025 // message. |
| 2016 // TODO(rafaelw): Figure out where the best place to set this for extensions | 2026 // TODO(rafaelw): Figure out where the best place to set this for extensions |
| 2017 // is. It isn't clean to test for ExtensionView by examining the | 2027 // is. It isn't clean to test for ExtensionView by examining the |
| 2018 // enabled_bindings. This needs to be generalized as it becomes clear what | 2028 // enabled_bindings. This needs to be generalized as it becomes clear what |
| 2019 // extension toolbars need. | 2029 // extension toolbars need. |
| 2020 if (BindingsPolicy::is_extension_enabled(enabled_bindings_) || | 2030 if (BindingsPolicy::is_extension_enabled(enabled_bindings_) || |
| 2021 send_preferred_width_changes_) { | 2031 send_preferred_width_changes_) { |
| 2022 // WebCore likes to tell us things have changed even when they haven't, so | 2032 // WebCore likes to tell us things have changed even when they haven't, so |
| 2023 // cache the width and only send the IPC message when we're sure the | 2033 // cache the width and only send the IPC message when we're sure the |
| 2024 // width is different. | 2034 // width is different. |
| 2025 int width = webview()->GetMainFrame()->GetContentsPreferredWidth(); | 2035 int width = webview()->GetMainFrame()->contentsPreferredWidth(); |
| 2026 if (width != preferred_width_) { | 2036 if (width != preferred_width_) { |
| 2027 Send(new ViewHostMsg_DidContentsPreferredWidthChange(routing_id_, width)); | 2037 Send(new ViewHostMsg_DidContentsPreferredWidthChange(routing_id_, width)); |
| 2028 preferred_width_ = width; | 2038 preferred_width_ = width; |
| 2029 } | 2039 } |
| 2030 } | 2040 } |
| 2031 } | 2041 } |
| 2032 | 2042 |
| 2033 // We are supposed to get a single call to Show for a newly created RenderView | 2043 // We are supposed to get a single call to Show for a newly created RenderView |
| 2034 // that was created via RenderView::CreateWebView. So, we wait until this | 2044 // that was created via RenderView::CreateWebView. So, we wait until this |
| 2035 // point to dispatch the ShowView message. | 2045 // point to dispatch the ShowView message. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2065 IPC::SyncMessage* msg = new ViewHostMsg_RunModal(routing_id_); | 2075 IPC::SyncMessage* msg = new ViewHostMsg_RunModal(routing_id_); |
| 2066 | 2076 |
| 2067 msg->set_pump_messages_event(modal_dialog_event_.get()); | 2077 msg->set_pump_messages_event(modal_dialog_event_.get()); |
| 2068 Send(msg); | 2078 Send(msg); |
| 2069 } | 2079 } |
| 2070 | 2080 |
| 2071 void RenderView::SyncNavigationState() { | 2081 void RenderView::SyncNavigationState() { |
| 2072 if (!webview()) | 2082 if (!webview()) |
| 2073 return; | 2083 return; |
| 2074 | 2084 |
| 2075 const WebHistoryItem& item = | 2085 const WebHistoryItem& item = webview()->GetMainFrame()->currentHistoryItem(); |
| 2076 webview()->GetMainFrame()->GetCurrentHistoryItem(); | |
| 2077 if (item.isNull()) | 2086 if (item.isNull()) |
| 2078 return; | 2087 return; |
| 2079 | 2088 |
| 2080 Send(new ViewHostMsg_UpdateState( | 2089 Send(new ViewHostMsg_UpdateState( |
| 2081 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); | 2090 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); |
| 2082 } | 2091 } |
| 2083 | 2092 |
| 2084 void RenderView::ShowContextMenu(WebView* webview, | 2093 void RenderView::ShowContextMenu(WebView* webview, |
| 2085 ContextNodeType node_type, | 2094 ContextNodeType node_type, |
| 2086 int x, | 2095 int x, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2101 params.y = y; | 2110 params.y = y; |
| 2102 params.src_url = src_url; | 2111 params.src_url = src_url; |
| 2103 params.link_url = link_url; | 2112 params.link_url = link_url; |
| 2104 params.unfiltered_link_url = link_url; | 2113 params.unfiltered_link_url = link_url; |
| 2105 params.page_url = page_url; | 2114 params.page_url = page_url; |
| 2106 params.frame_url = frame_url; | 2115 params.frame_url = frame_url; |
| 2107 params.media_params = media_params; | 2116 params.media_params = media_params; |
| 2108 params.selection_text = selection_text; | 2117 params.selection_text = selection_text; |
| 2109 params.misspelled_word = misspelled_word; | 2118 params.misspelled_word = misspelled_word; |
| 2110 params.spellcheck_enabled = | 2119 params.spellcheck_enabled = |
| 2111 webview->GetFocusedFrame()->SpellCheckEnabled(); | 2120 webview->GetFocusedFrame()->isContinuousSpellCheckingEnabled(); |
| 2112 params.edit_flags = edit_flags; | 2121 params.edit_flags = edit_flags; |
| 2113 params.security_info = security_info; | 2122 params.security_info = security_info; |
| 2114 params.frame_charset = frame_charset; | 2123 params.frame_charset = frame_charset; |
| 2115 Send(new ViewHostMsg_ContextMenu(routing_id_, params)); | 2124 Send(new ViewHostMsg_ContextMenu(routing_id_, params)); |
| 2116 } | 2125 } |
| 2117 | 2126 |
| 2118 void RenderView::StartDragging(WebView* webview, | 2127 void RenderView::StartDragging(WebView* webview, |
| 2119 const WebDragData& drag_data) { | 2128 const WebDragData& drag_data) { |
| 2120 Send(new ViewHostMsg_StartDragging(routing_id_, WebDropData(drag_data))); | 2129 Send(new ViewHostMsg_StartDragging(routing_id_, WebDropData(drag_data))); |
| 2121 } | 2130 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2248 bool multi_frame = (frame_after_main != main_frame); | 2257 bool multi_frame = (frame_after_main != main_frame); |
| 2249 | 2258 |
| 2250 // If we have multiple frames, we don't want to wrap the search within the | 2259 // If we have multiple frames, we don't want to wrap the search within the |
| 2251 // frame, so we check here if we only have main_frame in the chain. | 2260 // frame, so we check here if we only have main_frame in the chain. |
| 2252 bool wrap_within_frame = !multi_frame; | 2261 bool wrap_within_frame = !multi_frame; |
| 2253 | 2262 |
| 2254 WebRect selection_rect; | 2263 WebRect selection_rect; |
| 2255 bool result = false; | 2264 bool result = false; |
| 2256 | 2265 |
| 2257 do { | 2266 do { |
| 2258 result = search_frame->Find( | 2267 result = search_frame->find( |
| 2259 request_id, search_text, options, wrap_within_frame, &selection_rect); | 2268 request_id, search_text, options, wrap_within_frame, &selection_rect); |
| 2260 | 2269 |
| 2261 if (!result) { | 2270 if (!result) { |
| 2262 // don't leave text selected as you move to the next frame. | 2271 // don't leave text selected as you move to the next frame. |
| 2263 search_frame->ClearSelection(); | 2272 search_frame->clearSelection(); |
| 2264 | 2273 |
| 2265 // Find the next frame, but skip the invisible ones. | 2274 // Find the next frame, but skip the invisible ones. |
| 2266 do { | 2275 do { |
| 2267 // What is the next frame to search? (we might be going backwards). Note | 2276 // What is the next frame to search? (we might be going backwards). Note |
| 2268 // that we specify wrap=true so that search_frame never becomes NULL. | 2277 // that we specify wrap=true so that search_frame never becomes NULL. |
| 2269 search_frame = options.forward ? | 2278 search_frame = options.forward ? |
| 2270 webview()->GetNextFrameAfter(search_frame, true) : | 2279 webview()->GetNextFrameAfter(search_frame, true) : |
| 2271 webview()->GetPreviousFrameBefore(search_frame, true); | 2280 webview()->GetPreviousFrameBefore(search_frame, true); |
| 2272 } while (!search_frame->Visible() && search_frame != focused_frame); | 2281 } while (!search_frame->hasVisibleContent() && |
| 2282 search_frame != focused_frame); |
| 2273 | 2283 |
| 2274 // Make sure selection doesn't affect the search operation in new frame. | 2284 // Make sure selection doesn't affect the search operation in new frame. |
| 2275 search_frame->ClearSelection(); | 2285 search_frame->clearSelection(); |
| 2276 | 2286 |
| 2277 // If we have multiple frames and we have wrapped back around to the | 2287 // If we have multiple frames and we have wrapped back around to the |
| 2278 // focused frame, we need to search it once more allowing wrap within | 2288 // focused frame, we need to search it once more allowing wrap within |
| 2279 // the frame, otherwise it will report 'no match' if the focused frame has | 2289 // the frame, otherwise it will report 'no match' if the focused frame has |
| 2280 // reported matches, but no frames after the focused_frame contain a | 2290 // reported matches, but no frames after the focused_frame contain a |
| 2281 // match for the search word(s). | 2291 // match for the search word(s). |
| 2282 if (multi_frame && search_frame == focused_frame) { | 2292 if (multi_frame && search_frame == focused_frame) { |
| 2283 result = search_frame->Find( | 2293 result = search_frame->find( |
| 2284 request_id, search_text, options, true, // Force wrapping. | 2294 request_id, search_text, options, true, // Force wrapping. |
| 2285 &selection_rect); | 2295 &selection_rect); |
| 2286 } | 2296 } |
| 2287 } | 2297 } |
| 2288 | 2298 |
| 2289 webview()->SetFocusedFrame(search_frame); | 2299 webview()->SetFocusedFrame(search_frame); |
| 2290 } while (!result && search_frame != focused_frame); | 2300 } while (!result && search_frame != focused_frame); |
| 2291 | 2301 |
| 2292 if (options.findNext) { | 2302 if (options.findNext) { |
| 2293 // Force the main_frame to report the actual count. | 2303 // Force the main_frame to report the actual count. |
| 2294 main_frame->IncreaseMatchCount(0, request_id); | 2304 main_frame->increaseMatchCount(0, request_id); |
| 2295 } else { | 2305 } else { |
| 2296 // If nothing is found, set result to "0 of 0", otherwise, set it to | 2306 // If nothing is found, set result to "0 of 0", otherwise, set it to |
| 2297 // "-1 of 1" to indicate that we found at least one item, but we don't know | 2307 // "-1 of 1" to indicate that we found at least one item, but we don't know |
| 2298 // yet what is active. | 2308 // yet what is active. |
| 2299 int ordinal = result ? -1 : 0; // -1 here means, we might know more later. | 2309 int ordinal = result ? -1 : 0; // -1 here means, we might know more later. |
| 2300 int match_count = result ? 1 : 0; // 1 here means possibly more coming. | 2310 int match_count = result ? 1 : 0; // 1 here means possibly more coming. |
| 2301 | 2311 |
| 2302 // If we find no matches then this will be our last status update. | 2312 // If we find no matches then this will be our last status update. |
| 2303 // Otherwise the scoping effort will send more results. | 2313 // Otherwise the scoping effort will send more results. |
| 2304 bool final_status_update = !result; | 2314 bool final_status_update = !result; |
| 2305 | 2315 |
| 2306 // Send the search result over to the browser process. | 2316 // Send the search result over to the browser process. |
| 2307 Send(new ViewHostMsg_Find_Reply(routing_id_, | 2317 Send(new ViewHostMsg_Find_Reply(routing_id_, |
| 2308 request_id, | 2318 request_id, |
| 2309 match_count, | 2319 match_count, |
| 2310 selection_rect, | 2320 selection_rect, |
| 2311 ordinal, | 2321 ordinal, |
| 2312 final_status_update)); | 2322 final_status_update)); |
| 2313 | 2323 |
| 2314 // Scoping effort begins, starting with the mainframe. | 2324 // Scoping effort begins, starting with the mainframe. |
| 2315 search_frame = main_frame; | 2325 search_frame = main_frame; |
| 2316 | 2326 |
| 2317 main_frame->ResetMatchCount(); | 2327 main_frame->resetMatchCount(); |
| 2318 | 2328 |
| 2319 do { | 2329 do { |
| 2320 // Cancel all old scoping requests before starting a new one. | 2330 // Cancel all old scoping requests before starting a new one. |
| 2321 search_frame->CancelPendingScopingEffort(); | 2331 search_frame->cancelPendingScopingEffort(); |
| 2322 | 2332 |
| 2323 // We don't start another scoping effort unless at least one match has | 2333 // We don't start another scoping effort unless at least one match has |
| 2324 // been found. | 2334 // been found. |
| 2325 if (result) { | 2335 if (result) { |
| 2326 // Start new scoping request. If the scoping function determines that it | 2336 // Start new scoping request. If the scoping function determines that it |
| 2327 // needs to scope, it will defer until later. | 2337 // needs to scope, it will defer until later. |
| 2328 search_frame->ScopeStringMatches(request_id, | 2338 search_frame->scopeStringMatches(request_id, |
| 2329 search_text, | 2339 search_text, |
| 2330 options, | 2340 options, |
| 2331 true); // reset the tickmarks | 2341 true); // reset the tickmarks |
| 2332 } | 2342 } |
| 2333 | 2343 |
| 2334 // Iterate to the next frame. The frame will not necessarily scope, for | 2344 // Iterate to the next frame. The frame will not necessarily scope, for |
| 2335 // example if it is not visible. | 2345 // example if it is not visible. |
| 2336 search_frame = webview()->GetNextFrameAfter(search_frame, true); | 2346 search_frame = webview()->GetNextFrameAfter(search_frame, true); |
| 2337 } while (search_frame != main_frame); | 2347 } while (search_frame != main_frame); |
| 2338 } | 2348 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2455 break; | 2465 break; |
| 2456 default: | 2466 default: |
| 2457 NOTREACHED(); | 2467 NOTREACHED(); |
| 2458 } | 2468 } |
| 2459 } | 2469 } |
| 2460 | 2470 |
| 2461 void RenderView::OnInsertText(const string16& text) { | 2471 void RenderView::OnInsertText(const string16& text) { |
| 2462 WebFrame* frame = webview()->GetFocusedFrame(); | 2472 WebFrame* frame = webview()->GetFocusedFrame(); |
| 2463 if (!frame) | 2473 if (!frame) |
| 2464 return; | 2474 return; |
| 2465 WebTextInput* text_input = frame->GetTextInput(); | 2475 frame->insertText(text); |
| 2466 if (text_input) | |
| 2467 text_input->InsertText(text); | |
| 2468 } | 2476 } |
| 2469 | 2477 |
| 2470 void RenderView::OnSetPageEncoding(const std::wstring& encoding_name) { | 2478 void RenderView::OnSetPageEncoding(const std::wstring& encoding_name) { |
| 2471 webview()->SetPageEncoding(encoding_name); | 2479 webview()->SetPageEncoding(encoding_name); |
| 2472 } | 2480 } |
| 2473 | 2481 |
| 2474 void RenderView::NavigateBackForwardSoon(int offset) { | 2482 void RenderView::NavigateBackForwardSoon(int offset) { |
| 2475 history_back_list_count_ += offset; | 2483 history_back_list_count_ += offset; |
| 2476 history_forward_list_count_ -= offset; | 2484 history_forward_list_count_ -= offset; |
| 2477 | 2485 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2503 | 2511 |
| 2504 void RenderView::DidChangeSelection(bool is_empty_selection) { | 2512 void RenderView::DidChangeSelection(bool is_empty_selection) { |
| 2505 #if defined(OS_LINUX) | 2513 #if defined(OS_LINUX) |
| 2506 // TODO(estade): investigate incremental updates to the selection so that we | 2514 // TODO(estade): investigate incremental updates to the selection so that we |
| 2507 // don't send the entire selection over IPC every time. | 2515 // don't send the entire selection over IPC every time. |
| 2508 if (!is_empty_selection) { | 2516 if (!is_empty_selection) { |
| 2509 // Sometimes we get repeated DidChangeSelection calls from webkit when | 2517 // Sometimes we get repeated DidChangeSelection calls from webkit when |
| 2510 // the selection hasn't actually changed. We don't want to report these | 2518 // the selection hasn't actually changed. We don't want to report these |
| 2511 // because it will cause us to continually claim the X clipboard. | 2519 // because it will cause us to continually claim the X clipboard. |
| 2512 const std::string& this_selection = | 2520 const std::string& this_selection = |
| 2513 webview()->GetFocusedFrame()->GetSelection(false); | 2521 webview()->GetFocusedFrame()->selectionAsText().utf8(); |
| 2514 if (this_selection == last_selection_) | 2522 if (this_selection == last_selection_) |
| 2515 return; | 2523 return; |
| 2516 | 2524 |
| 2517 Send(new ViewHostMsg_SelectionChanged(routing_id_, | 2525 Send(new ViewHostMsg_SelectionChanged(routing_id_, |
| 2518 this_selection)); | 2526 this_selection)); |
| 2519 last_selection_ = this_selection; | 2527 last_selection_ = this_selection; |
| 2520 } else { | 2528 } else { |
| 2521 last_selection_.clear(); | 2529 last_selection_.clear(); |
| 2522 } | 2530 } |
| 2523 #endif | 2531 #endif |
| 2524 } | 2532 } |
| 2525 | 2533 |
| 2526 void RenderView::DownloadUrl(const GURL& url, const GURL& referrer) { | 2534 void RenderView::DownloadUrl(const GURL& url, const GURL& referrer) { |
| 2527 Send(new ViewHostMsg_DownloadUrl(routing_id_, url, referrer)); | 2535 Send(new ViewHostMsg_DownloadUrl(routing_id_, url, referrer)); |
| 2528 } | 2536 } |
| 2529 | 2537 |
| 2530 void RenderView::UpdateInspectorSettings(const std::wstring& raw_settings) { | 2538 void RenderView::UpdateInspectorSettings(const std::wstring& raw_settings) { |
| 2531 Send(new ViewHostMsg_UpdateInspectorSettings(routing_id_, raw_settings)); | 2539 Send(new ViewHostMsg_UpdateInspectorSettings(routing_id_, raw_settings)); |
| 2532 } | 2540 } |
| 2533 | 2541 |
| 2534 WebDevToolsAgentDelegate* RenderView::GetWebDevToolsAgentDelegate() { | 2542 WebDevToolsAgentDelegate* RenderView::GetWebDevToolsAgentDelegate() { |
| 2535 return devtools_agent_.get(); | 2543 return devtools_agent_.get(); |
| 2536 } | 2544 } |
| 2537 | 2545 |
| 2538 void RenderView::PasteFromSelectionClipboard() { | 2546 void RenderView::PasteFromSelectionClipboard() { |
| 2539 Send(new ViewHostMsg_PasteFromSelectionClipboard(routing_id_)); | 2547 Send(new ViewHostMsg_PasteFromSelectionClipboard(routing_id_)); |
| 2540 } | 2548 } |
| 2541 | 2549 |
| 2542 WebFrame* RenderView::GetChildFrame(const std::wstring& frame_xpath) const { | 2550 WebFrame* RenderView::GetChildFrame(const std::wstring& xpath) const { |
| 2543 WebFrame* web_frame; | 2551 if (xpath.empty()) |
| 2544 if (frame_xpath.empty()) { | 2552 return webview()->GetMainFrame(); |
| 2545 web_frame = webview()->GetMainFrame(); | 2553 |
| 2546 } else { | 2554 // xpath string can represent a frame deep down the tree (across multiple |
| 2547 web_frame = webview()->GetMainFrame()->GetChildFrame(frame_xpath); | 2555 // frame DOMs). |
| 2556 // Example, /html/body/table/tbody/tr/td/iframe\n/frameset/frame[0] |
| 2557 // should break into 2 xpaths |
| 2558 // /html/body/table/tbody/tr/td/iframe & /frameset/frame[0] |
| 2559 |
| 2560 WebFrame* frame = webview()->GetMainFrame(); |
| 2561 |
| 2562 std::wstring xpath_remaining = xpath; |
| 2563 while (!xpath_remaining.empty()) { |
| 2564 std::wstring::size_type delim_pos = xpath_remaining.find_first_of(L'\n'); |
| 2565 std::wstring xpath_child; |
| 2566 if (delim_pos != std::wstring::npos) { |
| 2567 xpath_child = xpath_remaining.substr(0, delim_pos); |
| 2568 xpath_remaining.erase(0, delim_pos + 1); |
| 2569 } else { |
| 2570 xpath_remaining.swap(xpath_child); |
| 2571 } |
| 2572 frame = frame->findChildByExpression(WideToUTF16Hack(xpath_child)); |
| 2548 } | 2573 } |
| 2549 | 2574 |
| 2550 return web_frame; | 2575 return frame; |
| 2551 } | 2576 } |
| 2552 | 2577 |
| 2553 void RenderView::EvaluateScript(const std::wstring& frame_xpath, | 2578 void RenderView::EvaluateScript(const std::wstring& frame_xpath, |
| 2554 const std::wstring& script) { | 2579 const std::wstring& script) { |
| 2555 WebFrame* web_frame = GetChildFrame(frame_xpath); | 2580 WebFrame* web_frame = GetChildFrame(frame_xpath); |
| 2556 if (!web_frame) | 2581 if (!web_frame) |
| 2557 return; | 2582 return; |
| 2558 | 2583 |
| 2559 web_frame->ExecuteScript(WebScriptSource(WideToUTF16Hack(script))); | 2584 web_frame->executeScript(WebScriptSource(WideToUTF16Hack(script))); |
| 2560 } | 2585 } |
| 2561 | 2586 |
| 2562 void RenderView::InsertCSS(const std::wstring& frame_xpath, | 2587 void RenderView::InsertCSS(const std::wstring& frame_xpath, |
| 2563 const std::string& css) { | 2588 const std::string& css) { |
| 2564 WebFrame* web_frame = GetChildFrame(frame_xpath); | 2589 WebFrame* web_frame = GetChildFrame(frame_xpath); |
| 2565 if (!web_frame) | 2590 if (!web_frame) |
| 2566 return; | 2591 return; |
| 2567 | 2592 |
| 2568 web_frame->InsertCSSStyles(css); | 2593 web_frame->insertStyleText(WebString::fromUTF8(css)); |
| 2569 } | 2594 } |
| 2570 | 2595 |
| 2571 void RenderView::OnScriptEvalRequest(const std::wstring& frame_xpath, | 2596 void RenderView::OnScriptEvalRequest(const std::wstring& frame_xpath, |
| 2572 const std::wstring& jscript) { | 2597 const std::wstring& jscript) { |
| 2573 EvaluateScript(frame_xpath, jscript); | 2598 EvaluateScript(frame_xpath, jscript); |
| 2574 } | 2599 } |
| 2575 | 2600 |
| 2576 void RenderView::OnCSSInsertRequest(const std::wstring& frame_xpath, | 2601 void RenderView::OnCSSInsertRequest(const std::wstring& frame_xpath, |
| 2577 const std::string& css) { | 2602 const std::string& css) { |
| 2578 InsertCSS(frame_xpath, css); | 2603 InsertCSS(frame_xpath, css); |
| 2579 | 2604 |
| 2580 // Notify RenderViewHost that css has been inserted into the frame. | 2605 // Notify RenderViewHost that css has been inserted into the frame. |
| 2581 Send(new ViewHostMsg_OnCSSInserted(routing_id_)); | 2606 Send(new ViewHostMsg_OnCSSInserted(routing_id_)); |
| 2582 } | 2607 } |
| 2583 | 2608 |
| 2584 void RenderView::OnAddMessageToConsole( | 2609 void RenderView::OnAddMessageToConsole( |
| 2585 const string16& frame_xpath, | 2610 const string16& frame_xpath, |
| 2586 const string16& message, | 2611 const string16& message, |
| 2587 const WebConsoleMessage::Level& level) { | 2612 const WebConsoleMessage::Level& level) { |
| 2588 WebFrame* web_frame = GetChildFrame(UTF16ToWideHack(frame_xpath)); | 2613 WebFrame* web_frame = GetChildFrame(UTF16ToWideHack(frame_xpath)); |
| 2589 if (web_frame) | 2614 if (web_frame) |
| 2590 web_frame->AddMessageToConsole(WebConsoleMessage(level, message)); | 2615 web_frame->addMessageToConsole(WebConsoleMessage(level, message)); |
| 2591 } | 2616 } |
| 2592 | 2617 |
| 2593 void RenderView::OnAllowBindings(int enabled_bindings_flags) { | 2618 void RenderView::OnAllowBindings(int enabled_bindings_flags) { |
| 2594 enabled_bindings_ |= enabled_bindings_flags; | 2619 enabled_bindings_ |= enabled_bindings_flags; |
| 2595 } | 2620 } |
| 2596 | 2621 |
| 2597 void RenderView::OnSetDOMUIProperty(const std::string& name, | 2622 void RenderView::OnSetDOMUIProperty(const std::string& name, |
| 2598 const std::string& value) { | 2623 const std::string& value) { |
| 2599 DCHECK(BindingsPolicy::is_dom_ui_enabled(enabled_bindings_)); | 2624 DCHECK(BindingsPolicy::is_dom_ui_enabled(enabled_bindings_)); |
| 2600 dom_ui_bindings_.SetProperty(name, value); | 2625 dom_ui_bindings_.SetProperty(name, value); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2721 file_chooser_.reset(); | 2746 file_chooser_.reset(); |
| 2722 } | 2747 } |
| 2723 | 2748 |
| 2724 void RenderView::OnEnableViewSourceMode() { | 2749 void RenderView::OnEnableViewSourceMode() { |
| 2725 if (!webview()) | 2750 if (!webview()) |
| 2726 return; | 2751 return; |
| 2727 WebFrame* main_frame = webview()->GetMainFrame(); | 2752 WebFrame* main_frame = webview()->GetMainFrame(); |
| 2728 if (!main_frame) | 2753 if (!main_frame) |
| 2729 return; | 2754 return; |
| 2730 | 2755 |
| 2731 main_frame->SetInViewSourceMode(true); | 2756 main_frame->enableViewSourceMode(true); |
| 2732 } | 2757 } |
| 2733 | 2758 |
| 2734 void RenderView::OnEnableIntrinsicWidthChangedMode() { | 2759 void RenderView::OnEnableIntrinsicWidthChangedMode() { |
| 2735 send_preferred_width_changes_ = true; | 2760 send_preferred_width_changes_ = true; |
| 2736 } | 2761 } |
| 2737 | 2762 |
| 2738 void RenderView::OnSetRendererPrefs(const RendererPreferences& renderer_prefs) { | 2763 void RenderView::OnSetRendererPrefs(const RendererPreferences& renderer_prefs) { |
| 2739 renderer_preferences_ = renderer_prefs; | 2764 renderer_preferences_ = renderer_prefs; |
| 2740 UpdateFontRenderingFromRendererPrefs(); | 2765 UpdateFontRenderingFromRendererPrefs(); |
| 2741 } | 2766 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2844 void RenderView::OnClosePage(const ViewMsg_ClosePage_Params& params) { | 2869 void RenderView::OnClosePage(const ViewMsg_ClosePage_Params& params) { |
| 2845 // TODO(creis): We'd rather use webview()->Close() here, but that currently | 2870 // TODO(creis): We'd rather use webview()->Close() here, but that currently |
| 2846 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs | 2871 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs |
| 2847 // in the onunload handler from appearing. For now, we're bypassing that and | 2872 // in the onunload handler from appearing. For now, we're bypassing that and |
| 2848 // calling the FrameLoader's CloseURL method directly. This should be | 2873 // calling the FrameLoader's CloseURL method directly. This should be |
| 2849 // revisited to avoid having two ways to close a page. Having a single way | 2874 // revisited to avoid having two ways to close a page. Having a single way |
| 2850 // to close that can run onunload is also useful for fixing | 2875 // to close that can run onunload is also useful for fixing |
| 2851 // http://b/issue?id=753080. | 2876 // http://b/issue?id=753080. |
| 2852 WebFrame* main_frame = webview()->GetMainFrame(); | 2877 WebFrame* main_frame = webview()->GetMainFrame(); |
| 2853 if (main_frame) { | 2878 if (main_frame) { |
| 2854 const GURL& url = main_frame->GetURL(); | 2879 const GURL& url = main_frame->url(); |
| 2855 // TODO(davemoore) this code should be removed once WillCloseFrame() gets | 2880 // TODO(davemoore) this code should be removed once WillCloseFrame() gets |
| 2856 // called when a page is destroyed. DumpLoadHistograms() is safe to call | 2881 // called when a page is destroyed. DumpLoadHistograms() is safe to call |
| 2857 // multiple times for the same frame, but it will simplify things. | 2882 // multiple times for the same frame, but it will simplify things. |
| 2858 if (url.SchemeIs(chrome::kHttpScheme) || url.SchemeIs(chrome::kHttpsScheme)) | 2883 if (url.SchemeIs(chrome::kHttpScheme) || |
| 2884 url.SchemeIs(chrome::kHttpsScheme)) |
| 2859 DumpLoadHistograms(); | 2885 DumpLoadHistograms(); |
| 2860 } | 2886 } |
| 2861 webview()->ClosePage(); | 2887 webview()->ClosePage(); |
| 2862 | 2888 |
| 2863 // Just echo back the params in the ACK. | 2889 // Just echo back the params in the ACK. |
| 2864 Send(new ViewHostMsg_ClosePage_ACK(routing_id_, params)); | 2890 Send(new ViewHostMsg_ClosePage_ACK(routing_id_, params)); |
| 2865 } | 2891 } |
| 2866 | 2892 |
| 2867 void RenderView::OnThemeChanged() { | 2893 void RenderView::OnThemeChanged() { |
| 2868 #if defined(OS_WIN) | 2894 #if defined(OS_WIN) |
| 2869 gfx::NativeTheme::instance()->CloseHandles(); | 2895 gfx::NativeTheme::instance()->CloseHandles(); |
| 2870 gfx::Rect view_rect(0, 0, size_.width(), size_.height()); | 2896 gfx::Rect view_rect(0, 0, size_.width(), size_.height()); |
| 2871 didInvalidateRect(view_rect); | 2897 didInvalidateRect(view_rect); |
| 2872 #else // defined(OS_WIN) | 2898 #else // defined(OS_WIN) |
| 2873 // TODO(port): we don't support theming on non-Windows platforms yet | 2899 // TODO(port): we don't support theming on non-Windows platforms yet |
| 2874 NOTIMPLEMENTED(); | 2900 NOTIMPLEMENTED(); |
| 2875 #endif | 2901 #endif |
| 2876 } | 2902 } |
| 2877 | 2903 |
| 2878 void RenderView::DidAddHistoryItem() { | 2904 void RenderView::DidAddHistoryItem() { |
| 2879 // We don't want to update the history length for the start page | 2905 // We don't want to update the history length for the start page |
| 2880 // navigation. | 2906 // navigation. |
| 2881 WebFrame* main_frame = webview()->GetMainFrame(); | 2907 WebFrame* main_frame = webview()->GetMainFrame(); |
| 2882 DCHECK(main_frame != NULL); | 2908 DCHECK(main_frame != NULL); |
| 2883 | 2909 |
| 2884 WebDataSource* ds = main_frame->GetDataSource(); | 2910 WebDataSource* ds = main_frame->dataSource(); |
| 2885 DCHECK(ds != NULL); | 2911 DCHECK(ds != NULL); |
| 2886 | 2912 |
| 2887 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 2913 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
| 2888 DCHECK(navigation_state); | 2914 DCHECK(navigation_state); |
| 2889 if (navigation_state->transition_type() == PageTransition::START_PAGE) | 2915 if (navigation_state->transition_type() == PageTransition::START_PAGE) |
| 2890 return; | 2916 return; |
| 2891 | 2917 |
| 2892 history_back_list_count_++; | 2918 history_back_list_count_++; |
| 2893 history_forward_list_count_ = 0; | 2919 history_forward_list_count_ = 0; |
| 2894 } | 2920 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2911 } | 2937 } |
| 2912 | 2938 |
| 2913 bool RenderView::MaybeLoadAlternateErrorPage(WebFrame* frame, | 2939 bool RenderView::MaybeLoadAlternateErrorPage(WebFrame* frame, |
| 2914 const WebURLError& error, | 2940 const WebURLError& error, |
| 2915 bool replace) { | 2941 bool replace) { |
| 2916 // We only show alternate error pages in the main frame. They are | 2942 // We only show alternate error pages in the main frame. They are |
| 2917 // intended to assist the user when navigating, so there is not much | 2943 // intended to assist the user when navigating, so there is not much |
| 2918 // value in showing them for failed subframes. Ideally, we would be | 2944 // value in showing them for failed subframes. Ideally, we would be |
| 2919 // able to use the TYPED transition type for this, but that flag is | 2945 // able to use the TYPED transition type for this, but that flag is |
| 2920 // not preserved across page reloads. | 2946 // not preserved across page reloads. |
| 2921 if (frame->GetParent()) | 2947 if (frame->parent()) |
| 2922 return false; | 2948 return false; |
| 2923 | 2949 |
| 2924 // Use the alternate error page service if this is a DNS failure or | 2950 // Use the alternate error page service if this is a DNS failure or |
| 2925 // connection failure. | 2951 // connection failure. |
| 2926 int ec = error.reason; | 2952 int ec = error.reason; |
| 2927 if (ec != net::ERR_NAME_NOT_RESOLVED && | 2953 if (ec != net::ERR_NAME_NOT_RESOLVED && |
| 2928 ec != net::ERR_CONNECTION_FAILED && | 2954 ec != net::ERR_CONNECTION_FAILED && |
| 2929 ec != net::ERR_CONNECTION_REFUSED && | 2955 ec != net::ERR_CONNECTION_REFUSED && |
| 2930 ec != net::ERR_ADDRESS_UNREACHABLE && | 2956 ec != net::ERR_ADDRESS_UNREACHABLE && |
| 2931 ec != net::ERR_CONNECTION_TIMED_OUT) | 2957 ec != net::ERR_CONNECTION_TIMED_OUT) |
| 2932 return false; | 2958 return false; |
| 2933 | 2959 |
| 2934 const GURL& error_page_url = GetAlternateErrorPageURL(error.unreachableURL, | 2960 const GURL& error_page_url = GetAlternateErrorPageURL(error.unreachableURL, |
| 2935 ec == net::ERR_NAME_NOT_RESOLVED ? DNS_ERROR : CONNECTION_ERROR); | 2961 ec == net::ERR_NAME_NOT_RESOLVED ? DNS_ERROR : CONNECTION_ERROR); |
| 2936 if (!error_page_url.is_valid()) | 2962 if (!error_page_url.is_valid()) |
| 2937 return false; | 2963 return false; |
| 2938 | 2964 |
| 2939 // Load an empty page first so there is an immediate response to the error, | 2965 // Load an empty page first so there is an immediate response to the error, |
| 2940 // and then kick off a request for the alternate error page. | 2966 // and then kick off a request for the alternate error page. |
| 2941 frame->LoadHTMLString(std::string(), | 2967 frame->loadHTMLString(std::string(), |
| 2942 GURL(kUnreachableWebDataURL), | 2968 GURL(kUnreachableWebDataURL), |
| 2943 error.unreachableURL, | 2969 error.unreachableURL, |
| 2944 replace); | 2970 replace); |
| 2945 | 2971 |
| 2946 // Now, create a fetcher for the error page and associate it with the data | 2972 // Now, create a fetcher for the error page and associate it with the data |
| 2947 // source we just created via the LoadHTMLString call. That way if another | 2973 // source we just created via the LoadHTMLString call. That way if another |
| 2948 // navigation occurs, the fetcher will get destroyed. | 2974 // navigation occurs, the fetcher will get destroyed. |
| 2949 NavigationState* navigation_state = | 2975 NavigationState* navigation_state = |
| 2950 NavigationState::FromDataSource(frame->GetProvisionalDataSource()); | 2976 NavigationState::FromDataSource(frame->provisionalDataSource()); |
| 2951 navigation_state->set_alt_error_page_fetcher( | 2977 navigation_state->set_alt_error_page_fetcher( |
| 2952 new AltErrorPageResourceFetcher( | 2978 new AltErrorPageResourceFetcher( |
| 2953 error_page_url, frame, error, | 2979 error_page_url, frame, error, |
| 2954 NewCallback(this, &RenderView::AltErrorPageFinished))); | 2980 NewCallback(this, &RenderView::AltErrorPageFinished))); |
| 2955 return true; | 2981 return true; |
| 2956 } | 2982 } |
| 2957 | 2983 |
| 2958 std::string RenderView::GetAltHTMLForTemplate( | 2984 std::string RenderView::GetAltHTMLForTemplate( |
| 2959 const DictionaryValue& error_strings, int template_resource_id) const { | 2985 const DictionaryValue& error_strings, int template_resource_id) const { |
| 2960 const StringPiece template_html( | 2986 const StringPiece template_html( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2975 const WebURLError& original_error, | 3001 const WebURLError& original_error, |
| 2976 const std::string& html) { | 3002 const std::string& html) { |
| 2977 // Here, we replace the blank page we loaded previously. | 3003 // Here, we replace the blank page we loaded previously. |
| 2978 | 3004 |
| 2979 // If we failed to download the alternate error page, fall back to the | 3005 // If we failed to download the alternate error page, fall back to the |
| 2980 // original error page if present. Otherwise, LoadNavigationErrorPage | 3006 // original error page if present. Otherwise, LoadNavigationErrorPage |
| 2981 // will simply display a default error page. | 3007 // will simply display a default error page. |
| 2982 const std::string* html_to_load = &html; | 3008 const std::string* html_to_load = &html; |
| 2983 if (html.empty()) { | 3009 if (html.empty()) { |
| 2984 NavigationState* navigation_state = | 3010 NavigationState* navigation_state = |
| 2985 NavigationState::FromDataSource(frame->GetDataSource()); | 3011 NavigationState::FromDataSource(frame->dataSource()); |
| 2986 html_to_load = &navigation_state->postponed_data(); | 3012 html_to_load = &navigation_state->postponed_data(); |
| 2987 } | 3013 } |
| 2988 LoadNavigationErrorPage( | 3014 LoadNavigationErrorPage( |
| 2989 frame, WebURLRequest(), original_error, *html_to_load, true); | 3015 frame, WebURLRequest(), original_error, *html_to_load, true); |
| 2990 } | 3016 } |
| 2991 | 3017 |
| 2992 void RenderView::OnMoveOrResizeStarted() { | 3018 void RenderView::OnMoveOrResizeStarted() { |
| 2993 if (webview()) | 3019 if (webview()) |
| 2994 webview()->HideAutofillPopup(); | 3020 webview()->HideAutofillPopup(); |
| 2995 } | 3021 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3067 // commit->first_paint_after_load, | 3093 // commit->first_paint_after_load, |
| 3068 // finish->first_paint_after_load, | 3094 // finish->first_paint_after_load, |
| 3069 // | 3095 // |
| 3070 // It's possible for the request time not to be set, if a client | 3096 // It's possible for the request time not to be set, if a client |
| 3071 // redirect had been done (the user never requested the page) | 3097 // redirect had been done (the user never requested the page) |
| 3072 // Also, it's possible to load a page without ever laying it out | 3098 // Also, it's possible to load a page without ever laying it out |
| 3073 // so first_paint and first_paint_after_load can be 0. | 3099 // so first_paint and first_paint_after_load can be 0. |
| 3074 void RenderView::DumpLoadHistograms() const { | 3100 void RenderView::DumpLoadHistograms() const { |
| 3075 WebFrame* main_frame = webview()->GetMainFrame(); | 3101 WebFrame* main_frame = webview()->GetMainFrame(); |
| 3076 NavigationState* navigation_state = | 3102 NavigationState* navigation_state = |
| 3077 NavigationState::FromDataSource(main_frame->GetDataSource()); | 3103 NavigationState::FromDataSource(main_frame->dataSource()); |
| 3078 Time finish = navigation_state->finish_load_time(); | 3104 Time finish = navigation_state->finish_load_time(); |
| 3079 | 3105 |
| 3080 // If we've already dumped or we haven't finished loading, do nothing. | 3106 // If we've already dumped or we haven't finished loading, do nothing. |
| 3081 if (navigation_state->load_histograms_recorded() || finish.is_null()) | 3107 if (navigation_state->load_histograms_recorded() || finish.is_null()) |
| 3082 return; | 3108 return; |
| 3083 | 3109 |
| 3084 Time request = navigation_state->request_time(); | 3110 Time request = navigation_state->request_time(); |
| 3085 Time start = navigation_state->start_load_time(); | 3111 Time start = navigation_state->start_load_time(); |
| 3086 Time commit = navigation_state->commit_load_time(); | 3112 Time commit = navigation_state->commit_load_time(); |
| 3087 Time finish_doc = navigation_state->finish_document_load_time(); | 3113 Time finish_doc = navigation_state->finish_document_load_time(); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3243 | 3269 |
| 3244 void RenderView::DidMovePlugin(const WebPluginGeometry& move) { | 3270 void RenderView::DidMovePlugin(const WebPluginGeometry& move) { |
| 3245 SchedulePluginMove(move); | 3271 SchedulePluginMove(move); |
| 3246 } | 3272 } |
| 3247 | 3273 |
| 3248 void RenderView::WillDestroyPluginWindow(gfx::PluginWindowHandle window) { | 3274 void RenderView::WillDestroyPluginWindow(gfx::PluginWindowHandle window) { |
| 3249 CleanupWindowInPluginMoves(window); | 3275 CleanupWindowInPluginMoves(window); |
| 3250 } | 3276 } |
| 3251 | 3277 |
| 3252 void RenderView::SendPasswordForms(WebFrame* frame) { | 3278 void RenderView::SendPasswordForms(WebFrame* frame) { |
| 3253 std::vector<WebForm> forms; | 3279 WebVector<WebForm> forms; |
| 3254 frame->GetForms(&forms); | 3280 frame->forms(forms); |
| 3255 | 3281 |
| 3256 std::vector<PasswordForm> password_forms; | 3282 std::vector<PasswordForm> password_forms; |
| 3257 for (size_t i = 0; i < forms.size(); ++i) { | 3283 for (size_t i = 0; i < forms.size(); ++i) { |
| 3258 const WebForm& form = forms[i]; | 3284 const WebForm& form = forms[i]; |
| 3259 | 3285 |
| 3260 // Respect autocomplete=off. | 3286 // Respect autocomplete=off. |
| 3261 if (form.isAutoCompleteEnabled()) { | 3287 if (form.isAutoCompleteEnabled()) { |
| 3262 scoped_ptr<PasswordForm> password_form( | 3288 scoped_ptr<PasswordForm> password_form( |
| 3263 PasswordFormDomManager::CreatePasswordForm(form)); | 3289 PasswordFormDomManager::CreatePasswordForm(form)); |
| 3264 if (password_form.get()) | 3290 if (password_form.get()) |
| 3265 password_forms.push_back(*password_form); | 3291 password_forms.push_back(*password_form); |
| 3266 } | 3292 } |
| 3267 } | 3293 } |
| 3268 | 3294 |
| 3269 if (!password_forms.empty()) | 3295 if (!password_forms.empty()) |
| 3270 Send(new ViewHostMsg_PasswordFormsSeen(routing_id_, password_forms)); | 3296 Send(new ViewHostMsg_PasswordFormsSeen(routing_id_, password_forms)); |
| 3271 } | 3297 } |
| 3272 | 3298 |
| 3273 void RenderView::Print(WebFrame* frame, bool script_initiated) { | 3299 void RenderView::Print(WebFrame* frame, bool script_initiated) { |
| 3274 DCHECK(frame); | 3300 DCHECK(frame); |
| 3275 if (print_helper_.get() == NULL) { | 3301 if (print_helper_.get() == NULL) { |
| 3276 print_helper_.reset(new PrintWebViewHelper(this)); | 3302 print_helper_.reset(new PrintWebViewHelper(this)); |
| 3277 } | 3303 } |
| 3278 print_helper_->Print(frame, script_initiated); | 3304 print_helper_->Print(frame, script_initiated); |
| 3279 } | 3305 } |
| OLD | NEW |