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/history_ui.h" | 5 #include "chrome/browser/ui/webui/history_ui.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 bool IsLocalOnlyResult(const BrowsingHistoryHandler::HistoryEntry& entry) { | 226 bool IsLocalOnlyResult(const BrowsingHistoryHandler::HistoryEntry& entry) { |
227 return entry.entry_type == BrowsingHistoryHandler::HistoryEntry::LOCAL_ENTRY; | 227 return entry.entry_type == BrowsingHistoryHandler::HistoryEntry::LOCAL_ENTRY; |
228 } | 228 } |
229 | 229 |
230 // Gets the name and type of a device for the given sync client ID. | 230 // Gets the name and type of a device for the given sync client ID. |
231 // |name| and |type| are out parameters. | 231 // |name| and |type| are out parameters. |
232 void GetDeviceNameAndType(const ProfileSyncService* sync_service, | 232 void GetDeviceNameAndType(const ProfileSyncService* sync_service, |
233 const std::string& client_id, | 233 const std::string& client_id, |
234 std::string* name, | 234 std::string* name, |
235 std::string* type) { | 235 std::string* type) { |
236 if (sync_service && sync_service->sync_initialized()) { | 236 // DeviceInfoTracker becomes available when Sync backend gets initialed. |
| 237 // It must exist in order for remote history entries to be available. |
| 238 if (sync_service && sync_service->GetDeviceInfoTracker()) { |
237 scoped_ptr<browser_sync::DeviceInfo> device_info = | 239 scoped_ptr<browser_sync::DeviceInfo> device_info = |
238 sync_service->GetDeviceInfo(client_id); | 240 sync_service->GetDeviceInfoTracker()->GetDeviceInfo(client_id); |
239 if (device_info.get()) { | 241 if (device_info.get()) { |
240 *name = device_info->client_name(); | 242 *name = device_info->client_name(); |
241 switch (device_info->device_type()) { | 243 switch (device_info->device_type()) { |
242 case sync_pb::SyncEnums::TYPE_PHONE: | 244 case sync_pb::SyncEnums::TYPE_PHONE: |
243 *type = kDeviceTypePhone; | 245 *type = kDeviceTypePhone; |
244 break; | 246 break; |
245 case sync_pb::SyncEnums::TYPE_TABLET: | 247 case sync_pb::SyncEnums::TYPE_TABLET: |
246 *type = kDeviceTypeTablet; | 248 *type = kDeviceTypeTablet; |
247 break; | 249 break; |
248 default: | 250 default: |
249 *type = kDeviceTypeLaptop; | 251 *type = kDeviceTypeLaptop; |
250 } | 252 } |
251 return; | 253 return; |
252 } | 254 } |
253 } else { | 255 } else { |
254 NOTREACHED() << "Got a remote history entry but no ProfileSyncService."; | 256 NOTREACHED() << "Got a remote history entry but no DeviceInfoTracker."; |
255 } | 257 } |
256 *name = l10n_util::GetStringUTF8(IDS_HISTORY_UNKNOWN_DEVICE); | 258 *name = l10n_util::GetStringUTF8(IDS_HISTORY_UNKNOWN_DEVICE); |
257 *type = kDeviceTypeLaptop; | 259 *type = kDeviceTypeLaptop; |
258 } | 260 } |
259 | 261 |
260 } // namespace | 262 } // namespace |
261 | 263 |
262 //////////////////////////////////////////////////////////////////////////////// | 264 //////////////////////////////////////////////////////////////////////////////// |
263 // | 265 // |
264 // BrowsingHistoryHandler | 266 // BrowsingHistoryHandler |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 Profile* profile = Profile::FromWebUI(web_ui); | 1017 Profile* profile = Profile::FromWebUI(web_ui); |
1016 content::WebUIDataSource::Add(profile, CreateHistoryUIHTMLSource(profile)); | 1018 content::WebUIDataSource::Add(profile, CreateHistoryUIHTMLSource(profile)); |
1017 } | 1019 } |
1018 | 1020 |
1019 // static | 1021 // static |
1020 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( | 1022 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( |
1021 ui::ScaleFactor scale_factor) { | 1023 ui::ScaleFactor scale_factor) { |
1022 return ResourceBundle::GetSharedInstance(). | 1024 return ResourceBundle::GetSharedInstance(). |
1023 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); | 1025 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); |
1024 } | 1026 } |
OLD | NEW |