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

Side by Side Diff: chrome/browser/ui/webui/session_favicon_source.cc

Issue 11762004: Make favicons for about:history and about:bookmarks switch from lodpi to hidpi when dragging browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 "chrome/browser/ui/webui/session_favicon_source.h" 5 #include "chrome/browser/ui/webui/session_favicon_source.h"
6 6
7 #include "chrome/browser/sync/glue/session_model_associator.h" 7 #include "chrome/browser/sync/glue/session_model_associator.h"
8 #include "chrome/browser/sync/profile_sync_service_factory.h" 8 #include "chrome/browser/sync/profile_sync_service_factory.h"
9 #include "chrome/browser/sync/profile_sync_service.h" 9 #include "chrome/browser/sync/profile_sync_service.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
11 11
12 using browser_sync::SessionModelAssociator; 12 using browser_sync::SessionModelAssociator;
13 13
14 SessionFaviconSource::SessionFaviconSource(Profile* profile) 14 SessionFaviconSource::SessionFaviconSource(Profile* profile)
15 : FaviconSource(profile, 15 : FaviconSource(profile,
16 FaviconSource::FAVICON, 16 FaviconSource::FAVICON,
17 chrome::kChromeUISessionFaviconHost) { 17 chrome::kChromeUISessionFaviconHost) {
18 } 18 }
19 19
20 SessionFaviconSource::~SessionFaviconSource() { 20 SessionFaviconSource::~SessionFaviconSource() {
21 } 21 }
22 22
23 void SessionFaviconSource::StartDataRequest(const std::string& path,
24 bool is_incognito,
25 int request_id) {
26 ProfileSyncService* sync_service =
27 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
28 SessionModelAssociator* associator = sync_service ?
29 sync_service->GetSessionModelAssociator() : NULL;
30
31 std::string favicon_data;
32 if (associator &&
33 associator->GetSyncedFaviconForPageURL(path, &favicon_data)) {
34 scoped_refptr<base::RefCountedString> response =
35 new base::RefCountedString();
36 response->data() = favicon_data;
37 SendResponse(request_id, response);
38 } else {
39 FaviconSource::StartDataRequest(path, is_incognito, request_id);
40 }
41 }
42
43 std::string SessionFaviconSource::GetMimeType(const std::string&) const { 23 std::string SessionFaviconSource::GetMimeType(const std::string&) const {
44 return "image/png"; 24 return "image/png";
45 } 25 }
46 26
47 bool SessionFaviconSource::ShouldReplaceExistingSource() const { 27 bool SessionFaviconSource::ShouldReplaceExistingSource() const {
48 // Leave the existing DataSource in place, otherwise we'll drop any pending 28 // Leave the existing DataSource in place, otherwise we'll drop any pending
49 // requests on the floor. 29 // requests on the floor.
50 return false; 30 return false;
51 } 31 }
52 32
53 bool SessionFaviconSource::AllowCaching() const { 33 bool SessionFaviconSource::AllowCaching() const {
54 // Prevent responses from being cached, otherwise session favicons won't 34 // Prevent responses from being cached, otherwise session favicons won't
55 // update in a timely manner. 35 // update in a timely manner.
56 return false; 36 return false;
57 } 37 }
38
39 bool SessionFaviconSource::HandleMissingResource(const IconRequest& request) {
40 ProfileSyncService* sync_service =
41 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
42 SessionModelAssociator* associator = sync_service ?
43 sync_service->GetSessionModelAssociator() : NULL;
44
45 std::string favicon_data;
46 if (associator &&
47 associator->GetSyncedFaviconForPageURL(request.request_path,
48 &favicon_data)) {
49 scoped_refptr<base::RefCountedString> response =
50 new base::RefCountedString();
51 response->data() = favicon_data;
52 SendResponse(request.request_id, response);
53 return true;
54 }
55 return false;
56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698