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