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/cocoa/history_menu_bridge.h" | 5 #include "chrome/browser/ui/cocoa/history_menu_bridge.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 create_in_progress_(false), | 67 create_in_progress_(false), |
68 need_recreate_(false), | 68 need_recreate_(false), |
69 history_service_observer_(this) { | 69 history_service_observer_(this) { |
70 // If we don't have a profile, do not bother initializing our data sources. | 70 // If we don't have a profile, do not bother initializing our data sources. |
71 // This shouldn't happen except in unit tests. | 71 // This shouldn't happen except in unit tests. |
72 if (profile_) { | 72 if (profile_) { |
73 // Check to see if the history service is ready. Because it loads async, it | 73 // Check to see if the history service is ready. Because it loads async, it |
74 // may not be ready when the Bridge is created. If this happens, register | 74 // may not be ready when the Bridge is created. If this happens, register |
75 // for a notification that tells us the HistoryService is ready. | 75 // for a notification that tells us the HistoryService is ready. |
76 HistoryService* hs = HistoryServiceFactory::GetForProfile( | 76 HistoryService* hs = HistoryServiceFactory::GetForProfile( |
77 profile_, Profile::EXPLICIT_ACCESS); | 77 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
78 if (hs) { | 78 if (hs) { |
79 history_service_observer_.Add(hs); | 79 history_service_observer_.Add(hs); |
80 if (hs->BackendLoaded()) { | 80 if (hs->BackendLoaded()) { |
81 history_service_ = hs; | 81 history_service_ = hs; |
82 Init(); | 82 Init(); |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 tab_restore_service_ = TabRestoreServiceFactory::GetForProfile(profile_); | 86 tab_restore_service_ = TabRestoreServiceFactory::GetForProfile(profile_); |
87 if (tab_restore_service_) { | 87 if (tab_restore_service_) { |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 item->url = current_navigation.virtual_url(); | 425 item->url = current_navigation.virtual_url(); |
426 item->session_id = entry.id; | 426 item->session_id = entry.id; |
427 | 427 |
428 // Tab navigations don't come with icons, so we always have to request them. | 428 // Tab navigations don't come with icons, so we always have to request them. |
429 GetFaviconForHistoryItem(item); | 429 GetFaviconForHistoryItem(item); |
430 | 430 |
431 return item; | 431 return item; |
432 } | 432 } |
433 | 433 |
434 void HistoryMenuBridge::GetFaviconForHistoryItem(HistoryItem* item) { | 434 void HistoryMenuBridge::GetFaviconForHistoryItem(HistoryItem* item) { |
435 FaviconService* service = | 435 FaviconService* service = FaviconServiceFactory::GetForProfile( |
436 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 436 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
437 base::CancelableTaskTracker::TaskId task_id = | 437 base::CancelableTaskTracker::TaskId task_id = |
438 service->GetFaviconImageForPageURL( | 438 service->GetFaviconImageForPageURL( |
439 item->url, | 439 item->url, |
440 base::Bind( | 440 base::Bind( |
441 &HistoryMenuBridge::GotFaviconData, base::Unretained(this), item), | 441 &HistoryMenuBridge::GotFaviconData, base::Unretained(this), item), |
442 &cancelable_task_tracker_); | 442 &cancelable_task_tracker_); |
443 item->icon_task_id = task_id; | 443 item->icon_task_id = task_id; |
444 item->icon_requested = true; | 444 item->icon_requested = true; |
445 } | 445 } |
446 | 446 |
(...skipping 15 matching lines...) Expand all Loading... |
462 } | 462 } |
463 | 463 |
464 void HistoryMenuBridge::CancelFaviconRequest(HistoryItem* item) { | 464 void HistoryMenuBridge::CancelFaviconRequest(HistoryItem* item) { |
465 DCHECK(item); | 465 DCHECK(item); |
466 if (item->icon_requested) { | 466 if (item->icon_requested) { |
467 cancelable_task_tracker_.TryCancel(item->icon_task_id); | 467 cancelable_task_tracker_.TryCancel(item->icon_task_id); |
468 item->icon_requested = false; | 468 item->icon_requested = false; |
469 item->icon_task_id = base::CancelableTaskTracker::kBadTaskId; | 469 item->icon_task_id = base::CancelableTaskTracker::kBadTaskId; |
470 } | 470 } |
471 } | 471 } |
OLD | NEW |