| 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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceDeleted, | 550 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceDeleted, |
| 567 OnPepperInstanceDeleted) | 551 OnPepperInstanceDeleted) |
| 568 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) | 552 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) |
| 569 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) | 553 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) |
| 570 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, | 554 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, |
| 571 OnRequestPpapiBrokerPermission) | 555 OnRequestPpapiBrokerPermission) |
| 572 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, | 556 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, |
| 573 OnBrowserPluginMessage(render_frame_host, | 557 OnBrowserPluginMessage(render_frame_host, |
| 574 message)) | 558 message)) |
| 575 #endif | 559 #endif |
| 576 IPC_MESSAGE_HANDLER(ImageHostMsg_DidDownloadImage, OnDidDownloadImage) | |
| 577 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) | 560 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) |
| 578 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage, | 561 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage, |
| 579 OnShowValidationMessage) | 562 OnShowValidationMessage) |
| 580 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, | 563 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, |
| 581 OnHideValidationMessage) | 564 OnHideValidationMessage) |
| 582 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage, | 565 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage, |
| 583 OnMoveValidationMessage) | 566 OnMoveValidationMessage) |
| 584 #if defined(OS_ANDROID) | 567 #if defined(OS_ANDROID) |
| 585 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, | 568 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, |
| 586 OnFindMatchRectsReply) | 569 OnFindMatchRectsReply) |
| (...skipping 1933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2520 rfh->Send(new FrameMsg_DidEndColorChooser( | 2503 rfh->Send(new FrameMsg_DidEndColorChooser( |
| 2521 rfh->GetRoutingID(), color_chooser_info_->identifier)); | 2504 rfh->GetRoutingID(), color_chooser_info_->identifier)); |
| 2522 color_chooser_info_.reset(); | 2505 color_chooser_info_.reset(); |
| 2523 } | 2506 } |
| 2524 | 2507 |
| 2525 int WebContentsImpl::DownloadImage(const GURL& url, | 2508 int WebContentsImpl::DownloadImage(const GURL& url, |
| 2526 bool is_favicon, | 2509 bool is_favicon, |
| 2527 uint32_t max_bitmap_size, | 2510 uint32_t max_bitmap_size, |
| 2528 bool bypass_cache, | 2511 bool bypass_cache, |
| 2529 const ImageDownloadCallback& callback) { | 2512 const ImageDownloadCallback& callback) { |
| 2530 int id = StartDownload(GetMainFrame(), url, is_favicon, max_bitmap_size, | 2513 int id = GetMainFrame()->DownloadImage(url, is_favicon, max_bitmap_size, |
| 2531 bypass_cache); | 2514 bypass_cache, callback); |
| 2532 image_download_map_[id] = callback; | |
| 2533 return id; | 2515 return id; |
| 2534 } | 2516 } |
| 2535 | 2517 |
| 2536 bool WebContentsImpl::IsSubframe() const { | 2518 bool WebContentsImpl::IsSubframe() const { |
| 2537 return is_subframe_; | 2519 return is_subframe_; |
| 2538 } | 2520 } |
| 2539 | 2521 |
| 2540 void WebContentsImpl::Find(int request_id, | 2522 void WebContentsImpl::Find(int request_id, |
| 2541 const base::string16& search_text, | 2523 const base::string16& search_text, |
| 2542 const blink::WebFindOptions& options) { | 2524 const blink::WebFindOptions& options) { |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3095 } | 3077 } |
| 3096 | 3078 |
| 3097 void WebContentsImpl::OnBrowserPluginMessage(RenderFrameHost* render_frame_host, | 3079 void WebContentsImpl::OnBrowserPluginMessage(RenderFrameHost* render_frame_host, |
| 3098 const IPC::Message& message) { | 3080 const IPC::Message& message) { |
| 3099 CHECK(!browser_plugin_embedder_.get()); | 3081 CHECK(!browser_plugin_embedder_.get()); |
| 3100 CreateBrowserPluginEmbedderIfNecessary(); | 3082 CreateBrowserPluginEmbedderIfNecessary(); |
| 3101 browser_plugin_embedder_->OnMessageReceived(message, render_frame_host); | 3083 browser_plugin_embedder_->OnMessageReceived(message, render_frame_host); |
| 3102 } | 3084 } |
| 3103 #endif // defined(ENABLE_PLUGINS) | 3085 #endif // defined(ENABLE_PLUGINS) |
| 3104 | 3086 |
| 3105 void WebContentsImpl::OnDidDownloadImage( | |
| 3106 int id, | |
| 3107 int http_status_code, | |
| 3108 const GURL& image_url, | |
| 3109 const std::vector<SkBitmap>& bitmaps, | |
| 3110 const std::vector<gfx::Size>& original_bitmap_sizes) { | |
| 3111 if (bitmaps.size() != original_bitmap_sizes.size()) | |
| 3112 return; | |
| 3113 | |
| 3114 ImageDownloadMap::iterator iter = image_download_map_.find(id); | |
| 3115 if (iter == image_download_map_.end()) { | |
| 3116 // Currently WebContents notifies us of ANY downloads so that it is | |
| 3117 // possible to get here. | |
| 3118 return; | |
| 3119 } | |
| 3120 if (!iter->second.is_null()) { | |
| 3121 iter->second.Run( | |
| 3122 id, http_status_code, image_url, bitmaps, original_bitmap_sizes); | |
| 3123 } | |
| 3124 image_download_map_.erase(id); | |
| 3125 } | |
| 3126 | |
| 3127 void WebContentsImpl::OnUpdateFaviconURL( | 3087 void WebContentsImpl::OnUpdateFaviconURL( |
| 3128 const std::vector<FaviconURL>& candidates) { | 3088 const std::vector<FaviconURL>& candidates) { |
| 3129 // We get updated favicon URLs after the page stops loading. If a cross-site | 3089 // We get updated favicon URLs after the page stops loading. If a cross-site |
| 3130 // navigation occurs while a page is still loading, the initial page | 3090 // navigation occurs while a page is still loading, the initial page |
| 3131 // may stop loading and send us updated favicon URLs after the navigation | 3091 // may stop loading and send us updated favicon URLs after the navigation |
| 3132 // for the new page has committed. | 3092 // for the new page has committed. |
| 3133 RenderViewHostImpl* rvhi = | 3093 RenderViewHostImpl* rvhi = |
| 3134 static_cast<RenderViewHostImpl*>(render_view_message_source_); | 3094 static_cast<RenderViewHostImpl*>(render_view_message_source_); |
| 3135 if (!rvhi->is_active()) | 3095 if (!rvhi->is_active()) |
| 3136 return; | 3096 return; |
| (...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4453 player_map->erase(it); | 4413 player_map->erase(it); |
| 4454 } | 4414 } |
| 4455 | 4415 |
| 4456 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4416 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
| 4457 force_disable_overscroll_content_ = force_disable; | 4417 force_disable_overscroll_content_ = force_disable; |
| 4458 if (view_) | 4418 if (view_) |
| 4459 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4419 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 4460 } | 4420 } |
| 4461 | 4421 |
| 4462 } // namespace content | 4422 } // namespace content |
| OLD | NEW |