OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 // Note that all requests sent to either the history service or the favicon | 113 // Note that all requests sent to either the history service or the favicon |
114 // service will be automatically cancelled by their respective Consumers, so | 114 // service will be automatically cancelled by their respective Consumers, so |
115 // task cancellation is not done manually here in the dtor. | 115 // task cancellation is not done manually here in the dtor. |
116 HistoryMenuBridge::~HistoryMenuBridge() { | 116 HistoryMenuBridge::~HistoryMenuBridge() { |
117 // Unregister ourselves as observers and notifications. | 117 // Unregister ourselves as observers and notifications. |
118 DCHECK(profile_); | 118 DCHECK(profile_); |
119 if (history_service_) { | 119 if (history_service_) { |
120 registrar_.Remove(this, chrome::NOTIFICATION_HISTORY_TYPED_URLS_MODIFIED, | 120 registrar_.Remove(this, chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, |
121 content::Source<Profile>(profile_)); | 121 content::Source<Profile>(profile_)); |
122 registrar_.Remove(this, chrome::NOTIFICATION_HISTORY_URL_VISITED, | 122 registrar_.Remove(this, chrome::NOTIFICATION_HISTORY_URL_VISITED, |
123 content::Source<Profile>(profile_)); | 123 content::Source<Profile>(profile_)); |
124 registrar_.Remove(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, | 124 registrar_.Remove(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, |
125 content::Source<Profile>(profile_)); | 125 content::Source<Profile>(profile_)); |
126 } else { | 126 } else { |
127 registrar_.Remove(this, chrome::NOTIFICATION_HISTORY_LOADED, | 127 registrar_.Remove(this, chrome::NOTIFICATION_HISTORY_LOADED, |
128 content::Source<Profile>(profile_)); | 128 content::Source<Profile>(profile_)); |
129 } | 129 } |
130 | 130 |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 url_string.c_str()]; | 361 url_string.c_str()]; |
362 [item->menu_item setToolTip:tooltip]; | 362 [item->menu_item setToolTip:tooltip]; |
363 | 363 |
364 [menu insertItem:item->menu_item.get() atIndex:index]; | 364 [menu insertItem:item->menu_item.get() atIndex:index]; |
365 menu_item_map_.insert(std::make_pair(item->menu_item.get(), item)); | 365 menu_item_map_.insert(std::make_pair(item->menu_item.get(), item)); |
366 | 366 |
367 return item->menu_item.get(); | 367 return item->menu_item.get(); |
368 } | 368 } |
369 | 369 |
370 void HistoryMenuBridge::Init() { | 370 void HistoryMenuBridge::Init() { |
371 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_TYPED_URLS_MODIFIED, | 371 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, |
372 content::Source<Profile>(profile_)); | 372 content::Source<Profile>(profile_)); |
373 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URL_VISITED, | 373 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URL_VISITED, |
374 content::Source<Profile>(profile_)); | 374 content::Source<Profile>(profile_)); |
375 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, | 375 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, |
376 content::Source<Profile>(profile_)); | 376 content::Source<Profile>(profile_)); |
377 } | 377 } |
378 | 378 |
379 void HistoryMenuBridge::CreateMenu() { | 379 void HistoryMenuBridge::CreateMenu() { |
380 // If we're currently running CreateMenu(), wait until it finishes. | 380 // If we're currently running CreateMenu(), wait until it finishes. |
381 if (create_in_progress_) | 381 if (create_in_progress_) |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 void HistoryMenuBridge::CancelFaviconRequest(HistoryItem* item) { | 484 void HistoryMenuBridge::CancelFaviconRequest(HistoryItem* item) { |
485 DCHECK(item); | 485 DCHECK(item); |
486 if (item->icon_requested) { | 486 if (item->icon_requested) { |
487 FaviconService* service = | 487 FaviconService* service = |
488 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); | 488 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); |
489 service->CancelRequest(item->icon_handle); | 489 service->CancelRequest(item->icon_handle); |
490 item->icon_requested = false; | 490 item->icon_requested = false; |
491 item->icon_handle = NULL; | 491 item->icon_handle = NULL; |
492 } | 492 } |
493 } | 493 } |
OLD | NEW |