| 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/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 55 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 56 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host_
impl.h" | 56 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host_
impl.h" |
| 57 #include "content/browser/site_instance_impl.h" | 57 #include "content/browser/site_instance_impl.h" |
| 58 #include "content/browser/web_contents/web_contents_view_guest.h" | 58 #include "content/browser/web_contents/web_contents_view_guest.h" |
| 59 #include "content/browser/webui/generic_handler.h" | 59 #include "content/browser/webui/generic_handler.h" |
| 60 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 60 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
| 61 #include "content/browser/webui/web_ui_impl.h" | 61 #include "content/browser/webui/web_ui_impl.h" |
| 62 #include "content/common/browser_plugin/browser_plugin_constants.h" | 62 #include "content/common/browser_plugin/browser_plugin_constants.h" |
| 63 #include "content/common/browser_plugin/browser_plugin_messages.h" | 63 #include "content/common/browser_plugin/browser_plugin_messages.h" |
| 64 #include "content/common/frame_messages.h" | 64 #include "content/common/frame_messages.h" |
| 65 #include "content/common/image_messages.h" | |
| 66 #include "content/common/input_messages.h" | 65 #include "content/common/input_messages.h" |
| 67 #include "content/common/ssl_status_serialization.h" | 66 #include "content/common/ssl_status_serialization.h" |
| 68 #include "content/common/view_messages.h" | 67 #include "content/common/view_messages.h" |
| 69 #include "content/public/browser/ax_event_notification_details.h" | 68 #include "content/public/browser/ax_event_notification_details.h" |
| 70 #include "content/public/browser/browser_context.h" | 69 #include "content/public/browser/browser_context.h" |
| 71 #include "content/public/browser/browser_plugin_guest_manager.h" | 70 #include "content/public/browser/browser_plugin_guest_manager.h" |
| 72 #include "content/public/browser/content_browser_client.h" | 71 #include "content/public/browser/content_browser_client.h" |
| 73 #include "content/public/browser/devtools_agent_host.h" | 72 #include "content/public/browser/devtools_agent_host.h" |
| 74 #include "content/public/browser/download_manager.h" | 73 #include "content/public/browser/download_manager.h" |
| 75 #include "content/public/browser/download_url_parameters.h" | 74 #include "content/public/browser/download_url_parameters.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; | 127 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; |
| 129 const char kDotGoogleDotCom[] = ".google.com"; | 128 const char kDotGoogleDotCom[] = ".google.com"; |
| 130 | 129 |
| 131 #if defined(OS_ANDROID) | 130 #if defined(OS_ANDROID) |
| 132 const char kWebContentsAndroidKey[] = "web_contents_android"; | 131 const char kWebContentsAndroidKey[] = "web_contents_android"; |
| 133 #endif // OS_ANDROID | 132 #endif // OS_ANDROID |
| 134 | 133 |
| 135 base::LazyInstance<std::vector<WebContentsImpl::CreatedCallback> > | 134 base::LazyInstance<std::vector<WebContentsImpl::CreatedCallback> > |
| 136 g_created_callbacks = LAZY_INSTANCE_INITIALIZER; | 135 g_created_callbacks = LAZY_INSTANCE_INITIALIZER; |
| 137 | 136 |
| 138 static int StartDownload(RenderFrameHost* rfh, | |
| 139 const GURL& url, | |
| 140 bool is_favicon, | |
| 141 uint32_t max_bitmap_size, | |
| 142 bool bypass_cache) { | |
| 143 static int g_next_image_download_id = 0; | |
| 144 rfh->Send(new ImageMsg_DownloadImage(rfh->GetRoutingID(), | |
| 145 ++g_next_image_download_id, | |
| 146 url, | |
| 147 is_favicon, | |
| 148 max_bitmap_size, | |
| 149 bypass_cache)); | |
| 150 return g_next_image_download_id; | |
| 151 } | |
| 152 | |
| 153 void NotifyCacheOnIO( | 137 void NotifyCacheOnIO( |
| 154 scoped_refptr<net::URLRequestContextGetter> request_context, | 138 scoped_refptr<net::URLRequestContextGetter> request_context, |
| 155 const GURL& url, | 139 const GURL& url, |
| 156 const std::string& http_method) { | 140 const std::string& http_method) { |
| 157 net::HttpCache* cache = request_context->GetURLRequestContext()-> | 141 net::HttpCache* cache = request_context->GetURLRequestContext()-> |
| 158 http_transaction_factory()->GetCache(); | 142 http_transaction_factory()->GetCache(); |
| 159 if (cache) | 143 if (cache) |
| 160 cache->OnExternalCacheHit(url, http_method); | 144 cache->OnExternalCacheHit(url, http_method); |
| 161 } | 145 } |
| 162 | 146 |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceDeleted, | 588 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceDeleted, |
| 605 OnPepperInstanceDeleted) | 589 OnPepperInstanceDeleted) |
| 606 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) | 590 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) |
| 607 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) | 591 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) |
| 608 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, | 592 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, |
| 609 OnRequestPpapiBrokerPermission) | 593 OnRequestPpapiBrokerPermission) |
| 610 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, | 594 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, |
| 611 OnBrowserPluginMessage(render_frame_host, | 595 OnBrowserPluginMessage(render_frame_host, |
| 612 message)) | 596 message)) |
| 613 #endif | 597 #endif |
| 614 IPC_MESSAGE_HANDLER(ImageHostMsg_DidDownloadImage, OnDidDownloadImage) | |
| 615 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) | 598 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) |
| 616 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage, | 599 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage, |
| 617 OnShowValidationMessage) | 600 OnShowValidationMessage) |
| 618 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, | 601 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, |
| 619 OnHideValidationMessage) | 602 OnHideValidationMessage) |
| 620 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage, | 603 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage, |
| 621 OnMoveValidationMessage) | 604 OnMoveValidationMessage) |
| 622 #if defined(OS_ANDROID) | 605 #if defined(OS_ANDROID) |
| 623 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, | 606 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, |
| 624 OnFindMatchRectsReply) | 607 OnFindMatchRectsReply) |
| (...skipping 1947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2572 rfh->Send(new FrameMsg_DidEndColorChooser( | 2555 rfh->Send(new FrameMsg_DidEndColorChooser( |
| 2573 rfh->GetRoutingID(), color_chooser_info_->identifier)); | 2556 rfh->GetRoutingID(), color_chooser_info_->identifier)); |
| 2574 color_chooser_info_.reset(); | 2557 color_chooser_info_.reset(); |
| 2575 } | 2558 } |
| 2576 | 2559 |
| 2577 int WebContentsImpl::DownloadImage(const GURL& url, | 2560 int WebContentsImpl::DownloadImage(const GURL& url, |
| 2578 bool is_favicon, | 2561 bool is_favicon, |
| 2579 uint32_t max_bitmap_size, | 2562 uint32_t max_bitmap_size, |
| 2580 bool bypass_cache, | 2563 bool bypass_cache, |
| 2581 const ImageDownloadCallback& callback) { | 2564 const ImageDownloadCallback& callback) { |
| 2582 int id = StartDownload(GetMainFrame(), url, is_favicon, max_bitmap_size, | 2565 int id = GetMainFrame()->DownloadImage(url, is_favicon, max_bitmap_size, |
| 2583 bypass_cache); | 2566 bypass_cache, callback); |
| 2584 image_download_map_[id] = callback; | |
| 2585 return id; | 2567 return id; |
| 2586 } | 2568 } |
| 2587 | 2569 |
| 2588 bool WebContentsImpl::IsSubframe() const { | 2570 bool WebContentsImpl::IsSubframe() const { |
| 2589 return is_subframe_; | 2571 return is_subframe_; |
| 2590 } | 2572 } |
| 2591 | 2573 |
| 2592 void WebContentsImpl::Find(int request_id, | 2574 void WebContentsImpl::Find(int request_id, |
| 2593 const base::string16& search_text, | 2575 const base::string16& search_text, |
| 2594 const blink::WebFindOptions& options) { | 2576 const blink::WebFindOptions& options) { |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3150 } | 3132 } |
| 3151 | 3133 |
| 3152 void WebContentsImpl::OnBrowserPluginMessage(RenderFrameHost* render_frame_host, | 3134 void WebContentsImpl::OnBrowserPluginMessage(RenderFrameHost* render_frame_host, |
| 3153 const IPC::Message& message) { | 3135 const IPC::Message& message) { |
| 3154 CHECK(!browser_plugin_embedder_.get()); | 3136 CHECK(!browser_plugin_embedder_.get()); |
| 3155 CreateBrowserPluginEmbedderIfNecessary(); | 3137 CreateBrowserPluginEmbedderIfNecessary(); |
| 3156 browser_plugin_embedder_->OnMessageReceived(message, render_frame_host); | 3138 browser_plugin_embedder_->OnMessageReceived(message, render_frame_host); |
| 3157 } | 3139 } |
| 3158 #endif // defined(ENABLE_PLUGINS) | 3140 #endif // defined(ENABLE_PLUGINS) |
| 3159 | 3141 |
| 3160 void WebContentsImpl::OnDidDownloadImage( | |
| 3161 int id, | |
| 3162 int http_status_code, | |
| 3163 const GURL& image_url, | |
| 3164 const std::vector<SkBitmap>& bitmaps, | |
| 3165 const std::vector<gfx::Size>& original_bitmap_sizes) { | |
| 3166 if (bitmaps.size() != original_bitmap_sizes.size()) | |
| 3167 return; | |
| 3168 | |
| 3169 ImageDownloadMap::iterator iter = image_download_map_.find(id); | |
| 3170 if (iter == image_download_map_.end()) { | |
| 3171 // Currently WebContents notifies us of ANY downloads so that it is | |
| 3172 // possible to get here. | |
| 3173 return; | |
| 3174 } | |
| 3175 if (!iter->second.is_null()) { | |
| 3176 iter->second.Run( | |
| 3177 id, http_status_code, image_url, bitmaps, original_bitmap_sizes); | |
| 3178 } | |
| 3179 image_download_map_.erase(id); | |
| 3180 } | |
| 3181 | |
| 3182 void WebContentsImpl::OnUpdateFaviconURL( | 3142 void WebContentsImpl::OnUpdateFaviconURL( |
| 3183 const std::vector<FaviconURL>& candidates) { | 3143 const std::vector<FaviconURL>& candidates) { |
| 3184 // We get updated favicon URLs after the page stops loading. If a cross-site | 3144 // We get updated favicon URLs after the page stops loading. If a cross-site |
| 3185 // navigation occurs while a page is still loading, the initial page | 3145 // navigation occurs while a page is still loading, the initial page |
| 3186 // may stop loading and send us updated favicon URLs after the navigation | 3146 // may stop loading and send us updated favicon URLs after the navigation |
| 3187 // for the new page has committed. | 3147 // for the new page has committed. |
| 3188 RenderViewHostImpl* rvhi = | 3148 RenderViewHostImpl* rvhi = |
| 3189 static_cast<RenderViewHostImpl*>(render_view_message_source_); | 3149 static_cast<RenderViewHostImpl*>(render_view_message_source_); |
| 3190 if (!rvhi->is_active()) | 3150 if (!rvhi->is_active()) |
| 3191 return; | 3151 return; |
| (...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4484 player_map->erase(it); | 4444 player_map->erase(it); |
| 4485 } | 4445 } |
| 4486 | 4446 |
| 4487 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4447 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
| 4488 force_disable_overscroll_content_ = force_disable; | 4448 force_disable_overscroll_content_ = force_disable; |
| 4489 if (view_) | 4449 if (view_) |
| 4490 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4450 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 4491 } | 4451 } |
| 4492 | 4452 |
| 4493 } // namespace content | 4453 } // namespace content |
| OLD | NEW |