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

Side by Side Diff: chrome/browser/dom_ui/web_ui_favicon_source.cc

Issue 6546078: Makes a handful of DataSources not replace the existing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 10 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/dom_ui/web_ui_favicon_source.h" 5 #include "chrome/browser/dom_ui/web_ui_favicon_source.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/common/url_constants.h" 9 #include "chrome/common/url_constants.h"
10 #include "grit/app_resources.h" 10 #include "grit/app_resources.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 SendResponse(request_id, NULL); 47 SendResponse(request_id, NULL);
48 } 48 }
49 } 49 }
50 50
51 std::string WebUIFavIconSource::GetMimeType(const std::string&) const { 51 std::string WebUIFavIconSource::GetMimeType(const std::string&) const {
52 // We need to explicitly return a mime type, otherwise if the user tries to 52 // We need to explicitly return a mime type, otherwise if the user tries to
53 // drag the image they get no extension. 53 // drag the image they get no extension.
54 return "image/png"; 54 return "image/png";
55 } 55 }
56 56
57 bool WebUIFavIconSource::ShouldReplaceExistingSource() const {
58 // Leave the existing DataSource in place, otherwise we'll drop any pending
59 // requests on the floor.
60 return false;
61 }
62
57 void WebUIFavIconSource::OnFavIconDataAvailable( 63 void WebUIFavIconSource::OnFavIconDataAvailable(
58 FaviconService::Handle request_handle, 64 FaviconService::Handle request_handle,
59 bool know_favicon, 65 bool know_favicon,
60 scoped_refptr<RefCountedMemory> data, 66 scoped_refptr<RefCountedMemory> data,
61 bool expired, 67 bool expired,
62 GURL icon_url) { 68 GURL icon_url) {
63 FaviconService* favicon_service = 69 FaviconService* favicon_service =
64 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); 70 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
65 int request_id = cancelable_consumer_.GetClientData(favicon_service, 71 int request_id = cancelable_consumer_.GetClientData(favicon_service,
66 request_handle); 72 request_handle);
67 73
68 if (know_favicon && data.get() && data->size()) { 74 if (know_favicon && data.get() && data->size()) {
69 // Forward the data along to the networking system. 75 // Forward the data along to the networking system.
70 SendResponse(request_id, data); 76 SendResponse(request_id, data);
71 } else { 77 } else {
72 SendDefaultResponse(request_id); 78 SendDefaultResponse(request_id);
73 } 79 }
74 } 80 }
75 81
76 void WebUIFavIconSource::SendDefaultResponse(int request_id) { 82 void WebUIFavIconSource::SendDefaultResponse(int request_id) {
77 if (!default_favicon_.get()) { 83 if (!default_favicon_.get()) {
78 default_favicon_ = 84 default_favicon_ =
79 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( 85 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
80 IDR_DEFAULT_FAVICON); 86 IDR_DEFAULT_FAVICON);
81 } 87 }
82 88
83 SendResponse(request_id, default_favicon_); 89 SendResponse(request_id, default_favicon_);
84 } 90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698