Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 12780024: Split FaviconHelper in two: ImageLoadingHelper and FaviconHelper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: caitp feedback Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser, 689 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser,
690 OnSetSelectedColorInColorChooser) 690 OnSetSelectedColorInColorChooser)
691 IPC_MESSAGE_HANDLER(ViewHostMsg_PepperPluginHung, OnPepperPluginHung) 691 IPC_MESSAGE_HANDLER(ViewHostMsg_PepperPluginHung, OnPepperPluginHung)
692 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) 692 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend)
693 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, 693 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission,
694 OnRequestPpapiBrokerPermission) 694 OnRequestPpapiBrokerPermission)
695 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_AllocateInstanceID, 695 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_AllocateInstanceID,
696 OnBrowserPluginMessage(message)) 696 OnBrowserPluginMessage(message))
697 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach, 697 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_Attach,
698 OnBrowserPluginMessage(message)) 698 OnBrowserPluginMessage(message))
699 IPC_MESSAGE_HANDLER(IconHostMsg_DidDownloadFavicon, OnDidDownloadFavicon) 699 IPC_MESSAGE_HANDLER(ImageHostMsg_DidDownloadImage, OnDidDownloadImage)
700 IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) 700 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL)
701 #if defined(OS_ANDROID) 701 #if defined(OS_ANDROID)
702 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, 702 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply,
703 OnFindMatchRectsReply) 703 OnFindMatchRectsReply)
704 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, 704 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog,
705 OnOpenDateTimeDialog) 705 OnOpenDateTimeDialog)
706 #endif 706 #endif
707 IPC_MESSAGE_HANDLER(ViewHostMsg_FrameDetached, OnFrameDetached) 707 IPC_MESSAGE_HANDLER(ViewHostMsg_FrameDetached, OnFrameDetached)
708 IPC_MESSAGE_UNHANDLED(handled = false) 708 IPC_MESSAGE_UNHANDLED(handled = false)
709 IPC_END_MESSAGE_MAP_EX() 709 IPC_END_MESSAGE_MAP_EX()
710 message_source_ = NULL; 710 message_source_ = NULL;
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1983 GetRoutingID(), color_chooser_id, color)); 1983 GetRoutingID(), color_chooser_id, color));
1984 } 1984 }
1985 1985
1986 void WebContentsImpl::DidEndColorChooser(int color_chooser_id) { 1986 void WebContentsImpl::DidEndColorChooser(int color_chooser_id) {
1987 Send(new ViewMsg_DidEndColorChooser(GetRoutingID(), color_chooser_id)); 1987 Send(new ViewMsg_DidEndColorChooser(GetRoutingID(), color_chooser_id));
1988 if (delegate_) 1988 if (delegate_)
1989 delegate_->DidEndColorChooser(); 1989 delegate_->DidEndColorChooser();
1990 color_chooser_ = NULL; 1990 color_chooser_ = NULL;
1991 } 1991 }
1992 1992
1993 int WebContentsImpl::DownloadFavicon(const GURL& url, 1993 int WebContentsImpl::DownloadImage(const GURL& url,
1994 bool is_favicon, 1994 bool is_favicon,
1995 int image_size, 1995 int image_size,
1996 const FaviconDownloadCallback& callback) { 1996 const ImageDownloadCallback& callback) {
1997 RenderViewHost* host = GetRenderViewHost(); 1997 RenderViewHost* host = GetRenderViewHost();
1998 int id = StartDownload(host, url, is_favicon, image_size); 1998 int id = StartDownload(host, url, is_favicon, image_size);
1999 favicon_download_map_[id] = callback; 1999 image_download_map_[id] = callback;
2000 return id; 2000 return id;
2001 } 2001 }
2002 2002
2003 bool WebContentsImpl::FocusLocationBarByDefault() { 2003 bool WebContentsImpl::FocusLocationBarByDefault() {
2004 WebUI* web_ui = GetWebUIForCurrentState(); 2004 WebUI* web_ui = GetWebUIForCurrentState();
2005 if (web_ui) 2005 if (web_ui)
2006 return web_ui->ShouldFocusLocationBarByDefault(); 2006 return web_ui->ShouldFocusLocationBarByDefault();
2007 NavigationEntry* entry = controller_.GetActiveEntry(); 2007 NavigationEntry* entry = controller_.GetActiveEntry();
2008 if (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)) 2008 if (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL))
2009 return true; 2009 return true;
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
2401 // This creates a BrowserPluginEmbedder, which handles all the BrowserPlugin 2401 // This creates a BrowserPluginEmbedder, which handles all the BrowserPlugin
2402 // specific messages for this WebContents. This means that any message from 2402 // specific messages for this WebContents. This means that any message from
2403 // a BrowserPlugin prior to this will be ignored. 2403 // a BrowserPlugin prior to this will be ignored.
2404 // For more info, see comment above classes BrowserPluginEmbedder and 2404 // For more info, see comment above classes BrowserPluginEmbedder and
2405 // BrowserPluginGuest. 2405 // BrowserPluginGuest.
2406 CHECK(!browser_plugin_embedder_.get()); 2406 CHECK(!browser_plugin_embedder_.get());
2407 browser_plugin_embedder_.reset(BrowserPluginEmbedder::Create(this)); 2407 browser_plugin_embedder_.reset(BrowserPluginEmbedder::Create(this));
2408 browser_plugin_embedder_->OnMessageReceived(message); 2408 browser_plugin_embedder_->OnMessageReceived(message);
2409 } 2409 }
2410 2410
2411 void WebContentsImpl::OnDidDownloadFavicon( 2411 void WebContentsImpl::OnDidDownloadImage(
2412 int id, 2412 int id,
2413 const GURL& image_url, 2413 const GURL& image_url,
2414 int requested_size, 2414 int requested_size,
2415 const std::vector<SkBitmap>& bitmaps) { 2415 const std::vector<SkBitmap>& bitmaps) {
2416 FaviconDownloadMap::iterator iter = favicon_download_map_.find(id); 2416 ImageDownloadMap::iterator iter = image_download_map_.find(id);
2417 if (iter == favicon_download_map_.end()) { 2417 if (iter == image_download_map_.end()) {
2418 // Currently WebContents notifies us of ANY downloads so that it is 2418 // Currently WebContents notifies us of ANY downloads so that it is
2419 // possible to get here. 2419 // possible to get here.
2420 return; 2420 return;
2421 } 2421 }
2422 if (!iter->second.is_null()) { 2422 if (!iter->second.is_null()) {
2423 iter->second.Run(id, image_url, requested_size, bitmaps); 2423 iter->second.Run(id, image_url, requested_size, bitmaps);
2424 } 2424 }
2425 favicon_download_map_.erase(id); 2425 image_download_map_.erase(id);
2426 } 2426 }
2427 2427
2428 void WebContentsImpl::OnUpdateFaviconURL( 2428 void WebContentsImpl::OnUpdateFaviconURL(
2429 int32 page_id, 2429 int32 page_id,
2430 const std::vector<FaviconURL>& candidates) { 2430 const std::vector<FaviconURL>& candidates) {
2431 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 2431 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
2432 DidUpdateFaviconURL(page_id, candidates)); 2432 DidUpdateFaviconURL(page_id, candidates));
2433 } 2433 }
2434 2434
2435 void WebContentsImpl::OnFrameDetached(int64 frame_id) { 2435 void WebContentsImpl::OnFrameDetached(int64 frame_id) {
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
3468 } 3468 }
3469 3469
3470 BrowserPluginGuestManager* 3470 BrowserPluginGuestManager*
3471 WebContentsImpl::GetBrowserPluginGuestManager() const { 3471 WebContentsImpl::GetBrowserPluginGuestManager() const {
3472 return static_cast<BrowserPluginGuestManager*>( 3472 return static_cast<BrowserPluginGuestManager*>(
3473 GetBrowserContext()->GetUserData( 3473 GetBrowserContext()->GetUserData(
3474 browser_plugin::kBrowserPluginGuestManagerKeyName)); 3474 browser_plugin::kBrowserPluginGuestManagerKeyName));
3475 } 3475 }
3476 3476
3477 } // namespace content 3477 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/common/content_message_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698