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" |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 399 |
400 ui::Accelerator accelerator; | 400 ui::Accelerator accelerator; |
401 if (browser_view_->GetAccelerator(it->first, &accelerator)) | 401 if (browser_view_->GetAccelerator(it->first, &accelerator)) |
402 RegisterAccelerator(it->second, accelerator); | 402 RegisterAccelerator(it->second, accelerator); |
403 | 403 |
404 chrome::AddCommandObserver(browser_, it->first, this); | 404 chrome::AddCommandObserver(browser_, it->first, this); |
405 } | 405 } |
406 | 406 |
407 pref_change_registrar_.Init(browser_->profile()->GetPrefs()); | 407 pref_change_registrar_.Init(browser_->profile()->GetPrefs()); |
408 pref_change_registrar_.Add( | 408 pref_change_registrar_.Add( |
409 prefs::kShowBookmarkBar, | 409 bookmarks::prefs::kShowBookmarkBar, |
410 base::Bind(&GlobalMenuBarX11::OnBookmarkBarVisibilityChanged, | 410 base::Bind(&GlobalMenuBarX11::OnBookmarkBarVisibilityChanged, |
411 base::Unretained(this))); | 411 base::Unretained(this))); |
412 OnBookmarkBarVisibilityChanged(); | 412 OnBookmarkBarVisibilityChanged(); |
413 | 413 |
414 top_sites_ = profile_->GetTopSites(); | 414 top_sites_ = profile_->GetTopSites(); |
415 if (top_sites_) { | 415 if (top_sites_) { |
416 GetTopSitesData(); | 416 GetTopSitesData(); |
417 | 417 |
418 // Register for notification when TopSites changes so that we can update | 418 // Register for notification when TopSites changes so that we can update |
419 // ourself. | 419 // ourself. |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 } | 573 } |
574 } | 574 } |
575 | 575 |
576 void GlobalMenuBarX11::OnBookmarkBarVisibilityChanged() { | 576 void GlobalMenuBarX11::OnBookmarkBarVisibilityChanged() { |
577 CommandIDMenuItemMap::iterator it = | 577 CommandIDMenuItemMap::iterator it = |
578 id_to_menu_item_.find(IDC_SHOW_BOOKMARK_BAR); | 578 id_to_menu_item_.find(IDC_SHOW_BOOKMARK_BAR); |
579 if (it != id_to_menu_item_.end()) { | 579 if (it != id_to_menu_item_.end()) { |
580 PrefService* prefs = browser_->profile()->GetPrefs(); | 580 PrefService* prefs = browser_->profile()->GetPrefs(); |
581 // Note: Unlike the GTK version, we don't appear to need to do tricks where | 581 // Note: Unlike the GTK version, we don't appear to need to do tricks where |
582 // we block activation while setting the toggle. | 582 // we block activation while setting the toggle. |
583 menuitem_property_set_int(it->second, kPropertyToggleState, | 583 menuitem_property_set_int( |
584 prefs->GetBoolean(prefs::kShowBookmarkBar)); | 584 it->second, |
| 585 kPropertyToggleState, |
| 586 prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
585 } | 587 } |
586 } | 588 } |
587 | 589 |
588 int GlobalMenuBarX11::GetIndexOfMenuItemWithTag(DbusmenuMenuitem* menu, | 590 int GlobalMenuBarX11::GetIndexOfMenuItemWithTag(DbusmenuMenuitem* menu, |
589 int tag_id) { | 591 int tag_id) { |
590 GList* childs = menuitem_get_children(menu); | 592 GList* childs = menuitem_get_children(menu); |
591 int i = 0; | 593 int i = 0; |
592 for (; childs != NULL; childs = childs->next, i++) { | 594 for (; childs != NULL; childs = childs->next, i++) { |
593 int tag = | 595 int tag = |
594 GPOINTER_TO_INT(g_object_get_data(G_OBJECT(childs->data), kTypeTag)); | 596 GPOINTER_TO_INT(g_object_get_data(G_OBJECT(childs->data), kTypeTag)); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 tab_restore_service_->LoadTabsFromLastSession(); | 783 tab_restore_service_->LoadTabsFromLastSession(); |
782 tab_restore_service_->AddObserver(this); | 784 tab_restore_service_->AddObserver(this); |
783 | 785 |
784 // If LoadTabsFromLastSession doesn't load tabs, it won't call | 786 // If LoadTabsFromLastSession doesn't load tabs, it won't call |
785 // TabRestoreServiceChanged(). This ensures that all new windows after | 787 // TabRestoreServiceChanged(). This ensures that all new windows after |
786 // the first one will have their menus populated correctly. | 788 // the first one will have their menus populated correctly. |
787 TabRestoreServiceChanged(tab_restore_service_); | 789 TabRestoreServiceChanged(tab_restore_service_); |
788 } | 790 } |
789 } | 791 } |
790 } | 792 } |
OLD | NEW |