| 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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "content/browser/site_instance_impl.h" | 36 #include "content/browser/site_instance_impl.h" |
| 37 #include "content/browser/web_contents/interstitial_page_impl.h" | 37 #include "content/browser/web_contents/interstitial_page_impl.h" |
| 38 #include "content/browser/web_contents/navigation_entry_impl.h" | 38 #include "content/browser/web_contents/navigation_entry_impl.h" |
| 39 #include "content/browser/web_contents/web_contents_view_guest.h" | 39 #include "content/browser/web_contents/web_contents_view_guest.h" |
| 40 #include "content/browser/webui/generic_handler.h" | 40 #include "content/browser/webui/generic_handler.h" |
| 41 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 41 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
| 42 #include "content/browser/webui/web_ui_impl.h" | 42 #include "content/browser/webui/web_ui_impl.h" |
| 43 #include "content/common/browser_plugin/browser_plugin_constants.h" | 43 #include "content/common/browser_plugin/browser_plugin_constants.h" |
| 44 #include "content/common/browser_plugin/browser_plugin_messages.h" | 44 #include "content/common/browser_plugin/browser_plugin_messages.h" |
| 45 #include "content/common/icon_messages.h" | 45 #include "content/common/icon_messages.h" |
| 46 #include "content/common/image_messages.h" |
| 46 #include "content/common/ssl_status_serialization.h" | 47 #include "content/common/ssl_status_serialization.h" |
| 47 #include "content/common/view_messages.h" | 48 #include "content/common/view_messages.h" |
| 48 #include "content/port/browser/render_view_host_delegate_view.h" | 49 #include "content/port/browser/render_view_host_delegate_view.h" |
| 49 #include "content/port/browser/render_widget_host_view_port.h" | 50 #include "content/port/browser/render_widget_host_view_port.h" |
| 50 #include "content/public/browser/browser_context.h" | 51 #include "content/public/browser/browser_context.h" |
| 51 #include "content/public/browser/color_chooser.h" | 52 #include "content/public/browser/color_chooser.h" |
| 52 #include "content/public/browser/compositor_util.h" | 53 #include "content/public/browser/compositor_util.h" |
| 53 #include "content/public/browser/content_browser_client.h" | 54 #include "content/public/browser/content_browser_client.h" |
| 54 #include "content/public/browser/devtools_agent_host.h" | 55 #include "content/public/browser/devtools_agent_host.h" |
| 55 #include "content/public/browser/download_manager.h" | 56 #include "content/public/browser/download_manager.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // is queried for its state and pushed to the NavigationEntry. | 150 // is queried for its state and pushed to the NavigationEntry. |
| 150 const int kQueryStateDelay = 5000; | 151 const int kQueryStateDelay = 5000; |
| 151 | 152 |
| 152 const int kSyncWaitDelay = 40; | 153 const int kSyncWaitDelay = 40; |
| 153 | 154 |
| 154 const char kDotGoogleDotCom[] = ".google.com"; | 155 const char kDotGoogleDotCom[] = ".google.com"; |
| 155 | 156 |
| 156 static int StartDownload(content::RenderViewHost* rvh, | 157 static int StartDownload(content::RenderViewHost* rvh, |
| 157 const GURL& url, | 158 const GURL& url, |
| 158 int image_size) { | 159 int image_size) { |
| 159 static int g_next_favicon_download_id = 0; | 160 static int g_next_image_download_id = 0; |
| 160 rvh->Send(new IconMsg_DownloadFavicon(rvh->GetRoutingID(), | 161 rvh->Send(new ImageMsg_DownloadImage(rvh->GetRoutingID(), |
| 161 ++g_next_favicon_download_id, | 162 ++g_next_image_download_id, |
| 162 url, | 163 url, |
| 163 image_size)); | 164 image_size)); |
| 164 return g_next_favicon_download_id; | 165 return g_next_image_download_id; |
| 165 } | 166 } |
| 166 | 167 |
| 167 ViewMsg_Navigate_Type::Value GetNavigationType( | 168 ViewMsg_Navigate_Type::Value GetNavigationType( |
| 168 BrowserContext* browser_context, const NavigationEntryImpl& entry, | 169 BrowserContext* browser_context, const NavigationEntryImpl& entry, |
| 169 NavigationController::ReloadType reload_type) { | 170 NavigationController::ReloadType reload_type) { |
| 170 switch (reload_type) { | 171 switch (reload_type) { |
| 171 case NavigationControllerImpl::RELOAD: | 172 case NavigationControllerImpl::RELOAD: |
| 172 return ViewMsg_Navigate_Type::RELOAD; | 173 return ViewMsg_Navigate_Type::RELOAD; |
| 173 case NavigationControllerImpl::RELOAD_IGNORING_CACHE: | 174 case NavigationControllerImpl::RELOAD_IGNORING_CACHE: |
| 174 return ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; | 175 return ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser, | 703 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser, |
| 703 OnSetSelectedColorInColorChooser) | 704 OnSetSelectedColorInColorChooser) |
| 704 IPC_MESSAGE_HANDLER(ViewHostMsg_PepperPluginHung, OnPepperPluginHung) | 705 IPC_MESSAGE_HANDLER(ViewHostMsg_PepperPluginHung, OnPepperPluginHung) |
| 705 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) | 706 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) |
| 706 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, | 707 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, |
| 707 OnRequestPpapiBrokerPermission) | 708 OnRequestPpapiBrokerPermission) |
| 708 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_AllocateInstanceID, | 709 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_AllocateInstanceID, |
| 709 OnBrowserPluginMessage(message)) | 710 OnBrowserPluginMessage(message)) |
| 710 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, | 711 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, |
| 711 OnBrowserPluginMessage(message)) | 712 OnBrowserPluginMessage(message)) |
| 712 IPC_MESSAGE_HANDLER(IconHostMsg_DidDownloadFavicon, OnDidDownloadFavicon) | 713 IPC_MESSAGE_HANDLER(ImageHostMsg_DidDownloadImage, OnDidDownloadImage) |
| 713 IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) | 714 IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) |
| 714 #if defined(OS_ANDROID) | 715 #if defined(OS_ANDROID) |
| 715 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, | 716 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, |
| 716 OnFindMatchRectsReply) | 717 OnFindMatchRectsReply) |
| 717 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, | 718 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, |
| 718 OnOpenDateTimeDialog) | 719 OnOpenDateTimeDialog) |
| 719 #endif | 720 #endif |
| 720 IPC_MESSAGE_HANDLER(ViewHostMsg_FrameDetached, OnFrameDetached) | 721 IPC_MESSAGE_HANDLER(ViewHostMsg_FrameDetached, OnFrameDetached) |
| 721 IPC_MESSAGE_UNHANDLED(handled = false) | 722 IPC_MESSAGE_UNHANDLED(handled = false) |
| 722 IPC_END_MESSAGE_MAP_EX() | 723 IPC_END_MESSAGE_MAP_EX() |
| (...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2035 GetRoutingID(), color_chooser_id, color)); | 2036 GetRoutingID(), color_chooser_id, color)); |
| 2036 } | 2037 } |
| 2037 | 2038 |
| 2038 void WebContentsImpl::DidEndColorChooser(int color_chooser_id) { | 2039 void WebContentsImpl::DidEndColorChooser(int color_chooser_id) { |
| 2039 Send(new ViewMsg_DidEndColorChooser(GetRoutingID(), color_chooser_id)); | 2040 Send(new ViewMsg_DidEndColorChooser(GetRoutingID(), color_chooser_id)); |
| 2040 if (delegate_) | 2041 if (delegate_) |
| 2041 delegate_->DidEndColorChooser(); | 2042 delegate_->DidEndColorChooser(); |
| 2042 color_chooser_ = NULL; | 2043 color_chooser_ = NULL; |
| 2043 } | 2044 } |
| 2044 | 2045 |
| 2045 int WebContentsImpl::DownloadFavicon(const GURL& url, int image_size, | 2046 int WebContentsImpl::DownloadImage(const GURL& url, int image_size, |
| 2046 const FaviconDownloadCallback& callback) { | 2047 const ImageDownloadCallback& callback) { |
| 2047 RenderViewHost* host = GetRenderViewHost(); | 2048 RenderViewHost* host = GetRenderViewHost(); |
| 2048 int id = StartDownload(host, url, image_size); | 2049 int id = StartDownload(host, url, image_size); |
| 2049 favicon_download_map_[id] = callback; | 2050 image_download_map_[id] = callback; |
| 2050 return id; | 2051 return id; |
| 2051 } | 2052 } |
| 2052 | 2053 |
| 2053 bool WebContentsImpl::FocusLocationBarByDefault() { | 2054 bool WebContentsImpl::FocusLocationBarByDefault() { |
| 2054 WebUI* web_ui = GetWebUIForCurrentState(); | 2055 WebUI* web_ui = GetWebUIForCurrentState(); |
| 2055 if (web_ui) | 2056 if (web_ui) |
| 2056 return web_ui->ShouldFocusLocationBarByDefault(); | 2057 return web_ui->ShouldFocusLocationBarByDefault(); |
| 2057 NavigationEntry* entry = controller_.GetActiveEntry(); | 2058 NavigationEntry* entry = controller_.GetActiveEntry(); |
| 2058 if (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)) | 2059 if (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)) |
| 2059 return true; | 2060 return true; |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2451 // This creates a BrowserPluginEmbedder, which handles all the BrowserPlugin | 2452 // This creates a BrowserPluginEmbedder, which handles all the BrowserPlugin |
| 2452 // specific messages for this WebContents. This means that any message from | 2453 // specific messages for this WebContents. This means that any message from |
| 2453 // a BrowserPlugin prior to this will be ignored. | 2454 // a BrowserPlugin prior to this will be ignored. |
| 2454 // For more info, see comment above classes BrowserPluginEmbedder and | 2455 // For more info, see comment above classes BrowserPluginEmbedder and |
| 2455 // BrowserPluginGuest. | 2456 // BrowserPluginGuest. |
| 2456 CHECK(!browser_plugin_embedder_.get()); | 2457 CHECK(!browser_plugin_embedder_.get()); |
| 2457 browser_plugin_embedder_.reset(BrowserPluginEmbedder::Create(this)); | 2458 browser_plugin_embedder_.reset(BrowserPluginEmbedder::Create(this)); |
| 2458 browser_plugin_embedder_->OnMessageReceived(message); | 2459 browser_plugin_embedder_->OnMessageReceived(message); |
| 2459 } | 2460 } |
| 2460 | 2461 |
| 2461 void WebContentsImpl::OnDidDownloadFavicon( | 2462 void WebContentsImpl::OnDidDownloadImage( |
| 2462 int id, | 2463 int id, |
| 2463 const GURL& image_url, | 2464 const GURL& image_url, |
| 2464 int requested_size, | 2465 int requested_size, |
| 2465 const std::vector<SkBitmap>& bitmaps) { | 2466 const std::vector<SkBitmap>& bitmaps) { |
| 2466 FaviconDownloadMap::iterator iter = favicon_download_map_.find(id); | 2467 ImageDownloadMap::iterator iter = image_download_map_.find(id); |
| 2467 if (iter == favicon_download_map_.end()) { | 2468 if (iter == image_download_map_.end()) { |
| 2468 // Currently WebContents notifies us of ANY downloads so that it is | 2469 // Currently WebContents notifies us of ANY downloads so that it is |
| 2469 // possible to get here. | 2470 // possible to get here. |
| 2470 return; | 2471 return; |
| 2471 } | 2472 } |
| 2472 if (!iter->second.is_null()) { | 2473 if (!iter->second.is_null()) { |
| 2473 iter->second.Run(id, image_url, requested_size, bitmaps); | 2474 iter->second.Run(id, image_url, requested_size, bitmaps); |
| 2474 } | 2475 } |
| 2475 favicon_download_map_.erase(id); | 2476 image_download_map_.erase(id); |
| 2476 } | 2477 } |
| 2477 | 2478 |
| 2478 void WebContentsImpl::OnUpdateFaviconURL( | 2479 void WebContentsImpl::OnUpdateFaviconURL( |
| 2479 int32 page_id, | 2480 int32 page_id, |
| 2480 const std::vector<FaviconURL>& candidates) { | 2481 const std::vector<FaviconURL>& candidates) { |
| 2481 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2482 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2482 DidUpdateFaviconURL(page_id, candidates)); | 2483 DidUpdateFaviconURL(page_id, candidates)); |
| 2483 } | 2484 } |
| 2484 | 2485 |
| 2485 void WebContentsImpl::OnFrameDetached(int64 frame_id) { | 2486 void WebContentsImpl::OnFrameDetached(int64 frame_id) { |
| (...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3536 } | 3537 } |
| 3537 | 3538 |
| 3538 BrowserPluginGuestManager* | 3539 BrowserPluginGuestManager* |
| 3539 WebContentsImpl::GetBrowserPluginGuestManager() const { | 3540 WebContentsImpl::GetBrowserPluginGuestManager() const { |
| 3540 return static_cast<BrowserPluginGuestManager*>( | 3541 return static_cast<BrowserPluginGuestManager*>( |
| 3541 GetBrowserContext()->GetUserData( | 3542 GetBrowserContext()->GetUserData( |
| 3542 browser_plugin::kBrowserPluginGuestManagerKeyName)); | 3543 browser_plugin::kBrowserPluginGuestManagerKeyName)); |
| 3543 } | 3544 } |
| 3544 | 3545 |
| 3545 } // namespace content | 3546 } // namespace content |
| OLD | NEW |