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/debug/leak_annotations.h" | 10 #include "base/debug/leak_annotations.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "chrome/app/chrome_command_ids.h" | 17 #include "chrome/app/chrome_command_ids.h" |
18 #include "chrome/browser/browser_process.h" | |
18 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
19 #include "chrome/browser/history/top_sites.h" | 20 #include "chrome/browser/history/top_sites.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/profiles/profile_info_cache.h" | |
23 #include "chrome/browser/profiles/profile_manager.h" | |
21 #include "chrome/browser/sessions/tab_restore_service.h" | 24 #include "chrome/browser/sessions/tab_restore_service.h" |
22 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 25 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
23 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
24 #include "chrome/browser/ui/browser_commands.h" | 27 #include "chrome/browser/ui/browser_commands.h" |
28 #include "chrome/browser/ui/browser_list.h" | |
25 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" | 29 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" |
26 #include "chrome/browser/ui/views/frame/browser_desktop_window_tree_host_x11.h" | 30 #include "chrome/browser/ui/views/frame/browser_desktop_window_tree_host_x11.h" |
27 #include "chrome/browser/ui/views/frame/browser_view.h" | 31 #include "chrome/browser/ui/views/frame/browser_view.h" |
28 #include "chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.h" | 32 #include "chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.h" |
29 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
30 #include "chrome/grit/generated_resources.h" | 34 #include "chrome/grit/generated_resources.h" |
31 #include "content/public/browser/notification_source.h" | 35 #include "content/public/browser/notification_source.h" |
32 #include "ui/base/accelerators/menu_label_accelerator_util_linux.h" | 36 #include "ui/base/accelerators/menu_label_accelerator_util_linux.h" |
33 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
34 #include "ui/events/keycodes/keyboard_code_conversion_x.h" | 38 #include "ui/events/keycodes/keyboard_code_conversion_x.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 const char kPropertyToggleType[] = "toggle-type"; | 110 const char kPropertyToggleType[] = "toggle-type"; |
107 const char kPropertyToggleState[] = "toggle-state"; | 111 const char kPropertyToggleState[] = "toggle-state"; |
108 const char kPropertyVisible[] = "visible"; | 112 const char kPropertyVisible[] = "visible"; |
109 | 113 |
110 const char kTypeCheckmark[] = "checkmark"; | 114 const char kTypeCheckmark[] = "checkmark"; |
111 const char kTypeSeparator[] = "separator"; | 115 const char kTypeSeparator[] = "separator"; |
112 | 116 |
113 // Data set on GObjectgs. | 117 // Data set on GObjectgs. |
114 const char kTypeTag[] = "type-tag"; | 118 const char kTypeTag[] = "type-tag"; |
115 const char kHistoryItem[] = "history-item"; | 119 const char kHistoryItem[] = "history-item"; |
120 const char kProfileId[] = "profile-id"; | |
116 | 121 |
117 // The maximum number of most visited items to display. | 122 // The maximum number of most visited items to display. |
118 const unsigned int kMostVisitedCount = 8; | 123 const unsigned int kMostVisitedCount = 8; |
119 | 124 |
120 // The number of recently closed items to get. | 125 // The number of recently closed items to get. |
121 const unsigned int kRecentlyClosedCount = 8; | 126 const unsigned int kRecentlyClosedCount = 8; |
122 | 127 |
123 // Menus more than this many chars long will get trimmed. | 128 // Menus more than this many chars long will get trimmed. |
124 const int kMaximumMenuWidthInChars = 50; | 129 const int kMaximumMenuWidthInChars = 50; |
125 | 130 |
126 // Constants used in menu definitions. | 131 // Constants used in menu definitions. |
127 const int MENU_SEPARATOR =-1; | 132 const int MENU_SEPARATOR =-1; |
128 const int MENU_END = -2; | 133 const int MENU_END = -2; |
129 const int MENU_DISABLED_ID = -3; | 134 const int MENU_DISABLED_ID = -3; |
130 | 135 |
131 // These tag values are used to refer to menu items. | 136 // These tag values are used to refer to menu items. |
132 const int TAG_MOST_VISITED = 1; | 137 const int TAG_MOST_VISITED = 1; |
133 const int TAG_RECENTLY_CLOSED = 2; | 138 const int TAG_RECENTLY_CLOSED = 2; |
134 const int TAG_MOST_VISITED_HEADER = 3; | 139 const int TAG_MOST_VISITED_HEADER = 3; |
135 const int TAG_RECENTLY_CLOSED_HEADER = 4; | 140 const int TAG_RECENTLY_CLOSED_HEADER = 4; |
141 const int TAG_PROFILES = 5; | |
136 | 142 |
137 GlobalMenuBarCommand file_menu[] = { | 143 GlobalMenuBarCommand file_menu[] = { |
138 { IDS_NEW_TAB, IDC_NEW_TAB }, | 144 { IDS_NEW_TAB, IDC_NEW_TAB }, |
139 { IDS_NEW_WINDOW, IDC_NEW_WINDOW }, | 145 { IDS_NEW_WINDOW, IDC_NEW_WINDOW }, |
140 { IDS_NEW_INCOGNITO_WINDOW, IDC_NEW_INCOGNITO_WINDOW }, | 146 { IDS_NEW_INCOGNITO_WINDOW, IDC_NEW_INCOGNITO_WINDOW }, |
141 { IDS_REOPEN_CLOSED_TABS_LINUX, IDC_RESTORE_TAB }, | 147 { IDS_REOPEN_CLOSED_TABS_LINUX, IDC_RESTORE_TAB }, |
142 { IDS_OPEN_FILE_LINUX, IDC_OPEN_FILE }, | 148 { IDS_OPEN_FILE_LINUX, IDC_OPEN_FILE }, |
143 { IDS_OPEN_LOCATION_LINUX, IDC_FOCUS_LOCATION }, | 149 { IDS_OPEN_LOCATION_LINUX, IDC_FOCUS_LOCATION }, |
144 | 150 |
145 { MENU_SEPARATOR, MENU_SEPARATOR }, | 151 { MENU_SEPARATOR, MENU_SEPARATOR }, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 }; | 240 }; |
235 | 241 |
236 GlobalMenuBarCommand help_menu[] = { | 242 GlobalMenuBarCommand help_menu[] = { |
237 #if defined(GOOGLE_CHROME_BUILD) | 243 #if defined(GOOGLE_CHROME_BUILD) |
238 { IDS_FEEDBACK, IDC_FEEDBACK }, | 244 { IDS_FEEDBACK, IDC_FEEDBACK }, |
239 #endif | 245 #endif |
240 { IDS_HELP_PAGE , IDC_HELP_PAGE_VIA_MENU }, | 246 { IDS_HELP_PAGE , IDC_HELP_PAGE_VIA_MENU }, |
241 { MENU_END, MENU_END } | 247 { MENU_END, MENU_END } |
242 }; | 248 }; |
243 | 249 |
250 GlobalMenuBarCommand profiles_menu[] = { | |
251 { MENU_SEPARATOR, MENU_SEPARATOR }, | |
252 { MENU_END, MENU_END } | |
253 }; | |
254 | |
244 void EnsureMethodsLoaded() { | 255 void EnsureMethodsLoaded() { |
245 static bool attempted_load = false; | 256 static bool attempted_load = false; |
246 if (attempted_load) | 257 if (attempted_load) |
247 return; | 258 return; |
248 attempted_load = true; | 259 attempted_load = true; |
249 | 260 |
250 void* dbusmenu_lib = dlopen("libdbusmenu-glib.so", RTLD_LAZY); | 261 void* dbusmenu_lib = dlopen("libdbusmenu-glib.so", RTLD_LAZY); |
251 if (!dbusmenu_lib) | 262 if (!dbusmenu_lib) |
252 dbusmenu_lib = dlopen("libdbusmenu-glib.so.4", RTLD_LAZY); | 263 dbusmenu_lib = dlopen("libdbusmenu-glib.so.4", RTLD_LAZY); |
253 if (!dbusmenu_lib) | 264 if (!dbusmenu_lib) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 | 324 |
314 GlobalMenuBarX11::GlobalMenuBarX11(BrowserView* browser_view, | 325 GlobalMenuBarX11::GlobalMenuBarX11(BrowserView* browser_view, |
315 BrowserDesktopWindowTreeHostX11* host) | 326 BrowserDesktopWindowTreeHostX11* host) |
316 : browser_(browser_view->browser()), | 327 : browser_(browser_view->browser()), |
317 profile_(browser_->profile()), | 328 profile_(browser_->profile()), |
318 browser_view_(browser_view), | 329 browser_view_(browser_view), |
319 host_(host), | 330 host_(host), |
320 server_(NULL), | 331 server_(NULL), |
321 root_item_(NULL), | 332 root_item_(NULL), |
322 history_menu_(NULL), | 333 history_menu_(NULL), |
334 profiles_menu_(NULL), | |
323 top_sites_(NULL), | 335 top_sites_(NULL), |
324 tab_restore_service_(NULL), | 336 tab_restore_service_(NULL), |
325 weak_ptr_factory_(this) { | 337 weak_ptr_factory_(this) { |
326 EnsureMethodsLoaded(); | 338 EnsureMethodsLoaded(); |
327 | 339 |
328 if (server_new) | 340 if (server_new) |
329 host_->AddObserver(this); | 341 host_->AddObserver(this); |
342 | |
343 avatar_menu_.reset(new AvatarMenu( | |
344 &g_browser_process->profile_manager()->GetProfileInfoCache(), | |
345 this, | |
346 NULL)); | |
347 avatar_menu_->RebuildMenu(); | |
348 BrowserList::AddObserver(this); | |
330 } | 349 } |
331 | 350 |
332 GlobalMenuBarX11::~GlobalMenuBarX11() { | 351 GlobalMenuBarX11::~GlobalMenuBarX11() { |
333 if (server_) { | 352 if (server_) { |
334 Disable(); | 353 Disable(); |
335 | 354 |
336 if (tab_restore_service_) | 355 if (tab_restore_service_) |
337 tab_restore_service_->RemoveObserver(this); | 356 tab_restore_service_->RemoveObserver(this); |
338 | 357 |
339 g_object_unref(server_); | 358 g_object_unref(server_); |
340 host_->RemoveObserver(this); | 359 host_->RemoveObserver(this); |
341 } | 360 } |
361 BrowserList::RemoveObserver(this); | |
342 } | 362 } |
343 | 363 |
344 // static | 364 // static |
345 std::string GlobalMenuBarX11::GetPathForWindow(unsigned long xid) { | 365 std::string GlobalMenuBarX11::GetPathForWindow(unsigned long xid) { |
346 return base::StringPrintf("/com/canonical/menu/%lX", xid); | 366 return base::StringPrintf("/com/canonical/menu/%lX", xid); |
347 } | 367 } |
348 | 368 |
349 DbusmenuMenuitem* GlobalMenuBarX11::BuildSeparator() { | 369 DbusmenuMenuitem* GlobalMenuBarX11::BuildSeparator() { |
350 DbusmenuMenuitem* item = menuitem_new(); | 370 DbusmenuMenuitem* item = menuitem_new(); |
351 menuitem_property_set(item, kPropertyType, kTypeSeparator); | 371 menuitem_property_set(item, kPropertyType, kTypeSeparator); |
(...skipping 25 matching lines...) Expand all Loading... | |
377 menuitem_property_set(root_item_, kPropertyLabel, "Root"); | 397 menuitem_property_set(root_item_, kPropertyLabel, "Root"); |
378 menuitem_property_set_bool(root_item_, kPropertyVisible, true); | 398 menuitem_property_set_bool(root_item_, kPropertyVisible, true); |
379 | 399 |
380 // First build static menu content. | 400 // First build static menu content. |
381 BuildStaticMenu(root_item_, IDS_FILE_MENU_LINUX, file_menu); | 401 BuildStaticMenu(root_item_, IDS_FILE_MENU_LINUX, file_menu); |
382 BuildStaticMenu(root_item_, IDS_EDIT_MENU_LINUX, edit_menu); | 402 BuildStaticMenu(root_item_, IDS_EDIT_MENU_LINUX, edit_menu); |
383 BuildStaticMenu(root_item_, IDS_VIEW_MENU_LINUX, view_menu); | 403 BuildStaticMenu(root_item_, IDS_VIEW_MENU_LINUX, view_menu); |
384 history_menu_ = BuildStaticMenu( | 404 history_menu_ = BuildStaticMenu( |
385 root_item_, IDS_HISTORY_MENU_LINUX, history_menu); | 405 root_item_, IDS_HISTORY_MENU_LINUX, history_menu); |
386 BuildStaticMenu(root_item_, IDS_TOOLS_MENU_LINUX, tools_menu); | 406 BuildStaticMenu(root_item_, IDS_TOOLS_MENU_LINUX, tools_menu); |
407 profiles_menu_ = BuildStaticMenu( | |
408 root_item_, IDS_PROFILES_OPTIONS_GROUP_NAME, profiles_menu); | |
387 BuildStaticMenu(root_item_, IDS_HELP_MENU_LINUX, help_menu); | 409 BuildStaticMenu(root_item_, IDS_HELP_MENU_LINUX, help_menu); |
388 | 410 |
389 // We have to connect to |history_menu_item|'s "activate" signal instead of | 411 // We have to connect to |history_menu_item|'s "activate" signal instead of |
390 // |history_menu|'s "show" signal because we are not supposed to modify the | 412 // |history_menu|'s "show" signal because we are not supposed to modify the |
391 // menu during "show" | 413 // menu during "show" |
392 g_signal_connect(history_menu_, "about-to-show", | 414 g_signal_connect(history_menu_, "about-to-show", |
393 G_CALLBACK(OnHistoryMenuAboutToShowThunk), this); | 415 G_CALLBACK(OnHistoryMenuAboutToShowThunk), this); |
394 | 416 |
395 for (CommandIDMenuItemMap::const_iterator it = id_to_menu_item_.begin(); | 417 for (CommandIDMenuItemMap::const_iterator it = id_to_menu_item_.begin(); |
396 it != id_to_menu_item_.end(); ++it) { | 418 it != id_to_menu_item_.end(); ++it) { |
(...skipping 17 matching lines...) Expand all Loading... | |
414 top_sites_ = profile_->GetTopSites(); | 436 top_sites_ = profile_->GetTopSites(); |
415 if (top_sites_) { | 437 if (top_sites_) { |
416 GetTopSitesData(); | 438 GetTopSitesData(); |
417 | 439 |
418 // Register for notification when TopSites changes so that we can update | 440 // Register for notification when TopSites changes so that we can update |
419 // ourself. | 441 // ourself. |
420 registrar_.Add(this, chrome::NOTIFICATION_TOP_SITES_CHANGED, | 442 registrar_.Add(this, chrome::NOTIFICATION_TOP_SITES_CHANGED, |
421 content::Source<history::TopSites>(top_sites_)); | 443 content::Source<history::TopSites>(top_sites_)); |
422 } | 444 } |
423 | 445 |
446 RebuildProfilesMenu(); | |
447 | |
424 server_set_root(server_, root_item_); | 448 server_set_root(server_, root_item_); |
425 } | 449 } |
426 | 450 |
427 void GlobalMenuBarX11::Disable() { | 451 void GlobalMenuBarX11::Disable() { |
428 for (CommandIDMenuItemMap::const_iterator it = id_to_menu_item_.begin(); | 452 for (CommandIDMenuItemMap::const_iterator it = id_to_menu_item_.begin(); |
429 it != id_to_menu_item_.end(); ++it) { | 453 it != id_to_menu_item_.end(); ++it) { |
430 chrome::RemoveCommandObserver(browser_, it->first, this); | 454 chrome::RemoveCommandObserver(browser_, it->first, this); |
431 } | 455 } |
432 id_to_menu_item_.clear(); | 456 id_to_menu_item_.clear(); |
433 | 457 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
580 PrefService* prefs = browser_->profile()->GetPrefs(); | 604 PrefService* prefs = browser_->profile()->GetPrefs(); |
581 // Note: Unlike the GTK version, we don't appear to need to do tricks where | 605 // Note: Unlike the GTK version, we don't appear to need to do tricks where |
582 // we block activation while setting the toggle. | 606 // we block activation while setting the toggle. |
583 menuitem_property_set_int( | 607 menuitem_property_set_int( |
584 it->second, | 608 it->second, |
585 kPropertyToggleState, | 609 kPropertyToggleState, |
586 prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 610 prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
587 } | 611 } |
588 } | 612 } |
589 | 613 |
614 void GlobalMenuBarX11::RebuildProfilesMenu() { | |
615 ClearMenuSection(profiles_menu_, TAG_PROFILES); | |
616 | |
617 // Don't call avatar_menu_->GetActiveProfileIndex() as the as the index might | |
618 // be incorrect if RebuildProfilesMenu() is called while we deleting the | |
619 // active profile and closing all its browser windows. | |
620 int active_profile_index = -1; | |
621 | |
622 for (size_t i = 0; i < avatar_menu_->GetNumberOfItems(); ++i) { | |
623 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(i); | |
624 base::string16 title = item.name; | |
625 gfx::ElideString(title, kMaximumMenuWidthInChars, &title); | |
626 | |
627 DbusmenuMenuitem* menu_item = BuildMenuItem( | |
628 base::UTF16ToUTF8(title), TAG_PROFILES); | |
629 g_object_set_data(G_OBJECT(menu_item), kProfileId, GINT_TO_POINTER(i)); | |
630 g_signal_connect(menu_item, "item-activated", | |
631 G_CALLBACK(OnProfileItemActivatedThunk), this); | |
632 menuitem_property_set(menu_item, kPropertyToggleType, kTypeCheckmark); | |
633 menuitem_property_set_int(menu_item, kPropertyToggleState, item.active); | |
634 | |
635 if (item.active) | |
636 active_profile_index = i; | |
637 | |
638 menuitem_child_add_position(profiles_menu_, menu_item, i); | |
639 g_object_unref(menu_item); | |
640 } | |
641 | |
642 // There is a separator between the list of profiles and the possible actions. | |
643 int index = avatar_menu_->GetNumberOfItems() + 1; | |
644 | |
645 DbusmenuMenuitem* edit_profile_item = BuildMenuItem( | |
646 l10n_util::GetStringUTF8(IDS_PROFILES_MANAGE_BUTTON_LABEL), TAG_PROFILES); | |
647 DbusmenuMenuitem* create_profile_item = BuildMenuItem( | |
648 l10n_util::GetStringUTF8(IDS_PROFILES_CREATE_BUTTON_LABEL), | |
649 TAG_PROFILES); | |
650 | |
651 // There is no active profile in Guest mode, in which case the action buttons | |
652 // should be disabled. | |
Elliot Glaysher
2014/10/01 20:27:52
OK, so I have two windows: one of my normal profil
noms (inactive)
2014/10/01 20:34:14
Yup, that's it. The checkmark is "which profile is
| |
653 if (active_profile_index >= 0) { | |
654 g_object_set_data(G_OBJECT(edit_profile_item), kProfileId, | |
655 GINT_TO_POINTER(active_profile_index)); | |
656 g_signal_connect(edit_profile_item, "item-activated", | |
657 G_CALLBACK(OnEditProfileItemActivatedThunk), this); | |
658 g_signal_connect(create_profile_item, "item-activated", | |
659 G_CALLBACK(OnCreateProfileItemActivatedThunk), this); | |
660 } else { | |
661 menuitem_property_set_bool(edit_profile_item, kPropertyEnabled, false); | |
662 menuitem_property_set_bool(create_profile_item, kPropertyEnabled, false); | |
663 } | |
664 | |
665 menuitem_child_add_position(profiles_menu_, edit_profile_item, index++); | |
666 menuitem_child_add_position(profiles_menu_, create_profile_item, index); | |
667 g_object_unref(edit_profile_item); | |
668 g_object_unref(create_profile_item); | |
669 } | |
670 | |
590 int GlobalMenuBarX11::GetIndexOfMenuItemWithTag(DbusmenuMenuitem* menu, | 671 int GlobalMenuBarX11::GetIndexOfMenuItemWithTag(DbusmenuMenuitem* menu, |
591 int tag_id) { | 672 int tag_id) { |
592 GList* childs = menuitem_get_children(menu); | 673 GList* childs = menuitem_get_children(menu); |
593 int i = 0; | 674 int i = 0; |
594 for (; childs != NULL; childs = childs->next, i++) { | 675 for (; childs != NULL; childs = childs->next, i++) { |
595 int tag = | 676 int tag = |
596 GPOINTER_TO_INT(g_object_get_data(G_OBJECT(childs->data), kTypeTag)); | 677 GPOINTER_TO_INT(g_object_get_data(G_OBJECT(childs->data), kTypeTag)); |
597 if (tag == tag_id) | 678 if (tag == tag_id) |
598 return i; | 679 return i; |
599 } | 680 } |
(...skipping 23 matching lines...) Expand all Loading... | |
623 } | 704 } |
624 } | 705 } |
625 | 706 |
626 // static | 707 // static |
627 void GlobalMenuBarX11::DeleteHistoryItem(void* void_item) { | 708 void GlobalMenuBarX11::DeleteHistoryItem(void* void_item) { |
628 HistoryItem* item = | 709 HistoryItem* item = |
629 reinterpret_cast<GlobalMenuBarX11::HistoryItem*>(void_item); | 710 reinterpret_cast<GlobalMenuBarX11::HistoryItem*>(void_item); |
630 delete item; | 711 delete item; |
631 } | 712 } |
632 | 713 |
714 void GlobalMenuBarX11::OnAvatarMenuChanged(AvatarMenu* avatar_menu) { | |
715 RebuildProfilesMenu(); | |
716 } | |
717 | |
718 void GlobalMenuBarX11::OnBrowserSetLastActive(Browser* browser) { | |
719 // Rebuild the avatar menu so that the items have the correct active state. | |
720 avatar_menu_->RebuildMenu(); | |
721 avatar_menu_->ActiveBrowserChanged(browser); | |
722 RebuildProfilesMenu(); | |
723 } | |
724 | |
633 void GlobalMenuBarX11::EnabledStateChangedForCommand(int id, bool enabled) { | 725 void GlobalMenuBarX11::EnabledStateChangedForCommand(int id, bool enabled) { |
634 CommandIDMenuItemMap::iterator it = id_to_menu_item_.find(id); | 726 CommandIDMenuItemMap::iterator it = id_to_menu_item_.find(id); |
635 if (it != id_to_menu_item_.end()) | 727 if (it != id_to_menu_item_.end()) |
636 menuitem_property_set_bool(it->second, kPropertyEnabled, enabled); | 728 menuitem_property_set_bool(it->second, kPropertyEnabled, enabled); |
637 } | 729 } |
638 | 730 |
639 void GlobalMenuBarX11::Observe(int type, | 731 void GlobalMenuBarX11::Observe(int type, |
640 const content::NotificationSource& source, | 732 const content::NotificationSource& source, |
641 const content::NotificationDetails& details) { | 733 const content::NotificationDetails& details) { |
642 if (type == chrome::NOTIFICATION_TOP_SITES_CHANGED) { | 734 if (type == chrome::NOTIFICATION_TOP_SITES_CHANGED) { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
783 tab_restore_service_->LoadTabsFromLastSession(); | 875 tab_restore_service_->LoadTabsFromLastSession(); |
784 tab_restore_service_->AddObserver(this); | 876 tab_restore_service_->AddObserver(this); |
785 | 877 |
786 // If LoadTabsFromLastSession doesn't load tabs, it won't call | 878 // If LoadTabsFromLastSession doesn't load tabs, it won't call |
787 // TabRestoreServiceChanged(). This ensures that all new windows after | 879 // TabRestoreServiceChanged(). This ensures that all new windows after |
788 // the first one will have their menus populated correctly. | 880 // the first one will have their menus populated correctly. |
789 TabRestoreServiceChanged(tab_restore_service_); | 881 TabRestoreServiceChanged(tab_restore_service_); |
790 } | 882 } |
791 } | 883 } |
792 } | 884 } |
885 | |
886 void GlobalMenuBarX11::OnProfileItemActivated(DbusmenuMenuitem* sender, | |
887 unsigned int timestamp) { | |
888 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(sender), "profile-id")); | |
Elliot Glaysher
2014/10/01 20:27:52
kProfileId?
noms (inactive)
2014/10/01 20:34:14
Oh, of course. Done.
On 2014/10/01 20:27:52, Ellio
| |
889 avatar_menu_->SwitchToProfile(id, false, ProfileMetrics::SWITCH_PROFILE_MENU); | |
890 } | |
891 | |
892 void GlobalMenuBarX11::OnEditProfileItemActivated(DbusmenuMenuitem* sender, | |
893 unsigned int timestamp) { | |
894 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(sender), "profile-id")); | |
Elliot Glaysher
2014/10/01 20:27:52
kProfileId?
noms (inactive)
2014/10/01 20:34:14
Done.
| |
895 avatar_menu_->EditProfile(id); | |
896 } | |
897 | |
898 void GlobalMenuBarX11::OnCreateProfileItemActivated(DbusmenuMenuitem* sender, | |
899 unsigned int timestamp) { | |
900 avatar_menu_->AddNewProfile(ProfileMetrics::ADD_NEW_USER_MENU); | |
901 } | |
OLD | NEW |