| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/views/frame/global_menu_bar_x11.h" | 5 #include "chrome/browser/ui/views/frame/global_menu_bar_x11.h" |
| 6 | 6 |
| 7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
| 8 #include <glib-object.h> | 8 #include <glib-object.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" | 24 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" |
| 25 #include "chrome/browser/ui/views/frame/browser_desktop_root_window_host_x11.h" | 25 #include "chrome/browser/ui/views/frame/browser_desktop_root_window_host_x11.h" |
| 26 #include "chrome/browser/ui/views/frame/browser_view.h" | 26 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 27 #include "chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.h" | 27 #include "chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.h" |
| 28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 29 #include "content/public/browser/notification_source.h" | 29 #include "content/public/browser/notification_source.h" |
| 30 #include "grit/generated_resources.h" | 30 #include "grit/generated_resources.h" |
| 31 #include "ui/base/accelerators/menu_label_accelerator_util_linux.h" | 31 #include "ui/base/accelerators/menu_label_accelerator_util_linux.h" |
| 32 #include "ui/base/keycodes/keyboard_code_conversion_x.h" | 32 #include "ui/base/keycodes/keyboard_code_conversion_x.h" |
| 33 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
| 34 #include "ui/base/text/text_elider.h" | 34 #include "ui/gfx/text_elider.h" |
| 35 | 35 |
| 36 // libdbusmenu-glib types | 36 // libdbusmenu-glib types |
| 37 typedef struct _DbusmenuMenuitem DbusmenuMenuitem; | 37 typedef struct _DbusmenuMenuitem DbusmenuMenuitem; |
| 38 typedef DbusmenuMenuitem* (*dbusmenu_menuitem_new_func)(); | 38 typedef DbusmenuMenuitem* (*dbusmenu_menuitem_new_func)(); |
| 39 typedef bool (*dbusmenu_menuitem_child_add_position_func)( | 39 typedef bool (*dbusmenu_menuitem_child_add_position_func)( |
| 40 DbusmenuMenuitem* parent, | 40 DbusmenuMenuitem* parent, |
| 41 DbusmenuMenuitem* child, | 41 DbusmenuMenuitem* child, |
| 42 unsigned int position); | 42 unsigned int position); |
| 43 typedef DbusmenuMenuitem* (*dbusmenu_menuitem_child_append_func)( | 43 typedef DbusmenuMenuitem* (*dbusmenu_menuitem_child_append_func)( |
| 44 DbusmenuMenuitem* parent, | 44 DbusmenuMenuitem* parent, |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 | 517 |
| 518 void GlobalMenuBarX11::AddHistoryItemToMenu(HistoryItem* item, | 518 void GlobalMenuBarX11::AddHistoryItemToMenu(HistoryItem* item, |
| 519 DbusmenuMenuitem* menu, | 519 DbusmenuMenuitem* menu, |
| 520 int tag, | 520 int tag, |
| 521 int index) { | 521 int index) { |
| 522 string16 title = item->title; | 522 string16 title = item->title; |
| 523 std::string url_string = item->url.possibly_invalid_spec(); | 523 std::string url_string = item->url.possibly_invalid_spec(); |
| 524 | 524 |
| 525 if (title.empty()) | 525 if (title.empty()) |
| 526 title = UTF8ToUTF16(url_string); | 526 title = UTF8ToUTF16(url_string); |
| 527 ui::ElideString(title, kMaximumMenuWidthInChars, &title); | 527 gfx::ElideString(title, kMaximumMenuWidthInChars, &title); |
| 528 | 528 |
| 529 DbusmenuMenuitem* menu_item = BuildMenuItem(UTF16ToUTF8(title), tag); | 529 DbusmenuMenuitem* menu_item = BuildMenuItem(UTF16ToUTF8(title), tag); |
| 530 g_signal_connect(menu_item, "item-activated", | 530 g_signal_connect(menu_item, "item-activated", |
| 531 G_CALLBACK(OnHistoryItemActivatedThunk), this); | 531 G_CALLBACK(OnHistoryItemActivatedThunk), this); |
| 532 | 532 |
| 533 g_object_set_data_full(G_OBJECT(menu_item), kHistoryItem, item, | 533 g_object_set_data_full(G_OBJECT(menu_item), kHistoryItem, item, |
| 534 DeleteHistoryItem); | 534 DeleteHistoryItem); |
| 535 menuitem_child_add_position(menu, menu_item, index); | 535 menuitem_child_add_position(menu, menu_item, index); |
| 536 g_object_unref(menu_item); | 536 g_object_unref(menu_item); |
| 537 } | 537 } |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 tab_restore_service_->LoadTabsFromLastSession(); | 775 tab_restore_service_->LoadTabsFromLastSession(); |
| 776 tab_restore_service_->AddObserver(this); | 776 tab_restore_service_->AddObserver(this); |
| 777 | 777 |
| 778 // If LoadTabsFromLastSession doesn't load tabs, it won't call | 778 // If LoadTabsFromLastSession doesn't load tabs, it won't call |
| 779 // TabRestoreServiceChanged(). This ensures that all new windows after | 779 // TabRestoreServiceChanged(). This ensures that all new windows after |
| 780 // the first one will have their menus populated correctly. | 780 // the first one will have their menus populated correctly. |
| 781 TabRestoreServiceChanged(tab_restore_service_); | 781 TabRestoreServiceChanged(tab_restore_service_); |
| 782 } | 782 } |
| 783 } | 783 } |
| 784 } | 784 } |
| OLD | NEW |