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

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

Issue 11411180: move favicon download code from chrome/ into content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix order Created 8 years 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 21 matching lines...) Expand all
32 #include "content/browser/loader/resource_dispatcher_host_impl.h" 32 #include "content/browser/loader/resource_dispatcher_host_impl.h"
33 #include "content/browser/renderer_host/render_process_host_impl.h" 33 #include "content/browser/renderer_host/render_process_host_impl.h"
34 #include "content/browser/renderer_host/render_view_host_impl.h" 34 #include "content/browser/renderer_host/render_view_host_impl.h"
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/web_ui_impl.h" 40 #include "content/browser/webui/web_ui_impl.h"
41 #include "content/common/browser_plugin_messages.h" 41 #include "content/common/browser_plugin_messages.h"
42 #include "content/common/icon_messages.h"
42 #include "content/common/intents_messages.h" 43 #include "content/common/intents_messages.h"
43 #include "content/common/ssl_status_serialization.h" 44 #include "content/common/ssl_status_serialization.h"
44 #include "content/common/view_messages.h" 45 #include "content/common/view_messages.h"
45 #include "content/port/browser/render_view_host_delegate_view.h" 46 #include "content/port/browser/render_view_host_delegate_view.h"
46 #include "content/port/browser/render_widget_host_view_port.h" 47 #include "content/port/browser/render_widget_host_view_port.h"
47 #include "content/public/browser/browser_context.h" 48 #include "content/public/browser/browser_context.h"
48 #include "content/public/browser/color_chooser.h" 49 #include "content/public/browser/color_chooser.h"
49 #include "content/public/browser/content_browser_client.h" 50 #include "content/public/browser/content_browser_client.h"
50 #include "content/public/browser/devtools_agent_host_registry.h" 51 #include "content/public/browser/devtools_agent_host_registry.h"
51 #include "content/public/browser/download_manager.h" 52 #include "content/public/browser/download_manager.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 namespace { 142 namespace {
142 143
143 // Amount of time we wait between when a key event is received and the renderer 144 // Amount of time we wait between when a key event is received and the renderer
144 // is queried for its state and pushed to the NavigationEntry. 145 // is queried for its state and pushed to the NavigationEntry.
145 const int kQueryStateDelay = 5000; 146 const int kQueryStateDelay = 5000;
146 147
147 const int kSyncWaitDelay = 40; 148 const int kSyncWaitDelay = 40;
148 149
149 const char kDotGoogleDotCom[] = ".google.com"; 150 const char kDotGoogleDotCom[] = ".google.com";
150 151
152 static int StartDownload(content::RenderViewHost* rvh,
153 const GURL& url,
154 int image_size) {
155 static int g_next_favicon_download_id = 0;
156 rvh->Send(new IconMsg_DownloadFavicon(rvh->GetRoutingID(),
157 ++g_next_favicon_download_id,
158 url,
159 image_size));
160 return g_next_favicon_download_id;
161 }
162
151 #if defined(OS_WIN) 163 #if defined(OS_WIN)
152 164
153 BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { 165 BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) {
154 // Note: erase is required to properly paint some widgets borders. This can 166 // Note: erase is required to properly paint some widgets borders. This can
155 // be seen with textfields. 167 // be seen with textfields.
156 InvalidateRect(hwnd, NULL, TRUE); 168 InvalidateRect(hwnd, NULL, TRUE);
157 return TRUE; 169 return TRUE;
158 } 170 }
159 #endif 171 #endif
160 172
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenColorChooser, OnOpenColorChooser) 751 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenColorChooser, OnOpenColorChooser)
740 IPC_MESSAGE_HANDLER(ViewHostMsg_EndColorChooser, OnEndColorChooser) 752 IPC_MESSAGE_HANDLER(ViewHostMsg_EndColorChooser, OnEndColorChooser)
741 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser, 753 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser,
742 OnSetSelectedColorInColorChooser) 754 OnSetSelectedColorInColorChooser)
743 IPC_MESSAGE_HANDLER(ViewHostMsg_PepperPluginHung, OnPepperPluginHung) 755 IPC_MESSAGE_HANDLER(ViewHostMsg_PepperPluginHung, OnPepperPluginHung)
744 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) 756 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend)
745 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, 757 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission,
746 OnRequestPpapiBrokerPermission) 758 OnRequestPpapiBrokerPermission)
747 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CreateGuest, 759 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CreateGuest,
748 OnBrowserPluginCreateGuest) 760 OnBrowserPluginCreateGuest)
761 IPC_MESSAGE_HANDLER(IconHostMsg_DidDownloadFavicon, OnDidDownloadFavicon)
762 IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL)
749 IPC_MESSAGE_UNHANDLED(handled = false) 763 IPC_MESSAGE_UNHANDLED(handled = false)
750 IPC_END_MESSAGE_MAP_EX() 764 IPC_END_MESSAGE_MAP_EX()
751 message_source_ = NULL; 765 message_source_ = NULL;
752 766
753 if (!message_is_ok) { 767 if (!message_is_ok) {
754 RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); 768 RecordAction(UserMetricsAction("BadMessageTerminate_RVD"));
755 GetRenderProcessHost()->ReceivedBadMessage(); 769 GetRenderProcessHost()->ReceivedBadMessage();
756 } 770 }
757 771
758 return handled; 772 return handled;
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 GetRoutingID(), color_chooser_id, color)); 1957 GetRoutingID(), color_chooser_id, color));
1944 } 1958 }
1945 1959
1946 void WebContentsImpl::DidEndColorChooser(int color_chooser_id) { 1960 void WebContentsImpl::DidEndColorChooser(int color_chooser_id) {
1947 Send(new ViewMsg_DidEndColorChooser(GetRoutingID(), color_chooser_id)); 1961 Send(new ViewMsg_DidEndColorChooser(GetRoutingID(), color_chooser_id));
1948 if (delegate_) 1962 if (delegate_)
1949 delegate_->DidEndColorChooser(); 1963 delegate_->DidEndColorChooser();
1950 color_chooser_ = NULL; 1964 color_chooser_ = NULL;
1951 } 1965 }
1952 1966
1967 int WebContentsImpl::DownloadFavicon(const GURL& url, int image_size,
1968 const FaviconDownloadCallback& callback) {
1969 RenderViewHost* host = GetRenderViewHost();
1970 int id = StartDownload(host, url, image_size);
1971 favicon_download_map_[id] = callback;
1972 return id;
1973 }
1974
1953 bool WebContentsImpl::FocusLocationBarByDefault() { 1975 bool WebContentsImpl::FocusLocationBarByDefault() {
1954 WebUI* web_ui = GetWebUIForCurrentState(); 1976 WebUI* web_ui = GetWebUIForCurrentState();
1955 if (web_ui) 1977 if (web_ui)
1956 return web_ui->ShouldFocusLocationBarByDefault(); 1978 return web_ui->ShouldFocusLocationBarByDefault();
1957 NavigationEntry* entry = controller_.GetActiveEntry(); 1979 NavigationEntry* entry = controller_.GetActiveEntry();
1958 return (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)); 1980 return (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL));
1959 } 1981 }
1960 1982
1961 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { 1983 void WebContentsImpl::SetFocusToLocationBar(bool select_all) {
1962 if (delegate_) 1984 if (delegate_)
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
2358 // BrowserPluginEmbedder. Thus, this code will not be executed if a 2380 // BrowserPluginEmbedder. Thus, this code will not be executed if a
2359 // BrowserPluginEmbedder exists for this WebContents. 2381 // BrowserPluginEmbedder exists for this WebContents.
2360 CHECK(!browser_plugin_embedder_.get()); 2382 CHECK(!browser_plugin_embedder_.get());
2361 browser_plugin_embedder_.reset( 2383 browser_plugin_embedder_.reset(
2362 BrowserPluginEmbedder::Create(this, GetRenderViewHost())); 2384 BrowserPluginEmbedder::Create(this, GetRenderViewHost()));
2363 browser_plugin_embedder_->CreateGuest(GetRenderViewHost(), 2385 browser_plugin_embedder_->CreateGuest(GetRenderViewHost(),
2364 instance_id, 2386 instance_id,
2365 params); 2387 params);
2366 } 2388 }
2367 2389
2390 void WebContentsImpl::OnDidDownloadFavicon(
2391 int id,
2392 const GURL& image_url,
2393 bool errored,
2394 int requested_size,
2395 const std::vector<SkBitmap>& bitmaps) {
2396 FaviconDownloadMap::iterator iter = favicon_download_map_.find(id);
2397 if (iter == favicon_download_map_.end()) {
2398 // Currently WebContents notifies us of ANY downloads so that it is
2399 // possible to get here.
2400 return;
2401 }
2402 if (!iter->second.is_null()) {
2403 iter->second.Run(id, image_url, errored, requested_size, bitmaps);
2404 }
2405 favicon_download_map_.erase(id);
2406 }
2407
2408 void WebContentsImpl::OnUpdateFaviconURL(
2409 int32 page_id,
2410 const std::vector<FaviconURL>& candidates) {
2411 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
2412 DidUpdateFaviconURL(page_id, candidates));
2413 }
2414
2368 void WebContentsImpl::DidBlock3DAPIs(const GURL& url, 2415 void WebContentsImpl::DidBlock3DAPIs(const GURL& url,
2369 ThreeDAPIType requester) { 2416 ThreeDAPIType requester) {
2370 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 2417 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
2371 DidBlock3DAPIs(url, requester)); 2418 DidBlock3DAPIs(url, requester));
2372 } 2419 }
2373 2420
2374 // Notifies the RenderWidgetHost instance about the fact that the page is 2421 // Notifies the RenderWidgetHost instance about the fact that the page is
2375 // loading, or done loading and calls the base implementation. 2422 // loading, or done loading and calls the base implementation.
2376 void WebContentsImpl::SetIsLoading(bool is_loading, 2423 void WebContentsImpl::SetIsLoading(bool is_loading,
2377 LoadNotificationDetails* details) { 2424 LoadNotificationDetails* details) {
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
3359 3406
3360 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { 3407 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() {
3361 return browser_plugin_guest_.get(); 3408 return browser_plugin_guest_.get();
3362 } 3409 }
3363 3410
3364 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { 3411 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() {
3365 return browser_plugin_embedder_.get(); 3412 return browser_plugin_embedder_.get();
3366 } 3413 }
3367 3414
3368 } // namespace content 3415 } // 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