| 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/gtk/global_history_menu.h" | 5 #include "chrome/browser/ui/gtk/global_history_menu.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 item->icon_requested = true; | 215 item->icon_requested = true; |
| 216 } | 216 } |
| 217 | 217 |
| 218 void GlobalHistoryMenu::GotFaviconData(FaviconService::Handle handle, | 218 void GlobalHistoryMenu::GotFaviconData(FaviconService::Handle handle, |
| 219 history::FaviconData favicon) { | 219 history::FaviconData favicon) { |
| 220 HistoryItem* item = | 220 HistoryItem* item = |
| 221 favicon_consumer_.GetClientData( | 221 favicon_consumer_.GetClientData( |
| 222 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), handle); | 222 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), handle); |
| 223 DCHECK(item); | 223 DCHECK(item); |
| 224 item->icon_requested = false; | 224 item->icon_requested = false; |
| 225 item->icon_handle = NULL; | 225 item->icon_handle = static_cast<CancelableRequestProvider::Handle>(NULL); |
| 226 | 226 |
| 227 SkBitmap icon; | 227 SkBitmap icon; |
| 228 if (favicon.is_valid() && | 228 if (favicon.is_valid() && |
| 229 gfx::PNGCodec::Decode(favicon.image_data->front(), | 229 gfx::PNGCodec::Decode(favicon.image_data->front(), |
| 230 favicon.image_data->size(), &icon)) { | 230 favicon.image_data->size(), &icon)) { |
| 231 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&icon); | 231 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&icon); |
| 232 if (pixbuf) { | 232 if (pixbuf) { |
| 233 item->icon_image.Own(gtk_image_new_from_pixbuf(pixbuf)); | 233 item->icon_image.Own(gtk_image_new_from_pixbuf(pixbuf)); |
| 234 g_object_unref(pixbuf); | 234 g_object_unref(pixbuf); |
| 235 | 235 |
| 236 if (item->menu_item) { | 236 if (item->menu_item) { |
| 237 gtk_image_menu_item_set_image( | 237 gtk_image_menu_item_set_image( |
| 238 GTK_IMAGE_MENU_ITEM(item->menu_item), | 238 GTK_IMAGE_MENU_ITEM(item->menu_item), |
| 239 item->icon_image.get()); | 239 item->icon_image.get()); |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 } | 242 } |
| 243 } | 243 } |
| 244 | 244 |
| 245 void GlobalHistoryMenu::CancelFaviconRequest(HistoryItem* item) { | 245 void GlobalHistoryMenu::CancelFaviconRequest(HistoryItem* item) { |
| 246 DCHECK(item); | 246 DCHECK(item); |
| 247 if (item->icon_requested) { | 247 if (item->icon_requested) { |
| 248 FaviconService* service = | 248 FaviconService* service = |
| 249 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); | 249 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); |
| 250 service->CancelRequest(item->icon_handle); | 250 service->CancelRequest(item->icon_handle); |
| 251 item->icon_requested = false; | 251 item->icon_requested = false; |
| 252 item->icon_handle = NULL; | 252 item->icon_handle = static_cast<CancelableRequestProvider::Handle>(NULL); |
| 253 } | 253 } |
| 254 } | 254 } |
| 255 | 255 |
| 256 int GlobalHistoryMenu::GetIndexOfMenuItemWithTag(GtkWidget* menu, int tag_id) { | 256 int GlobalHistoryMenu::GetIndexOfMenuItemWithTag(GtkWidget* menu, int tag_id) { |
| 257 GetIndexClosure closure; | 257 GetIndexClosure closure; |
| 258 closure.found = false; | 258 closure.found = false; |
| 259 closure.current_index = 0; | 259 closure.current_index = 0; |
| 260 closure.tag = tag_id; | 260 closure.tag = tag_id; |
| 261 | 261 |
| 262 gtk_container_foreach( | 262 gtk_container_foreach( |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 TabRestoreService* service = browser_->profile()->GetTabRestoreService(); | 453 TabRestoreService* service = browser_->profile()->GetTabRestoreService(); |
| 454 if (item->session_id && service) { | 454 if (item->session_id && service) { |
| 455 service->RestoreEntryById(browser_->tab_restore_service_delegate(), | 455 service->RestoreEntryById(browser_->tab_restore_service_delegate(), |
| 456 item->session_id, false); | 456 item->session_id, false); |
| 457 } else { | 457 } else { |
| 458 DCHECK(item->url.is_valid()); | 458 DCHECK(item->url.is_valid()); |
| 459 browser_->OpenURL(item->url, GURL(), disposition, | 459 browser_->OpenURL(item->url, GURL(), disposition, |
| 460 PageTransition::AUTO_BOOKMARK); | 460 PageTransition::AUTO_BOOKMARK); |
| 461 } | 461 } |
| 462 } | 462 } |
| OLD | NEW |