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 "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/browser/ui/webui/chrome_url_data_manager.h" |
10 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
11 | 12 |
12 using browser_sync::SessionModelAssociator; | 13 using browser_sync::SessionModelAssociator; |
13 | 14 |
14 SessionFaviconSource::SessionFaviconSource(Profile* profile) | 15 SessionFaviconSource::SessionFaviconSource(Profile* profile) |
15 : FaviconSource(profile, | 16 : FaviconSource(profile, FaviconSource::FAVICON) { |
16 FaviconSource::FAVICON, | |
17 chrome::kChromeUISessionFaviconHost) { | |
18 } | 17 } |
19 | 18 |
20 SessionFaviconSource::~SessionFaviconSource() { | 19 SessionFaviconSource::~SessionFaviconSource() { |
21 } | 20 } |
22 | 21 |
| 22 std::string SessionFaviconSource::GetSource() { |
| 23 return chrome::kChromeUISessionFaviconHost; |
| 24 } |
| 25 |
23 std::string SessionFaviconSource::GetMimeType(const std::string&) const { | 26 std::string SessionFaviconSource::GetMimeType(const std::string&) const { |
24 return "image/png"; | 27 return "image/png"; |
25 } | 28 } |
26 | 29 |
27 bool SessionFaviconSource::ShouldReplaceExistingSource() const { | 30 bool SessionFaviconSource::ShouldReplaceExistingSource() const { |
28 // Leave the existing DataSource in place, otherwise we'll drop any pending | 31 // Leave the existing DataSource in place, otherwise we'll drop any pending |
29 // requests on the floor. | 32 // requests on the floor. |
30 return false; | 33 return false; |
31 } | 34 } |
32 | 35 |
33 bool SessionFaviconSource::AllowCaching() const { | 36 bool SessionFaviconSource::AllowCaching() const { |
34 // Prevent responses from being cached, otherwise session favicons won't | 37 // Prevent responses from being cached, otherwise session favicons won't |
35 // update in a timely manner. | 38 // update in a timely manner. |
36 return false; | 39 return false; |
37 } | 40 } |
38 | 41 |
39 bool SessionFaviconSource::HandleMissingResource(const IconRequest& request) { | 42 bool SessionFaviconSource::HandleMissingResource(const IconRequest& request) { |
40 ProfileSyncService* sync_service = | 43 ProfileSyncService* sync_service = |
41 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); | 44 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); |
42 SessionModelAssociator* associator = sync_service ? | 45 SessionModelAssociator* associator = sync_service ? |
43 sync_service->GetSessionModelAssociator() : NULL; | 46 sync_service->GetSessionModelAssociator() : NULL; |
44 | 47 |
45 std::string favicon_data; | 48 std::string favicon_data; |
46 if (associator && | 49 if (associator && |
47 associator->GetSyncedFaviconForPageURL(request.request_path, | 50 associator->GetSyncedFaviconForPageURL(request.request_path, |
48 &favicon_data)) { | 51 &favicon_data)) { |
49 scoped_refptr<base::RefCountedString> response = | 52 scoped_refptr<base::RefCountedString> response = |
50 new base::RefCountedString(); | 53 new base::RefCountedString(); |
51 response->data() = favicon_data; | 54 response->data() = favicon_data; |
52 SendResponse(request.request_id, response); | 55 url_data_source()->SendResponse(request.request_id, response); |
53 return true; | 56 return true; |
54 } | 57 } |
55 return false; | 58 return false; |
56 } | 59 } |
OLD | NEW |