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/browser_process.h" |
19 #include "chrome/browser/history/top_sites.h" | 19 #include "chrome/browser/history/top_sites.h" |
| 20 #include "chrome/browser/history/top_sites_factory.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/profiles/profile_info_cache.h" | 22 #include "chrome/browser/profiles/profile_info_cache.h" |
22 #include "chrome/browser/profiles/profile_manager.h" | 23 #include "chrome/browser/profiles/profile_manager.h" |
23 #include "chrome/browser/sessions/tab_restore_service.h" | 24 #include "chrome/browser/sessions/tab_restore_service.h" |
24 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 25 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
25 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
26 #include "chrome/browser/ui/browser_commands.h" | 27 #include "chrome/browser/ui/browser_commands.h" |
27 #include "chrome/browser/ui/browser_list.h" | 28 #include "chrome/browser/ui/browser_list.h" |
28 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" | 29 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" |
29 #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" |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 chrome::AddCommandObserver(browser_, it->first, this); | 419 chrome::AddCommandObserver(browser_, it->first, this); |
419 } | 420 } |
420 | 421 |
421 pref_change_registrar_.Init(browser_->profile()->GetPrefs()); | 422 pref_change_registrar_.Init(browser_->profile()->GetPrefs()); |
422 pref_change_registrar_.Add( | 423 pref_change_registrar_.Add( |
423 bookmarks::prefs::kShowBookmarkBar, | 424 bookmarks::prefs::kShowBookmarkBar, |
424 base::Bind(&GlobalMenuBarX11::OnBookmarkBarVisibilityChanged, | 425 base::Bind(&GlobalMenuBarX11::OnBookmarkBarVisibilityChanged, |
425 base::Unretained(this))); | 426 base::Unretained(this))); |
426 OnBookmarkBarVisibilityChanged(); | 427 OnBookmarkBarVisibilityChanged(); |
427 | 428 |
428 top_sites_ = profile_->GetTopSites(); | 429 top_sites_ = TopSitesFactory::GetForProfile(profile_); |
429 if (top_sites_) { | 430 if (top_sites_) { |
430 GetTopSitesData(); | 431 GetTopSitesData(); |
431 | 432 |
432 // Register as TopSitesObserver so that we can update ourselves when the | 433 // Register as TopSitesObserver so that we can update ourselves when the |
433 // TopSites changes. | 434 // TopSites changes. |
434 scoped_observer_.Add(top_sites_); | 435 scoped_observer_.Add(top_sites_.get()); |
435 } | 436 } |
436 | 437 |
437 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 438 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
438 DCHECK(profile_manager); | 439 DCHECK(profile_manager); |
439 avatar_menu_.reset(new AvatarMenu( | 440 avatar_menu_.reset(new AvatarMenu( |
440 &profile_manager->GetProfileInfoCache(), this, nullptr)); | 441 &profile_manager->GetProfileInfoCache(), this, nullptr)); |
441 avatar_menu_->RebuildMenu(); | 442 avatar_menu_->RebuildMenu(); |
442 BrowserList::AddObserver(this); | 443 BrowserList::AddObserver(this); |
443 | 444 |
444 RebuildProfilesMenu(); | 445 RebuildProfilesMenu(); |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 void GlobalMenuBarX11::OnEditProfileItemActivated(DbusmenuMenuitem* sender, | 888 void GlobalMenuBarX11::OnEditProfileItemActivated(DbusmenuMenuitem* sender, |
888 unsigned int timestamp) { | 889 unsigned int timestamp) { |
889 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(sender), kProfileId)); | 890 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(sender), kProfileId)); |
890 avatar_menu_->EditProfile(id); | 891 avatar_menu_->EditProfile(id); |
891 } | 892 } |
892 | 893 |
893 void GlobalMenuBarX11::OnCreateProfileItemActivated(DbusmenuMenuitem* sender, | 894 void GlobalMenuBarX11::OnCreateProfileItemActivated(DbusmenuMenuitem* sender, |
894 unsigned int timestamp) { | 895 unsigned int timestamp) { |
895 avatar_menu_->AddNewProfile(ProfileMetrics::ADD_NEW_USER_MENU); | 896 avatar_menu_->AddNewProfile(ProfileMetrics::ADD_NEW_USER_MENU); |
896 } | 897 } |
OLD | NEW |