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/favicon_source.h" | 5 #include "chrome/browser/ui/webui/favicon_source.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "chrome/browser/favicon/favicon_service_factory.h" | 10 #include "chrome/browser/favicon/favicon_service_factory.h" |
11 #include "chrome/browser/history/top_sites.h" | 11 #include "chrome/browser/history/top_sites.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/search/instant_io_context.h" | 13 #include "chrome/browser/search/instant_io_context.h" |
14 #include "chrome/browser/sync/glue/session_model_associator.h" | 14 #include "chrome/browser/sync/open_tabs_ui_delegate.h" |
15 #include "chrome/browser/sync/profile_sync_service.h" | 15 #include "chrome/browser/sync/profile_sync_service.h" |
16 #include "chrome/browser/sync/profile_sync_service_factory.h" | 16 #include "chrome/browser/sync/profile_sync_service_factory.h" |
17 #include "chrome/common/favicon/favicon_url_parser.h" | 17 #include "chrome/common/favicon/favicon_url_parser.h" |
18 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
19 #include "grit/locale_settings.h" | 19 #include "grit/locale_settings.h" |
20 #include "grit/ui_resources.h" | 20 #include "grit/ui_resources.h" |
21 #include "net/url_request/url_request.h" | 21 #include "net/url_request/url_request.h" |
22 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
23 #include "ui/base/layout.h" | 23 #include "ui/base/layout.h" |
24 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 bool FaviconSource::ShouldServiceRequest(const net::URLRequest* request) const { | 136 bool FaviconSource::ShouldServiceRequest(const net::URLRequest* request) const { |
137 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) | 137 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) |
138 return InstantIOContext::ShouldServiceRequest(request); | 138 return InstantIOContext::ShouldServiceRequest(request); |
139 return URLDataSource::ShouldServiceRequest(request); | 139 return URLDataSource::ShouldServiceRequest(request); |
140 } | 140 } |
141 | 141 |
142 bool FaviconSource::HandleMissingResource(const IconRequest& request) { | 142 bool FaviconSource::HandleMissingResource(const IconRequest& request) { |
143 // If the favicon is not available, try to use the synced favicon. | 143 // If the favicon is not available, try to use the synced favicon. |
144 ProfileSyncService* sync_service = | 144 ProfileSyncService* sync_service = |
145 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); | 145 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); |
146 browser_sync::SessionModelAssociator* associator = sync_service ? | 146 browser_sync::OpenTabsUIDelegate* open_tabs = sync_service ? |
147 sync_service->GetSessionModelAssociator() : NULL; | 147 sync_service->GetOpenTabsUIDelegate() : NULL; |
148 | 148 |
149 scoped_refptr<base::RefCountedMemory> response; | 149 scoped_refptr<base::RefCountedMemory> response; |
150 if (associator && | 150 if (open_tabs && |
151 associator->GetSyncedFaviconForPageURL(request.request_path.spec(), | 151 open_tabs->GetSyncedFaviconForPageURL(request.request_path.spec(), |
152 &response)) { | 152 &response)) { |
153 request.callback.Run(response.get()); | 153 request.callback.Run(response.get()); |
154 return true; | 154 return true; |
155 } | 155 } |
156 return false; | 156 return false; |
157 } | 157 } |
158 | 158 |
159 void FaviconSource::OnFaviconDataAvailable( | 159 void FaviconSource::OnFaviconDataAvailable( |
160 const IconRequest& request, | 160 const IconRequest& request, |
161 const chrome::FaviconBitmapResult& bitmap_result) { | 161 const chrome::FaviconBitmapResult& bitmap_result) { |
162 if (bitmap_result.is_valid()) { | 162 if (bitmap_result.is_valid()) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 if (!default_favicon) { | 196 if (!default_favicon) { |
197 ui::ScaleFactor scale_factor = icon_request.scale_factor; | 197 ui::ScaleFactor scale_factor = icon_request.scale_factor; |
198 default_favicon = ResourceBundle::GetSharedInstance() | 198 default_favicon = ResourceBundle::GetSharedInstance() |
199 .LoadDataResourceBytesForScale(resource_id, scale_factor); | 199 .LoadDataResourceBytesForScale(resource_id, scale_factor); |
200 default_favicons_[favicon_index] = default_favicon; | 200 default_favicons_[favicon_index] = default_favicon; |
201 } | 201 } |
202 | 202 |
203 icon_request.callback.Run(default_favicon); | 203 icon_request.callback.Run(default_favicon); |
204 } | 204 } |
OLD | NEW |