| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | 9 |
| 12 #include "base/bind.h" | 10 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 14 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 15 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 16 #include "base/debug/trace_event.h" | 14 #include "base/debug/trace_event.h" |
| 17 #include "base/json/json_reader.h" | 15 #include "base/json/json_reader.h" |
| 18 #include "base/json/json_writer.h" | 16 #include "base/json/json_writer.h" |
| 19 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
| 20 #include "base/message_loop_proxy.h" | 18 #include "base/message_loop_proxy.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 using WebKit::WebURLError; | 312 using WebKit::WebURLError; |
| 315 using WebKit::WebURLRequest; | 313 using WebKit::WebURLRequest; |
| 316 using WebKit::WebURLResponse; | 314 using WebKit::WebURLResponse; |
| 317 using WebKit::WebVector; | 315 using WebKit::WebVector; |
| 318 using WebKit::WebView; | 316 using WebKit::WebView; |
| 319 using WebKit::WebWidget; | 317 using WebKit::WebWidget; |
| 320 using WebKit::WebWindowFeatures; | 318 using WebKit::WebWindowFeatures; |
| 321 using appcache::WebApplicationCacheHostImpl; | 319 using appcache::WebApplicationCacheHostImpl; |
| 322 using base::Time; | 320 using base::Time; |
| 323 using base::TimeDelta; | 321 using base::TimeDelta; |
| 324 using content::DocumentState; | 322 |
| 325 using content::NavigationState; | |
| 326 using content::PasswordForm; | |
| 327 using content::Referrer; | |
| 328 using content::RenderThread; | |
| 329 using content::RenderViewObserver; | |
| 330 using content::RenderViewVisitor; | |
| 331 using content::RendererAccessibilityComplete; | |
| 332 using content::RendererAccessibilityFocusOnly; | |
| 333 using content::V8ValueConverter; | |
| 334 using webkit_glue::AltErrorPageResourceFetcher; | 323 using webkit_glue::AltErrorPageResourceFetcher; |
| 335 using webkit_glue::ResourceFetcher; | 324 using webkit_glue::ResourceFetcher; |
| 336 using webkit_glue::WebPreferences; | 325 using webkit_glue::WebPreferences; |
| 337 using webkit_glue::WebURLResponseExtraDataImpl; | 326 using webkit_glue::WebURLResponseExtraDataImpl; |
| 338 | 327 |
| 339 #if defined(OS_ANDROID) | 328 #if defined(OS_ANDROID) |
| 340 using content::AddressDetector; | |
| 341 using content::ContentDetector; | |
| 342 using content::EmailDetector; | |
| 343 using content::PhoneNumberDetector; | |
| 344 using WebKit::WebContentDetectionResult; | 329 using WebKit::WebContentDetectionResult; |
| 345 using WebKit::WebFloatPoint; | 330 using WebKit::WebFloatPoint; |
| 346 using WebKit::WebFloatRect; | 331 using WebKit::WebFloatRect; |
| 347 using WebKit::WebHitTestResult; | 332 using WebKit::WebHitTestResult; |
| 348 #endif | 333 #endif |
| 349 | 334 |
| 335 namespace content { |
| 336 |
| 350 //----------------------------------------------------------------------------- | 337 //----------------------------------------------------------------------------- |
| 351 | 338 |
| 352 typedef std::map<WebKit::WebView*, RenderViewImpl*> ViewMap; | 339 typedef std::map<WebKit::WebView*, RenderViewImpl*> ViewMap; |
| 353 static base::LazyInstance<ViewMap> g_view_map = LAZY_INSTANCE_INITIALIZER; | 340 static base::LazyInstance<ViewMap> g_view_map = LAZY_INSTANCE_INITIALIZER; |
| 354 | 341 |
| 355 // Time, in seconds, we delay before sending content state changes (such as form | 342 // Time, in seconds, we delay before sending content state changes (such as form |
| 356 // state and scroll position) to the browser. We delay sending changes to avoid | 343 // state and scroll position) to the browser. We delay sending changes to avoid |
| 357 // spamming the browser. | 344 // spamming the browser. |
| 358 // To avoid having tab/session restore require sending a message to get the | 345 // To avoid having tab/session restore require sending a message to get the |
| 359 // current content state during tab closing we use a shorter timeout for the | 346 // current content state during tab closing we use a shorter timeout for the |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 NotifyTimezoneChange(child); | 491 NotifyTimezoneChange(child); |
| 505 } | 492 } |
| 506 | 493 |
| 507 // Recursively walks the frame tree and serializes it to JSON as described in | 494 // Recursively walks the frame tree and serializes it to JSON as described in |
| 508 // the comment for ViewMsg_UpdateFrameTree. If |exclude_frame_subtree| is not | 495 // the comment for ViewMsg_UpdateFrameTree. If |exclude_frame_subtree| is not |
| 509 // NULL, the subtree for the frame is not included in the serialized form. | 496 // NULL, the subtree for the frame is not included in the serialized form. |
| 510 // This is used when a frame is going to be removed from the tree. | 497 // This is used when a frame is going to be removed from the tree. |
| 511 static void ConstructFrameTree(WebKit::WebFrame* frame, | 498 static void ConstructFrameTree(WebKit::WebFrame* frame, |
| 512 WebKit::WebFrame* exclude_frame_subtree, | 499 WebKit::WebFrame* exclude_frame_subtree, |
| 513 base::DictionaryValue* dict) { | 500 base::DictionaryValue* dict) { |
| 514 dict->SetString(content::kFrameTreeNodeNameKey, | 501 dict->SetString(kFrameTreeNodeNameKey, |
| 515 UTF16ToUTF8(frame->assignedName()).c_str()); | 502 UTF16ToUTF8(frame->assignedName()).c_str()); |
| 516 dict->SetInteger(content::kFrameTreeNodeIdKey, frame->identifier()); | 503 dict->SetInteger(kFrameTreeNodeIdKey, frame->identifier()); |
| 517 | 504 |
| 518 WebFrame* child = frame->firstChild(); | 505 WebFrame* child = frame->firstChild(); |
| 519 ListValue* children = new ListValue(); | 506 ListValue* children = new ListValue(); |
| 520 for (; child; child = child->nextSibling()) { | 507 for (; child; child = child->nextSibling()) { |
| 521 if (child == exclude_frame_subtree) | 508 if (child == exclude_frame_subtree) |
| 522 continue; | 509 continue; |
| 523 | 510 |
| 524 base::DictionaryValue* d = new base::DictionaryValue(); | 511 base::DictionaryValue* d = new base::DictionaryValue(); |
| 525 ConstructFrameTree(child, exclude_frame_subtree, d); | 512 ConstructFrameTree(child, exclude_frame_subtree, d); |
| 526 children->Append(d); | 513 children->Append(d); |
| 527 } | 514 } |
| 528 if (children->GetSize() > 0) | 515 if (children->GetSize() > 0) |
| 529 dict->Set(content::kFrameTreeNodeSubtreeKey, children); | 516 dict->Set(kFrameTreeNodeSubtreeKey, children); |
| 530 } | 517 } |
| 531 | 518 |
| 532 /////////////////////////////////////////////////////////////////////////////// | 519 /////////////////////////////////////////////////////////////////////////////// |
| 533 | 520 |
| 534 struct RenderViewImpl::PendingFileChooser { | 521 struct RenderViewImpl::PendingFileChooser { |
| 535 PendingFileChooser(const content::FileChooserParams& p, | 522 PendingFileChooser(const FileChooserParams& p, WebFileChooserCompletion* c) |
| 536 WebFileChooserCompletion* c) | |
| 537 : params(p), | 523 : params(p), |
| 538 completion(c) { | 524 completion(c) { |
| 539 } | 525 } |
| 540 content::FileChooserParams params; | 526 FileChooserParams params; |
| 541 WebFileChooserCompletion* completion; // MAY BE NULL to skip callback. | 527 WebFileChooserCompletion* completion; // MAY BE NULL to skip callback. |
| 542 }; | 528 }; |
| 543 | 529 |
| 544 namespace { | 530 namespace { |
| 545 | 531 |
| 546 class WebWidgetLockTarget : public MouseLockDispatcher::LockTarget { | 532 class WebWidgetLockTarget : public MouseLockDispatcher::LockTarget { |
| 547 public: | 533 public: |
| 548 explicit WebWidgetLockTarget(WebKit::WebWidget* webwidget) | 534 explicit WebWidgetLockTarget(WebKit::WebWidget* webwidget) |
| 549 : webwidget_(webwidget) {} | 535 : webwidget_(webwidget) {} |
| 550 | 536 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 577 return -1; | 563 return -1; |
| 578 | 564 |
| 579 return item.httpBody().identifier(); | 565 return item.httpBody().identifier(); |
| 580 } | 566 } |
| 581 | 567 |
| 582 } // namespace | 568 } // namespace |
| 583 | 569 |
| 584 RenderViewImpl::RenderViewImpl( | 570 RenderViewImpl::RenderViewImpl( |
| 585 gfx::NativeViewId parent_hwnd, | 571 gfx::NativeViewId parent_hwnd, |
| 586 int32 opener_id, | 572 int32 opener_id, |
| 587 const content::RendererPreferences& renderer_prefs, | 573 const RendererPreferences& renderer_prefs, |
| 588 const WebPreferences& webkit_prefs, | 574 const WebPreferences& webkit_prefs, |
| 589 SharedRenderViewCounter* counter, | 575 SharedRenderViewCounter* counter, |
| 590 int32 routing_id, | 576 int32 routing_id, |
| 591 int32 surface_id, | 577 int32 surface_id, |
| 592 int64 session_storage_namespace_id, | 578 int64 session_storage_namespace_id, |
| 593 const string16& frame_name, | 579 const string16& frame_name, |
| 594 bool is_renderer_created, | 580 bool is_renderer_created, |
| 595 bool swapped_out, | 581 bool swapped_out, |
| 596 int32 next_page_id, | 582 int32 next_page_id, |
| 597 const WebKit::WebScreenInfo& screen_info, | 583 const WebKit::WebScreenInfo& screen_info, |
| 598 content::old::GuestToEmbedderChannel* guest_to_embedder_channel, | 584 old::GuestToEmbedderChannel* guest_to_embedder_channel, |
| 599 AccessibilityMode accessibility_mode) | 585 AccessibilityMode accessibility_mode) |
| 600 : RenderWidget(WebKit::WebPopupTypeNone, screen_info, swapped_out), | 586 : RenderWidget(WebKit::WebPopupTypeNone, screen_info, swapped_out), |
| 601 webkit_preferences_(webkit_prefs), | 587 webkit_preferences_(webkit_prefs), |
| 602 send_content_state_immediately_(false), | 588 send_content_state_immediately_(false), |
| 603 enabled_bindings_(0), | 589 enabled_bindings_(0), |
| 604 send_preferred_size_changes_(false), | 590 send_preferred_size_changes_(false), |
| 605 is_loading_(false), | 591 is_loading_(false), |
| 606 navigation_gesture_(NavigationGestureUnknown), | 592 navigation_gesture_(NavigationGestureUnknown), |
| 607 opened_by_user_gesture_(true), | 593 opened_by_user_gesture_(true), |
| 608 opener_suppressed_(false), | 594 opener_suppressed_(false), |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 #else | 647 #else |
| 662 notification_provider_ = NULL; | 648 notification_provider_ = NULL; |
| 663 #endif | 649 #endif |
| 664 | 650 |
| 665 webwidget_ = WebView::create(this); | 651 webwidget_ = WebView::create(this); |
| 666 webwidget_mouse_lock_target_.reset(new WebWidgetLockTarget(webwidget_)); | 652 webwidget_mouse_lock_target_.reset(new WebWidgetLockTarget(webwidget_)); |
| 667 | 653 |
| 668 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 654 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 669 | 655 |
| 670 #if defined(OS_ANDROID) | 656 #if defined(OS_ANDROID) |
| 671 scoped_ptr<content::DeviceInfo> device_info(new content::DeviceInfo()); | 657 scoped_ptr<DeviceInfo> device_info(new DeviceInfo()); |
| 672 | 658 |
| 673 webview()->setDeviceScaleFactor(device_info->GetDPIScale()); | 659 webview()->setDeviceScaleFactor(device_info->GetDPIScale()); |
| 674 | 660 |
| 675 const std::string region_code = | 661 const std::string region_code = |
| 676 command_line.HasSwitch(switches::kNetworkCountryIso) | 662 command_line.HasSwitch(switches::kNetworkCountryIso) |
| 677 ? command_line.GetSwitchValueASCII(switches::kNetworkCountryIso) | 663 ? command_line.GetSwitchValueASCII(switches::kNetworkCountryIso) |
| 678 : device_info->GetNetworkCountryIso(); | 664 : device_info->GetNetworkCountryIso(); |
| 679 content_detectors_.push_back(linked_ptr<ContentDetector>( | 665 content_detectors_.push_back(linked_ptr<ContentDetector>( |
| 680 new AddressDetector())); | 666 new AddressDetector())); |
| 681 content_detectors_.push_back(linked_ptr<ContentDetector>( | 667 content_detectors_.push_back(linked_ptr<ContentDetector>( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 devtools_agent_ = new DevToolsAgent(this); | 727 devtools_agent_ = new DevToolsAgent(this); |
| 742 mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); | 728 mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); |
| 743 intents_host_ = new WebIntentsHost(this); | 729 intents_host_ = new WebIntentsHost(this); |
| 744 | 730 |
| 745 // Create renderer_accessibility_ if needed. | 731 // Create renderer_accessibility_ if needed. |
| 746 OnSetAccessibilityMode(accessibility_mode); | 732 OnSetAccessibilityMode(accessibility_mode); |
| 747 | 733 |
| 748 new IdleUserDetector(this); | 734 new IdleUserDetector(this); |
| 749 | 735 |
| 750 if (command_line.HasSwitch(switches::kDomAutomationController)) | 736 if (command_line.HasSwitch(switches::kDomAutomationController)) |
| 751 enabled_bindings_ |= content::BINDINGS_POLICY_DOM_AUTOMATION; | 737 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; |
| 752 | 738 |
| 753 ProcessViewLayoutFlags(command_line); | 739 ProcessViewLayoutFlags(command_line); |
| 754 | 740 |
| 755 content::GetContentClient()->renderer()->RenderViewCreated(this); | 741 GetContentClient()->renderer()->RenderViewCreated(this); |
| 756 | 742 |
| 757 // If we have an opener_id but we weren't created by a renderer, then | 743 // If we have an opener_id but we weren't created by a renderer, then |
| 758 // it's the browser asking us to set our opener to another RenderView. | 744 // it's the browser asking us to set our opener to another RenderView. |
| 759 if (opener_id != MSG_ROUTING_NONE && !is_renderer_created) { | 745 if (opener_id != MSG_ROUTING_NONE && !is_renderer_created) { |
| 760 RenderViewImpl* opener_view = FromRoutingID(opener_id); | 746 RenderViewImpl* opener_view = FromRoutingID(opener_id); |
| 761 if (opener_view) | 747 if (opener_view) |
| 762 webview()->mainFrame()->setOpener(opener_view->webview()->mainFrame()); | 748 webview()->mainFrame()->setOpener(opener_view->webview()->mainFrame()); |
| 763 } | 749 } |
| 764 | 750 |
| 765 // If we are initially swapped out, navigate to kSwappedOutURL. | 751 // If we are initially swapped out, navigate to kSwappedOutURL. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 } | 791 } |
| 806 | 792 |
| 807 /*static*/ | 793 /*static*/ |
| 808 RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { | 794 RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { |
| 809 ViewMap* views = g_view_map.Pointer(); | 795 ViewMap* views = g_view_map.Pointer(); |
| 810 ViewMap::iterator it = views->find(webview); | 796 ViewMap::iterator it = views->find(webview); |
| 811 return it == views->end() ? NULL : it->second; | 797 return it == views->end() ? NULL : it->second; |
| 812 } | 798 } |
| 813 | 799 |
| 814 /*static*/ | 800 /*static*/ |
| 815 content::RenderView* | 801 RenderView* RenderView::FromWebView(WebKit::WebView* webview) { |
| 816 content::RenderView::FromWebView(WebKit::WebView* webview) { | |
| 817 return RenderViewImpl::FromWebView(webview); | 802 return RenderViewImpl::FromWebView(webview); |
| 818 } | 803 } |
| 819 | 804 |
| 820 /*static*/ | 805 /*static*/ |
| 821 void content::RenderView::ForEach(content::RenderViewVisitor* visitor) { | 806 void RenderView::ForEach(RenderViewVisitor* visitor) { |
| 822 ViewMap* views = g_view_map.Pointer(); | 807 ViewMap* views = g_view_map.Pointer(); |
| 823 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) { | 808 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) { |
| 824 if (!visitor->Visit(it->second)) | 809 if (!visitor->Visit(it->second)) |
| 825 return; | 810 return; |
| 826 } | 811 } |
| 827 } | 812 } |
| 828 | 813 |
| 829 /*static*/ | 814 /*static*/ |
| 830 RenderViewImpl* RenderViewImpl::Create( | 815 RenderViewImpl* RenderViewImpl::Create( |
| 831 gfx::NativeViewId parent_hwnd, | 816 gfx::NativeViewId parent_hwnd, |
| 832 int32 opener_id, | 817 int32 opener_id, |
| 833 const content::RendererPreferences& renderer_prefs, | 818 const RendererPreferences& renderer_prefs, |
| 834 const WebPreferences& webkit_prefs, | 819 const WebPreferences& webkit_prefs, |
| 835 SharedRenderViewCounter* counter, | 820 SharedRenderViewCounter* counter, |
| 836 int32 routing_id, | 821 int32 routing_id, |
| 837 int32 surface_id, | 822 int32 surface_id, |
| 838 int64 session_storage_namespace_id, | 823 int64 session_storage_namespace_id, |
| 839 const string16& frame_name, | 824 const string16& frame_name, |
| 840 bool is_renderer_created, | 825 bool is_renderer_created, |
| 841 bool swapped_out, | 826 bool swapped_out, |
| 842 int32 next_page_id, | 827 int32 next_page_id, |
| 843 const WebKit::WebScreenInfo& screen_info, | 828 const WebKit::WebScreenInfo& screen_info, |
| 844 content::old::GuestToEmbedderChannel* guest_to_embedder_channel, | 829 old::GuestToEmbedderChannel* guest_to_embedder_channel, |
| 845 AccessibilityMode accessibility_mode) { | 830 AccessibilityMode accessibility_mode) { |
| 846 DCHECK(routing_id != MSG_ROUTING_NONE); | 831 DCHECK(routing_id != MSG_ROUTING_NONE); |
| 847 return new RenderViewImpl( | 832 return new RenderViewImpl( |
| 848 parent_hwnd, | 833 parent_hwnd, |
| 849 opener_id, | 834 opener_id, |
| 850 renderer_prefs, | 835 renderer_prefs, |
| 851 webkit_prefs, | 836 webkit_prefs, |
| 852 counter, | 837 counter, |
| 853 routing_id, | 838 routing_id, |
| 854 surface_id, | 839 surface_id, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 877 | 862 |
| 878 void RenderViewImpl::SetReportLoadProgressEnabled(bool enabled) { | 863 void RenderViewImpl::SetReportLoadProgressEnabled(bool enabled) { |
| 879 if (!enabled) { | 864 if (!enabled) { |
| 880 load_progress_tracker_.reset(NULL); | 865 load_progress_tracker_.reset(NULL); |
| 881 return; | 866 return; |
| 882 } | 867 } |
| 883 if (load_progress_tracker_ == NULL) | 868 if (load_progress_tracker_ == NULL) |
| 884 load_progress_tracker_.reset(new LoadProgressTracker(this)); | 869 load_progress_tracker_.reset(new LoadProgressTracker(this)); |
| 885 } | 870 } |
| 886 | 871 |
| 887 content::old::GuestToEmbedderChannel* | 872 old::GuestToEmbedderChannel* RenderViewImpl::GetGuestToEmbedderChannel() const { |
| 888 RenderViewImpl::GetGuestToEmbedderChannel() const { | |
| 889 return guest_to_embedder_channel_; | 873 return guest_to_embedder_channel_; |
| 890 } | 874 } |
| 891 | 875 |
| 892 void RenderViewImpl::SetGuestToEmbedderChannel( | 876 void RenderViewImpl::SetGuestToEmbedderChannel( |
| 893 content::old::GuestToEmbedderChannel* channel) { | 877 old::GuestToEmbedderChannel* channel) { |
| 894 guest_to_embedder_channel_ = channel; | 878 guest_to_embedder_channel_ = channel; |
| 895 } | 879 } |
| 896 | 880 |
| 897 void RenderViewImpl::PluginCrashed(const FilePath& plugin_path) { | 881 void RenderViewImpl::PluginCrashed(const FilePath& plugin_path) { |
| 898 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); | 882 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); |
| 899 } | 883 } |
| 900 | 884 |
| 901 void RenderViewImpl::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { | 885 void RenderViewImpl::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { |
| 902 plugin_delegates_.insert(delegate); | 886 plugin_delegates_.insert(delegate); |
| 903 // If the renderer is visible, set initial visibility and focus state. | 887 // If the renderer is visible, set initial visibility and focus state. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 webview()->transferActiveWheelFlingAnimation(params); | 921 webview()->transferActiveWheelFlingAnimation(params); |
| 938 } | 922 } |
| 939 | 923 |
| 940 bool RenderViewImpl::HasIMETextFocus() { | 924 bool RenderViewImpl::HasIMETextFocus() { |
| 941 return GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE; | 925 return GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE; |
| 942 } | 926 } |
| 943 | 927 |
| 944 bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { | 928 bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { |
| 945 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; | 929 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; |
| 946 if (main_frame) | 930 if (main_frame) |
| 947 content::GetContentClient()->SetActiveURL(main_frame->document().url()); | 931 GetContentClient()->SetActiveURL(main_frame->document().url()); |
| 948 | 932 |
| 949 ObserverListBase<RenderViewObserver>::Iterator it(observers_); | 933 ObserverListBase<RenderViewObserver>::Iterator it(observers_); |
| 950 RenderViewObserver* observer; | 934 RenderViewObserver* observer; |
| 951 while ((observer = it.GetNext()) != NULL) | 935 while ((observer = it.GetNext()) != NULL) |
| 952 if (observer->OnMessageReceived(message)) | 936 if (observer->OnMessageReceived(message)) |
| 953 return true; | 937 return true; |
| 954 | 938 |
| 955 bool handled = true; | 939 bool handled = true; |
| 956 bool msg_is_ok = true; | 940 bool msg_is_ok = true; |
| 957 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewImpl, message, msg_is_ok) | 941 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewImpl, message, msg_is_ok) |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; | 1069 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; |
| 1086 } | 1070 } |
| 1087 | 1071 |
| 1088 return handled; | 1072 return handled; |
| 1089 } | 1073 } |
| 1090 | 1074 |
| 1091 void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { | 1075 void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { |
| 1092 // If we don't have guest-to-embedder channel associated with this RenderView | 1076 // If we don't have guest-to-embedder channel associated with this RenderView |
| 1093 // but we need one, grab one now. | 1077 // but we need one, grab one now. |
| 1094 if (!params.embedder_channel_name.empty() && !GetGuestToEmbedderChannel()) { | 1078 if (!params.embedder_channel_name.empty() && !GetGuestToEmbedderChannel()) { |
| 1095 content::old::GuestToEmbedderChannel* embedder_channel = | 1079 old::GuestToEmbedderChannel* embedder_channel = |
| 1096 RenderThreadImpl::current()->browser_plugin_channel_manager()-> | 1080 RenderThreadImpl::current()->browser_plugin_channel_manager()-> |
| 1097 GetChannelByName(params.embedder_channel_name); | 1081 GetChannelByName(params.embedder_channel_name); |
| 1098 DCHECK(embedder_channel); | 1082 DCHECK(embedder_channel); |
| 1099 SetGuestToEmbedderChannel(embedder_channel); | 1083 SetGuestToEmbedderChannel(embedder_channel); |
| 1100 host_window_set_ = false; | 1084 host_window_set_ = false; |
| 1101 // TODO(fsamuel): This is test code. Need to find a better way to tell | 1085 // TODO(fsamuel): This is test code. Need to find a better way to tell |
| 1102 // a WebView to drop its context. This needs to change in | 1086 // a WebView to drop its context. This needs to change in |
| 1103 // GuestToEmbedderChannel::OnContextLost. | 1087 // GuestToEmbedderChannel::OnContextLost. |
| 1104 GetWebView()->loseCompositorContext(1); | 1088 GetWebView()->loseCompositorContext(1); |
| 1105 RenderThreadImpl::current()->browser_plugin_channel_manager()-> | 1089 RenderThreadImpl::current()->browser_plugin_channel_manager()-> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1130 } | 1114 } |
| 1131 | 1115 |
| 1132 history_list_offset_ = params.current_history_list_offset; | 1116 history_list_offset_ = params.current_history_list_offset; |
| 1133 history_list_length_ = params.current_history_list_length; | 1117 history_list_length_ = params.current_history_list_length; |
| 1134 if (history_list_length_ >= 0) | 1118 if (history_list_length_ >= 0) |
| 1135 history_page_ids_.resize(history_list_length_, -1); | 1119 history_page_ids_.resize(history_list_length_, -1); |
| 1136 if (params.pending_history_list_offset >= 0 && | 1120 if (params.pending_history_list_offset >= 0 && |
| 1137 params.pending_history_list_offset < history_list_length_) | 1121 params.pending_history_list_offset < history_list_length_) |
| 1138 history_page_ids_[params.pending_history_list_offset] = params.page_id; | 1122 history_page_ids_[params.pending_history_list_offset] = params.page_id; |
| 1139 | 1123 |
| 1140 content::GetContentClient()->SetActiveURL(params.url); | 1124 GetContentClient()->SetActiveURL(params.url); |
| 1141 | 1125 |
| 1142 WebFrame* main_frame = webview()->mainFrame(); | 1126 WebFrame* main_frame = webview()->mainFrame(); |
| 1143 if (is_reload && main_frame->currentHistoryItem().isNull()) { | 1127 if (is_reload && main_frame->currentHistoryItem().isNull()) { |
| 1144 // We cannot reload if we do not have any history state. This happens, for | 1128 // We cannot reload if we do not have any history state. This happens, for |
| 1145 // example, when recovering from a crash. Our workaround here is a bit of | 1129 // example, when recovering from a crash. Our workaround here is a bit of |
| 1146 // a hack since it means that reload after a crashed tab does not cause an | 1130 // a hack since it means that reload after a crashed tab does not cause an |
| 1147 // end-to-end cache validation. | 1131 // end-to-end cache validation. |
| 1148 is_reload = false; | 1132 is_reload = false; |
| 1149 } | 1133 } |
| 1150 | 1134 |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 webkit_glue::CreateHistoryStateForURL(GURL(request.url())); | 1558 webkit_glue::CreateHistoryStateForURL(GURL(request.url())); |
| 1575 } | 1559 } |
| 1576 | 1560 |
| 1577 if (!frame->parent()) { | 1561 if (!frame->parent()) { |
| 1578 // Top-level navigation. | 1562 // Top-level navigation. |
| 1579 | 1563 |
| 1580 // Reset the zoom limits in case a plugin had changed them previously. This | 1564 // Reset the zoom limits in case a plugin had changed them previously. This |
| 1581 // will also call us back which will cause us to send a message to | 1565 // will also call us back which will cause us to send a message to |
| 1582 // update WebContentsImpl. | 1566 // update WebContentsImpl. |
| 1583 webview()->zoomLimitsChanged( | 1567 webview()->zoomLimitsChanged( |
| 1584 WebView::zoomFactorToZoomLevel(content::kMinimumZoomFactor), | 1568 WebView::zoomFactorToZoomLevel(kMinimumZoomFactor), |
| 1585 WebView::zoomFactorToZoomLevel(content::kMaximumZoomFactor)); | 1569 WebView::zoomFactorToZoomLevel(kMaximumZoomFactor)); |
| 1586 | 1570 |
| 1587 // Set zoom level, but don't do it for full-page plugin since they don't use | 1571 // Set zoom level, but don't do it for full-page plugin since they don't use |
| 1588 // the same zoom settings. | 1572 // the same zoom settings. |
| 1589 HostZoomLevels::iterator host_zoom = | 1573 HostZoomLevels::iterator host_zoom = |
| 1590 host_zoom_levels_.find(GURL(request.url())); | 1574 host_zoom_levels_.find(GURL(request.url())); |
| 1591 if (webview()->mainFrame()->document().isPluginDocument()) { | 1575 if (webview()->mainFrame()->document().isPluginDocument()) { |
| 1592 // Reset the zoom levels for plugins. | 1576 // Reset the zoom levels for plugins. |
| 1593 webview()->setZoomLevel(false, 0); | 1577 webview()->setZoomLevel(false, 0); |
| 1594 } else { | 1578 } else { |
| 1595 if (host_zoom != host_zoom_levels_.end()) | 1579 if (host_zoom != host_zoom_levels_.end()) |
| 1596 webview()->setZoomLevel(false, host_zoom->second); | 1580 webview()->setZoomLevel(false, host_zoom->second); |
| 1597 } | 1581 } |
| 1598 | 1582 |
| 1599 if (host_zoom != host_zoom_levels_.end()) { | 1583 if (host_zoom != host_zoom_levels_.end()) { |
| 1600 // This zoom level was merely recorded transiently for this load. We can | 1584 // This zoom level was merely recorded transiently for this load. We can |
| 1601 // erase it now. If at some point we reload this page, the browser will | 1585 // erase it now. If at some point we reload this page, the browser will |
| 1602 // send us a new, up-to-date zoom level. | 1586 // send us a new, up-to-date zoom level. |
| 1603 host_zoom_levels_.erase(host_zoom); | 1587 host_zoom_levels_.erase(host_zoom); |
| 1604 } | 1588 } |
| 1605 | 1589 |
| 1606 // Update contents MIME type for main frame. | 1590 // Update contents MIME type for main frame. |
| 1607 params.contents_mime_type = ds->response().mimeType().utf8(); | 1591 params.contents_mime_type = ds->response().mimeType().utf8(); |
| 1608 | 1592 |
| 1609 params.transition = navigation_state->transition_type(); | 1593 params.transition = navigation_state->transition_type(); |
| 1610 if (!content::PageTransitionIsMainFrame(params.transition)) { | 1594 if (!PageTransitionIsMainFrame(params.transition)) { |
| 1611 // If the main frame does a load, it should not be reported as a subframe | 1595 // If the main frame does a load, it should not be reported as a subframe |
| 1612 // navigation. This can occur in the following case: | 1596 // navigation. This can occur in the following case: |
| 1613 // 1. You're on a site with frames. | 1597 // 1. You're on a site with frames. |
| 1614 // 2. You do a subframe navigation. This is stored with transition type | 1598 // 2. You do a subframe navigation. This is stored with transition type |
| 1615 // MANUAL_SUBFRAME. | 1599 // MANUAL_SUBFRAME. |
| 1616 // 3. You navigate to some non-frame site, say, google.com. | 1600 // 3. You navigate to some non-frame site, say, google.com. |
| 1617 // 4. You navigate back to the page from step 2. Since it was initially | 1601 // 4. You navigate back to the page from step 2. Since it was initially |
| 1618 // MANUAL_SUBFRAME, it will be that same transition type here. | 1602 // MANUAL_SUBFRAME, it will be that same transition type here. |
| 1619 // We don't want that, because any navigation that changes the toplevel | 1603 // We don't want that, because any navigation that changes the toplevel |
| 1620 // frame should be tracked as a toplevel navigation (this allows us to | 1604 // frame should be tracked as a toplevel navigation (this allows us to |
| 1621 // update the URL bar, etc). | 1605 // update the URL bar, etc). |
| 1622 params.transition = content::PAGE_TRANSITION_LINK; | 1606 params.transition = PAGE_TRANSITION_LINK; |
| 1623 } | 1607 } |
| 1624 | 1608 |
| 1625 // If we have a valid consumed client redirect source, | 1609 // If we have a valid consumed client redirect source, |
| 1626 // the page contained a client redirect (meta refresh, document.loc...), | 1610 // the page contained a client redirect (meta refresh, document.loc...), |
| 1627 // so we set the referrer and transition to match. | 1611 // so we set the referrer and transition to match. |
| 1628 if (completed_client_redirect_src_.url.is_valid()) { | 1612 if (completed_client_redirect_src_.url.is_valid()) { |
| 1629 DCHECK(completed_client_redirect_src_.url == params.redirects[0]); | 1613 DCHECK(completed_client_redirect_src_.url == params.redirects[0]); |
| 1630 params.referrer = completed_client_redirect_src_; | 1614 params.referrer = completed_client_redirect_src_; |
| 1631 params.transition = static_cast<content::PageTransition>( | 1615 params.transition = static_cast<PageTransition>( |
| 1632 params.transition | content::PAGE_TRANSITION_CLIENT_REDIRECT); | 1616 params.transition | PAGE_TRANSITION_CLIENT_REDIRECT); |
| 1633 } else { | 1617 } else { |
| 1634 // Bug 654101: the referrer will be empty on https->http transitions. It | 1618 // Bug 654101: the referrer will be empty on https->http transitions. It |
| 1635 // would be nice if we could get the real referrer from somewhere. | 1619 // would be nice if we could get the real referrer from somewhere. |
| 1636 params.referrer = Referrer(GURL( | 1620 params.referrer = Referrer(GURL( |
| 1637 original_request.httpHeaderField(WebString::fromUTF8("Referer"))), | 1621 original_request.httpHeaderField(WebString::fromUTF8("Referer"))), |
| 1638 GetReferrerPolicyFromRequest(frame, original_request)); | 1622 GetReferrerPolicyFromRequest(frame, original_request)); |
| 1639 } | 1623 } |
| 1640 | 1624 |
| 1641 string16 method = request.httpMethod(); | 1625 string16 method = request.httpMethod(); |
| 1642 if (EqualsASCII(method, "POST")) { | 1626 if (EqualsASCII(method, "POST")) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1661 // these functions send a ViewHostMsg_ContentBlocked message, it arrives | 1645 // these functions send a ViewHostMsg_ContentBlocked message, it arrives |
| 1662 // after the ViewHostMsg_FrameNavigate message. | 1646 // after the ViewHostMsg_FrameNavigate message. |
| 1663 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); | 1647 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); |
| 1664 } else { | 1648 } else { |
| 1665 // Subframe navigation: the type depends on whether this navigation | 1649 // Subframe navigation: the type depends on whether this navigation |
| 1666 // generated a new session history entry. When they do generate a session | 1650 // generated a new session history entry. When they do generate a session |
| 1667 // history entry, it means the user initiated the navigation and we should | 1651 // history entry, it means the user initiated the navigation and we should |
| 1668 // mark it as such. This test checks if this is the first time UpdateURL | 1652 // mark it as such. This test checks if this is the first time UpdateURL |
| 1669 // has been called since WillNavigateToURL was called to initiate the load. | 1653 // has been called since WillNavigateToURL was called to initiate the load. |
| 1670 if (page_id_ > last_page_id_sent_to_browser_) | 1654 if (page_id_ > last_page_id_sent_to_browser_) |
| 1671 params.transition = content::PAGE_TRANSITION_MANUAL_SUBFRAME; | 1655 params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME; |
| 1672 else | 1656 else |
| 1673 params.transition = content::PAGE_TRANSITION_AUTO_SUBFRAME; | 1657 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; |
| 1674 | 1658 |
| 1675 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); | 1659 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); |
| 1676 } | 1660 } |
| 1677 | 1661 |
| 1678 last_page_id_sent_to_browser_ = | 1662 last_page_id_sent_to_browser_ = |
| 1679 std::max(last_page_id_sent_to_browser_, page_id_); | 1663 std::max(last_page_id_sent_to_browser_, page_id_); |
| 1680 | 1664 |
| 1681 // If we end up reusing this WebRequest (for example, due to a #ref click), | 1665 // If we end up reusing this WebRequest (for example, due to a #ref click), |
| 1682 // we don't want the transition type to persist. Just clear it. | 1666 // we don't want the transition type to persist. Just clear it. |
| 1683 navigation_state->set_transition_type(content::PAGE_TRANSITION_LINK); | 1667 navigation_state->set_transition_type(PAGE_TRANSITION_LINK); |
| 1684 } | 1668 } |
| 1685 | 1669 |
| 1686 // Tell the embedding application that the title of the active page has changed | 1670 // Tell the embedding application that the title of the active page has changed |
| 1687 void RenderViewImpl::UpdateTitle(WebFrame* frame, | 1671 void RenderViewImpl::UpdateTitle(WebFrame* frame, |
| 1688 const string16& title, | 1672 const string16& title, |
| 1689 WebTextDirection title_direction) { | 1673 WebTextDirection title_direction) { |
| 1690 // Ignore all but top level navigations. | 1674 // Ignore all but top level navigations. |
| 1691 if (frame->parent()) | 1675 if (frame->parent()) |
| 1692 return; | 1676 return; |
| 1693 | 1677 |
| 1694 string16 shortened_title = title.substr(0, content::kMaxTitleChars); | 1678 string16 shortened_title = title.substr(0, kMaxTitleChars); |
| 1695 Send(new ViewHostMsg_UpdateTitle(routing_id_, page_id_, shortened_title, | 1679 Send(new ViewHostMsg_UpdateTitle(routing_id_, page_id_, shortened_title, |
| 1696 title_direction)); | 1680 title_direction)); |
| 1697 } | 1681 } |
| 1698 | 1682 |
| 1699 void RenderViewImpl::UpdateEncoding(WebFrame* frame, | 1683 void RenderViewImpl::UpdateEncoding(WebFrame* frame, |
| 1700 const std::string& encoding_name) { | 1684 const std::string& encoding_name) { |
| 1701 // Only update main frame's encoding_name. | 1685 // Only update main frame's encoding_name. |
| 1702 if (webview()->mainFrame() == frame && | 1686 if (webview()->mainFrame() == frame && |
| 1703 last_encoding_name_ != encoding_name) { | 1687 last_encoding_name_ != encoding_name) { |
| 1704 // Save the encoding name for later comparing. | 1688 // Save the encoding name for later comparing. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1720 | 1704 |
| 1721 const WebHistoryItem& item = | 1705 const WebHistoryItem& item = |
| 1722 webview()->mainFrame()->previousHistoryItem(); | 1706 webview()->mainFrame()->previousHistoryItem(); |
| 1723 SendUpdateState(item); | 1707 SendUpdateState(item); |
| 1724 } | 1708 } |
| 1725 | 1709 |
| 1726 void RenderViewImpl::SendUpdateState(const WebHistoryItem& item) { | 1710 void RenderViewImpl::SendUpdateState(const WebHistoryItem& item) { |
| 1727 if (item.isNull()) | 1711 if (item.isNull()) |
| 1728 return; | 1712 return; |
| 1729 | 1713 |
| 1730 // Don't send state updates for content::kSwappedOutURL. | 1714 // Don't send state updates for kSwappedOutURL. |
| 1731 if (item.urlString() == WebString::fromUTF8(content::kSwappedOutURL)) | 1715 if (item.urlString() == WebString::fromUTF8(kSwappedOutURL)) |
| 1732 return; | 1716 return; |
| 1733 | 1717 |
| 1734 Send(new ViewHostMsg_UpdateState( | 1718 Send(new ViewHostMsg_UpdateState( |
| 1735 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); | 1719 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); |
| 1736 } | 1720 } |
| 1737 | 1721 |
| 1738 void RenderViewImpl::OpenURL(WebFrame* frame, | 1722 void RenderViewImpl::OpenURL(WebFrame* frame, |
| 1739 const GURL& url, | 1723 const GURL& url, |
| 1740 const Referrer& referrer, | 1724 const Referrer& referrer, |
| 1741 WebNavigationPolicy policy) { | 1725 WebNavigationPolicy policy) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1754 const WebURLRequest& failed_request, | 1738 const WebURLRequest& failed_request, |
| 1755 const WebURLError& error, | 1739 const WebURLError& error, |
| 1756 const std::string& html, | 1740 const std::string& html, |
| 1757 bool replace) { | 1741 bool replace) { |
| 1758 std::string alt_html; | 1742 std::string alt_html; |
| 1759 const std::string* error_html; | 1743 const std::string* error_html; |
| 1760 | 1744 |
| 1761 if (!html.empty()) { | 1745 if (!html.empty()) { |
| 1762 error_html = &html; | 1746 error_html = &html; |
| 1763 } else { | 1747 } else { |
| 1764 content::GetContentClient()->renderer()->GetNavigationErrorStrings( | 1748 GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 1765 failed_request, error, &alt_html, NULL); | 1749 failed_request, error, &alt_html, NULL); |
| 1766 error_html = &alt_html; | 1750 error_html = &alt_html; |
| 1767 } | 1751 } |
| 1768 | 1752 |
| 1769 frame->loadHTMLString(*error_html, | 1753 frame->loadHTMLString(*error_html, |
| 1770 GURL(content::kUnreachableWebDataURL), | 1754 GURL(kUnreachableWebDataURL), |
| 1771 error.unreachableURL, | 1755 error.unreachableURL, |
| 1772 replace); | 1756 replace); |
| 1773 } | 1757 } |
| 1774 | 1758 |
| 1775 bool RenderViewImpl::RunJavaScriptMessage(content::JavaScriptMessageType type, | 1759 bool RenderViewImpl::RunJavaScriptMessage(JavaScriptMessageType type, |
| 1776 const string16& message, | 1760 const string16& message, |
| 1777 const string16& default_value, | 1761 const string16& default_value, |
| 1778 const GURL& frame_url, | 1762 const GURL& frame_url, |
| 1779 string16* result) { | 1763 string16* result) { |
| 1780 bool success = false; | 1764 bool success = false; |
| 1781 string16 result_temp; | 1765 string16 result_temp; |
| 1782 if (!result) | 1766 if (!result) |
| 1783 result = &result_temp; | 1767 result = &result_temp; |
| 1784 | 1768 |
| 1785 SendAndRunNestedMessageLoop(new ViewHostMsg_RunJavaScriptMessage( | 1769 SendAndRunNestedMessageLoop(new ViewHostMsg_RunJavaScriptMessage( |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2123 color_chooser->Open(static_cast<SkColor>(initial_color)); | 2107 color_chooser->Open(static_cast<SkColor>(initial_color)); |
| 2124 return color_chooser; | 2108 return color_chooser; |
| 2125 } | 2109 } |
| 2126 | 2110 |
| 2127 bool RenderViewImpl::runFileChooser( | 2111 bool RenderViewImpl::runFileChooser( |
| 2128 const WebKit::WebFileChooserParams& params, | 2112 const WebKit::WebFileChooserParams& params, |
| 2129 WebFileChooserCompletion* chooser_completion) { | 2113 WebFileChooserCompletion* chooser_completion) { |
| 2130 // Do not open the file dialog in a hidden RenderView. | 2114 // Do not open the file dialog in a hidden RenderView. |
| 2131 if (is_hidden()) | 2115 if (is_hidden()) |
| 2132 return false; | 2116 return false; |
| 2133 content::FileChooserParams ipc_params; | 2117 FileChooserParams ipc_params; |
| 2134 if (params.directory) | 2118 if (params.directory) |
| 2135 ipc_params.mode = content::FileChooserParams::OpenFolder; | 2119 ipc_params.mode = FileChooserParams::OpenFolder; |
| 2136 else if (params.multiSelect) | 2120 else if (params.multiSelect) |
| 2137 ipc_params.mode = content::FileChooserParams::OpenMultiple; | 2121 ipc_params.mode = FileChooserParams::OpenMultiple; |
| 2138 else if (params.saveAs) | 2122 else if (params.saveAs) |
| 2139 ipc_params.mode = content::FileChooserParams::Save; | 2123 ipc_params.mode = FileChooserParams::Save; |
| 2140 else | 2124 else |
| 2141 ipc_params.mode = content::FileChooserParams::Open; | 2125 ipc_params.mode = FileChooserParams::Open; |
| 2142 ipc_params.title = params.title; | 2126 ipc_params.title = params.title; |
| 2143 ipc_params.default_file_name = | 2127 ipc_params.default_file_name = |
| 2144 webkit_glue::WebStringToFilePath(params.initialValue); | 2128 webkit_glue::WebStringToFilePath(params.initialValue); |
| 2145 ipc_params.accept_types.reserve(params.acceptTypes.size()); | 2129 ipc_params.accept_types.reserve(params.acceptTypes.size()); |
| 2146 for (size_t i = 0; i < params.acceptTypes.size(); ++i) | 2130 for (size_t i = 0; i < params.acceptTypes.size(); ++i) |
| 2147 ipc_params.accept_types.push_back(params.acceptTypes[i]); | 2131 ipc_params.accept_types.push_back(params.acceptTypes[i]); |
| 2148 | 2132 |
| 2149 return ScheduleFileChooser(ipc_params, chooser_completion); | 2133 return ScheduleFileChooser(ipc_params, chooser_completion); |
| 2150 } | 2134 } |
| 2151 | 2135 |
| 2152 void RenderViewImpl::runModalAlertDialog(WebFrame* frame, | 2136 void RenderViewImpl::runModalAlertDialog(WebFrame* frame, |
| 2153 const WebString& message) { | 2137 const WebString& message) { |
| 2154 RunJavaScriptMessage(content::JAVASCRIPT_MESSAGE_TYPE_ALERT, | 2138 RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_ALERT, |
| 2155 message, | 2139 message, |
| 2156 string16(), | 2140 string16(), |
| 2157 frame->document().url(), | 2141 frame->document().url(), |
| 2158 NULL); | 2142 NULL); |
| 2159 } | 2143 } |
| 2160 | 2144 |
| 2161 bool RenderViewImpl::runModalConfirmDialog(WebFrame* frame, | 2145 bool RenderViewImpl::runModalConfirmDialog(WebFrame* frame, |
| 2162 const WebString& message) { | 2146 const WebString& message) { |
| 2163 return RunJavaScriptMessage(content::JAVASCRIPT_MESSAGE_TYPE_CONFIRM, | 2147 return RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_CONFIRM, |
| 2164 message, | 2148 message, |
| 2165 string16(), | 2149 string16(), |
| 2166 frame->document().url(), | 2150 frame->document().url(), |
| 2167 NULL); | 2151 NULL); |
| 2168 } | 2152 } |
| 2169 | 2153 |
| 2170 bool RenderViewImpl::runModalPromptDialog(WebFrame* frame, | 2154 bool RenderViewImpl::runModalPromptDialog(WebFrame* frame, |
| 2171 const WebString& message, | 2155 const WebString& message, |
| 2172 const WebString& default_value, | 2156 const WebString& default_value, |
| 2173 WebString* actual_value) { | 2157 WebString* actual_value) { |
| 2174 string16 result; | 2158 string16 result; |
| 2175 bool ok = RunJavaScriptMessage(content::JAVASCRIPT_MESSAGE_TYPE_PROMPT, | 2159 bool ok = RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_PROMPT, |
| 2176 message, | 2160 message, |
| 2177 default_value, | 2161 default_value, |
| 2178 frame->document().url(), | 2162 frame->document().url(), |
| 2179 &result); | 2163 &result); |
| 2180 if (ok) | 2164 if (ok) |
| 2181 actual_value->assign(result); | 2165 actual_value->assign(result); |
| 2182 return ok; | 2166 return ok; |
| 2183 } | 2167 } |
| 2184 | 2168 |
| 2185 bool RenderViewImpl::runModalBeforeUnloadDialog( | 2169 bool RenderViewImpl::runModalBeforeUnloadDialog( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2206 } | 2190 } |
| 2207 | 2191 |
| 2208 void RenderViewImpl::showContextMenu( | 2192 void RenderViewImpl::showContextMenu( |
| 2209 WebFrame* frame, const WebContextMenuData& data) { | 2193 WebFrame* frame, const WebContextMenuData& data) { |
| 2210 // TODO(fsamuel): In the future, we might want the embedder to be able to | 2194 // TODO(fsamuel): In the future, we might want the embedder to be able to |
| 2211 // decide whether the guest can show a context menu or not. See | 2195 // decide whether the guest can show a context menu or not. See |
| 2212 // http://www.crbug.com/134207 | 2196 // http://www.crbug.com/134207 |
| 2213 if (GetGuestToEmbedderChannel()) | 2197 if (GetGuestToEmbedderChannel()) |
| 2214 return; | 2198 return; |
| 2215 | 2199 |
| 2216 content::ContextMenuParams params(data); | 2200 ContextMenuParams params(data); |
| 2217 | 2201 |
| 2218 // Plugins, e.g. PDF, don't currently update the render view when their | 2202 // Plugins, e.g. PDF, don't currently update the render view when their |
| 2219 // selected text changes, but the context menu params do contain the updated | 2203 // selected text changes, but the context menu params do contain the updated |
| 2220 // selection. If that's the case, update the render view's state just prior | 2204 // selection. If that's the case, update the render view's state just prior |
| 2221 // to showing the context menu. | 2205 // to showing the context menu. |
| 2222 // TODO(asvitkine): http://crbug.com/152432 | 2206 // TODO(asvitkine): http://crbug.com/152432 |
| 2223 if (params.selection_text != selection_text_) { | 2207 if (params.selection_text != selection_text_) { |
| 2224 selection_text_ = params.selection_text; | 2208 selection_text_ = params.selection_text; |
| 2225 // TODO(asvitkine): Text offset and range is not available in this case. | 2209 // TODO(asvitkine): Text offset and range is not available in this case. |
| 2226 selection_text_offset_ = 0; | 2210 selection_text_offset_ = 0; |
| 2227 selection_range_ = ui::Range(0, selection_text_.length()); | 2211 selection_range_ = ui::Range(0, selection_text_.length()); |
| 2228 Send(new ViewHostMsg_SelectionChanged(routing_id_, | 2212 Send(new ViewHostMsg_SelectionChanged(routing_id_, |
| 2229 selection_text_, | 2213 selection_text_, |
| 2230 selection_text_offset_, | 2214 selection_text_offset_, |
| 2231 selection_range_)); | 2215 selection_range_)); |
| 2232 } | 2216 } |
| 2233 | 2217 |
| 2234 // frame is NULL if invoked by BlockedPlugin. | 2218 // frame is NULL if invoked by BlockedPlugin. |
| 2235 if (frame) | 2219 if (frame) |
| 2236 params.frame_id = frame->identifier(); | 2220 params.frame_id = frame->identifier(); |
| 2237 | 2221 |
| 2238 // Serializing a GURL longer than content::kMaxURLChars will fail, so don't do | 2222 // Serializing a GURL longer than kMaxURLChars will fail, so don't do |
| 2239 // it. We replace it with an empty GURL so the appropriate items are disabled | 2223 // it. We replace it with an empty GURL so the appropriate items are disabled |
| 2240 // in the context menu. | 2224 // in the context menu. |
| 2241 // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large | 2225 // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large |
| 2242 // data encoded images. We should have a way to save them. | 2226 // data encoded images. We should have a way to save them. |
| 2243 if (params.src_url.spec().size() > content::kMaxURLChars) | 2227 if (params.src_url.spec().size() > kMaxURLChars) |
| 2244 params.src_url = GURL(); | 2228 params.src_url = GURL(); |
| 2245 context_menu_node_ = data.node; | 2229 context_menu_node_ = data.node; |
| 2246 | 2230 |
| 2247 #if defined(OS_ANDROID) | 2231 #if defined(OS_ANDROID) |
| 2248 gfx::Rect start_rect; | 2232 gfx::Rect start_rect; |
| 2249 gfx::Rect end_rect; | 2233 gfx::Rect end_rect; |
| 2250 GetSelectionBounds(&start_rect, &end_rect); | 2234 GetSelectionBounds(&start_rect, &end_rect); |
| 2251 gfx::Point start_point(start_rect.x(), | 2235 gfx::Point start_point(start_rect.x(), |
| 2252 start_rect.bottom()); | 2236 start_rect.bottom()); |
| 2253 gfx::Point end_point(end_rect.right(), | 2237 gfx::Point end_point(end_rect.right(), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2270 | 2254 |
| 2271 // Tell the browser to display a destination link. | 2255 // Tell the browser to display a destination link. |
| 2272 if (target_url_status_ == TARGET_INFLIGHT || | 2256 if (target_url_status_ == TARGET_INFLIGHT || |
| 2273 target_url_status_ == TARGET_PENDING) { | 2257 target_url_status_ == TARGET_PENDING) { |
| 2274 // If we have a request in-flight, save the URL to be sent when we | 2258 // If we have a request in-flight, save the URL to be sent when we |
| 2275 // receive an ACK to the in-flight request. We can happily overwrite | 2259 // receive an ACK to the in-flight request. We can happily overwrite |
| 2276 // any existing pending sends. | 2260 // any existing pending sends. |
| 2277 pending_target_url_ = latest_url; | 2261 pending_target_url_ = latest_url; |
| 2278 target_url_status_ = TARGET_PENDING; | 2262 target_url_status_ = TARGET_PENDING; |
| 2279 } else { | 2263 } else { |
| 2280 // URLs larger than |content::kMaxURLChars| cannot be sent through IPC - | 2264 // URLs larger than |kMaxURLChars| cannot be sent through IPC - |
| 2281 // see |ParamTraits<GURL>|. | 2265 // see |ParamTraits<GURL>|. |
| 2282 if (latest_url.possibly_invalid_spec().size() > content::kMaxURLChars) | 2266 if (latest_url.possibly_invalid_spec().size() > kMaxURLChars) |
| 2283 latest_url = GURL(); | 2267 latest_url = GURL(); |
| 2284 Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, latest_url)); | 2268 Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, latest_url)); |
| 2285 target_url_ = latest_url; | 2269 target_url_ = latest_url; |
| 2286 target_url_status_ = TARGET_INFLIGHT; | 2270 target_url_status_ = TARGET_INFLIGHT; |
| 2287 } | 2271 } |
| 2288 } | 2272 } |
| 2289 | 2273 |
| 2290 void RenderViewImpl::StartNavStateSyncTimerIfNecessary() { | 2274 void RenderViewImpl::StartNavStateSyncTimerIfNecessary() { |
| 2291 int delay; | 2275 int delay; |
| 2292 if (send_content_state_immediately_) | 2276 if (send_content_state_immediately_) |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2429 // created RenderView (i.e., as a blocked popup or as a new tab). | 2413 // created RenderView (i.e., as a blocked popup or as a new tab). |
| 2430 // | 2414 // |
| 2431 void RenderViewImpl::show(WebNavigationPolicy policy) { | 2415 void RenderViewImpl::show(WebNavigationPolicy policy) { |
| 2432 DCHECK(!did_show_) << "received extraneous Show call"; | 2416 DCHECK(!did_show_) << "received extraneous Show call"; |
| 2433 DCHECK(opener_id_ != MSG_ROUTING_NONE); | 2417 DCHECK(opener_id_ != MSG_ROUTING_NONE); |
| 2434 | 2418 |
| 2435 if (did_show_) | 2419 if (did_show_) |
| 2436 return; | 2420 return; |
| 2437 did_show_ = true; | 2421 did_show_ = true; |
| 2438 | 2422 |
| 2439 if (content::GetContentClient()->renderer()->AllowPopup(creator_url_)) | 2423 if (GetContentClient()->renderer()->AllowPopup(creator_url_)) |
| 2440 opened_by_user_gesture_ = true; | 2424 opened_by_user_gesture_ = true; |
| 2441 | 2425 |
| 2442 // Force new windows to a popup if they were not opened with a user gesture. | 2426 // Force new windows to a popup if they were not opened with a user gesture. |
| 2443 if (!opened_by_user_gesture_) { | 2427 if (!opened_by_user_gesture_) { |
| 2444 // We exempt background tabs for compat with older versions of Chrome. | 2428 // We exempt background tabs for compat with older versions of Chrome. |
| 2445 // TODO(darin): This seems bogus. These should have a user gesture, so | 2429 // TODO(darin): This seems bogus. These should have a user gesture, so |
| 2446 // we probably don't need this check. | 2430 // we probably don't need this check. |
| 2447 if (policy != WebKit::WebNavigationPolicyNewBackgroundTab) | 2431 if (policy != WebKit::WebNavigationPolicyNewBackgroundTab) |
| 2448 policy = WebKit::WebNavigationPolicyNewPopup; | 2432 policy = WebKit::WebNavigationPolicyNewPopup; |
| 2449 } | 2433 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2506 RenderWidget::didActivateCompositor(input_handler_identifier); | 2490 RenderWidget::didActivateCompositor(input_handler_identifier); |
| 2507 | 2491 |
| 2508 ProcessAcceleratedPinchZoomFlags(*CommandLine::ForCurrentProcess()); | 2492 ProcessAcceleratedPinchZoomFlags(*CommandLine::ForCurrentProcess()); |
| 2509 } | 2493 } |
| 2510 | 2494 |
| 2511 // WebKit::WebFrameClient ----------------------------------------------------- | 2495 // WebKit::WebFrameClient ----------------------------------------------------- |
| 2512 | 2496 |
| 2513 WebPlugin* RenderViewImpl::createPlugin(WebFrame* frame, | 2497 WebPlugin* RenderViewImpl::createPlugin(WebFrame* frame, |
| 2514 const WebPluginParams& params) { | 2498 const WebPluginParams& params) { |
| 2515 WebPlugin* plugin = NULL; | 2499 WebPlugin* plugin = NULL; |
| 2516 if (content::GetContentClient()->renderer()->OverrideCreatePlugin( | 2500 if (GetContentClient()->renderer()->OverrideCreatePlugin( |
| 2517 this, frame, params, &plugin)) { | 2501 this, frame, params, &plugin)) { |
| 2518 return plugin; | 2502 return plugin; |
| 2519 } | 2503 } |
| 2520 | 2504 |
| 2521 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 2505 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 2522 if (UTF16ToASCII(params.mimeType) == content::kBrowserPluginMimeType) { | 2506 if (UTF16ToASCII(params.mimeType) == kBrowserPluginMimeType) { |
| 2523 if (cmd_line->HasSwitch(switches::kEnableBrowserPluginOldImplementation)) { | 2507 if (cmd_line->HasSwitch(switches::kEnableBrowserPluginOldImplementation)) { |
| 2524 // TODO(fsamuel): Remove this once upstreaming of the new browser plugin | 2508 // TODO(fsamuel): Remove this once upstreaming of the new browser plugin |
| 2525 // is complete. | 2509 // is complete. |
| 2526 return content::old::BrowserPlugin::Create(this, frame, params); | 2510 return old::BrowserPlugin::Create(this, frame, params); |
| 2527 } else { | 2511 } else { |
| 2528 return content::BrowserPluginManager::Get()->CreateBrowserPlugin(this, | 2512 return BrowserPluginManager::Get()->CreateBrowserPlugin(this, frame, |
| 2529 frame, | 2513 params); |
| 2530 params); | |
| 2531 } | 2514 } |
| 2532 } | 2515 } |
| 2533 | 2516 |
| 2534 webkit::WebPluginInfo info; | 2517 webkit::WebPluginInfo info; |
| 2535 std::string mime_type; | 2518 std::string mime_type; |
| 2536 bool found = GetPluginInfo(params.url, frame->top()->document().url(), | 2519 bool found = GetPluginInfo(params.url, frame->top()->document().url(), |
| 2537 params.mimeType.utf8(), &info, &mime_type); | 2520 params.mimeType.utf8(), &info, &mime_type); |
| 2538 if (!found) | 2521 if (!found) |
| 2539 return NULL; | 2522 return NULL; |
| 2540 | 2523 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2575 FOR_EACH_OBSERVER( | 2558 FOR_EACH_OBSERVER( |
| 2576 RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client)); | 2559 RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client)); |
| 2577 | 2560 |
| 2578 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 2561 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 2579 #if defined(OS_ANDROID) | 2562 #if defined(OS_ANDROID) |
| 2580 WebGraphicsContext3D* resource_context = | 2563 WebGraphicsContext3D* resource_context = |
| 2581 GetWebView()->sharedGraphicsContext3D(); | 2564 GetWebView()->sharedGraphicsContext3D(); |
| 2582 | 2565 |
| 2583 GpuChannelHost* gpu_channel_host = | 2566 GpuChannelHost* gpu_channel_host = |
| 2584 RenderThreadImpl::current()->EstablishGpuChannelSync( | 2567 RenderThreadImpl::current()->EstablishGpuChannelSync( |
| 2585 content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); | 2568 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); |
| 2586 if (!gpu_channel_host) { | 2569 if (!gpu_channel_host) { |
| 2587 LOG(ERROR) << "Failed to establish GPU channel for media player"; | 2570 LOG(ERROR) << "Failed to establish GPU channel for media player"; |
| 2588 return NULL; | 2571 return NULL; |
| 2589 } | 2572 } |
| 2590 | 2573 |
| 2591 if (cmd_line->HasSwitch(switches::kMediaPlayerInRenderProcess)) { | 2574 if (cmd_line->HasSwitch(switches::kMediaPlayerInRenderProcess)) { |
| 2592 if (!media_bridge_manager_.get()) { | 2575 if (!media_bridge_manager_.get()) { |
| 2593 media_bridge_manager_.reset( | 2576 media_bridge_manager_.reset( |
| 2594 new webkit_media::MediaPlayerBridgeManagerImpl(1)); | 2577 new webkit_media::MediaPlayerBridgeManagerImpl(1)); |
| 2595 } | 2578 } |
| 2596 return new webkit_media::WebMediaPlayerInProcessAndroid( | 2579 return new webkit_media::WebMediaPlayerInProcessAndroid( |
| 2597 frame, | 2580 frame, |
| 2598 client, | 2581 client, |
| 2599 cookieJar(frame), | 2582 cookieJar(frame), |
| 2600 media_player_manager_.get(), | 2583 media_player_manager_.get(), |
| 2601 media_bridge_manager_.get(), | 2584 media_bridge_manager_.get(), |
| 2602 new content::StreamTextureFactoryImpl( | 2585 new StreamTextureFactoryImpl( |
| 2603 resource_context, gpu_channel_host, routing_id_), | 2586 resource_context, gpu_channel_host, routing_id_), |
| 2604 cmd_line->HasSwitch(switches::kDisableMediaHistoryLogging)); | 2587 cmd_line->HasSwitch(switches::kDisableMediaHistoryLogging)); |
| 2605 } | 2588 } |
| 2606 if (!media_player_proxy_) { | 2589 if (!media_player_proxy_) { |
| 2607 media_player_proxy_ = new content::WebMediaPlayerProxyImplAndroid( | 2590 media_player_proxy_ = new WebMediaPlayerProxyImplAndroid( |
| 2608 this, media_player_manager_.get()); | 2591 this, media_player_manager_.get()); |
| 2609 } | 2592 } |
| 2610 return new webkit_media::WebMediaPlayerImplAndroid( | 2593 return new webkit_media::WebMediaPlayerImplAndroid( |
| 2611 frame, | 2594 frame, |
| 2612 client, | 2595 client, |
| 2613 media_player_manager_.get(), | 2596 media_player_manager_.get(), |
| 2614 media_player_proxy_, | 2597 media_player_proxy_, |
| 2615 new content::StreamTextureFactoryImpl( | 2598 new StreamTextureFactoryImpl( |
| 2616 resource_context, gpu_channel_host, routing_id_)); | 2599 resource_context, gpu_channel_host, routing_id_)); |
| 2617 #endif | 2600 #endif |
| 2618 | 2601 |
| 2619 media::MessageLoopFactory* message_loop_factory = | 2602 media::MessageLoopFactory* message_loop_factory = |
| 2620 new media::MessageLoopFactory(); | 2603 new media::MessageLoopFactory(); |
| 2621 media::FilterCollection* collection = new media::FilterCollection(); | 2604 media::FilterCollection* collection = new media::FilterCollection(); |
| 2622 RenderMediaLog* render_media_log = new RenderMediaLog(); | 2605 RenderMediaLog* render_media_log = new RenderMediaLog(); |
| 2623 | 2606 |
| 2624 RenderAudioSourceProvider* audio_source_provider = NULL; | 2607 RenderAudioSourceProvider* audio_source_provider = NULL; |
| 2625 | 2608 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2640 if (!cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) | 2623 if (!cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) |
| 2641 context3d = RenderThreadImpl::current()->GetGpuVDAContext3D(); | 2624 context3d = RenderThreadImpl::current()->GetGpuVDAContext3D(); |
| 2642 if (context3d) { | 2625 if (context3d) { |
| 2643 scoped_refptr<base::MessageLoopProxy> factories_loop = | 2626 scoped_refptr<base::MessageLoopProxy> factories_loop = |
| 2644 RenderThreadImpl::current()->compositor_thread() ? | 2627 RenderThreadImpl::current()->compositor_thread() ? |
| 2645 RenderThreadImpl::current()->compositor_thread()->GetWebThread() | 2628 RenderThreadImpl::current()->compositor_thread()->GetWebThread() |
| 2646 ->message_loop()->message_loop_proxy() : | 2629 ->message_loop()->message_loop_proxy() : |
| 2647 base::MessageLoopProxy::current(); | 2630 base::MessageLoopProxy::current(); |
| 2648 GpuChannelHost* gpu_channel_host = | 2631 GpuChannelHost* gpu_channel_host = |
| 2649 RenderThreadImpl::current()->EstablishGpuChannelSync( | 2632 RenderThreadImpl::current()->EstablishGpuChannelSync( |
| 2650 content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); | 2633 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); |
| 2651 collection->GetVideoDecoders()->push_back(new media::GpuVideoDecoder( | 2634 collection->GetVideoDecoders()->push_back(new media::GpuVideoDecoder( |
| 2652 base::Bind(&media::MessageLoopFactory::GetMessageLoop, | 2635 base::Bind(&media::MessageLoopFactory::GetMessageLoop, |
| 2653 base::Unretained(message_loop_factory), | 2636 base::Unretained(message_loop_factory), |
| 2654 media::MessageLoopFactory::kDecoder), | 2637 media::MessageLoopFactory::kDecoder), |
| 2655 factories_loop, | 2638 factories_loop, |
| 2656 new RendererGpuVideoDecoderFactories( | 2639 new RendererGpuVideoDecoderFactories( |
| 2657 gpu_channel_host, factories_loop, context3d))); | 2640 gpu_channel_host, factories_loop, context3d))); |
| 2658 } | 2641 } |
| 2659 | 2642 |
| 2660 WebMediaPlayer* media_player = | 2643 WebMediaPlayer* media_player = |
| 2661 content::GetContentClient()->renderer()->OverrideCreateWebMediaPlayer( | 2644 GetContentClient()->renderer()->OverrideCreateWebMediaPlayer( |
| 2662 this, frame, client, AsWeakPtr(), collection, audio_source_provider, | 2645 this, frame, client, AsWeakPtr(), collection, audio_source_provider, |
| 2663 audio_source_provider, message_loop_factory, media_stream_impl_, | 2646 audio_source_provider, message_loop_factory, media_stream_impl_, |
| 2664 render_media_log); | 2647 render_media_log); |
| 2665 if (!media_player) { | 2648 if (!media_player) { |
| 2666 #if defined(ENABLE_WEBRTC) | 2649 #if defined(ENABLE_WEBRTC) |
| 2667 // TODO(wjia): when all patches related to WebMediaPlayerMS have been | 2650 // TODO(wjia): when all patches related to WebMediaPlayerMS have been |
| 2668 // landed, remove the switch. Refer to crbug.com/142988. | 2651 // landed, remove the switch. Refer to crbug.com/142988. |
| 2669 if (!cmd_line->HasSwitch(switches::kDisableWebMediaPlayerMS) && | 2652 if (!cmd_line->HasSwitch(switches::kDisableWebMediaPlayerMS) && |
| 2670 MediaStreamImpl::CheckMediaStream(url)) { | 2653 MediaStreamImpl::CheckMediaStream(url)) { |
| 2671 EnsureMediaStreamImpl(); | 2654 EnsureMediaStreamImpl(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2743 } | 2726 } |
| 2744 | 2727 |
| 2745 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( | 2728 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( |
| 2746 WebFrame* frame, const WebURLRequest& request, WebNavigationType type, | 2729 WebFrame* frame, const WebURLRequest& request, WebNavigationType type, |
| 2747 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { | 2730 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { |
| 2748 Referrer referrer( | 2731 Referrer referrer( |
| 2749 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), | 2732 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
| 2750 GetReferrerPolicyFromRequest(frame, request)); | 2733 GetReferrerPolicyFromRequest(frame, request)); |
| 2751 | 2734 |
| 2752 if (is_swapped_out_) { | 2735 if (is_swapped_out_) { |
| 2753 if (request.url() != GURL(content::kSwappedOutURL)) { | 2736 if (request.url() != GURL(kSwappedOutURL)) { |
| 2754 // Targeted links may try to navigate a swapped out frame. Allow the | 2737 // Targeted links may try to navigate a swapped out frame. Allow the |
| 2755 // browser process to navigate the tab instead. Note that it is also | 2738 // browser process to navigate the tab instead. Note that it is also |
| 2756 // possible for non-targeted navigations (from this view) to arrive | 2739 // possible for non-targeted navigations (from this view) to arrive |
| 2757 // here just after we are swapped out. It's ok to send them to the | 2740 // here just after we are swapped out. It's ok to send them to the |
| 2758 // browser, as long as they're for the top level frame. | 2741 // browser, as long as they're for the top level frame. |
| 2759 // TODO(creis): Ensure this supports targeted form submissions when | 2742 // TODO(creis): Ensure this supports targeted form submissions when |
| 2760 // fixing http://crbug.com/101395. | 2743 // fixing http://crbug.com/101395. |
| 2761 if (frame->parent() == NULL) { | 2744 if (frame->parent() == NULL) { |
| 2762 OpenURL(frame, request.url(), referrer, default_policy); | 2745 OpenURL(frame, request.url(), referrer, default_policy); |
| 2763 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. | 2746 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
| 2764 } | 2747 } |
| 2765 | 2748 |
| 2766 // We should otherwise ignore in-process iframe navigations, if they | 2749 // We should otherwise ignore in-process iframe navigations, if they |
| 2767 // arrive just after we are swapped out. | 2750 // arrive just after we are swapped out. |
| 2768 return WebKit::WebNavigationPolicyIgnore; | 2751 return WebKit::WebNavigationPolicyIgnore; |
| 2769 } | 2752 } |
| 2770 | 2753 |
| 2771 // Allow content::kSwappedOutURL to complete. | 2754 // Allow kSwappedOutURL to complete. |
| 2772 return default_policy; | 2755 return default_policy; |
| 2773 } | 2756 } |
| 2774 | 2757 |
| 2775 // Webkit is asking whether to navigate to a new URL. | 2758 // Webkit is asking whether to navigate to a new URL. |
| 2776 // This is fine normally, except if we're showing UI from one security | 2759 // This is fine normally, except if we're showing UI from one security |
| 2777 // context and they're trying to navigate to a different context. | 2760 // context and they're trying to navigate to a different context. |
| 2778 const GURL& url = request.url(); | 2761 const GURL& url = request.url(); |
| 2779 | 2762 |
| 2780 // A content initiated navigation may have originated from a link-click, | 2763 // A content initiated navigation may have originated from a link-click, |
| 2781 // script, drag-n-drop operation, etc. | 2764 // script, drag-n-drop operation, etc. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2851 // must be handled by the browser process so that the correct bindings and | 2834 // must be handled by the browser process so that the correct bindings and |
| 2852 // data sources can be registered. | 2835 // data sources can be registered. |
| 2853 // Similarly, navigations to view-source URLs or within ViewSource mode | 2836 // Similarly, navigations to view-source URLs or within ViewSource mode |
| 2854 // must be handled by the browser process. | 2837 // must be handled by the browser process. |
| 2855 // Lastly, access to file:// URLs from non-file:// URL pages must be | 2838 // Lastly, access to file:// URLs from non-file:// URL pages must be |
| 2856 // handled by the browser so that ordinary renderer processes don't get | 2839 // handled by the browser so that ordinary renderer processes don't get |
| 2857 // blessed with file permissions. | 2840 // blessed with file permissions. |
| 2858 int cumulative_bindings = RenderProcess::current()->GetEnabledBindings(); | 2841 int cumulative_bindings = RenderProcess::current()->GetEnabledBindings(); |
| 2859 bool is_initial_navigation = page_id_ == -1; | 2842 bool is_initial_navigation = page_id_ == -1; |
| 2860 bool should_fork = | 2843 bool should_fork = |
| 2861 content::GetContentClient()->HasWebUIScheme(url) || | 2844 GetContentClient()->HasWebUIScheme(url) || |
| 2862 (cumulative_bindings & content::BINDINGS_POLICY_WEB_UI) || | 2845 (cumulative_bindings & BINDINGS_POLICY_WEB_UI) || |
| 2863 url.SchemeIs(chrome::kViewSourceScheme) || | 2846 url.SchemeIs(chrome::kViewSourceScheme) || |
| 2864 frame->isViewSourceModeEnabled(); | 2847 frame->isViewSourceModeEnabled(); |
| 2865 | 2848 |
| 2866 if (!should_fork && url.SchemeIs(chrome::kFileScheme)) { | 2849 if (!should_fork && url.SchemeIs(chrome::kFileScheme)) { |
| 2867 // Fork non-file to file opens. Check the opener URL if this is the | 2850 // Fork non-file to file opens. Check the opener URL if this is the |
| 2868 // initial navigation in a newly opened window. | 2851 // initial navigation in a newly opened window. |
| 2869 GURL source_url(old_url); | 2852 GURL source_url(old_url); |
| 2870 if (is_initial_navigation && source_url.is_empty() && frame->opener()) | 2853 if (is_initial_navigation && source_url.is_empty() && frame->opener()) |
| 2871 source_url = frame->opener()->top()->document().url(); | 2854 source_url = frame->opener()->top()->document().url(); |
| 2872 DCHECK(!source_url.is_empty()); | 2855 DCHECK(!source_url.is_empty()); |
| 2873 should_fork = !source_url.SchemeIs(chrome::kFileScheme); | 2856 should_fork = !source_url.SchemeIs(chrome::kFileScheme); |
| 2874 } | 2857 } |
| 2875 | 2858 |
| 2876 if (!should_fork) { | 2859 if (!should_fork) { |
| 2877 // Give the embedder a chance. | 2860 // Give the embedder a chance. |
| 2878 // For now, we skip this for POST submissions. This is because | 2861 // For now, we skip this for POST submissions. This is because |
| 2879 // http://crbug.com/101395 is more likely to cause compatibility issues | 2862 // http://crbug.com/101395 is more likely to cause compatibility issues |
| 2880 // with hosted apps and extensions than WebUI pages. We will remove this | 2863 // with hosted apps and extensions than WebUI pages. We will remove this |
| 2881 // check when cross-process POST submissions are supported. | 2864 // check when cross-process POST submissions are supported. |
| 2882 if (request.httpMethod() == "GET") { | 2865 if (request.httpMethod() == "GET") { |
| 2883 should_fork = content::GetContentClient()->renderer()->ShouldFork( | 2866 should_fork = GetContentClient()->renderer()->ShouldFork( |
| 2884 frame, url, is_initial_navigation, &send_referrer); | 2867 frame, url, is_initial_navigation, &send_referrer); |
| 2885 } | 2868 } |
| 2886 } | 2869 } |
| 2887 | 2870 |
| 2888 if (should_fork) { | 2871 if (should_fork) { |
| 2889 OpenURL( | 2872 OpenURL( |
| 2890 frame, url, send_referrer ? referrer : Referrer(), default_policy); | 2873 frame, url, send_referrer ? referrer : Referrer(), default_policy); |
| 2891 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. | 2874 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
| 2892 } | 2875 } |
| 2893 } | 2876 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2961 } | 2944 } |
| 2962 | 2945 |
| 2963 void RenderViewImpl::willSendSubmitEvent(WebKit::WebFrame* frame, | 2946 void RenderViewImpl::willSendSubmitEvent(WebKit::WebFrame* frame, |
| 2964 const WebKit::WebFormElement& form) { | 2947 const WebKit::WebFormElement& form) { |
| 2965 // Some login forms have onSubmit handlers that put a hash of the password | 2948 // Some login forms have onSubmit handlers that put a hash of the password |
| 2966 // into a hidden field and then clear the password. (Issue 28910.) | 2949 // into a hidden field and then clear the password. (Issue 28910.) |
| 2967 // This method gets called before any of those handlers run, so save away | 2950 // This method gets called before any of those handlers run, so save away |
| 2968 // a copy of the password in case it gets lost. | 2951 // a copy of the password in case it gets lost. |
| 2969 DocumentState* document_state = | 2952 DocumentState* document_state = |
| 2970 DocumentState::FromDataSource(frame->dataSource()); | 2953 DocumentState::FromDataSource(frame->dataSource()); |
| 2971 document_state->set_password_form_data(content::CreatePasswordForm(form)); | 2954 document_state->set_password_form_data(CreatePasswordForm(form)); |
| 2972 } | 2955 } |
| 2973 | 2956 |
| 2974 void RenderViewImpl::willSubmitForm(WebFrame* frame, | 2957 void RenderViewImpl::willSubmitForm(WebFrame* frame, |
| 2975 const WebFormElement& form) { | 2958 const WebFormElement& form) { |
| 2976 DocumentState* document_state = | 2959 DocumentState* document_state = |
| 2977 DocumentState::FromDataSource(frame->provisionalDataSource()); | 2960 DocumentState::FromDataSource(frame->provisionalDataSource()); |
| 2978 NavigationState* navigation_state = document_state->navigation_state(); | 2961 NavigationState* navigation_state = document_state->navigation_state(); |
| 2979 | 2962 |
| 2980 if (navigation_state->transition_type() == content::PAGE_TRANSITION_LINK) | 2963 if (navigation_state->transition_type() == PAGE_TRANSITION_LINK) |
| 2981 navigation_state->set_transition_type(content::PAGE_TRANSITION_FORM_SUBMIT); | 2964 navigation_state->set_transition_type(PAGE_TRANSITION_FORM_SUBMIT); |
| 2982 | 2965 |
| 2983 // Save these to be processed when the ensuing navigation is committed. | 2966 // Save these to be processed when the ensuing navigation is committed. |
| 2984 WebSearchableFormData web_searchable_form_data(form); | 2967 WebSearchableFormData web_searchable_form_data(form); |
| 2985 document_state->set_searchable_form_url(web_searchable_form_data.url()); | 2968 document_state->set_searchable_form_url(web_searchable_form_data.url()); |
| 2986 document_state->set_searchable_form_encoding( | 2969 document_state->set_searchable_form_encoding( |
| 2987 web_searchable_form_data.encoding().utf8()); | 2970 web_searchable_form_data.encoding().utf8()); |
| 2988 scoped_ptr<PasswordForm> password_form_data = | 2971 scoped_ptr<PasswordForm> password_form_data = |
| 2989 content::CreatePasswordForm(form); | 2972 CreatePasswordForm(form); |
| 2990 | 2973 |
| 2991 // In order to save the password that the user actually typed and not one | 2974 // In order to save the password that the user actually typed and not one |
| 2992 // that may have gotten transformed by the site prior to submit, recover it | 2975 // that may have gotten transformed by the site prior to submit, recover it |
| 2993 // from the form contents already stored by |willSendSubmitEvent| into the | 2976 // from the form contents already stored by |willSendSubmitEvent| into the |
| 2994 // dataSource's NavigationState (as opposed to the provisionalDataSource's, | 2977 // dataSource's NavigationState (as opposed to the provisionalDataSource's, |
| 2995 // which is what we're storing into now.) | 2978 // which is what we're storing into now.) |
| 2996 if (password_form_data.get()) { | 2979 if (password_form_data.get()) { |
| 2997 DocumentState* old_document_state = | 2980 DocumentState* old_document_state = |
| 2998 DocumentState::FromDataSource(frame->dataSource()); | 2981 DocumentState::FromDataSource(frame->dataSource()); |
| 2999 if (old_document_state) { | 2982 if (old_document_state) { |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3239 if (is_top_most) { | 3222 if (is_top_most) { |
| 3240 navigation_gesture_ = frame->isProcessingUserGesture() ? | 3223 navigation_gesture_ = frame->isProcessingUserGesture() ? |
| 3241 NavigationGestureUser : NavigationGestureAuto; | 3224 NavigationGestureUser : NavigationGestureAuto; |
| 3242 | 3225 |
| 3243 // Make sure redirect tracking state is clear for the new load. | 3226 // Make sure redirect tracking state is clear for the new load. |
| 3244 completed_client_redirect_src_ = Referrer(); | 3227 completed_client_redirect_src_ = Referrer(); |
| 3245 } else if (frame->parent()->isLoading()) { | 3228 } else if (frame->parent()->isLoading()) { |
| 3246 // Take note of AUTO_SUBFRAME loads here, so that we can know how to | 3229 // Take note of AUTO_SUBFRAME loads here, so that we can know how to |
| 3247 // load an error page. See didFailProvisionalLoad. | 3230 // load an error page. See didFailProvisionalLoad. |
| 3248 document_state->navigation_state()->set_transition_type( | 3231 document_state->navigation_state()->set_transition_type( |
| 3249 content::PAGE_TRANSITION_AUTO_SUBFRAME); | 3232 PAGE_TRANSITION_AUTO_SUBFRAME); |
| 3250 } | 3233 } |
| 3251 | 3234 |
| 3252 FOR_EACH_OBSERVER( | 3235 FOR_EACH_OBSERVER( |
| 3253 RenderViewObserver, observers_, DidStartProvisionalLoad(frame)); | 3236 RenderViewObserver, observers_, DidStartProvisionalLoad(frame)); |
| 3254 | 3237 |
| 3255 Send(new ViewHostMsg_DidStartProvisionalLoadForFrame( | 3238 Send(new ViewHostMsg_DidStartProvisionalLoadForFrame( |
| 3256 routing_id_, frame->identifier(), | 3239 routing_id_, frame->identifier(), |
| 3257 frame->parent() ? frame->parent()->identifier() : -1, | 3240 frame->parent() ? frame->parent()->identifier() : -1, |
| 3258 is_top_most, GetOpenerUrl(), ds->request().url())); | 3241 is_top_most, GetOpenerUrl(), ds->request().url())); |
| 3259 } | 3242 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3294 RenderViewObserver, observers_, DidFailProvisionalLoad(frame, error)); | 3277 RenderViewObserver, observers_, DidFailProvisionalLoad(frame, error)); |
| 3295 | 3278 |
| 3296 bool show_repost_interstitial = | 3279 bool show_repost_interstitial = |
| 3297 (error.reason == net::ERR_CACHE_MISS && | 3280 (error.reason == net::ERR_CACHE_MISS && |
| 3298 EqualsASCII(failed_request.httpMethod(), "POST")); | 3281 EqualsASCII(failed_request.httpMethod(), "POST")); |
| 3299 | 3282 |
| 3300 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; | 3283 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; |
| 3301 params.frame_id = frame->identifier(); | 3284 params.frame_id = frame->identifier(); |
| 3302 params.is_main_frame = !frame->parent(); | 3285 params.is_main_frame = !frame->parent(); |
| 3303 params.error_code = error.reason; | 3286 params.error_code = error.reason; |
| 3304 content::GetContentClient()->renderer()->GetNavigationErrorStrings( | 3287 GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 3305 failed_request, | 3288 failed_request, |
| 3306 error, | 3289 error, |
| 3307 NULL, | 3290 NULL, |
| 3308 ¶ms.error_description); | 3291 ¶ms.error_description); |
| 3309 params.url = error.unreachableURL; | 3292 params.url = error.unreachableURL; |
| 3310 params.showing_repost_interstitial = show_repost_interstitial; | 3293 params.showing_repost_interstitial = show_repost_interstitial; |
| 3311 Send(new ViewHostMsg_DidFailProvisionalLoadWithError( | 3294 Send(new ViewHostMsg_DidFailProvisionalLoadWithError( |
| 3312 routing_id_, params)); | 3295 routing_id_, params)); |
| 3313 | 3296 |
| 3314 // Don't display an error page if this is simply a cancelled load. Aside | 3297 // Don't display an error page if this is simply a cancelled load. Aside |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3326 // 'replace' load. This is necessary to avoid messing up session history. | 3309 // 'replace' load. This is necessary to avoid messing up session history. |
| 3327 // Otherwise, we do a normal load, which simulates a 'go' navigation as far | 3310 // Otherwise, we do a normal load, which simulates a 'go' navigation as far |
| 3328 // as session history is concerned. | 3311 // as session history is concerned. |
| 3329 // | 3312 // |
| 3330 // AUTO_SUBFRAME loads should always be treated as loads that do not advance | 3313 // AUTO_SUBFRAME loads should always be treated as loads that do not advance |
| 3331 // the page id. | 3314 // the page id. |
| 3332 // | 3315 // |
| 3333 bool replace = | 3316 bool replace = |
| 3334 navigation_state->pending_page_id() != -1 || | 3317 navigation_state->pending_page_id() != -1 || |
| 3335 navigation_state->transition_type() == | 3318 navigation_state->transition_type() == |
| 3336 content::PAGE_TRANSITION_AUTO_SUBFRAME; | 3319 PAGE_TRANSITION_AUTO_SUBFRAME; |
| 3337 | 3320 |
| 3338 // If we failed on a browser initiated request, then make sure that our error | 3321 // If we failed on a browser initiated request, then make sure that our error |
| 3339 // page load is regarded as the same browser initiated request. | 3322 // page load is regarded as the same browser initiated request. |
| 3340 if (!navigation_state->is_content_initiated()) { | 3323 if (!navigation_state->is_content_initiated()) { |
| 3341 pending_navigation_params_.reset(new ViewMsg_Navigate_Params); | 3324 pending_navigation_params_.reset(new ViewMsg_Navigate_Params); |
| 3342 pending_navigation_params_->page_id = | 3325 pending_navigation_params_->page_id = |
| 3343 navigation_state->pending_page_id(); | 3326 navigation_state->pending_page_id(); |
| 3344 pending_navigation_params_->pending_history_list_offset = | 3327 pending_navigation_params_->pending_history_list_offset = |
| 3345 navigation_state->pending_history_list_offset(); | 3328 navigation_state->pending_history_list_offset(); |
| 3346 pending_navigation_params_->transition = | 3329 pending_navigation_params_->transition = |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3380 } | 3363 } |
| 3381 | 3364 |
| 3382 if (is_new_navigation) { | 3365 if (is_new_navigation) { |
| 3383 // When we perform a new navigation, we need to update the last committed | 3366 // When we perform a new navigation, we need to update the last committed |
| 3384 // session history entry with state for the page we are leaving. | 3367 // session history entry with state for the page we are leaving. |
| 3385 UpdateSessionHistory(frame); | 3368 UpdateSessionHistory(frame); |
| 3386 | 3369 |
| 3387 // We bump our Page ID to correspond with the new session history entry. | 3370 // We bump our Page ID to correspond with the new session history entry. |
| 3388 page_id_ = next_page_id_++; | 3371 page_id_ = next_page_id_++; |
| 3389 | 3372 |
| 3390 // Don't update history_page_ids_ (etc) for content::kSwappedOutURL, since | 3373 // Don't update history_page_ids_ (etc) for kSwappedOutURL, since |
| 3391 // we don't want to forget the entry that was there, and since we will | 3374 // we don't want to forget the entry that was there, and since we will |
| 3392 // never come back to content::kSwappedOutURL. Note that we have to call | 3375 // never come back to kSwappedOutURL. Note that we have to call |
| 3393 // UpdateSessionHistory and update page_id_ even in this case, so that | 3376 // UpdateSessionHistory and update page_id_ even in this case, so that |
| 3394 // the current entry gets a state update and so that we don't send a | 3377 // the current entry gets a state update and so that we don't send a |
| 3395 // state update to the wrong entry when we swap back in. | 3378 // state update to the wrong entry when we swap back in. |
| 3396 if (GetLoadingUrl(frame) != GURL(content::kSwappedOutURL)) { | 3379 if (GetLoadingUrl(frame) != GURL(kSwappedOutURL)) { |
| 3397 // Advance our offset in session history, applying the length limit. | 3380 // Advance our offset in session history, applying the length limit. |
| 3398 // There is now no forward history. | 3381 // There is now no forward history. |
| 3399 history_list_offset_++; | 3382 history_list_offset_++; |
| 3400 if (history_list_offset_ >= content::kMaxSessionHistoryEntries) | 3383 if (history_list_offset_ >= kMaxSessionHistoryEntries) |
| 3401 history_list_offset_ = content::kMaxSessionHistoryEntries - 1; | 3384 history_list_offset_ = kMaxSessionHistoryEntries - 1; |
| 3402 history_list_length_ = history_list_offset_ + 1; | 3385 history_list_length_ = history_list_offset_ + 1; |
| 3403 history_page_ids_.resize(history_list_length_, -1); | 3386 history_page_ids_.resize(history_list_length_, -1); |
| 3404 history_page_ids_[history_list_offset_] = page_id_; | 3387 history_page_ids_[history_list_offset_] = page_id_; |
| 3405 } | 3388 } |
| 3406 } else { | 3389 } else { |
| 3407 // Inspect the navigation_state on this frame to see if the navigation | 3390 // Inspect the navigation_state on this frame to see if the navigation |
| 3408 // corresponds to a session history navigation... Note: |frame| may or | 3391 // corresponds to a session history navigation... Note: |frame| may or |
| 3409 // may not be the toplevel frame, but for the case of capturing session | 3392 // may not be the toplevel frame, but for the case of capturing session |
| 3410 // history, the first committed frame suffices. We keep track of whether | 3393 // history, the first committed frame suffices. We keep track of whether |
| 3411 // we've seen this commit before so that only capture session history once | 3394 // we've seen this commit before so that only capture session history once |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3458 g_view_map.Get().size()); | 3441 g_view_map.Get().size()); |
| 3459 } | 3442 } |
| 3460 } | 3443 } |
| 3461 } | 3444 } |
| 3462 | 3445 |
| 3463 void RenderViewImpl::didClearWindowObject(WebFrame* frame) { | 3446 void RenderViewImpl::didClearWindowObject(WebFrame* frame) { |
| 3464 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 3447 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 3465 DidClearWindowObject(frame)); | 3448 DidClearWindowObject(frame)); |
| 3466 | 3449 |
| 3467 GURL frame_url = frame->document().url(); | 3450 GURL frame_url = frame->document().url(); |
| 3468 if ((enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) && | 3451 if ((enabled_bindings_ & BINDINGS_POLICY_WEB_UI) && |
| 3469 (frame_url.SchemeIs(chrome::kChromeUIScheme) || | 3452 (frame_url.SchemeIs(chrome::kChromeUIScheme) || |
| 3470 frame_url.SchemeIs(chrome::kDataScheme))) { | 3453 frame_url.SchemeIs(chrome::kDataScheme))) { |
| 3471 GetWebUIBindings()->BindToJavascript(frame, "chrome"); | 3454 GetWebUIBindings()->BindToJavascript(frame, "chrome"); |
| 3472 } | 3455 } |
| 3473 | 3456 |
| 3474 if (enabled_bindings_ & content::BINDINGS_POLICY_DOM_AUTOMATION) { | 3457 if (enabled_bindings_ & BINDINGS_POLICY_DOM_AUTOMATION) { |
| 3475 if (!dom_automation_controller_.get()) | 3458 if (!dom_automation_controller_.get()) |
| 3476 dom_automation_controller_.reset(new DomAutomationController()); | 3459 dom_automation_controller_.reset(new DomAutomationController()); |
| 3477 dom_automation_controller_->set_message_sender( | 3460 dom_automation_controller_->set_message_sender( |
| 3478 static_cast<content::RenderView*>(this)); | 3461 static_cast<RenderView*>(this)); |
| 3479 dom_automation_controller_->set_routing_id(routing_id()); | 3462 dom_automation_controller_->set_routing_id(routing_id()); |
| 3480 dom_automation_controller_->BindToJavascript(frame, | 3463 dom_automation_controller_->BindToJavascript(frame, |
| 3481 "domAutomationController"); | 3464 "domAutomationController"); |
| 3482 } | 3465 } |
| 3483 | 3466 |
| 3484 content::InjectDoNotTrackBindings(frame); | 3467 InjectDoNotTrackBindings(frame); |
| 3485 } | 3468 } |
| 3486 | 3469 |
| 3487 void RenderViewImpl::didCreateDocumentElement(WebFrame* frame) { | 3470 void RenderViewImpl::didCreateDocumentElement(WebFrame* frame) { |
| 3488 // Notify the browser about non-blank documents loading in the top frame. | 3471 // Notify the browser about non-blank documents loading in the top frame. |
| 3489 GURL url = frame->document().url(); | 3472 GURL url = frame->document().url(); |
| 3490 if (url.is_valid() && url.spec() != chrome::kAboutBlankURL) { | 3473 if (url.is_valid() && url.spec() != chrome::kAboutBlankURL) { |
| 3491 if (frame == webview()->mainFrame()) | 3474 if (frame == webview()->mainFrame()) |
| 3492 Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_)); | 3475 Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_)); |
| 3493 } | 3476 } |
| 3494 | 3477 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3532 | 3515 |
| 3533 void RenderViewImpl::didFailLoad(WebFrame* frame, const WebURLError& error) { | 3516 void RenderViewImpl::didFailLoad(WebFrame* frame, const WebURLError& error) { |
| 3534 WebDataSource* ds = frame->dataSource(); | 3517 WebDataSource* ds = frame->dataSource(); |
| 3535 DCHECK(ds); | 3518 DCHECK(ds); |
| 3536 | 3519 |
| 3537 | 3520 |
| 3538 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFailLoad(frame, error)); | 3521 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFailLoad(frame, error)); |
| 3539 | 3522 |
| 3540 const WebURLRequest& failed_request = ds->request(); | 3523 const WebURLRequest& failed_request = ds->request(); |
| 3541 string16 error_description; | 3524 string16 error_description; |
| 3542 content::GetContentClient()->renderer()->GetNavigationErrorStrings( | 3525 GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 3543 failed_request, | 3526 failed_request, |
| 3544 error, | 3527 error, |
| 3545 NULL, | 3528 NULL, |
| 3546 &error_description); | 3529 &error_description); |
| 3547 Send(new ViewHostMsg_DidFailLoadWithError(routing_id_, | 3530 Send(new ViewHostMsg_DidFailLoadWithError(routing_id_, |
| 3548 frame->identifier(), | 3531 frame->identifier(), |
| 3549 failed_request.url(), | 3532 failed_request.url(), |
| 3550 !frame->parent(), | 3533 !frame->parent(), |
| 3551 error.reason, | 3534 error.reason, |
| 3552 error_description)); | 3535 error_description)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3602 WebURLRequest& request, | 3585 WebURLRequest& request, |
| 3603 const WebURLResponse& redirect_response) { | 3586 const WebURLResponse& redirect_response) { |
| 3604 WebFrame* top_frame = frame->top(); | 3587 WebFrame* top_frame = frame->top(); |
| 3605 if (!top_frame) | 3588 if (!top_frame) |
| 3606 top_frame = frame; | 3589 top_frame = frame; |
| 3607 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); | 3590 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); |
| 3608 WebDataSource* top_data_source = top_frame->dataSource(); | 3591 WebDataSource* top_data_source = top_frame->dataSource(); |
| 3609 WebDataSource* data_source = | 3592 WebDataSource* data_source = |
| 3610 provisional_data_source ? provisional_data_source : top_data_source; | 3593 provisional_data_source ? provisional_data_source : top_data_source; |
| 3611 | 3594 |
| 3612 content::PageTransition transition_type = content::PAGE_TRANSITION_LINK; | 3595 PageTransition transition_type = PAGE_TRANSITION_LINK; |
| 3613 DocumentState* document_state = DocumentState::FromDataSource(data_source); | 3596 DocumentState* document_state = DocumentState::FromDataSource(data_source); |
| 3614 DCHECK(document_state); | 3597 DCHECK(document_state); |
| 3615 NavigationState* navigation_state = document_state->navigation_state(); | 3598 NavigationState* navigation_state = document_state->navigation_state(); |
| 3616 transition_type = navigation_state->transition_type(); | 3599 transition_type = navigation_state->transition_type(); |
| 3617 | 3600 |
| 3618 GURL request_url(request.url()); | 3601 GURL request_url(request.url()); |
| 3619 GURL new_url; | 3602 GURL new_url; |
| 3620 if (content::GetContentClient()->renderer()->WillSendRequest( | 3603 if (GetContentClient()->renderer()->WillSendRequest( |
| 3621 frame, transition_type, request_url, &new_url)) { | 3604 frame, transition_type, request_url, &new_url)) { |
| 3622 request.setURL(WebURL(new_url)); | 3605 request.setURL(WebURL(new_url)); |
| 3623 } | 3606 } |
| 3624 | 3607 |
| 3625 if (document_state->is_cache_policy_override_set()) | 3608 if (document_state->is_cache_policy_override_set()) |
| 3626 request.setCachePolicy(document_state->cache_policy_override()); | 3609 request.setCachePolicy(document_state->cache_policy_override()); |
| 3627 | 3610 |
| 3628 WebKit::WebReferrerPolicy referrer_policy; | 3611 WebKit::WebReferrerPolicy referrer_policy; |
| 3629 if (document_state && document_state->is_referrer_policy_set()) { | 3612 if (document_state && document_state->is_referrer_policy_set()) { |
| 3630 referrer_policy = document_state->referrer_policy(); | 3613 referrer_policy = document_state->referrer_policy(); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3743 document_state->set_alt_error_page_fetcher( | 3726 document_state->set_alt_error_page_fetcher( |
| 3744 new AltErrorPageResourceFetcher( | 3727 new AltErrorPageResourceFetcher( |
| 3745 error_page_url, frame, original_error, | 3728 error_page_url, frame, original_error, |
| 3746 base::Bind(&RenderViewImpl::AltErrorPageFinished, | 3729 base::Bind(&RenderViewImpl::AltErrorPageFinished, |
| 3747 base::Unretained(this)))); | 3730 base::Unretained(this)))); |
| 3748 return; | 3731 return; |
| 3749 } | 3732 } |
| 3750 } | 3733 } |
| 3751 | 3734 |
| 3752 std::string error_domain; | 3735 std::string error_domain; |
| 3753 if (content::GetContentClient()->renderer()->HasErrorPage( | 3736 if (GetContentClient()->renderer()->HasErrorPage( |
| 3754 http_status_code, &error_domain)) { | 3737 http_status_code, &error_domain)) { |
| 3755 WebURLError error; | 3738 WebURLError error; |
| 3756 error.unreachableURL = frame->document().url(); | 3739 error.unreachableURL = frame->document().url(); |
| 3757 error.domain = WebString::fromUTF8(error_domain); | 3740 error.domain = WebString::fromUTF8(error_domain); |
| 3758 error.reason = http_status_code; | 3741 error.reason = http_status_code; |
| 3759 | 3742 |
| 3760 LoadNavigationErrorPage( | 3743 LoadNavigationErrorPage( |
| 3761 frame, frame->dataSource()->request(), error, std::string(), true); | 3744 frame, frame->dataSource()->request(), error, std::string(), true); |
| 3762 } | 3745 } |
| 3763 } | 3746 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3802 } | 3785 } |
| 3803 | 3786 |
| 3804 void RenderViewImpl::didExhaustMemoryAvailableForScript(WebFrame* frame) { | 3787 void RenderViewImpl::didExhaustMemoryAvailableForScript(WebFrame* frame) { |
| 3805 Send(new ViewHostMsg_JSOutOfMemory(routing_id_)); | 3788 Send(new ViewHostMsg_JSOutOfMemory(routing_id_)); |
| 3806 } | 3789 } |
| 3807 | 3790 |
| 3808 void RenderViewImpl::didCreateScriptContext(WebFrame* frame, | 3791 void RenderViewImpl::didCreateScriptContext(WebFrame* frame, |
| 3809 v8::Handle<v8::Context> context, | 3792 v8::Handle<v8::Context> context, |
| 3810 int extension_group, | 3793 int extension_group, |
| 3811 int world_id) { | 3794 int world_id) { |
| 3812 content::GetContentClient()->renderer()->DidCreateScriptContext( | 3795 GetContentClient()->renderer()->DidCreateScriptContext( |
| 3813 frame, context, extension_group, world_id); | 3796 frame, context, extension_group, world_id); |
| 3814 | 3797 |
| 3815 intents_host_->DidCreateScriptContext( | 3798 intents_host_->DidCreateScriptContext( |
| 3816 frame, context, extension_group, world_id); | 3799 frame, context, extension_group, world_id); |
| 3817 } | 3800 } |
| 3818 | 3801 |
| 3819 void RenderViewImpl::willReleaseScriptContext(WebFrame* frame, | 3802 void RenderViewImpl::willReleaseScriptContext(WebFrame* frame, |
| 3820 v8::Handle<v8::Context> context, | 3803 v8::Handle<v8::Context> context, |
| 3821 int world_id) { | 3804 int world_id) { |
| 3822 content::GetContentClient()->renderer()->WillReleaseScriptContext( | 3805 GetContentClient()->renderer()->WillReleaseScriptContext( |
| 3823 frame, context, world_id); | 3806 frame, context, world_id); |
| 3824 } | 3807 } |
| 3825 | 3808 |
| 3826 void RenderViewImpl::CheckPreferredSize() { | 3809 void RenderViewImpl::CheckPreferredSize() { |
| 3827 // We don't always want to send the change messages over IPC, only if we've | 3810 // We don't always want to send the change messages over IPC, only if we've |
| 3828 // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| | 3811 // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
| 3829 // message. | 3812 // message. |
| 3830 if (!send_preferred_size_changes_ || !webview()) | 3813 if (!send_preferred_size_changes_ || !webview()) |
| 3831 return; | 3814 return; |
| 3832 | 3815 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3879 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( | 3862 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
| 3880 new WebGraphicsContext3DCommandBufferImpl( | 3863 new WebGraphicsContext3DCommandBufferImpl( |
| 3881 surface_id(), | 3864 surface_id(), |
| 3882 url, | 3865 url, |
| 3883 RenderThreadImpl::current(), | 3866 RenderThreadImpl::current(), |
| 3884 AsWeakPtr())); | 3867 AsWeakPtr())); |
| 3885 | 3868 |
| 3886 if (!context->Initialize( | 3869 if (!context->Initialize( |
| 3887 attributes, | 3870 attributes, |
| 3888 false /* bind generates resources */, | 3871 false /* bind generates resources */, |
| 3889 content::CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_
INITIALIZE)) | 3872 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZ
E)) |
| 3890 return NULL; | 3873 return NULL; |
| 3891 return context.release(); | 3874 return context.release(); |
| 3892 } | 3875 } |
| 3893 } | 3876 } |
| 3894 | 3877 |
| 3895 // The browser process needs to know the shape of the tree, as well as the names | 3878 // The browser process needs to know the shape of the tree, as well as the names |
| 3896 // and ids of all frames. This allows it to properly route JavaScript messages | 3879 // and ids of all frames. This allows it to properly route JavaScript messages |
| 3897 // across processes and frames. The serialization format is described in the | 3880 // across processes and frames. The serialization format is described in the |
| 3898 // comments of the ViewMsg_FrameTreeUpdated message. | 3881 // comments of the ViewMsg_FrameTreeUpdated message. |
| 3899 // This function sends those updates to the browser and updates the RVH | 3882 // This function sends those updates to the browser and updates the RVH |
| 3900 // corresponding to this object. It must be called on any events that modify | 3883 // corresponding to this object. It must be called on any events that modify |
| 3901 // the tree structure or the names of any frames. | 3884 // the tree structure or the names of any frames. |
| 3902 void RenderViewImpl::SendUpdatedFrameTree( | 3885 void RenderViewImpl::SendUpdatedFrameTree( |
| 3903 WebKit::WebFrame* exclude_frame_subtree) { | 3886 WebKit::WebFrame* exclude_frame_subtree) { |
| 3904 // TODO(nasko): Frame tree updates are causing issues with postMessage, as | 3887 // TODO(nasko): Frame tree updates are causing issues with postMessage, as |
| 3905 // described in http://crbug.com/153701. Disable them until a proper fix is | 3888 // described in http://crbug.com/153701. Disable them until a proper fix is |
| 3906 // in place. | 3889 // in place. |
| 3907 } | 3890 } |
| 3908 | 3891 |
| 3909 void RenderViewImpl::CreateFrameTree(WebKit::WebFrame* frame, | 3892 void RenderViewImpl::CreateFrameTree(WebKit::WebFrame* frame, |
| 3910 DictionaryValue* frame_tree) { | 3893 DictionaryValue* frame_tree) { |
| 3911 // TODO(nasko): Remove once http://crbug.com/153701 is fixed. | 3894 // TODO(nasko): Remove once http://crbug.com/153701 is fixed. |
| 3912 DCHECK(false); | 3895 DCHECK(false); |
| 3913 NavigateToSwappedOutURL(frame); | 3896 NavigateToSwappedOutURL(frame); |
| 3914 | 3897 |
| 3915 string16 name; | 3898 string16 name; |
| 3916 if (frame_tree->GetString(content::kFrameTreeNodeNameKey, &name) && | 3899 if (frame_tree->GetString(kFrameTreeNodeNameKey, &name) && !name.empty()) |
| 3917 !name.empty()) { | |
| 3918 frame->setName(name); | 3900 frame->setName(name); |
| 3919 } | |
| 3920 | 3901 |
| 3921 int remote_id; | 3902 int remote_id; |
| 3922 if (frame_tree->GetInteger(content::kFrameTreeNodeIdKey, &remote_id)) | 3903 if (frame_tree->GetInteger(kFrameTreeNodeIdKey, &remote_id)) |
| 3923 active_frame_id_map_.insert(std::pair<int, int>(frame->identifier(), | 3904 active_frame_id_map_.insert(std::pair<int, int>(frame->identifier(), |
| 3924 remote_id)); | 3905 remote_id)); |
| 3925 | 3906 |
| 3926 ListValue* children; | 3907 ListValue* children; |
| 3927 if (!frame_tree->GetList(content::kFrameTreeNodeSubtreeKey, &children)) | 3908 if (!frame_tree->GetList(kFrameTreeNodeSubtreeKey, &children)) |
| 3928 return; | 3909 return; |
| 3929 | 3910 |
| 3930 // Create an invisible iframe tree in the swapped out page. | 3911 // Create an invisible iframe tree in the swapped out page. |
| 3931 base::DictionaryValue* child; | 3912 base::DictionaryValue* child; |
| 3932 for (size_t i = 0; i < children->GetSize(); ++i) { | 3913 for (size_t i = 0; i < children->GetSize(); ++i) { |
| 3933 if (!children->GetDictionary(i, &child)) | 3914 if (!children->GetDictionary(i, &child)) |
| 3934 continue; | 3915 continue; |
| 3935 WebElement element = frame->document().createElement("iframe"); | 3916 WebElement element = frame->document().createElement("iframe"); |
| 3936 element.setAttribute("width", "0"); | 3917 element.setAttribute("width", "0"); |
| 3937 element.setAttribute("height", "0"); | 3918 element.setAttribute("height", "0"); |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4273 const WebURL& frame_url, | 4254 const WebURL& frame_url, |
| 4274 const WebCString& data, | 4255 const WebCString& data, |
| 4275 WebPageSerializerClient::PageSerializationStatus status) { | 4256 WebPageSerializerClient::PageSerializationStatus status) { |
| 4276 Send(new ViewHostMsg_SendSerializedHtmlData( | 4257 Send(new ViewHostMsg_SendSerializedHtmlData( |
| 4277 routing_id(), | 4258 routing_id(), |
| 4278 frame_url, | 4259 frame_url, |
| 4279 data.data(), | 4260 data.data(), |
| 4280 static_cast<int32>(status))); | 4261 static_cast<int32>(status))); |
| 4281 } | 4262 } |
| 4282 | 4263 |
| 4283 // content::RenderView implementation ------------------------------------------ | 4264 // RenderView implementation --------------------------------------------------- |
| 4284 | 4265 |
| 4285 bool RenderViewImpl::Send(IPC::Message* message) { | 4266 bool RenderViewImpl::Send(IPC::Message* message) { |
| 4286 return RenderWidget::Send(message); | 4267 return RenderWidget::Send(message); |
| 4287 } | 4268 } |
| 4288 | 4269 |
| 4289 int RenderViewImpl::GetRoutingID() const { | 4270 int RenderViewImpl::GetRoutingID() const { |
| 4290 return routing_id_; | 4271 return routing_id_; |
| 4291 } | 4272 } |
| 4292 | 4273 |
| 4293 int RenderViewImpl::GetPageId() const { | 4274 int RenderViewImpl::GetPageId() const { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4434 } | 4415 } |
| 4435 | 4416 |
| 4436 bool RenderViewImpl::GetContentStateImmediately() const { | 4417 bool RenderViewImpl::GetContentStateImmediately() const { |
| 4437 return send_content_state_immediately_; | 4418 return send_content_state_immediately_; |
| 4438 } | 4419 } |
| 4439 | 4420 |
| 4440 float RenderViewImpl::GetFilteredTimePerFrame() const { | 4421 float RenderViewImpl::GetFilteredTimePerFrame() const { |
| 4441 return filtered_time_per_frame(); | 4422 return filtered_time_per_frame(); |
| 4442 } | 4423 } |
| 4443 | 4424 |
| 4444 int RenderViewImpl::ShowContextMenu(content::ContextMenuClient* client, | 4425 int RenderViewImpl::ShowContextMenu(ContextMenuClient* client, |
| 4445 const content::ContextMenuParams& params) { | 4426 const ContextMenuParams& params) { |
| 4446 DCHECK(client); // A null client means "internal" when we issue callbacks. | 4427 DCHECK(client); // A null client means "internal" when we issue callbacks. |
| 4447 content::ContextMenuParams our_params(params); | 4428 ContextMenuParams our_params(params); |
| 4448 our_params.custom_context.request_id = pending_context_menus_.Add(client); | 4429 our_params.custom_context.request_id = pending_context_menus_.Add(client); |
| 4449 Send(new ViewHostMsg_ContextMenu(routing_id_, our_params)); | 4430 Send(new ViewHostMsg_ContextMenu(routing_id_, our_params)); |
| 4450 return our_params.custom_context.request_id; | 4431 return our_params.custom_context.request_id; |
| 4451 } | 4432 } |
| 4452 | 4433 |
| 4453 void RenderViewImpl::CancelContextMenu(int request_id) { | 4434 void RenderViewImpl::CancelContextMenu(int request_id) { |
| 4454 DCHECK(pending_context_menus_.Lookup(request_id)); | 4435 DCHECK(pending_context_menus_.Lookup(request_id)); |
| 4455 pending_context_menus_.Remove(request_id); | 4436 pending_context_menus_.Remove(request_id); |
| 4456 } | 4437 } |
| 4457 | 4438 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4491 NOTIMPLEMENTED(); | 4472 NOTIMPLEMENTED(); |
| 4492 return NULL; | 4473 return NULL; |
| 4493 #endif | 4474 #endif |
| 4494 } | 4475 } |
| 4495 | 4476 |
| 4496 return new WebPluginDelegateProxy(mime_type, AsWeakPtr()); | 4477 return new WebPluginDelegateProxy(mime_type, AsWeakPtr()); |
| 4497 } | 4478 } |
| 4498 | 4479 |
| 4499 WebKit::WebPlugin* RenderViewImpl::CreatePluginReplacement( | 4480 WebKit::WebPlugin* RenderViewImpl::CreatePluginReplacement( |
| 4500 const FilePath& file_path) { | 4481 const FilePath& file_path) { |
| 4501 return content::GetContentClient()->renderer()->CreatePluginReplacement( | 4482 return GetContentClient()->renderer()->CreatePluginReplacement( |
| 4502 this, file_path); | 4483 this, file_path); |
| 4503 } | 4484 } |
| 4504 | 4485 |
| 4505 void RenderViewImpl::CreatedPluginWindow(gfx::PluginWindowHandle window) { | 4486 void RenderViewImpl::CreatedPluginWindow(gfx::PluginWindowHandle window) { |
| 4506 #if defined(USE_X11) | 4487 #if defined(USE_X11) |
| 4507 Send(new ViewHostMsg_CreatePluginContainer(routing_id(), window)); | 4488 Send(new ViewHostMsg_CreatePluginContainer(routing_id(), window)); |
| 4508 #endif | 4489 #endif |
| 4509 } | 4490 } |
| 4510 | 4491 |
| 4511 void RenderViewImpl::WillDestroyPluginWindow(gfx::PluginWindowHandle window) { | 4492 void RenderViewImpl::WillDestroyPluginWindow(gfx::PluginWindowHandle window) { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4687 if (ds->hasUnreachableURL()) | 4668 if (ds->hasUnreachableURL()) |
| 4688 return ds->unreachableURL(); | 4669 return ds->unreachableURL(); |
| 4689 | 4670 |
| 4690 const WebURLRequest& request = ds->request(); | 4671 const WebURLRequest& request = ds->request(); |
| 4691 return request.url(); | 4672 return request.url(); |
| 4692 } | 4673 } |
| 4693 | 4674 |
| 4694 WebUIBindings* RenderViewImpl::GetWebUIBindings() { | 4675 WebUIBindings* RenderViewImpl::GetWebUIBindings() { |
| 4695 if (!web_ui_bindings_.get()) { | 4676 if (!web_ui_bindings_.get()) { |
| 4696 web_ui_bindings_.reset(new WebUIBindings( | 4677 web_ui_bindings_.reset(new WebUIBindings( |
| 4697 static_cast<content::RenderView*>(this), routing_id_)); | 4678 static_cast<RenderView*>(this), routing_id_)); |
| 4698 } | 4679 } |
| 4699 return web_ui_bindings_.get(); | 4680 return web_ui_bindings_.get(); |
| 4700 } | 4681 } |
| 4701 | 4682 |
| 4702 WebKit::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() { | 4683 WebKit::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() { |
| 4703 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); | 4684 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); |
| 4704 } | 4685 } |
| 4705 | 4686 |
| 4706 void RenderViewImpl::OnFind(int request_id, | 4687 void RenderViewImpl::OnFind(int request_id, |
| 4707 const string16& search_text, | 4688 const string16& search_text, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4827 true); // reset the tickmarks | 4808 true); // reset the tickmarks |
| 4828 } | 4809 } |
| 4829 | 4810 |
| 4830 // Iterate to the next frame. The frame will not necessarily scope, for | 4811 // Iterate to the next frame. The frame will not necessarily scope, for |
| 4831 // example if it is not visible. | 4812 // example if it is not visible. |
| 4832 search_frame = search_frame->traverseNext(true); | 4813 search_frame = search_frame->traverseNext(true); |
| 4833 } while (search_frame != main_frame); | 4814 } while (search_frame != main_frame); |
| 4834 } | 4815 } |
| 4835 } | 4816 } |
| 4836 | 4817 |
| 4837 void RenderViewImpl::OnStopFinding(content::StopFindAction action) { | 4818 void RenderViewImpl::OnStopFinding(StopFindAction action) { |
| 4838 #if defined(OS_ANDROID) | 4819 #if defined(OS_ANDROID) |
| 4839 // Make sure any asynchronous messages do not disrupt an ongoing synchronous | 4820 // Make sure any asynchronous messages do not disrupt an ongoing synchronous |
| 4840 // find request as it might lead to deadlocks. Also, these should be safe to | 4821 // find request as it might lead to deadlocks. Also, these should be safe to |
| 4841 // ignore since they would belong to a previous find request. | 4822 // ignore since they would belong to a previous find request. |
| 4842 if (synchronous_find_reply_message_.get()) | 4823 if (synchronous_find_reply_message_.get()) |
| 4843 return; | 4824 return; |
| 4844 #endif | 4825 #endif |
| 4845 | 4826 |
| 4846 StopFinding(action); | 4827 StopFinding(action); |
| 4847 } | 4828 } |
| 4848 | 4829 |
| 4849 void RenderViewImpl::StopFinding(content::StopFindAction action) { | 4830 void RenderViewImpl::StopFinding(StopFindAction action) { |
| 4850 WebView* view = webview(); | 4831 WebView* view = webview(); |
| 4851 if (!view) | 4832 if (!view) |
| 4852 return; | 4833 return; |
| 4853 | 4834 |
| 4854 WebDocument doc = view->mainFrame()->document(); | 4835 WebDocument doc = view->mainFrame()->document(); |
| 4855 if (doc.isPluginDocument() && GetWebPluginFromPluginDocument()) { | 4836 if (doc.isPluginDocument() && GetWebPluginFromPluginDocument()) { |
| 4856 GetWebPluginFromPluginDocument()->stopFind(); | 4837 GetWebPluginFromPluginDocument()->stopFind(); |
| 4857 return; | 4838 return; |
| 4858 } | 4839 } |
| 4859 | 4840 |
| 4860 bool clear_selection = action == content::STOP_FIND_ACTION_CLEAR_SELECTION; | 4841 bool clear_selection = action == STOP_FIND_ACTION_CLEAR_SELECTION; |
| 4861 if (clear_selection) | 4842 if (clear_selection) |
| 4862 view->focusedFrame()->executeCommand(WebString::fromUTF8("Unselect")); | 4843 view->focusedFrame()->executeCommand(WebString::fromUTF8("Unselect")); |
| 4863 | 4844 |
| 4864 WebFrame* frame = view->mainFrame(); | 4845 WebFrame* frame = view->mainFrame(); |
| 4865 while (frame) { | 4846 while (frame) { |
| 4866 frame->stopFinding(clear_selection); | 4847 frame->stopFinding(clear_selection); |
| 4867 frame = frame->traverseNext(false); | 4848 frame = frame->traverseNext(false); |
| 4868 } | 4849 } |
| 4869 | 4850 |
| 4870 if (action == content::STOP_FIND_ACTION_ACTIVATE_SELECTION) { | 4851 if (action == STOP_FIND_ACTION_ACTIVATE_SELECTION) { |
| 4871 WebFrame* focused_frame = view->focusedFrame(); | 4852 WebFrame* focused_frame = view->focusedFrame(); |
| 4872 if (focused_frame) { | 4853 if (focused_frame) { |
| 4873 WebDocument doc = focused_frame->document(); | 4854 WebDocument doc = focused_frame->document(); |
| 4874 if (!doc.isNull()) { | 4855 if (!doc.isNull()) { |
| 4875 WebNode node = doc.focusedNode(); | 4856 WebNode node = doc.focusedNode(); |
| 4876 if (!node.isNull()) | 4857 if (!node.isNull()) |
| 4877 node.simulateClick(); | 4858 node.simulateClick(); |
| 4878 } | 4859 } |
| 4879 } | 4860 } |
| 4880 } | 4861 } |
| 4881 } | 4862 } |
| 4882 | 4863 |
| 4883 #if defined(OS_ANDROID) | 4864 #if defined(OS_ANDROID) |
| 4884 void RenderViewImpl::OnSynchronousFind(int request_id, | 4865 void RenderViewImpl::OnSynchronousFind(int request_id, |
| 4885 const string16& search_string, | 4866 const string16& search_string, |
| 4886 const WebFindOptions& options, | 4867 const WebFindOptions& options, |
| 4887 IPC::Message* reply_msg) { | 4868 IPC::Message* reply_msg) { |
| 4888 // It is impossible for simultaneous blocking finds to occur. | 4869 // It is impossible for simultaneous blocking finds to occur. |
| 4889 CHECK(!synchronous_find_reply_message_.get()); | 4870 CHECK(!synchronous_find_reply_message_.get()); |
| 4890 synchronous_find_reply_message_.reset(reply_msg); | 4871 synchronous_find_reply_message_.reset(reply_msg); |
| 4891 | 4872 |
| 4892 // Find next should be asynchronous in order to minimize blocking | 4873 // Find next should be asynchronous in order to minimize blocking |
| 4893 // the UI thread as much as possible. | 4874 // the UI thread as much as possible. |
| 4894 DCHECK(!options.findNext); | 4875 DCHECK(!options.findNext); |
| 4895 StopFinding(content::STOP_FIND_ACTION_KEEP_SELECTION); | 4876 StopFinding(STOP_FIND_ACTION_KEEP_SELECTION); |
| 4896 synchronous_find_active_match_ordinal_ = -1; | 4877 synchronous_find_active_match_ordinal_ = -1; |
| 4897 | 4878 |
| 4898 Find(request_id, search_string, options); | 4879 Find(request_id, search_string, options); |
| 4899 } | 4880 } |
| 4900 | 4881 |
| 4901 void RenderViewImpl::OnActivateNearestFindResult(int request_id, | 4882 void RenderViewImpl::OnActivateNearestFindResult(int request_id, |
| 4902 float x, float y) { | 4883 float x, float y) { |
| 4903 if (!webview()) | 4884 if (!webview()) |
| 4904 return; | 4885 return; |
| 4905 | 4886 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4939 } | 4920 } |
| 4940 | 4921 |
| 4941 gfx::RectF active_rect = main_frame->activeFindMatchRect(); | 4922 gfx::RectF active_rect = main_frame->activeFindMatchRect(); |
| 4942 Send(new ViewHostMsg_FindMatchRects_Reply(routing_id_, | 4923 Send(new ViewHostMsg_FindMatchRects_Reply(routing_id_, |
| 4943 rects_version, | 4924 rects_version, |
| 4944 match_rects, | 4925 match_rects, |
| 4945 active_rect)); | 4926 active_rect)); |
| 4946 } | 4927 } |
| 4947 #endif | 4928 #endif |
| 4948 | 4929 |
| 4949 void RenderViewImpl::OnZoom(content::PageZoom zoom) { | 4930 void RenderViewImpl::OnZoom(PageZoom zoom) { |
| 4950 if (!webview()) // Not sure if this can happen, but no harm in being safe. | 4931 if (!webview()) // Not sure if this can happen, but no harm in being safe. |
| 4951 return; | 4932 return; |
| 4952 | 4933 |
| 4953 webview()->hidePopups(); | 4934 webview()->hidePopups(); |
| 4954 | 4935 |
| 4955 double old_zoom_level = webview()->zoomLevel(); | 4936 double old_zoom_level = webview()->zoomLevel(); |
| 4956 double zoom_level; | 4937 double zoom_level; |
| 4957 if (zoom == content::PAGE_ZOOM_RESET) { | 4938 if (zoom == PAGE_ZOOM_RESET) { |
| 4958 zoom_level = 0; | 4939 zoom_level = 0; |
| 4959 } else if (static_cast<int>(old_zoom_level) == old_zoom_level) { | 4940 } else if (static_cast<int>(old_zoom_level) == old_zoom_level) { |
| 4960 // Previous zoom level is a whole number, so just increment/decrement. | 4941 // Previous zoom level is a whole number, so just increment/decrement. |
| 4961 zoom_level = old_zoom_level + zoom; | 4942 zoom_level = old_zoom_level + zoom; |
| 4962 } else { | 4943 } else { |
| 4963 // Either the user hit the zoom factor limit and thus the zoom level is now | 4944 // Either the user hit the zoom factor limit and thus the zoom level is now |
| 4964 // not a whole number, or a plugin changed it to a custom value. We want | 4945 // not a whole number, or a plugin changed it to a custom value. We want |
| 4965 // to go to the next whole number so that the user can always get back to | 4946 // to go to the next whole number so that the user can always get back to |
| 4966 // 100% with the keyboard/menu. | 4947 // 100% with the keyboard/menu. |
| 4967 if ((old_zoom_level > 1 && zoom > 0) || | 4948 if ((old_zoom_level > 1 && zoom > 0) || |
| 4968 (old_zoom_level < 1 && zoom < 0)) { | 4949 (old_zoom_level < 1 && zoom < 0)) { |
| 4969 zoom_level = static_cast<int>(old_zoom_level + zoom); | 4950 zoom_level = static_cast<int>(old_zoom_level + zoom); |
| 4970 } else { | 4951 } else { |
| 4971 // We're going towards 100%, so first go to the next whole number. | 4952 // We're going towards 100%, so first go to the next whole number. |
| 4972 zoom_level = static_cast<int>(old_zoom_level); | 4953 zoom_level = static_cast<int>(old_zoom_level); |
| 4973 } | 4954 } |
| 4974 } | 4955 } |
| 4975 webview()->setZoomLevel(false, zoom_level); | 4956 webview()->setZoomLevel(false, zoom_level); |
| 4976 zoomLevelChanged(); | 4957 zoomLevelChanged(); |
| 4977 } | 4958 } |
| 4978 | 4959 |
| 4979 void RenderViewImpl::OnZoomFactor(content::PageZoom zoom, | 4960 void RenderViewImpl::OnZoomFactor(PageZoom zoom, int zoom_center_x, |
| 4980 int zoom_center_x, int zoom_center_y) { | 4961 int zoom_center_y) { |
| 4981 ZoomFactorHelper(zoom, zoom_center_x, zoom_center_y, | 4962 ZoomFactorHelper(zoom, zoom_center_x, zoom_center_y, |
| 4982 kScalingIncrementForGesture); | 4963 kScalingIncrementForGesture); |
| 4983 } | 4964 } |
| 4984 | 4965 |
| 4985 void RenderViewImpl::ZoomFactorHelper(content::PageZoom zoom, | 4966 void RenderViewImpl::ZoomFactorHelper(PageZoom zoom, |
| 4986 int zoom_center_x, | 4967 int zoom_center_x, |
| 4987 int zoom_center_y, | 4968 int zoom_center_y, |
| 4988 float scaling_increment) { | 4969 float scaling_increment) { |
| 4989 if (!webview()) // Not sure if this can happen, but no harm in being safe. | 4970 if (!webview()) // Not sure if this can happen, but no harm in being safe. |
| 4990 return; | 4971 return; |
| 4991 | 4972 |
| 4992 double old_page_scale_factor = webview()->pageScaleFactor(); | 4973 double old_page_scale_factor = webview()->pageScaleFactor(); |
| 4993 double page_scale_factor; | 4974 double page_scale_factor; |
| 4994 if (zoom == content::PAGE_ZOOM_RESET) { | 4975 if (zoom == PAGE_ZOOM_RESET) { |
| 4995 page_scale_factor = 1.0; | 4976 page_scale_factor = 1.0; |
| 4996 } else { | 4977 } else { |
| 4997 page_scale_factor = old_page_scale_factor + | 4978 page_scale_factor = old_page_scale_factor + |
| 4998 (zoom > 0 ? scaling_increment : -scaling_increment); | 4979 (zoom > 0 ? scaling_increment : -scaling_increment); |
| 4999 } | 4980 } |
| 5000 if (page_scale_factor > 0) { | 4981 if (page_scale_factor > 0) { |
| 5001 webview()->setPageScaleFactor(page_scale_factor, | 4982 webview()->setPageScaleFactor(page_scale_factor, |
| 5002 WebPoint(zoom_center_x, zoom_center_y)); | 4983 WebPoint(zoom_center_x, zoom_center_y)); |
| 5003 } | 4984 } |
| 5004 } | 4985 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5103 | 5084 |
| 5104 void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { | 5085 void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { |
| 5105 enabled_bindings_ |= enabled_bindings_flags; | 5086 enabled_bindings_ |= enabled_bindings_flags; |
| 5106 | 5087 |
| 5107 // Keep track of the total bindings accumulated in this process. | 5088 // Keep track of the total bindings accumulated in this process. |
| 5108 RenderProcess::current()->AddBindings(enabled_bindings_flags); | 5089 RenderProcess::current()->AddBindings(enabled_bindings_flags); |
| 5109 } | 5090 } |
| 5110 | 5091 |
| 5111 void RenderViewImpl::OnSetWebUIProperty(const std::string& name, | 5092 void RenderViewImpl::OnSetWebUIProperty(const std::string& name, |
| 5112 const std::string& value) { | 5093 const std::string& value) { |
| 5113 if (enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) | 5094 if (enabled_bindings_ & BINDINGS_POLICY_WEB_UI) |
| 5114 GetWebUIBindings()->SetProperty(name, value); | 5095 GetWebUIBindings()->SetProperty(name, value); |
| 5115 else | 5096 else |
| 5116 NOTREACHED() << "WebUI bindings not enabled."; | 5097 NOTREACHED() << "WebUI bindings not enabled."; |
| 5117 } | 5098 } |
| 5118 | 5099 |
| 5119 void RenderViewImpl::OnDragTargetDragEnter(const WebDropData& drop_data, | 5100 void RenderViewImpl::OnDragTargetDragEnter(const WebDropData& drop_data, |
| 5120 const gfx::Point& client_point, | 5101 const gfx::Point& client_point, |
| 5121 const gfx::Point& screen_point, | 5102 const gfx::Point& screen_point, |
| 5122 WebDragOperationsMask ops, | 5103 WebDragOperationsMask ops, |
| 5123 int key_modifiers) { | 5104 int key_modifiers) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5179 void RenderViewImpl::OnUpdateTimezone() { | 5160 void RenderViewImpl::OnUpdateTimezone() { |
| 5180 if (webview()) | 5161 if (webview()) |
| 5181 NotifyTimezoneChange(webview()->mainFrame()); | 5162 NotifyTimezoneChange(webview()->mainFrame()); |
| 5182 } | 5163 } |
| 5183 | 5164 |
| 5184 void RenderViewImpl::OnSetAltErrorPageURL(const GURL& url) { | 5165 void RenderViewImpl::OnSetAltErrorPageURL(const GURL& url) { |
| 5185 alternate_error_page_url_ = url; | 5166 alternate_error_page_url_ = url; |
| 5186 } | 5167 } |
| 5187 | 5168 |
| 5188 void RenderViewImpl::OnCustomContextMenuAction( | 5169 void RenderViewImpl::OnCustomContextMenuAction( |
| 5189 const content::CustomContextMenuContext& custom_context, | 5170 const CustomContextMenuContext& custom_context, |
| 5190 unsigned action) { | 5171 unsigned action) { |
| 5191 if (custom_context.request_id) { | 5172 if (custom_context.request_id) { |
| 5192 // External context menu request, look in our map. | 5173 // External context menu request, look in our map. |
| 5193 content::ContextMenuClient* client = | 5174 ContextMenuClient* client = |
| 5194 pending_context_menus_.Lookup(custom_context.request_id); | 5175 pending_context_menus_.Lookup(custom_context.request_id); |
| 5195 if (client) | 5176 if (client) |
| 5196 client->OnMenuAction(custom_context.request_id, action); | 5177 client->OnMenuAction(custom_context.request_id, action); |
| 5197 } else { | 5178 } else { |
| 5198 // Internal request, forward to WebKit. | 5179 // Internal request, forward to WebKit. |
| 5199 webview()->performCustomContextMenuAction(action); | 5180 webview()->performCustomContextMenuAction(action); |
| 5200 } | 5181 } |
| 5201 } | 5182 } |
| 5202 | 5183 |
| 5203 void RenderViewImpl::OnEnumerateDirectoryResponse( | 5184 void RenderViewImpl::OnEnumerateDirectoryResponse( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5270 // |didUpdateLayout| was already called). | 5251 // |didUpdateLayout| was already called). |
| 5271 didUpdateLayout(); | 5252 didUpdateLayout(); |
| 5272 } | 5253 } |
| 5273 | 5254 |
| 5274 void RenderViewImpl::OnDisableScrollbarsForSmallWindows( | 5255 void RenderViewImpl::OnDisableScrollbarsForSmallWindows( |
| 5275 const gfx::Size& disable_scrollbar_size_limit) { | 5256 const gfx::Size& disable_scrollbar_size_limit) { |
| 5276 disable_scrollbars_size_limit_ = disable_scrollbar_size_limit; | 5257 disable_scrollbars_size_limit_ = disable_scrollbar_size_limit; |
| 5277 } | 5258 } |
| 5278 | 5259 |
| 5279 void RenderViewImpl::OnSetRendererPrefs( | 5260 void RenderViewImpl::OnSetRendererPrefs( |
| 5280 const content::RendererPreferences& renderer_prefs) { | 5261 const RendererPreferences& renderer_prefs) { |
| 5281 double old_zoom_level = renderer_preferences_.default_zoom_level; | 5262 double old_zoom_level = renderer_preferences_.default_zoom_level; |
| 5282 renderer_preferences_ = renderer_prefs; | 5263 renderer_preferences_ = renderer_prefs; |
| 5283 UpdateFontRenderingFromRendererPrefs(); | 5264 UpdateFontRenderingFromRendererPrefs(); |
| 5284 #if defined(TOOLKIT_GTK) | 5265 #if defined(TOOLKIT_GTK) |
| 5285 WebColorName name = WebKit::WebColorWebkitFocusRingColor; | 5266 WebColorName name = WebKit::WebColorWebkitFocusRingColor; |
| 5286 WebKit::setNamedColors(&name, &renderer_prefs.focus_ring_color, 1); | 5267 WebKit::setNamedColors(&name, &renderer_prefs.focus_ring_color, 1); |
| 5287 WebKit::setCaretBlinkInterval(renderer_prefs.caret_blink_interval); | 5268 WebKit::setCaretBlinkInterval(renderer_prefs.caret_blink_interval); |
| 5288 ui::NativeTheme::instance()->SetScrollbarColors( | 5269 ui::NativeTheme::instance()->SetScrollbarColors( |
| 5289 renderer_prefs.thumb_inactive_color, | 5270 renderer_prefs.thumb_inactive_color, |
| 5290 renderer_prefs.thumb_active_color, | 5271 renderer_prefs.thumb_active_color, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 5304 renderer_prefs.active_selection_fg_color, | 5285 renderer_prefs.active_selection_fg_color, |
| 5305 renderer_prefs.inactive_selection_bg_color, | 5286 renderer_prefs.inactive_selection_bg_color, |
| 5306 renderer_prefs.inactive_selection_fg_color); | 5287 renderer_prefs.inactive_selection_fg_color); |
| 5307 webview()->themeChanged(); | 5288 webview()->themeChanged(); |
| 5308 } | 5289 } |
| 5309 #endif | 5290 #endif |
| 5310 | 5291 |
| 5311 // If the zoom level for this page matches the old zoom default, and this | 5292 // If the zoom level for this page matches the old zoom default, and this |
| 5312 // is not a plugin, update the zoom level to match the new default. | 5293 // is not a plugin, update the zoom level to match the new default. |
| 5313 if (webview() && !webview()->mainFrame()->document().isPluginDocument() && | 5294 if (webview() && !webview()->mainFrame()->document().isPluginDocument() && |
| 5314 content::ZoomValuesEqual(webview()->zoomLevel(), old_zoom_level)) { | 5295 ZoomValuesEqual(webview()->zoomLevel(), old_zoom_level)) { |
| 5315 webview()->setZoomLevel(false, renderer_preferences_.default_zoom_level); | 5296 webview()->setZoomLevel(false, renderer_preferences_.default_zoom_level); |
| 5316 zoomLevelChanged(); | 5297 zoomLevelChanged(); |
| 5317 } | 5298 } |
| 5318 } | 5299 } |
| 5319 | 5300 |
| 5320 void RenderViewImpl::OnMediaPlayerActionAt(const gfx::Point& location, | 5301 void RenderViewImpl::OnMediaPlayerActionAt(const gfx::Point& location, |
| 5321 const WebMediaPlayerAction& action) { | 5302 const WebMediaPlayerAction& action) { |
| 5322 if (webview()) | 5303 if (webview()) |
| 5323 webview()->performMediaPlayerAction(action, location); | 5304 webview()->performMediaPlayerAction(action, location); |
| 5324 } | 5305 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 5338 // Prepare list to storage all savable resource links. | 5319 // Prepare list to storage all savable resource links. |
| 5339 std::vector<GURL> resources_list; | 5320 std::vector<GURL> resources_list; |
| 5340 std::vector<GURL> referrer_urls_list; | 5321 std::vector<GURL> referrer_urls_list; |
| 5341 std::vector<WebKit::WebReferrerPolicy> referrer_policies_list; | 5322 std::vector<WebKit::WebReferrerPolicy> referrer_policies_list; |
| 5342 std::vector<GURL> frames_list; | 5323 std::vector<GURL> frames_list; |
| 5343 webkit_glue::SavableResourcesResult result(&resources_list, | 5324 webkit_glue::SavableResourcesResult result(&resources_list, |
| 5344 &referrer_urls_list, | 5325 &referrer_urls_list, |
| 5345 &referrer_policies_list, | 5326 &referrer_policies_list, |
| 5346 &frames_list); | 5327 &frames_list); |
| 5347 | 5328 |
| 5348 // webkit/ doesn't know about content::Referrer. | 5329 // webkit/ doesn't know about Referrer. |
| 5349 if (!webkit_glue::GetAllSavableResourceLinksForCurrentPage( | 5330 if (!webkit_glue::GetAllSavableResourceLinksForCurrentPage( |
| 5350 webview(), | 5331 webview(), |
| 5351 page_url, | 5332 page_url, |
| 5352 &result, | 5333 &result, |
| 5353 const_cast<const char**>(content::GetSavableSchemes()))) { | 5334 const_cast<const char**>(GetSavableSchemes()))) { |
| 5354 // If something is wrong when collecting all savable resource links, | 5335 // If something is wrong when collecting all savable resource links, |
| 5355 // send empty list to embedder(browser) to tell it failed. | 5336 // send empty list to embedder(browser) to tell it failed. |
| 5356 referrer_urls_list.clear(); | 5337 referrer_urls_list.clear(); |
| 5357 referrer_policies_list.clear(); | 5338 referrer_policies_list.clear(); |
| 5358 resources_list.clear(); | 5339 resources_list.clear(); |
| 5359 frames_list.clear(); | 5340 frames_list.clear(); |
| 5360 } | 5341 } |
| 5361 | 5342 |
| 5362 std::vector<content::Referrer> referrers_list; | 5343 std::vector<Referrer> referrers_list; |
| 5363 CHECK_EQ(referrer_urls_list.size(), referrer_policies_list.size()); | 5344 CHECK_EQ(referrer_urls_list.size(), referrer_policies_list.size()); |
| 5364 for (unsigned i = 0; i < referrer_urls_list.size(); ++i) { | 5345 for (unsigned i = 0; i < referrer_urls_list.size(); ++i) { |
| 5365 referrers_list.push_back( | 5346 referrers_list.push_back( |
| 5366 content::Referrer(referrer_urls_list[i], referrer_policies_list[i])); | 5347 Referrer(referrer_urls_list[i], referrer_policies_list[i])); |
| 5367 } | 5348 } |
| 5368 | 5349 |
| 5369 // Send result of all savable resource links to embedder. | 5350 // Send result of all savable resource links to embedder. |
| 5370 Send(new ViewHostMsg_SendCurrentPageAllSavableResourceLinks(routing_id(), | 5351 Send(new ViewHostMsg_SendCurrentPageAllSavableResourceLinks(routing_id(), |
| 5371 resources_list, | 5352 resources_list, |
| 5372 referrers_list, | 5353 referrers_list, |
| 5373 frames_list)); | 5354 frames_list)); |
| 5374 } | 5355 } |
| 5375 | 5356 |
| 5376 void RenderViewImpl::OnGetSerializedHtmlDataForCurrentPageWithLocalLinks( | 5357 void RenderViewImpl::OnGetSerializedHtmlDataForCurrentPageWithLocalLinks( |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5432 webview()->setVisibilityState(WebKit::WebPageVisibilityStateHidden, false); | 5413 webview()->setVisibilityState(WebKit::WebPageVisibilityStateHidden, false); |
| 5433 } | 5414 } |
| 5434 | 5415 |
| 5435 // Just echo back the params in the ACK. | 5416 // Just echo back the params in the ACK. |
| 5436 Send(new ViewHostMsg_SwapOut_ACK(routing_id_, params)); | 5417 Send(new ViewHostMsg_SwapOut_ACK(routing_id_, params)); |
| 5437 } | 5418 } |
| 5438 | 5419 |
| 5439 void RenderViewImpl::NavigateToSwappedOutURL(WebKit::WebFrame* frame) { | 5420 void RenderViewImpl::NavigateToSwappedOutURL(WebKit::WebFrame* frame) { |
| 5440 // We use loadRequest instead of loadHTMLString because the former commits | 5421 // We use loadRequest instead of loadHTMLString because the former commits |
| 5441 // synchronously. Otherwise a new navigation can interrupt the navigation | 5422 // synchronously. Otherwise a new navigation can interrupt the navigation |
| 5442 // to content::kSwappedOutURL. If that happens to be to the page we had been | 5423 // to kSwappedOutURL. If that happens to be to the page we had been |
| 5443 // showing, then WebKit will never send a commit and we'll be left spinning. | 5424 // showing, then WebKit will never send a commit and we'll be left spinning. |
| 5444 GURL swappedOutURL(content::kSwappedOutURL); | 5425 GURL swappedOutURL(kSwappedOutURL); |
| 5445 WebURLRequest request(swappedOutURL); | 5426 WebURLRequest request(swappedOutURL); |
| 5446 frame->loadRequest(request); | 5427 frame->loadRequest(request); |
| 5447 } | 5428 } |
| 5448 | 5429 |
| 5449 void RenderViewImpl::OnClosePage() { | 5430 void RenderViewImpl::OnClosePage() { |
| 5450 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage()); | 5431 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage()); |
| 5451 // TODO(creis): We'd rather use webview()->Close() here, but that currently | 5432 // TODO(creis): We'd rather use webview()->Close() here, but that currently |
| 5452 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs | 5433 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs |
| 5453 // in the onunload handler from appearing. For now, we're bypassing that and | 5434 // in the onunload handler from appearing. For now, we're bypassing that and |
| 5454 // calling the FrameLoader's CloseURL method directly. This should be | 5435 // calling the FrameLoader's CloseURL method directly. This should be |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5503 } | 5484 } |
| 5504 | 5485 |
| 5505 const GURL& error_page_url = GetAlternateErrorPageURL(error.unreachableURL, | 5486 const GURL& error_page_url = GetAlternateErrorPageURL(error.unreachableURL, |
| 5506 ec == net::ERR_NAME_NOT_RESOLVED ? DNS_ERROR : CONNECTION_ERROR); | 5487 ec == net::ERR_NAME_NOT_RESOLVED ? DNS_ERROR : CONNECTION_ERROR); |
| 5507 if (!error_page_url.is_valid()) | 5488 if (!error_page_url.is_valid()) |
| 5508 return false; | 5489 return false; |
| 5509 | 5490 |
| 5510 // Load an empty page first so there is an immediate response to the error, | 5491 // Load an empty page first so there is an immediate response to the error, |
| 5511 // and then kick off a request for the alternate error page. | 5492 // and then kick off a request for the alternate error page. |
| 5512 frame->loadHTMLString(std::string(), | 5493 frame->loadHTMLString(std::string(), |
| 5513 GURL(content::kUnreachableWebDataURL), | 5494 GURL(kUnreachableWebDataURL), |
| 5514 error.unreachableURL, | 5495 error.unreachableURL, |
| 5515 replace); | 5496 replace); |
| 5516 | 5497 |
| 5517 // Now, create a fetcher for the error page and associate it with the data | 5498 // Now, create a fetcher for the error page and associate it with the data |
| 5518 // source we just created via the LoadHTMLString call. That way if another | 5499 // source we just created via the LoadHTMLString call. That way if another |
| 5519 // navigation occurs, the fetcher will get destroyed. | 5500 // navigation occurs, the fetcher will get destroyed. |
| 5520 DocumentState* document_state = | 5501 DocumentState* document_state = |
| 5521 DocumentState::FromDataSource(frame->provisionalDataSource()); | 5502 DocumentState::FromDataSource(frame->provisionalDataSource()); |
| 5522 document_state->set_alt_error_page_fetcher( | 5503 document_state->set_alt_error_page_fetcher( |
| 5523 new AltErrorPageResourceFetcher( | 5504 new AltErrorPageResourceFetcher( |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5870 Send(new ViewHostMsg_ImeCancelComposition(routing_id())); | 5851 Send(new ViewHostMsg_ImeCancelComposition(routing_id())); |
| 5871 const ui::Range range(ui::Range::InvalidRange()); | 5852 const ui::Range range(ui::Range::InvalidRange()); |
| 5872 const std::vector<gfx::Rect> empty_bounds; | 5853 const std::vector<gfx::Rect> empty_bounds; |
| 5873 UpdateCompositionInfo(range, empty_bounds); | 5854 UpdateCompositionInfo(range, empty_bounds); |
| 5874 } | 5855 } |
| 5875 | 5856 |
| 5876 void RenderViewImpl::PpapiPluginSelectionChanged() { | 5857 void RenderViewImpl::PpapiPluginSelectionChanged() { |
| 5877 SyncSelectionIfRequired(); | 5858 SyncSelectionIfRequired(); |
| 5878 } | 5859 } |
| 5879 | 5860 |
| 5880 void RenderViewImpl::PpapiPluginCreated(content::RendererPpapiHost* host) { | 5861 void RenderViewImpl::PpapiPluginCreated(RendererPpapiHost* host) { |
| 5881 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 5862 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 5882 DidCreatePepperPlugin(host)); | 5863 DidCreatePepperPlugin(host)); |
| 5883 } | 5864 } |
| 5884 | 5865 |
| 5885 void RenderViewImpl::OnImeSetComposition( | 5866 void RenderViewImpl::OnImeSetComposition( |
| 5886 const string16& text, | 5867 const string16& text, |
| 5887 const std::vector<WebKit::WebCompositionUnderline>& underlines, | 5868 const std::vector<WebKit::WebCompositionUnderline>& underlines, |
| 5888 int selection_start, | 5869 int selection_start, |
| 5889 int selection_end) { | 5870 int selection_end) { |
| 5890 if (pepper_delegate_.IsPluginFocused()) { | 5871 if (pepper_delegate_.IsPluginFocused()) { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6097 } | 6078 } |
| 6098 | 6079 |
| 6099 void RenderViewImpl::AcceleratedSurfaceBuffersSwapped( | 6080 void RenderViewImpl::AcceleratedSurfaceBuffersSwapped( |
| 6100 gfx::PluginWindowHandle window, uint64 surface_handle) { | 6081 gfx::PluginWindowHandle window, uint64 surface_handle) { |
| 6101 Send(new ViewHostMsg_AcceleratedSurfaceBuffersSwapped( | 6082 Send(new ViewHostMsg_AcceleratedSurfaceBuffersSwapped( |
| 6102 routing_id(), window, surface_handle)); | 6083 routing_id(), window, surface_handle)); |
| 6103 } | 6084 } |
| 6104 #endif // defined(OS_MACOSX) | 6085 #endif // defined(OS_MACOSX) |
| 6105 | 6086 |
| 6106 bool RenderViewImpl::ScheduleFileChooser( | 6087 bool RenderViewImpl::ScheduleFileChooser( |
| 6107 const content::FileChooserParams& params, | 6088 const FileChooserParams& params, |
| 6108 WebFileChooserCompletion* completion) { | 6089 WebFileChooserCompletion* completion) { |
| 6109 static const size_t kMaximumPendingFileChooseRequests = 4; | 6090 static const size_t kMaximumPendingFileChooseRequests = 4; |
| 6110 if (file_chooser_completions_.size() > kMaximumPendingFileChooseRequests) { | 6091 if (file_chooser_completions_.size() > kMaximumPendingFileChooseRequests) { |
| 6111 // This sanity check prevents too many file choose requests from getting | 6092 // This sanity check prevents too many file choose requests from getting |
| 6112 // queued which could DoS the user. Getting these is most likely a | 6093 // queued which could DoS the user. Getting these is most likely a |
| 6113 // programming error (there are many ways to DoS the user so it's not | 6094 // programming error (there are many ways to DoS the user so it's not |
| 6114 // considered a "real" security check), either in JS requesting many file | 6095 // considered a "real" security check), either in JS requesting many file |
| 6115 // choosers to pop up, or in a plugin. | 6096 // choosers to pop up, or in a plugin. |
| 6116 // | 6097 // |
| 6117 // TODO(brettw) we might possibly want to require a user gesture to open | 6098 // TODO(brettw) we might possibly want to require a user gesture to open |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6203 absolute_url, | 6184 absolute_url, |
| 6204 title, | 6185 title, |
| 6205 user_gesture)); | 6186 user_gesture)); |
| 6206 } | 6187 } |
| 6207 | 6188 |
| 6208 WebKit::WebPageVisibilityState RenderViewImpl::visibilityState() const { | 6189 WebKit::WebPageVisibilityState RenderViewImpl::visibilityState() const { |
| 6209 WebKit::WebPageVisibilityState current_state = is_hidden() ? | 6190 WebKit::WebPageVisibilityState current_state = is_hidden() ? |
| 6210 WebKit::WebPageVisibilityStateHidden : | 6191 WebKit::WebPageVisibilityStateHidden : |
| 6211 WebKit::WebPageVisibilityStateVisible; | 6192 WebKit::WebPageVisibilityStateVisible; |
| 6212 WebKit::WebPageVisibilityState override_state = current_state; | 6193 WebKit::WebPageVisibilityState override_state = current_state; |
| 6213 if (content::GetContentClient()->renderer()-> | 6194 if (GetContentClient()->renderer()-> |
| 6214 ShouldOverridePageVisibilityState(this, | 6195 ShouldOverridePageVisibilityState(this, |
| 6215 &override_state)) | 6196 &override_state)) |
| 6216 return override_state; | 6197 return override_state; |
| 6217 return current_state; | 6198 return current_state; |
| 6218 } | 6199 } |
| 6219 | 6200 |
| 6220 WebKit::WebUserMediaClient* RenderViewImpl::userMediaClient() { | 6201 WebKit::WebUserMediaClient* RenderViewImpl::userMediaClient() { |
| 6221 EnsureMediaStreamImpl(); | 6202 EnsureMediaStreamImpl(); |
| 6222 return media_stream_impl_; | 6203 return media_stream_impl_; |
| 6223 } | 6204 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6323 // TODO(jcivelli): http:/b/5793321 Implement a better fix, as detailed in bug. | 6304 // TODO(jcivelli): http:/b/5793321 Implement a better fix, as detailed in bug. |
| 6324 if (!external_popup_menu_.get()) | 6305 if (!external_popup_menu_.get()) |
| 6325 return; | 6306 return; |
| 6326 | 6307 |
| 6327 external_popup_menu_->DidSelectItems(canceled, selected_indices); | 6308 external_popup_menu_->DidSelectItems(canceled, selected_indices); |
| 6328 external_popup_menu_.reset(); | 6309 external_popup_menu_.reset(); |
| 6329 } | 6310 } |
| 6330 #endif | 6311 #endif |
| 6331 | 6312 |
| 6332 void RenderViewImpl::OnContextMenuClosed( | 6313 void RenderViewImpl::OnContextMenuClosed( |
| 6333 const content::CustomContextMenuContext& custom_context) { | 6314 const CustomContextMenuContext& custom_context) { |
| 6334 if (custom_context.request_id) { | 6315 if (custom_context.request_id) { |
| 6335 // External request, should be in our map. | 6316 // External request, should be in our map. |
| 6336 content::ContextMenuClient* client = | 6317 ContextMenuClient* client = |
| 6337 pending_context_menus_.Lookup(custom_context.request_id); | 6318 pending_context_menus_.Lookup(custom_context.request_id); |
| 6338 if (client) { | 6319 if (client) { |
| 6339 client->OnMenuClosed(custom_context.request_id); | 6320 client->OnMenuClosed(custom_context.request_id); |
| 6340 pending_context_menus_.Remove(custom_context.request_id); | 6321 pending_context_menus_.Remove(custom_context.request_id); |
| 6341 } | 6322 } |
| 6342 } else { | 6323 } else { |
| 6343 // Internal request, forward to WebKit. | 6324 // Internal request, forward to WebKit. |
| 6344 context_menu_node_.reset(); | 6325 context_menu_node_.reset(); |
| 6345 } | 6326 } |
| 6346 } | 6327 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6387 target_process_id_ = process_id; | 6368 target_process_id_ = process_id; |
| 6388 target_routing_id_ = route_id; | 6369 target_routing_id_ = route_id; |
| 6389 CreateFrameTree(webview()->mainFrame(), frames); | 6370 CreateFrameTree(webview()->mainFrame(), frames); |
| 6390 | 6371 |
| 6391 updating_frame_tree_ = false; | 6372 updating_frame_tree_ = false; |
| 6392 } | 6373 } |
| 6393 | 6374 |
| 6394 bool RenderViewImpl::didTapMultipleTargets( | 6375 bool RenderViewImpl::didTapMultipleTargets( |
| 6395 const WebKit::WebGestureEvent& event, | 6376 const WebKit::WebGestureEvent& event, |
| 6396 const WebVector<WebRect>& target_rects) { | 6377 const WebVector<WebRect>& target_rects) { |
| 6397 using content::DisambiguationPopupHelper; | |
| 6398 gfx::Rect finger_rect( | 6378 gfx::Rect finger_rect( |
| 6399 event.x - event.data.tap.width / 2, event.y - event.data.tap.height / 2, | 6379 event.x - event.data.tap.width / 2, event.y - event.data.tap.height / 2, |
| 6400 event.data.tap.width, event.data.tap.height); | 6380 event.data.tap.width, event.data.tap.height); |
| 6401 gfx::Rect zoom_rect; | 6381 gfx::Rect zoom_rect; |
| 6402 float scale = DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( | 6382 float scale = DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( |
| 6403 finger_rect, target_rects, GetSize(), &zoom_rect); | 6383 finger_rect, target_rects, GetSize(), &zoom_rect); |
| 6404 if (!scale) | 6384 if (!scale) |
| 6405 return false; | 6385 return false; |
| 6406 | 6386 |
| 6407 gfx::Size canvas_size = zoom_rect.size(); | 6387 gfx::Size canvas_size = zoom_rect.size(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 6426 transport_dib->id())); | 6406 transport_dib->id())); |
| 6427 | 6407 |
| 6428 return true; | 6408 return true; |
| 6429 } | 6409 } |
| 6430 | 6410 |
| 6431 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( | 6411 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( |
| 6432 TransportDIB::Handle dib_handle) { | 6412 TransportDIB::Handle dib_handle) { |
| 6433 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); | 6413 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); |
| 6434 RenderProcess::current()->ReleaseTransportDIB(dib); | 6414 RenderProcess::current()->ReleaseTransportDIB(dib); |
| 6435 } | 6415 } |
| 6416 |
| 6417 } // namespace content |
| OLD | NEW |