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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 bool is_favicon, | 158 bool is_favicon, |
159 int image_size) { | 159 int image_size) { |
160 static int g_next_favicon_download_id = 0; | 160 static int g_next_image_download_id = 0; |
161 rvh->Send(new IconMsg_DownloadFavicon(rvh->GetRoutingID(), | 161 rvh->Send(new ImageMsg_DownloadImage(rvh->GetRoutingID(), |
162 ++g_next_favicon_download_id, | 162 ++g_next_image_download_id, |
163 url, | 163 url, |
164 is_favicon, | 164 is_favicon, |
165 image_size)); | 165 image_size)); |
166 return g_next_favicon_download_id; | 166 return g_next_image_download_id; |
167 } | 167 } |
168 | 168 |
169 ViewMsg_Navigate_Type::Value GetNavigationType( | 169 ViewMsg_Navigate_Type::Value GetNavigationType( |
170 BrowserContext* browser_context, const NavigationEntryImpl& entry, | 170 BrowserContext* browser_context, const NavigationEntryImpl& entry, |
171 NavigationController::ReloadType reload_type) { | 171 NavigationController::ReloadType reload_type) { |
172 switch (reload_type) { | 172 switch (reload_type) { |
173 case NavigationControllerImpl::RELOAD: | 173 case NavigationControllerImpl::RELOAD: |
174 return ViewMsg_Navigate_Type::RELOAD; | 174 return ViewMsg_Navigate_Type::RELOAD; |
175 case NavigationControllerImpl::RELOAD_IGNORING_CACHE: | 175 case NavigationControllerImpl::RELOAD_IGNORING_CACHE: |
176 return ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; | 176 return ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser, | 688 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser, |
689 OnSetSelectedColorInColorChooser) | 689 OnSetSelectedColorInColorChooser) |
690 IPC_MESSAGE_HANDLER(ViewHostMsg_PepperPluginHung, OnPepperPluginHung) | 690 IPC_MESSAGE_HANDLER(ViewHostMsg_PepperPluginHung, OnPepperPluginHung) |
691 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) | 691 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) |
692 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, | 692 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, |
693 OnRequestPpapiBrokerPermission) | 693 OnRequestPpapiBrokerPermission) |
694 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_AllocateInstanceID, | 694 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_AllocateInstanceID, |
695 OnBrowserPluginMessage(message)) | 695 OnBrowserPluginMessage(message)) |
696 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, | 696 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, |
697 OnBrowserPluginMessage(message)) | 697 OnBrowserPluginMessage(message)) |
698 IPC_MESSAGE_HANDLER(IconHostMsg_DidDownloadFavicon, OnDidDownloadFavicon) | 698 IPC_MESSAGE_HANDLER(ImageHostMsg_DidDownloadImage, OnDidDownloadImage) |
699 IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) | 699 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) |
700 #if defined(OS_ANDROID) | 700 #if defined(OS_ANDROID) |
701 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, | 701 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, |
702 OnFindMatchRectsReply) | 702 OnFindMatchRectsReply) |
703 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, | 703 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, |
704 OnOpenDateTimeDialog) | 704 OnOpenDateTimeDialog) |
705 #endif | 705 #endif |
706 IPC_MESSAGE_HANDLER(ViewHostMsg_FrameDetached, OnFrameDetached) | 706 IPC_MESSAGE_HANDLER(ViewHostMsg_FrameDetached, OnFrameDetached) |
707 IPC_MESSAGE_UNHANDLED(handled = false) | 707 IPC_MESSAGE_UNHANDLED(handled = false) |
708 IPC_END_MESSAGE_MAP_EX() | 708 IPC_END_MESSAGE_MAP_EX() |
709 message_source_ = NULL; | 709 message_source_ = NULL; |
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1982 GetRoutingID(), color_chooser_id, color)); | 1982 GetRoutingID(), color_chooser_id, color)); |
1983 } | 1983 } |
1984 | 1984 |
1985 void WebContentsImpl::DidEndColorChooser(int color_chooser_id) { | 1985 void WebContentsImpl::DidEndColorChooser(int color_chooser_id) { |
1986 Send(new ViewMsg_DidEndColorChooser(GetRoutingID(), color_chooser_id)); | 1986 Send(new ViewMsg_DidEndColorChooser(GetRoutingID(), color_chooser_id)); |
1987 if (delegate_) | 1987 if (delegate_) |
1988 delegate_->DidEndColorChooser(); | 1988 delegate_->DidEndColorChooser(); |
1989 color_chooser_ = NULL; | 1989 color_chooser_ = NULL; |
1990 } | 1990 } |
1991 | 1991 |
1992 int WebContentsImpl::DownloadFavicon(const GURL& url, | 1992 int WebContentsImpl::DownloadImage(const GURL& url, |
1993 bool is_favicon, | 1993 bool is_favicon, |
1994 int image_size, | 1994 int image_size, |
1995 const FaviconDownloadCallback& callback) { | 1995 const ImageDownloadCallback& callback) { |
1996 RenderViewHost* host = GetRenderViewHost(); | 1996 RenderViewHost* host = GetRenderViewHost(); |
1997 int id = StartDownload(host, url, is_favicon, image_size); | 1997 int id = StartDownload(host, url, is_favicon, image_size); |
1998 favicon_download_map_[id] = callback; | 1998 image_download_map_[id] = callback; |
1999 return id; | 1999 return id; |
2000 } | 2000 } |
2001 | 2001 |
2002 bool WebContentsImpl::FocusLocationBarByDefault() { | 2002 bool WebContentsImpl::FocusLocationBarByDefault() { |
2003 WebUI* web_ui = GetWebUIForCurrentState(); | 2003 WebUI* web_ui = GetWebUIForCurrentState(); |
2004 if (web_ui) | 2004 if (web_ui) |
2005 return web_ui->ShouldFocusLocationBarByDefault(); | 2005 return web_ui->ShouldFocusLocationBarByDefault(); |
2006 NavigationEntry* entry = controller_.GetActiveEntry(); | 2006 NavigationEntry* entry = controller_.GetActiveEntry(); |
2007 if (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)) | 2007 if (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)) |
2008 return true; | 2008 return true; |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2400 // This creates a BrowserPluginEmbedder, which handles all the BrowserPlugin | 2400 // This creates a BrowserPluginEmbedder, which handles all the BrowserPlugin |
2401 // specific messages for this WebContents. This means that any message from | 2401 // specific messages for this WebContents. This means that any message from |
2402 // a BrowserPlugin prior to this will be ignored. | 2402 // a BrowserPlugin prior to this will be ignored. |
2403 // For more info, see comment above classes BrowserPluginEmbedder and | 2403 // For more info, see comment above classes BrowserPluginEmbedder and |
2404 // BrowserPluginGuest. | 2404 // BrowserPluginGuest. |
2405 CHECK(!browser_plugin_embedder_.get()); | 2405 CHECK(!browser_plugin_embedder_.get()); |
2406 browser_plugin_embedder_.reset(BrowserPluginEmbedder::Create(this)); | 2406 browser_plugin_embedder_.reset(BrowserPluginEmbedder::Create(this)); |
2407 browser_plugin_embedder_->OnMessageReceived(message); | 2407 browser_plugin_embedder_->OnMessageReceived(message); |
2408 } | 2408 } |
2409 | 2409 |
2410 void WebContentsImpl::OnDidDownloadFavicon( | 2410 void WebContentsImpl::OnDidDownloadImage( |
2411 int id, | 2411 int id, |
2412 const GURL& image_url, | 2412 const GURL& image_url, |
2413 int requested_size, | 2413 int requested_size, |
2414 const std::vector<SkBitmap>& bitmaps) { | 2414 const std::vector<SkBitmap>& bitmaps) { |
2415 FaviconDownloadMap::iterator iter = favicon_download_map_.find(id); | 2415 ImageDownloadMap::iterator iter = image_download_map_.find(id); |
2416 if (iter == favicon_download_map_.end()) { | 2416 if (iter == image_download_map_.end()) { |
2417 // Currently WebContents notifies us of ANY downloads so that it is | 2417 // Currently WebContents notifies us of ANY downloads so that it is |
2418 // possible to get here. | 2418 // possible to get here. |
2419 return; | 2419 return; |
2420 } | 2420 } |
2421 if (!iter->second.is_null()) { | 2421 if (!iter->second.is_null()) { |
2422 iter->second.Run(id, image_url, requested_size, bitmaps); | 2422 iter->second.Run(id, image_url, requested_size, bitmaps); |
2423 } | 2423 } |
2424 favicon_download_map_.erase(id); | 2424 image_download_map_.erase(id); |
2425 } | 2425 } |
2426 | 2426 |
2427 void WebContentsImpl::OnUpdateFaviconURL( | 2427 void WebContentsImpl::OnUpdateFaviconURL( |
2428 int32 page_id, | 2428 int32 page_id, |
2429 const std::vector<FaviconURL>& candidates) { | 2429 const std::vector<FaviconURL>& candidates) { |
2430 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2430 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
2431 DidUpdateFaviconURL(page_id, candidates)); | 2431 DidUpdateFaviconURL(page_id, candidates)); |
2432 } | 2432 } |
2433 | 2433 |
2434 void WebContentsImpl::OnFrameDetached(int64 frame_id) { | 2434 void WebContentsImpl::OnFrameDetached(int64 frame_id) { |
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3467 } | 3467 } |
3468 | 3468 |
3469 BrowserPluginGuestManager* | 3469 BrowserPluginGuestManager* |
3470 WebContentsImpl::GetBrowserPluginGuestManager() const { | 3470 WebContentsImpl::GetBrowserPluginGuestManager() const { |
3471 return static_cast<BrowserPluginGuestManager*>( | 3471 return static_cast<BrowserPluginGuestManager*>( |
3472 GetBrowserContext()->GetUserData( | 3472 GetBrowserContext()->GetUserData( |
3473 browser_plugin::kBrowserPluginGuestManagerKeyName)); | 3473 browser_plugin::kBrowserPluginGuestManagerKeyName)); |
3474 } | 3474 } |
3475 | 3475 |
3476 } // namespace content | 3476 } // namespace content |
OLD | NEW |