| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 52 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 53 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host_
impl.h" | 53 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host_
impl.h" |
| 54 #include "content/browser/site_instance_impl.h" | 54 #include "content/browser/site_instance_impl.h" |
| 55 #include "content/browser/web_contents/web_contents_view_guest.h" | 55 #include "content/browser/web_contents/web_contents_view_guest.h" |
| 56 #include "content/browser/webui/generic_handler.h" | 56 #include "content/browser/webui/generic_handler.h" |
| 57 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 57 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
| 58 #include "content/browser/webui/web_ui_impl.h" | 58 #include "content/browser/webui/web_ui_impl.h" |
| 59 #include "content/common/browser_plugin/browser_plugin_constants.h" | 59 #include "content/common/browser_plugin/browser_plugin_constants.h" |
| 60 #include "content/common/browser_plugin/browser_plugin_messages.h" | 60 #include "content/common/browser_plugin/browser_plugin_messages.h" |
| 61 #include "content/common/frame_messages.h" | 61 #include "content/common/frame_messages.h" |
| 62 #include "content/common/image_messages.h" | |
| 63 #include "content/common/input_messages.h" | 62 #include "content/common/input_messages.h" |
| 64 #include "content/common/ssl_status_serialization.h" | 63 #include "content/common/ssl_status_serialization.h" |
| 65 #include "content/common/view_messages.h" | 64 #include "content/common/view_messages.h" |
| 66 #include "content/public/browser/ax_event_notification_details.h" | 65 #include "content/public/browser/ax_event_notification_details.h" |
| 67 #include "content/public/browser/browser_context.h" | 66 #include "content/public/browser/browser_context.h" |
| 68 #include "content/public/browser/browser_plugin_guest_manager.h" | 67 #include "content/public/browser/browser_plugin_guest_manager.h" |
| 69 #include "content/public/browser/content_browser_client.h" | 68 #include "content/public/browser/content_browser_client.h" |
| 70 #include "content/public/browser/devtools_agent_host.h" | 69 #include "content/public/browser/devtools_agent_host.h" |
| 71 #include "content/public/browser/download_manager.h" | 70 #include "content/public/browser/download_manager.h" |
| 72 #include "content/public/browser/download_url_parameters.h" | 71 #include "content/public/browser/download_url_parameters.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; | 124 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; |
| 126 const char kDotGoogleDotCom[] = ".google.com"; | 125 const char kDotGoogleDotCom[] = ".google.com"; |
| 127 | 126 |
| 128 #if defined(OS_ANDROID) | 127 #if defined(OS_ANDROID) |
| 129 const char kWebContentsAndroidKey[] = "web_contents_android"; | 128 const char kWebContentsAndroidKey[] = "web_contents_android"; |
| 130 #endif // OS_ANDROID | 129 #endif // OS_ANDROID |
| 131 | 130 |
| 132 base::LazyInstance<std::vector<WebContentsImpl::CreatedCallback> > | 131 base::LazyInstance<std::vector<WebContentsImpl::CreatedCallback> > |
| 133 g_created_callbacks = LAZY_INSTANCE_INITIALIZER; | 132 g_created_callbacks = LAZY_INSTANCE_INITIALIZER; |
| 134 | 133 |
| 135 static int StartDownload(RenderFrameHost* rfh, | |
| 136 const GURL& url, | |
| 137 bool is_favicon, | |
| 138 uint32_t max_bitmap_size, | |
| 139 bool bypass_cache) { | |
| 140 static int g_next_image_download_id = 0; | |
| 141 rfh->Send(new ImageMsg_DownloadImage(rfh->GetRoutingID(), | |
| 142 ++g_next_image_download_id, | |
| 143 url, | |
| 144 is_favicon, | |
| 145 max_bitmap_size, | |
| 146 bypass_cache)); | |
| 147 return g_next_image_download_id; | |
| 148 } | |
| 149 | |
| 150 void NotifyCacheOnIO( | 134 void NotifyCacheOnIO( |
| 151 scoped_refptr<net::URLRequestContextGetter> request_context, | 135 scoped_refptr<net::URLRequestContextGetter> request_context, |
| 152 const GURL& url, | 136 const GURL& url, |
| 153 const std::string& http_method) { | 137 const std::string& http_method) { |
| 154 net::HttpCache* cache = request_context->GetURLRequestContext()-> | 138 net::HttpCache* cache = request_context->GetURLRequestContext()-> |
| 155 http_transaction_factory()->GetCache(); | 139 http_transaction_factory()->GetCache(); |
| 156 if (cache) | 140 if (cache) |
| 157 cache->OnExternalCacheHit(url, http_method); | 141 cache->OnExternalCacheHit(url, http_method); |
| 158 } | 142 } |
| 159 | 143 |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) | 529 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) |
| 546 #if defined(ENABLE_PLUGINS) | 530 #if defined(ENABLE_PLUGINS) |
| 547 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) | 531 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) |
| 548 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) | 532 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) |
| 549 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, | 533 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, |
| 550 OnRequestPpapiBrokerPermission) | 534 OnRequestPpapiBrokerPermission) |
| 551 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, | 535 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, |
| 552 OnBrowserPluginMessage(render_frame_host, | 536 OnBrowserPluginMessage(render_frame_host, |
| 553 message)) | 537 message)) |
| 554 #endif | 538 #endif |
| 555 IPC_MESSAGE_HANDLER(ImageHostMsg_DidDownloadImage, OnDidDownloadImage) | |
| 556 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) | 539 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) |
| 557 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage, | 540 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage, |
| 558 OnShowValidationMessage) | 541 OnShowValidationMessage) |
| 559 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, | 542 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, |
| 560 OnHideValidationMessage) | 543 OnHideValidationMessage) |
| 561 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage, | 544 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage, |
| 562 OnMoveValidationMessage) | 545 OnMoveValidationMessage) |
| 563 #if defined(OS_ANDROID) | 546 #if defined(OS_ANDROID) |
| 564 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, | 547 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, |
| 565 OnFindMatchRectsReply) | 548 OnFindMatchRectsReply) |
| (...skipping 1910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2476 rfh->Send(new FrameMsg_DidEndColorChooser( | 2459 rfh->Send(new FrameMsg_DidEndColorChooser( |
| 2477 rfh->GetRoutingID(), color_chooser_info_->identifier)); | 2460 rfh->GetRoutingID(), color_chooser_info_->identifier)); |
| 2478 color_chooser_info_.reset(); | 2461 color_chooser_info_.reset(); |
| 2479 } | 2462 } |
| 2480 | 2463 |
| 2481 int WebContentsImpl::DownloadImage(const GURL& url, | 2464 int WebContentsImpl::DownloadImage(const GURL& url, |
| 2482 bool is_favicon, | 2465 bool is_favicon, |
| 2483 uint32_t max_bitmap_size, | 2466 uint32_t max_bitmap_size, |
| 2484 bool bypass_cache, | 2467 bool bypass_cache, |
| 2485 const ImageDownloadCallback& callback) { | 2468 const ImageDownloadCallback& callback) { |
| 2486 int id = StartDownload(GetMainFrame(), url, is_favicon, max_bitmap_size, | 2469 int id = GetMainFrame()->DownloadImage(url, is_favicon, max_bitmap_size, |
| 2487 bypass_cache); | 2470 bypass_cache, callback); |
| 2488 image_download_map_[id] = callback; | |
| 2489 return id; | 2471 return id; |
| 2490 } | 2472 } |
| 2491 | 2473 |
| 2492 bool WebContentsImpl::IsSubframe() const { | 2474 bool WebContentsImpl::IsSubframe() const { |
| 2493 return is_subframe_; | 2475 return is_subframe_; |
| 2494 } | 2476 } |
| 2495 | 2477 |
| 2496 void WebContentsImpl::Find(int request_id, | 2478 void WebContentsImpl::Find(int request_id, |
| 2497 const base::string16& search_text, | 2479 const base::string16& search_text, |
| 2498 const blink::WebFindOptions& options) { | 2480 const blink::WebFindOptions& options) { |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3174 } | 3156 } |
| 3175 | 3157 |
| 3176 void WebContentsImpl::OnBrowserPluginMessage(RenderFrameHost* render_frame_host, | 3158 void WebContentsImpl::OnBrowserPluginMessage(RenderFrameHost* render_frame_host, |
| 3177 const IPC::Message& message) { | 3159 const IPC::Message& message) { |
| 3178 CHECK(!browser_plugin_embedder_.get()); | 3160 CHECK(!browser_plugin_embedder_.get()); |
| 3179 CreateBrowserPluginEmbedderIfNecessary(); | 3161 CreateBrowserPluginEmbedderIfNecessary(); |
| 3180 browser_plugin_embedder_->OnMessageReceived(message, render_frame_host); | 3162 browser_plugin_embedder_->OnMessageReceived(message, render_frame_host); |
| 3181 } | 3163 } |
| 3182 #endif // defined(ENABLE_PLUGINS) | 3164 #endif // defined(ENABLE_PLUGINS) |
| 3183 | 3165 |
| 3184 void WebContentsImpl::OnDidDownloadImage( | |
| 3185 int id, | |
| 3186 int http_status_code, | |
| 3187 const GURL& image_url, | |
| 3188 const std::vector<SkBitmap>& bitmaps, | |
| 3189 const std::vector<gfx::Size>& original_bitmap_sizes) { | |
| 3190 if (bitmaps.size() != original_bitmap_sizes.size()) | |
| 3191 return; | |
| 3192 | |
| 3193 ImageDownloadMap::iterator iter = image_download_map_.find(id); | |
| 3194 if (iter == image_download_map_.end()) { | |
| 3195 // Currently WebContents notifies us of ANY downloads so that it is | |
| 3196 // possible to get here. | |
| 3197 return; | |
| 3198 } | |
| 3199 if (!iter->second.is_null()) { | |
| 3200 iter->second.Run( | |
| 3201 id, http_status_code, image_url, bitmaps, original_bitmap_sizes); | |
| 3202 } | |
| 3203 image_download_map_.erase(id); | |
| 3204 } | |
| 3205 | |
| 3206 void WebContentsImpl::OnUpdateFaviconURL( | 3166 void WebContentsImpl::OnUpdateFaviconURL( |
| 3207 const std::vector<FaviconURL>& candidates) { | 3167 const std::vector<FaviconURL>& candidates) { |
| 3208 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3168 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 3209 DidUpdateFaviconURL(candidates)); | 3169 DidUpdateFaviconURL(candidates)); |
| 3210 } | 3170 } |
| 3211 | 3171 |
| 3212 void WebContentsImpl::CreateAudioPowerSaveBlocker() { | 3172 void WebContentsImpl::CreateAudioPowerSaveBlocker() { |
| 3213 DCHECK(!audio_power_save_blocker_); | 3173 DCHECK(!audio_power_save_blocker_); |
| 3214 audio_power_save_blocker_ = PowerSaveBlocker::Create( | 3174 audio_power_save_blocker_ = PowerSaveBlocker::Create( |
| 3215 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, | 3175 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, |
| (...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4525 node->render_manager()->ResumeResponseDeferredAtStart(); | 4485 node->render_manager()->ResumeResponseDeferredAtStart(); |
| 4526 } | 4486 } |
| 4527 | 4487 |
| 4528 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4488 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
| 4529 force_disable_overscroll_content_ = force_disable; | 4489 force_disable_overscroll_content_ = force_disable; |
| 4530 if (view_) | 4490 if (view_) |
| 4531 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4491 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 4532 } | 4492 } |
| 4533 | 4493 |
| 4534 } // namespace content | 4494 } // namespace content |
| OLD | NEW |