| 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/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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" | 22 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" |
| 23 #include "chrome/browser/ui/gtk/event_utils.h" | 23 #include "chrome/browser/ui/gtk/event_utils.h" |
| 24 #include "chrome/browser/ui/gtk/global_menu_bar.h" | 24 #include "chrome/browser/ui/gtk/global_menu_bar.h" |
| 25 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 25 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 26 #include "chrome/browser/ui/gtk/gtk_util.h" | 26 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 27 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 28 #include "content/public/browser/notification_source.h" | 28 #include "content/public/browser/notification_source.h" |
| 29 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 30 #include "ui/base/gtk/owned_widget_gtk.h" | 30 #include "ui/base/gtk/owned_widget_gtk.h" |
| 31 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 32 #include "ui/base/text/text_elider.h" | |
| 33 #include "ui/gfx/codec/png_codec.h" | 32 #include "ui/gfx/codec/png_codec.h" |
| 34 #include "ui/gfx/gtk_util.h" | 33 #include "ui/gfx/gtk_util.h" |
| 34 #include "ui/gfx/text_elider.h" |
| 35 | 35 |
| 36 using content::OpenURLParams; | 36 using content::OpenURLParams; |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 // The maximum number of most visited items to display. | 40 // The maximum number of most visited items to display. |
| 41 const unsigned int kMostVisitedCount = 8; | 41 const unsigned int kMostVisitedCount = 8; |
| 42 | 42 |
| 43 // The number of recently closed items to get. | 43 // The number of recently closed items to get. |
| 44 const unsigned int kRecentlyClosedCount = 8; | 44 const unsigned int kRecentlyClosedCount = 8; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 191 |
| 192 GtkWidget* GlobalHistoryMenu::AddHistoryItemToMenu(HistoryItem* item, | 192 GtkWidget* GlobalHistoryMenu::AddHistoryItemToMenu(HistoryItem* item, |
| 193 GtkWidget* menu, | 193 GtkWidget* menu, |
| 194 int tag, | 194 int tag, |
| 195 int index) { | 195 int index) { |
| 196 string16 title = item->title; | 196 string16 title = item->title; |
| 197 std::string url_string = item->url.possibly_invalid_spec(); | 197 std::string url_string = item->url.possibly_invalid_spec(); |
| 198 | 198 |
| 199 if (title.empty()) | 199 if (title.empty()) |
| 200 title = UTF8ToUTF16(url_string); | 200 title = UTF8ToUTF16(url_string); |
| 201 ui::ElideString(title, kMaximumMenuWidthInChars, &title); | 201 gfx::ElideString(title, kMaximumMenuWidthInChars, &title); |
| 202 | 202 |
| 203 GtkWidget* menu_item = gtk_menu_item_new_with_label( | 203 GtkWidget* menu_item = gtk_menu_item_new_with_label( |
| 204 UTF16ToUTF8(title).c_str()); | 204 UTF16ToUTF8(title).c_str()); |
| 205 | 205 |
| 206 item->menu_item = menu_item; | 206 item->menu_item = menu_item; |
| 207 gtk_widget_show(menu_item); | 207 gtk_widget_show(menu_item); |
| 208 g_object_set_data(G_OBJECT(menu_item), "type-tag", GINT_TO_POINTER(tag)); | 208 g_object_set_data(G_OBJECT(menu_item), "type-tag", GINT_TO_POINTER(tag)); |
| 209 g_signal_connect(menu_item, "activate", | 209 g_signal_connect(menu_item, "activate", |
| 210 G_CALLBACK(OnRecentlyClosedItemActivatedThunk), this); | 210 G_CALLBACK(OnRecentlyClosedItemActivatedThunk), this); |
| 211 | 211 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 tab_restore_service_->LoadTabsFromLastSession(); | 409 tab_restore_service_->LoadTabsFromLastSession(); |
| 410 tab_restore_service_->AddObserver(this); | 410 tab_restore_service_->AddObserver(this); |
| 411 | 411 |
| 412 // If LoadTabsFromLastSession doesn't load tabs, it won't call | 412 // If LoadTabsFromLastSession doesn't load tabs, it won't call |
| 413 // TabRestoreServiceChanged(). This ensures that all new windows after | 413 // TabRestoreServiceChanged(). This ensures that all new windows after |
| 414 // the first one will have their menus populated correctly. | 414 // the first one will have their menus populated correctly. |
| 415 TabRestoreServiceChanged(tab_restore_service_); | 415 TabRestoreServiceChanged(tab_restore_service_); |
| 416 } | 416 } |
| 417 } | 417 } |
| 418 } | 418 } |
| OLD | NEW |