Commit 78240e99 authored by Alexander Dunaev's avatar Alexander Dunaev Committed by Commit Bot

Renamed the DBus appmenu classes appropriately.

This is a follow-up to [1] that fixes one compilation issue and also
renames the classes and files so they would match the purpose better.

No changes to functionality are intended.

[1] https://crrev.com/c/2289772

Bug: 990756
Change-Id: Ifffe052bff2d6bfcad81ce5fe38e6e5ad37dcb8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2317185
Auto-Submit: Alexander Dunaev <adunaev@igalia.com>
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791382}
parent 736f5348
...@@ -3072,10 +3072,10 @@ static_library("ui") { ...@@ -3072,10 +3072,10 @@ static_library("ui") {
if (use_dbus && (use_x11 || ozone_platform_x11)) { if (use_dbus && (use_x11 || ozone_platform_x11)) {
sources += [ sources += [
"views/frame/global_menu_bar_registrar_x11.cc", "views/frame/dbus_appmenu.cc",
"views/frame/global_menu_bar_registrar_x11.h", "views/frame/dbus_appmenu.h",
"views/frame/global_menu_bar_x11.cc", "views/frame/dbus_appmenu_registrar.cc",
"views/frame/global_menu_bar_x11.h", "views/frame/dbus_appmenu_registrar.h",
] ]
defines += [ "USE_DBUS_MENU" ] defines += [ "USE_DBUS_MENU" ]
deps += [ "//ui/gfx/x" ] deps += [ "//ui/gfx/x" ]
......
...@@ -6,7 +6,7 @@ specific_include_rules = { ...@@ -6,7 +6,7 @@ specific_include_rules = {
"browser_frame_ash\.*": [ "browser_frame_ash\.*": [
"+ash", "+ash",
], ],
"global_menu_bar_.*x11\.*": [ "dbus_appmenu\.*": [
"+dbus", "+dbus",
], ],
"top_controls_slide_controller_chromeos_browsertest.cc": [ "top_controls_slide_controller_chromeos_browsertest.cc": [
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include "ui/ozone/public/ozone_platform.h" #include "ui/ozone/public/ozone_platform.h"
#include "ui/platform_window/extensions/x11_extension.h" #include "ui/platform_window/extensions/x11_extension.h"
#if defined(USE_DBUS_MENU)
namespace { namespace {
#if defined(USE_DBUS_MENU) #if defined(USE_DBUS_MENU)
...@@ -33,6 +35,8 @@ bool CreateGlobalMenuBar() { ...@@ -33,6 +35,8 @@ bool CreateGlobalMenuBar() {
} // namespace } // namespace
#endif // defined(USE_DBUS_MENU)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// BrowserDesktopWindowTreeHostLinux, public: // BrowserDesktopWindowTreeHostLinux, public:
...@@ -96,17 +100,16 @@ void BrowserDesktopWindowTreeHostLinux::Init( ...@@ -96,17 +100,16 @@ void BrowserDesktopWindowTreeHostLinux::Init(
#if defined(USE_DBUS_MENU) #if defined(USE_DBUS_MENU)
// We have now created our backing X11 window. We now need to (possibly) // We have now created our backing X11 window. We now need to (possibly)
// alert the desktop environment that there's a menu bar attached to it. // alert the desktop environment that there's a menu bar attached to it.
if (CreateGlobalMenuBar()) { if (CreateGlobalMenuBar()) {
global_menu_bar_x11_ = std::make_unique<GlobalMenuBarX11>( dbus_appmenu_ =
browser_view_, GetAcceleratedWidget()); std::make_unique<DbusAppmenu>(browser_view_, GetAcceleratedWidget());
} }
#endif #endif
} }
void BrowserDesktopWindowTreeHostLinux::CloseNow() { void BrowserDesktopWindowTreeHostLinux::CloseNow() {
#if defined(USE_DBUS_MENU) #if defined(USE_DBUS_MENU)
global_menu_bar_x11_.reset(); dbus_appmenu_.reset();
#endif #endif
DesktopWindowTreeHostLinuxImpl::CloseNow(); DesktopWindowTreeHostLinuxImpl::CloseNow();
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "chrome/browser/ui/views/frame/browser_desktop_window_tree_host.h" #include "chrome/browser/ui/views/frame/browser_desktop_window_tree_host.h"
#if defined(USE_DBUS_MENU) #if defined(USE_DBUS_MENU)
#include "chrome/browser/ui/views/frame/global_menu_bar_x11.h" // nogncheck #include "chrome/browser/ui/views/frame/dbus_appmenu.h" // nogncheck
#endif #endif
#if defined(USE_X11) #if defined(USE_X11)
...@@ -70,7 +70,7 @@ class BrowserDesktopWindowTreeHostLinux ...@@ -70,7 +70,7 @@ class BrowserDesktopWindowTreeHostLinux
// Each browser frame maintains its own menu bar object because the lower // Each browser frame maintains its own menu bar object because the lower
// level dbus protocol associates a xid to a menu bar; we can't map multiple // level dbus protocol associates a xid to a menu bar; we can't map multiple
// xids to the same menu bar. // xids to the same menu bar.
std::unique_ptr<GlobalMenuBarX11> global_menu_bar_x11_; std::unique_ptr<DbusAppmenu> dbus_appmenu_;
#endif #endif
DISALLOW_COPY_AND_ASSIGN(BrowserDesktopWindowTreeHostLinux); DISALLOW_COPY_AND_ASSIGN(BrowserDesktopWindowTreeHostLinux);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/ui/views/frame/global_menu_bar_x11.h" #include "chrome/browser/ui/views/frame/dbus_appmenu.h"
#include <dlfcn.h> #include <dlfcn.h>
#include <glib-object.h> #include <glib-object.h>
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_live_tab_context.h" #include "chrome/browser/ui/browser_live_tab_context.h"
#include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.h" #include "chrome/browser/ui/views/frame/dbus_appmenu_registrar.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/bookmarks/common/bookmark_pref_names.h" #include "components/bookmarks/common/bookmark_pref_names.h"
#include "components/history/core/browser/top_sites.h" #include "components/history/core/browser/top_sites.h"
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
#include "ui/gfx/text_elider.h" #include "ui/gfx/text_elider.h"
// A line in the static menu definitions. // A line in the static menu definitions.
struct GlobalMenuBarCommand { struct DbusAppmenuCommand {
int command; int command;
int str_id; int str_id;
}; };
...@@ -80,7 +80,7 @@ enum ReservedCommandId { ...@@ -80,7 +80,7 @@ enum ReservedCommandId {
kFirstUnreservedCommandId kFirstUnreservedCommandId
}; };
constexpr GlobalMenuBarCommand kFileMenu[] = { constexpr DbusAppmenuCommand kFileMenu[] = {
{IDC_NEW_TAB, IDS_NEW_TAB}, {IDC_NEW_TAB, IDS_NEW_TAB},
{IDC_NEW_WINDOW, IDS_NEW_WINDOW}, {IDC_NEW_WINDOW, IDS_NEW_WINDOW},
{IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW}, {IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW},
...@@ -95,7 +95,7 @@ constexpr GlobalMenuBarCommand kFileMenu[] = { ...@@ -95,7 +95,7 @@ constexpr GlobalMenuBarCommand kFileMenu[] = {
{IDC_PRINT, IDS_PRINT}, {IDC_PRINT, IDS_PRINT},
{kMenuEnd}}; {kMenuEnd}};
constexpr GlobalMenuBarCommand kEditMenu[] = {{IDC_CUT, IDS_CUT}, constexpr DbusAppmenuCommand kEditMenu[] = {{IDC_CUT, IDS_CUT},
{IDC_COPY, IDS_COPY}, {IDC_COPY, IDS_COPY},
{IDC_PASTE, IDS_PASTE}, {IDC_PASTE, IDS_PASTE},
{kSeparator}, {kSeparator},
...@@ -104,7 +104,7 @@ constexpr GlobalMenuBarCommand kEditMenu[] = {{IDC_CUT, IDS_CUT}, ...@@ -104,7 +104,7 @@ constexpr GlobalMenuBarCommand kEditMenu[] = {{IDC_CUT, IDS_CUT},
{IDC_OPTIONS, IDS_PREFERENCES}, {IDC_OPTIONS, IDS_PREFERENCES},
{kMenuEnd}}; {kMenuEnd}};
constexpr GlobalMenuBarCommand kViewMenu[] = { constexpr DbusAppmenuCommand kViewMenu[] = {
{IDC_SHOW_BOOKMARK_BAR, IDS_SHOW_BOOKMARK_BAR}, {IDC_SHOW_BOOKMARK_BAR, IDS_SHOW_BOOKMARK_BAR},
{kSeparator}, {kSeparator},
{IDC_STOP, IDS_STOP_MENU_LINUX}, {IDC_STOP, IDS_STOP_MENU_LINUX},
...@@ -116,7 +116,7 @@ constexpr GlobalMenuBarCommand kViewMenu[] = { ...@@ -116,7 +116,7 @@ constexpr GlobalMenuBarCommand kViewMenu[] = {
{IDC_ZOOM_MINUS, IDS_TEXT_SMALLER_LINUX}, {IDC_ZOOM_MINUS, IDS_TEXT_SMALLER_LINUX},
{kMenuEnd}}; {kMenuEnd}};
constexpr GlobalMenuBarCommand kHistoryMenu[] = { constexpr DbusAppmenuCommand kHistoryMenu[] = {
{IDC_HOME, IDS_HISTORY_HOME_LINUX}, {IDC_HOME, IDS_HISTORY_HOME_LINUX},
{IDC_BACK, IDS_HISTORY_BACK_LINUX}, {IDC_BACK, IDS_HISTORY_BACK_LINUX},
{IDC_FORWARD, IDS_HISTORY_FORWARD_LINUX}, {IDC_FORWARD, IDS_HISTORY_FORWARD_LINUX},
...@@ -128,7 +128,7 @@ constexpr GlobalMenuBarCommand kHistoryMenu[] = { ...@@ -128,7 +128,7 @@ constexpr GlobalMenuBarCommand kHistoryMenu[] = {
{IDC_SHOW_HISTORY, IDS_HISTORY_SHOWFULLHISTORY_LINK}, {IDC_SHOW_HISTORY, IDS_HISTORY_SHOWFULLHISTORY_LINK},
{kMenuEnd}}; {kMenuEnd}};
constexpr GlobalMenuBarCommand kToolsMenu[] = { constexpr DbusAppmenuCommand kToolsMenu[] = {
{IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS}, {IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS},
{IDC_SHOW_HISTORY, IDS_HISTORY_SHOW_HISTORY}, {IDC_SHOW_HISTORY, IDS_HISTORY_SHOW_HISTORY},
{IDC_MANAGE_EXTENSIONS, IDS_SHOW_EXTENSIONS}, {IDC_MANAGE_EXTENSIONS, IDS_SHOW_EXTENSIONS},
...@@ -143,13 +143,13 @@ constexpr GlobalMenuBarCommand kToolsMenu[] = { ...@@ -143,13 +143,13 @@ constexpr GlobalMenuBarCommand kToolsMenu[] = {
{IDC_DEV_TOOLS_DEVICES, IDS_DEV_TOOLS_DEVICES}, {IDC_DEV_TOOLS_DEVICES, IDS_DEV_TOOLS_DEVICES},
{kMenuEnd}}; {kMenuEnd}};
constexpr GlobalMenuBarCommand kProfilesMenu[] = { constexpr DbusAppmenuCommand kProfilesMenu[] = {
{kSeparator}, {kSeparator},
{kTagProfileEdit, IDS_PROFILES_MANAGE_BUTTON_LABEL}, {kTagProfileEdit, IDS_PROFILES_MANAGE_BUTTON_LABEL},
{kTagProfileCreate, IDS_PROFILES_CREATE_BUTTON_LABEL}, {kTagProfileCreate, IDS_PROFILES_CREATE_BUTTON_LABEL},
{kMenuEnd}}; {kMenuEnd}};
constexpr GlobalMenuBarCommand kHelpMenu[] = { constexpr DbusAppmenuCommand kHelpMenu[] = {
#if BUILDFLAG(GOOGLE_CHROME_BRANDING) #if BUILDFLAG(GOOGLE_CHROME_BRANDING)
{IDC_FEEDBACK, IDS_FEEDBACK}, {IDC_FEEDBACK, IDS_FEEDBACK},
#endif #endif
...@@ -180,7 +180,7 @@ std::vector<std::pair<ui::MenuModel*, int>> FindMenuItemsForCommand( ...@@ -180,7 +180,7 @@ std::vector<std::pair<ui::MenuModel*, int>> FindMenuItemsForCommand(
} // namespace } // namespace
struct GlobalMenuBarX11::HistoryItem { struct DbusAppmenu::HistoryItem {
HistoryItem() : session_id(SessionID::InvalidValue()) {} HistoryItem() : session_id(SessionID::InvalidValue()) {}
// The title for the menu item. // The title for the menu item.
...@@ -196,7 +196,7 @@ struct GlobalMenuBarX11::HistoryItem { ...@@ -196,7 +196,7 @@ struct GlobalMenuBarX11::HistoryItem {
SessionID session_id; SessionID session_id;
// If the HistoryItem is a window, this will be the vector of tabs. Note // If the HistoryItem is a window, this will be the vector of tabs. Note
// that this is a list of weak references. GlobalMenuBarX11::history_items_ // that this is a list of weak references. DbusAppmenu::history_items_
// is the owner of all items. If it is not a window, then the entry is a // is the owner of all items. If it is not a window, then the entry is a
// single page and the vector will be empty. // single page and the vector will be empty.
std::vector<HistoryItem*> tabs; std::vector<HistoryItem*> tabs;
...@@ -205,19 +205,18 @@ struct GlobalMenuBarX11::HistoryItem { ...@@ -205,19 +205,18 @@ struct GlobalMenuBarX11::HistoryItem {
DISALLOW_COPY_AND_ASSIGN(HistoryItem); DISALLOW_COPY_AND_ASSIGN(HistoryItem);
}; };
GlobalMenuBarX11::GlobalMenuBarX11(BrowserView* browser_view, DbusAppmenu::DbusAppmenu(BrowserView* browser_view, uint32_t browser_frame_id)
uint32_t browser_frame_xid)
: browser_(browser_view->browser()), : browser_(browser_view->browser()),
profile_(browser_->profile()), profile_(browser_->profile()),
browser_view_(browser_view), browser_view_(browser_view),
browser_frame_xid_(browser_frame_xid), browser_frame_id_(browser_frame_id),
tab_restore_service_(nullptr), tab_restore_service_(nullptr),
last_command_id_(kFirstUnreservedCommandId - 1) { last_command_id_(kFirstUnreservedCommandId - 1) {
GlobalMenuBarRegistrarX11::GetInstance()->OnMenuBarCreated(this); DbusAppmenuRegistrar::GetInstance()->OnMenuBarCreated(this);
} }
GlobalMenuBarX11::~GlobalMenuBarX11() { DbusAppmenu::~DbusAppmenu() {
auto* registrar = GlobalMenuBarRegistrarX11::GetInstance(); auto* registrar = DbusAppmenuRegistrar::GetInstance();
registrar->OnMenuBarDestroyed(this); registrar->OnMenuBarDestroyed(this);
if (!initialized_) if (!initialized_)
...@@ -236,7 +235,7 @@ GlobalMenuBarX11::~GlobalMenuBarX11() { ...@@ -236,7 +235,7 @@ GlobalMenuBarX11::~GlobalMenuBarX11() {
BrowserList::RemoveObserver(this); BrowserList::RemoveObserver(this);
} }
void GlobalMenuBarX11::Initialize(DbusMenu::InitializedCallback callback) { void DbusAppmenu::Initialize(DbusMenu::InitializedCallback callback) {
DCHECK(!initialized_); DCHECK(!initialized_);
initialized_ = true; initialized_ = true;
...@@ -255,7 +254,7 @@ void GlobalMenuBarX11::Initialize(DbusMenu::InitializedCallback callback) { ...@@ -255,7 +254,7 @@ void GlobalMenuBarX11::Initialize(DbusMenu::InitializedCallback callback) {
pref_change_registrar_.Init(browser_->profile()->GetPrefs()); pref_change_registrar_.Init(browser_->profile()->GetPrefs());
pref_change_registrar_.Add( pref_change_registrar_.Add(
bookmarks::prefs::kShowBookmarkBar, bookmarks::prefs::kShowBookmarkBar,
base::Bind(&GlobalMenuBarX11::OnBookmarkBarVisibilityChanged, base::Bind(&DbusAppmenu::OnBookmarkBarVisibilityChanged,
base::Unretained(this))); base::Unretained(this)));
top_sites_ = TopSitesFactory::GetForProfile(profile_); top_sites_ = TopSitesFactory::GetForProfile(profile_);
...@@ -278,19 +277,19 @@ void GlobalMenuBarX11::Initialize(DbusMenu::InitializedCallback callback) { ...@@ -278,19 +277,19 @@ void GlobalMenuBarX11::Initialize(DbusMenu::InitializedCallback callback) {
RebuildProfilesMenu(); RebuildProfilesMenu();
menu_service_ = std::make_unique<DbusMenu>( menu_service_ = std::make_unique<DbusMenu>(
GlobalMenuBarRegistrarX11::GetInstance()->bus()->GetExportedObject( DbusAppmenuRegistrar::GetInstance()->bus()->GetExportedObject(
dbus::ObjectPath(GetPath())), dbus::ObjectPath(GetPath())),
std::move(callback)); std::move(callback));
menu_service_->SetModel(root_menu_.get(), false); menu_service_->SetModel(root_menu_.get(), false);
} }
std::string GlobalMenuBarX11::GetPath() const { std::string DbusAppmenu::GetPath() const {
return base::StringPrintf("/com/canonical/menu/%X", browser_frame_xid_); return base::StringPrintf("/com/canonical/menu/%X", browser_frame_id_);
} }
ui::SimpleMenuModel* GlobalMenuBarX11::BuildStaticMenu( ui::SimpleMenuModel* DbusAppmenu::BuildStaticMenu(
int string_id, int string_id,
const GlobalMenuBarCommand* commands) { const DbusAppmenuCommand* commands) {
toplevel_menus_.push_back(std::make_unique<ui::SimpleMenuModel>(this)); toplevel_menus_.push_back(std::make_unique<ui::SimpleMenuModel>(this));
ui::SimpleMenuModel* menu = toplevel_menus_.back().get(); ui::SimpleMenuModel* menu = toplevel_menus_.back().get();
for (; commands->command != kMenuEnd; commands++) { for (; commands->command != kMenuEnd; commands++) {
...@@ -320,8 +319,7 @@ ui::SimpleMenuModel* GlobalMenuBarX11::BuildStaticMenu( ...@@ -320,8 +319,7 @@ ui::SimpleMenuModel* GlobalMenuBarX11::BuildStaticMenu(
return menu; return menu;
} }
std::unique_ptr<GlobalMenuBarX11::HistoryItem> std::unique_ptr<DbusAppmenu::HistoryItem> DbusAppmenu::HistoryItemForTab(
GlobalMenuBarX11::HistoryItemForTab(
const sessions::TabRestoreService::Tab& entry) { const sessions::TabRestoreService::Tab& entry) {
const sessions::SerializedNavigationEntry& current_navigation = const sessions::SerializedNavigationEntry& current_navigation =
entry.navigations.at(entry.current_navigation_index); entry.navigations.at(entry.current_navigation_index);
...@@ -332,7 +330,7 @@ GlobalMenuBarX11::HistoryItemForTab( ...@@ -332,7 +330,7 @@ GlobalMenuBarX11::HistoryItemForTab(
return item; return item;
} }
void GlobalMenuBarX11::AddHistoryItemToMenu(std::unique_ptr<HistoryItem> item, void DbusAppmenu::AddHistoryItemToMenu(std::unique_ptr<HistoryItem> item,
ui::SimpleMenuModel* menu, ui::SimpleMenuModel* menu,
int index) { int index) {
base::string16 title = item->title; base::string16 title = item->title;
...@@ -347,14 +345,14 @@ void GlobalMenuBarX11::AddHistoryItemToMenu(std::unique_ptr<HistoryItem> item, ...@@ -347,14 +345,14 @@ void GlobalMenuBarX11::AddHistoryItemToMenu(std::unique_ptr<HistoryItem> item,
history_items_[command_id] = std::move(item); history_items_[command_id] = std::move(item);
} }
void GlobalMenuBarX11::GetTopSitesData() { void DbusAppmenu::GetTopSitesData() {
DCHECK(top_sites_); DCHECK(top_sites_);
top_sites_->GetMostVisitedURLs(base::BindOnce( top_sites_->GetMostVisitedURLs(base::BindOnce(
&GlobalMenuBarX11::OnTopSitesReceived, weak_ptr_factory_.GetWeakPtr())); &DbusAppmenu::OnTopSitesReceived, weak_ptr_factory_.GetWeakPtr()));
} }
void GlobalMenuBarX11::OnTopSitesReceived( void DbusAppmenu::OnTopSitesReceived(
const history::MostVisitedURLList& visited_list) { const history::MostVisitedURLList& visited_list) {
int index = ClearHistoryMenuSection(kTagMostVisited); int index = ClearHistoryMenuSection(kTagMostVisited);
...@@ -374,12 +372,12 @@ void GlobalMenuBarX11::OnTopSitesReceived( ...@@ -374,12 +372,12 @@ void GlobalMenuBarX11::OnTopSitesReceived(
menu_service_->MenuLayoutUpdated(history_menu_); menu_service_->MenuLayoutUpdated(history_menu_);
} }
void GlobalMenuBarX11::OnBookmarkBarVisibilityChanged() { void DbusAppmenu::OnBookmarkBarVisibilityChanged() {
menu_service_->MenuItemsPropertiesUpdated( menu_service_->MenuItemsPropertiesUpdated(
FindMenuItemsForCommand(root_menu_.get(), IDC_SHOW_BOOKMARK_BAR)); FindMenuItemsForCommand(root_menu_.get(), IDC_SHOW_BOOKMARK_BAR));
} }
void GlobalMenuBarX11::RebuildProfilesMenu() { void DbusAppmenu::RebuildProfilesMenu() {
while (profiles_menu_->GetTypeAt(0) != ui::MenuModel::TYPE_SEPARATOR) while (profiles_menu_->GetTypeAt(0) != ui::MenuModel::TYPE_SEPARATOR)
profiles_menu_->RemoveItemAt(0); profiles_menu_->RemoveItemAt(0);
profile_commands_.clear(); profile_commands_.clear();
...@@ -405,7 +403,7 @@ void GlobalMenuBarX11::RebuildProfilesMenu() { ...@@ -405,7 +403,7 @@ void GlobalMenuBarX11::RebuildProfilesMenu() {
menu_service_->MenuLayoutUpdated(profiles_menu_); menu_service_->MenuLayoutUpdated(profiles_menu_);
} }
int GlobalMenuBarX11::ClearHistoryMenuSection(int header_command_id) { int DbusAppmenu::ClearHistoryMenuSection(int header_command_id) {
int index = 0; int index = 0;
while (history_menu_->GetCommandIdAt(index++) != header_command_id) { while (history_menu_->GetCommandIdAt(index++) != header_command_id) {
} }
...@@ -416,7 +414,7 @@ int GlobalMenuBarX11::ClearHistoryMenuSection(int header_command_id) { ...@@ -416,7 +414,7 @@ int GlobalMenuBarX11::ClearHistoryMenuSection(int header_command_id) {
return index; return index;
} }
void GlobalMenuBarX11::RegisterCommandObserver(int command) { void DbusAppmenu::RegisterCommandObserver(int command) {
if (command > kLastChromeCommand) if (command > kLastChromeCommand)
return; return;
...@@ -429,7 +427,7 @@ void GlobalMenuBarX11::RegisterCommandObserver(int command) { ...@@ -429,7 +427,7 @@ void GlobalMenuBarX11::RegisterCommandObserver(int command) {
chrome::AddCommandObserver(browser_, command, this); chrome::AddCommandObserver(browser_, command, this);
} }
int GlobalMenuBarX11::NextCommandId() { int DbusAppmenu::NextCommandId() {
do { do {
if (last_command_id_ == std::numeric_limits<int>::max()) if (last_command_id_ == std::numeric_limits<int>::max())
last_command_id_ = kFirstUnreservedCommandId; last_command_id_ = kFirstUnreservedCommandId;
...@@ -440,11 +438,11 @@ int GlobalMenuBarX11::NextCommandId() { ...@@ -440,11 +438,11 @@ int GlobalMenuBarX11::NextCommandId() {
return last_command_id_; return last_command_id_;
} }
void GlobalMenuBarX11::OnAvatarMenuChanged(AvatarMenu* avatar_menu) { void DbusAppmenu::OnAvatarMenuChanged(AvatarMenu* avatar_menu) {
RebuildProfilesMenu(); RebuildProfilesMenu();
} }
void GlobalMenuBarX11::OnBrowserSetLastActive(Browser* browser) { void DbusAppmenu::OnBrowserSetLastActive(Browser* browser) {
// Notify the avatar menu of the change and rebuild the menu. Note: The // Notify the avatar menu of the change and rebuild the menu. Note: The
// ActiveBrowserChanged() call needs to happen first to update the state. // ActiveBrowserChanged() call needs to happen first to update the state.
avatar_menu_->ActiveBrowserChanged(browser); avatar_menu_->ActiveBrowserChanged(browser);
...@@ -452,19 +450,19 @@ void GlobalMenuBarX11::OnBrowserSetLastActive(Browser* browser) { ...@@ -452,19 +450,19 @@ void GlobalMenuBarX11::OnBrowserSetLastActive(Browser* browser) {
RebuildProfilesMenu(); RebuildProfilesMenu();
} }
void GlobalMenuBarX11::EnabledStateChangedForCommand(int id, bool enabled) { void DbusAppmenu::EnabledStateChangedForCommand(int id, bool enabled) {
menu_service_->MenuItemsPropertiesUpdated( menu_service_->MenuItemsPropertiesUpdated(
FindMenuItemsForCommand(root_menu_.get(), id)); FindMenuItemsForCommand(root_menu_.get(), id));
} }
void GlobalMenuBarX11::TopSitesLoaded(history::TopSites* top_sites) {} void DbusAppmenu::TopSitesLoaded(history::TopSites* top_sites) {}
void GlobalMenuBarX11::TopSitesChanged(history::TopSites* top_sites, void DbusAppmenu::TopSitesChanged(history::TopSites* top_sites,
ChangeReason change_reason) { ChangeReason change_reason) {
GetTopSitesData(); GetTopSitesData();
} }
void GlobalMenuBarX11::TabRestoreServiceChanged( void DbusAppmenu::TabRestoreServiceChanged(
sessions::TabRestoreService* service) { sessions::TabRestoreService* service) {
const sessions::TabRestoreService::Entries& entries = service->entries(); const sessions::TabRestoreService::Entries& entries = service->entries();
...@@ -521,12 +519,12 @@ void GlobalMenuBarX11::TabRestoreServiceChanged( ...@@ -521,12 +519,12 @@ void GlobalMenuBarX11::TabRestoreServiceChanged(
menu_service_->MenuLayoutUpdated(history_menu_); menu_service_->MenuLayoutUpdated(history_menu_);
} }
void GlobalMenuBarX11::TabRestoreServiceDestroyed( void DbusAppmenu::TabRestoreServiceDestroyed(
sessions::TabRestoreService* service) { sessions::TabRestoreService* service) {
tab_restore_service_ = nullptr; tab_restore_service_ = nullptr;
} }
bool GlobalMenuBarX11::IsCommandIdChecked(int command_id) const { bool DbusAppmenu::IsCommandIdChecked(int command_id) const {
if (command_id == IDC_SHOW_BOOKMARK_BAR) { if (command_id == IDC_SHOW_BOOKMARK_BAR) {
return browser_->profile()->GetPrefs()->GetBoolean( return browser_->profile()->GetPrefs()->GetBoolean(
bookmarks::prefs::kShowBookmarkBar); bookmarks::prefs::kShowBookmarkBar);
...@@ -536,7 +534,7 @@ bool GlobalMenuBarX11::IsCommandIdChecked(int command_id) const { ...@@ -536,7 +534,7 @@ bool GlobalMenuBarX11::IsCommandIdChecked(int command_id) const {
return it != profile_commands_.end() && it->second == active_profile_index_; return it != profile_commands_.end() && it->second == active_profile_index_;
} }
bool GlobalMenuBarX11::IsCommandIdEnabled(int command_id) const { bool DbusAppmenu::IsCommandIdEnabled(int command_id) const {
if (command_id <= kLastChromeCommand) if (command_id <= kLastChromeCommand)
return chrome::IsCommandEnabled(browser_, command_id); return chrome::IsCommandEnabled(browser_, command_id);
// There is no active profile in Guest mode, in which case the action // There is no active profile in Guest mode, in which case the action
...@@ -546,7 +544,7 @@ bool GlobalMenuBarX11::IsCommandIdEnabled(int command_id) const { ...@@ -546,7 +544,7 @@ bool GlobalMenuBarX11::IsCommandIdEnabled(int command_id) const {
return command_id != kTagRecentlyClosed && command_id != kTagMostVisited; return command_id != kTagRecentlyClosed && command_id != kTagMostVisited;
} }
void GlobalMenuBarX11::ExecuteCommand(int command_id, int event_flags) { void DbusAppmenu::ExecuteCommand(int command_id, int event_flags) {
if (command_id <= kLastChromeCommand) { if (command_id <= kLastChromeCommand) {
chrome::ExecuteCommand(browser_, command_id); chrome::ExecuteCommand(browser_, command_id);
} else if (command_id == kTagProfileEdit) { } else if (command_id == kTagProfileEdit) {
...@@ -575,7 +573,7 @@ void GlobalMenuBarX11::ExecuteCommand(int command_id, int event_flags) { ...@@ -575,7 +573,7 @@ void GlobalMenuBarX11::ExecuteCommand(int command_id, int event_flags) {
} }
} }
void GlobalMenuBarX11::OnMenuWillShow(ui::SimpleMenuModel* source) { void DbusAppmenu::OnMenuWillShow(ui::SimpleMenuModel* source) {
if (source != history_menu_ || tab_restore_service_) if (source != history_menu_ || tab_restore_service_)
return; return;
...@@ -592,7 +590,7 @@ void GlobalMenuBarX11::OnMenuWillShow(ui::SimpleMenuModel* source) { ...@@ -592,7 +590,7 @@ void GlobalMenuBarX11::OnMenuWillShow(ui::SimpleMenuModel* source) {
TabRestoreServiceChanged(tab_restore_service_); TabRestoreServiceChanged(tab_restore_service_);
} }
bool GlobalMenuBarX11::GetAcceleratorForCommandId( bool DbusAppmenu::GetAcceleratorForCommandId(
int command_id, int command_id,
ui::Accelerator* accelerator) const { ui::Accelerator* accelerator) const {
return browser_view_->GetAccelerator(command_id, accelerator); return browser_view_->GetAccelerator(command_id, accelerator);
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_GLOBAL_MENU_BAR_X11_H_ #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_DBUS_APPMENU_H_
#define CHROME_BROWSER_UI_VIEWS_FRAME_GLOBAL_MENU_BAR_X11_H_ #define CHROME_BROWSER_UI_VIEWS_FRAME_DBUS_APPMENU_H_
#include <map> #include <map>
#include <string> #include <string>
...@@ -33,7 +33,7 @@ class Accelerator; ...@@ -33,7 +33,7 @@ class Accelerator;
class Browser; class Browser;
class BrowserView; class BrowserView;
struct GlobalMenuBarCommand; struct DbusAppmenuCommand;
class Profile; class Profile;
// Controls the Mac style menu bar on Linux desktop environments. // Controls the Mac style menu bar on Linux desktop environments.
...@@ -42,22 +42,22 @@ class Profile; ...@@ -42,22 +42,22 @@ class Profile;
// depending on the active window. Unity has been discontinued but the menu // depending on the active window. Unity has been discontinued but the menu
// survived and is usually referred to as DBus AppMenu. There is support for it // survived and is usually referred to as DBus AppMenu. There is support for it
// in KDE Plasma in form of a widget that can be inserted into a panel. // in KDE Plasma in form of a widget that can be inserted into a panel.
class GlobalMenuBarX11 : public AvatarMenuObserver, class DbusAppmenu : public AvatarMenuObserver,
public BrowserListObserver, public BrowserListObserver,
public CommandObserver, public CommandObserver,
public history::TopSitesObserver, public history::TopSitesObserver,
public sessions::TabRestoreServiceObserver, public sessions::TabRestoreServiceObserver,
public ui::SimpleMenuModel::Delegate { public ui::SimpleMenuModel::Delegate {
public: public:
GlobalMenuBarX11(BrowserView* browser_view, uint32_t browser_frame_xid); DbusAppmenu(BrowserView* browser_view, uint32_t browser_frame_id);
~GlobalMenuBarX11() override; ~DbusAppmenu() override;
void Initialize(DbusMenu::InitializedCallback callback); void Initialize(DbusMenu::InitializedCallback callback);
// Creates the object path for DbusemenuServer which is attached to |window|. // Creates the object path for DbusemenuServer which is attached to |window|.
std::string GetPath() const; std::string GetPath() const;
uint32_t browser_frame_xid() const { return browser_frame_xid_; } uint32_t browser_frame_id() const { return browser_frame_id_; }
private: private:
struct HistoryItem; struct HistoryItem;
...@@ -65,7 +65,7 @@ class GlobalMenuBarX11 : public AvatarMenuObserver, ...@@ -65,7 +65,7 @@ class GlobalMenuBarX11 : public AvatarMenuObserver,
// Creates a whole menu defined with |commands| and titled with the string // Creates a whole menu defined with |commands| and titled with the string
// |string_id|. Then appends it to |root_menu_|. // |string_id|. Then appends it to |root_menu_|.
ui::SimpleMenuModel* BuildStaticMenu(int string_id, ui::SimpleMenuModel* BuildStaticMenu(int string_id,
const GlobalMenuBarCommand* commands); const DbusAppmenuCommand* commands);
// Creates a HistoryItem from the data in |entry|. // Creates a HistoryItem from the data in |entry|.
std::unique_ptr<HistoryItem> HistoryItemForTab( std::unique_ptr<HistoryItem> HistoryItemForTab(
...@@ -134,8 +134,8 @@ class GlobalMenuBarX11 : public AvatarMenuObserver, ...@@ -134,8 +134,8 @@ class GlobalMenuBarX11 : public AvatarMenuObserver,
// as plain int (and not as x11::Window) because it is never used for any // as plain int (and not as x11::Window) because it is never used for any
// calls to the X server, but it is always used for building string paths and // calls to the X server, but it is always used for building string paths and
// messages, for which it is converted to int (see GetPath() and calls to our // messages, for which it is converted to int (see GetPath() and calls to our
// browser_frame_xid() in GlobalMenuBarRegistrarX11). // browser_frame_id() in DbusAppmenuRegistrar).
const uint32_t browser_frame_xid_; const uint32_t browser_frame_id_;
// Has Initialize() been called? // Has Initialize() been called?
bool initialized_ = false; bool initialized_ = false;
...@@ -179,9 +179,9 @@ class GlobalMenuBarX11 : public AvatarMenuObserver, ...@@ -179,9 +179,9 @@ class GlobalMenuBarX11 : public AvatarMenuObserver,
int last_command_id_; int last_command_id_;
// For callbacks may be run after destruction. // For callbacks may be run after destruction.
base::WeakPtrFactory<GlobalMenuBarX11> weak_ptr_factory_{this}; base::WeakPtrFactory<DbusAppmenu> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(GlobalMenuBarX11); DISALLOW_COPY_AND_ASSIGN(DbusAppmenu);
}; };
#endif // CHROME_BROWSER_UI_VIEWS_FRAME_GLOBAL_MENU_BAR_X11_H_ #endif // CHROME_BROWSER_UI_VIEWS_FRAME_DBUS_APPMENU_H_
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.h" #include "chrome/browser/ui/views/frame/dbus_appmenu_registrar.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/check_op.h" #include "base/check_op.h"
#include "base/notreached.h" #include "base/notreached.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "chrome/browser/ui/views/frame/global_menu_bar_x11.h" #include "chrome/browser/ui/views/frame/dbus_appmenu.h"
#include "components/dbus/thread_linux/dbus_thread_linux.h" #include "components/dbus/thread_linux/dbus_thread_linux.h"
#include "dbus/bus.h" #include "dbus/bus.h"
#include "dbus/message.h" #include "dbus/message.h"
...@@ -25,11 +25,11 @@ const char kAppMenuRegistrarInterface[] = "com.canonical.AppMenu.Registrar"; ...@@ -25,11 +25,11 @@ const char kAppMenuRegistrarInterface[] = "com.canonical.AppMenu.Registrar";
} // namespace } // namespace
// static // static
GlobalMenuBarRegistrarX11* GlobalMenuBarRegistrarX11::GetInstance() { DbusAppmenuRegistrar* DbusAppmenuRegistrar::GetInstance() {
return base::Singleton<GlobalMenuBarRegistrarX11>::get(); return base::Singleton<DbusAppmenuRegistrar>::get();
} }
void GlobalMenuBarRegistrarX11::OnMenuBarCreated(GlobalMenuBarX11* menu) { void DbusAppmenuRegistrar::OnMenuBarCreated(DbusAppmenu* menu) {
if (base::Contains(menus_, menu)) { if (base::Contains(menus_, menu)) {
NOTREACHED(); NOTREACHED();
return; return;
...@@ -39,13 +39,13 @@ void GlobalMenuBarRegistrarX11::OnMenuBarCreated(GlobalMenuBarX11* menu) { ...@@ -39,13 +39,13 @@ void GlobalMenuBarRegistrarX11::OnMenuBarCreated(GlobalMenuBarX11* menu) {
InitializeMenu(menu); InitializeMenu(menu);
} }
void GlobalMenuBarRegistrarX11::OnMenuBarDestroyed(GlobalMenuBarX11* menu) { void DbusAppmenuRegistrar::OnMenuBarDestroyed(DbusAppmenu* menu) {
DCHECK(base::Contains(menus_, menu)); DCHECK(base::Contains(menus_, menu));
if (menus_[menu] == kRegistered) { if (menus_[menu] == kRegistered) {
dbus::MethodCall method_call(kAppMenuRegistrarInterface, dbus::MethodCall method_call(kAppMenuRegistrarInterface,
"UnregisterWindow"); "UnregisterWindow");
dbus::MessageWriter writer(&method_call); dbus::MessageWriter writer(&method_call);
writer.AppendUint32(menu->browser_frame_xid()); writer.AppendUint32(menu->browser_frame_id());
registrar_proxy_->CallMethod(&method_call, registrar_proxy_->CallMethod(&method_call,
dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::DoNothing()); base::DoNothing());
...@@ -53,7 +53,7 @@ void GlobalMenuBarRegistrarX11::OnMenuBarDestroyed(GlobalMenuBarX11* menu) { ...@@ -53,7 +53,7 @@ void GlobalMenuBarRegistrarX11::OnMenuBarDestroyed(GlobalMenuBarX11* menu) {
menus_.erase(menu); menus_.erase(menu);
} }
GlobalMenuBarRegistrarX11::GlobalMenuBarRegistrarX11() { DbusAppmenuRegistrar::DbusAppmenuRegistrar() {
dbus::Bus::Options bus_options; dbus::Bus::Options bus_options;
bus_options.bus_type = dbus::Bus::SESSION; bus_options.bus_type = dbus::Bus::SESSION;
bus_options.connection_type = dbus::Bus::PRIVATE; bus_options.connection_type = dbus::Bus::PRIVATE;
...@@ -64,40 +64,39 @@ GlobalMenuBarRegistrarX11::GlobalMenuBarRegistrarX11() { ...@@ -64,40 +64,39 @@ GlobalMenuBarRegistrarX11::GlobalMenuBarRegistrarX11() {
kAppMenuRegistrarName, dbus::ObjectPath(kAppMenuRegistrarPath)); kAppMenuRegistrarName, dbus::ObjectPath(kAppMenuRegistrarPath));
dbus::Bus::ServiceOwnerChangeCallback callback = dbus::Bus::ServiceOwnerChangeCallback callback =
base::BindRepeating(&GlobalMenuBarRegistrarX11::OnNameOwnerChanged, base::BindRepeating(&DbusAppmenuRegistrar::OnNameOwnerChanged,
weak_ptr_factory_.GetWeakPtr()); weak_ptr_factory_.GetWeakPtr());
bus_->ListenForServiceOwnerChange(kAppMenuRegistrarName, callback); bus_->ListenForServiceOwnerChange(kAppMenuRegistrarName, callback);
bus_->GetServiceOwner(kAppMenuRegistrarName, callback); bus_->GetServiceOwner(kAppMenuRegistrarName, callback);
} }
GlobalMenuBarRegistrarX11::~GlobalMenuBarRegistrarX11() { DbusAppmenuRegistrar::~DbusAppmenuRegistrar() {
DCHECK(menus_.empty()); DCHECK(menus_.empty());
bus_->GetDBusTaskRunner()->PostTask( bus_->GetDBusTaskRunner()->PostTask(
FROM_HERE, base::BindOnce(&dbus::Bus::ShutdownAndBlock, bus_)); FROM_HERE, base::BindOnce(&dbus::Bus::ShutdownAndBlock, bus_));
} }
void GlobalMenuBarRegistrarX11::InitializeMenu(GlobalMenuBarX11* menu) { void DbusAppmenuRegistrar::InitializeMenu(DbusAppmenu* menu) {
DCHECK(base::Contains(menus_, menu)); DCHECK(base::Contains(menus_, menu));
DCHECK_EQ(menus_[menu], kUninitialized); DCHECK_EQ(menus_[menu], kUninitialized);
menus_[menu] = kInitializing; menus_[menu] = kInitializing;
menu->Initialize(base::BindOnce(&GlobalMenuBarRegistrarX11::OnMenuInitialized, menu->Initialize(base::BindOnce(&DbusAppmenuRegistrar::OnMenuInitialized,
weak_ptr_factory_.GetWeakPtr(), menu)); weak_ptr_factory_.GetWeakPtr(), menu));
} }
void GlobalMenuBarRegistrarX11::RegisterMenu(GlobalMenuBarX11* menu) { void DbusAppmenuRegistrar::RegisterMenu(DbusAppmenu* menu) {
DCHECK(base::Contains(menus_, menu)); DCHECK(base::Contains(menus_, menu));
DCHECK(menus_[menu] == kInitializeSucceeded || menus_[menu] == kRegistered); DCHECK(menus_[menu] == kInitializeSucceeded || menus_[menu] == kRegistered);
menus_[menu] = kRegistered; menus_[menu] = kRegistered;
dbus::MethodCall method_call(kAppMenuRegistrarInterface, "RegisterWindow"); dbus::MethodCall method_call(kAppMenuRegistrarInterface, "RegisterWindow");
dbus::MessageWriter writer(&method_call); dbus::MessageWriter writer(&method_call);
writer.AppendUint32(menu->browser_frame_xid()); writer.AppendUint32(menu->browser_frame_id());
writer.AppendObjectPath(dbus::ObjectPath(menu->GetPath())); writer.AppendObjectPath(dbus::ObjectPath(menu->GetPath()));
registrar_proxy_->CallMethod( registrar_proxy_->CallMethod(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, base::DoNothing()); &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, base::DoNothing());
} }
void GlobalMenuBarRegistrarX11::OnMenuInitialized(GlobalMenuBarX11* menu, void DbusAppmenuRegistrar::OnMenuInitialized(DbusAppmenu* menu, bool success) {
bool success) {
DCHECK(base::Contains(menus_, menu)); DCHECK(base::Contains(menus_, menu));
DCHECK(menus_[menu] == kInitializing); DCHECK(menus_[menu] == kInitializing);
menus_[menu] = success ? kInitializeSucceeded : kInitializeFailed; menus_[menu] = success ? kInitializeSucceeded : kInitializeFailed;
...@@ -105,14 +104,14 @@ void GlobalMenuBarRegistrarX11::OnMenuInitialized(GlobalMenuBarX11* menu, ...@@ -105,14 +104,14 @@ void GlobalMenuBarRegistrarX11::OnMenuInitialized(GlobalMenuBarX11* menu,
RegisterMenu(menu); RegisterMenu(menu);
} }
void GlobalMenuBarRegistrarX11::OnNameOwnerChanged( void DbusAppmenuRegistrar::OnNameOwnerChanged(
const std::string& service_owner) { const std::string& service_owner) {
service_has_owner_ = !service_owner.empty(); service_has_owner_ = !service_owner.empty();
// If the name owner changed, we need to reregister all the live menus with // If the name owner changed, we need to reregister all the live menus with
// the system. // the system.
for (const auto& pair : menus_) { for (const auto& pair : menus_) {
GlobalMenuBarX11* menu = pair.first; DbusAppmenu* menu = pair.first;
switch (pair.second) { switch (pair.second) {
case kUninitialized: case kUninitialized:
if (service_has_owner_) if (service_has_owner_)
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_GLOBAL_MENU_BAR_REGISTRAR_X11_H_ #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_DBUS_APPMENU_REGISTRAR_H_
#define CHROME_BROWSER_UI_VIEWS_FRAME_GLOBAL_MENU_BAR_REGISTRAR_X11_H_ #define CHROME_BROWSER_UI_VIEWS_FRAME_DBUS_APPMENU_REGISTRAR_H_
#include <map> #include <map>
#include <string> #include <string>
...@@ -18,25 +18,25 @@ class Bus; ...@@ -18,25 +18,25 @@ class Bus;
class ObjectProxy; class ObjectProxy;
} // namespace dbus } // namespace dbus
class GlobalMenuBarX11; class DbusAppmenu;
// Advertises our menu bars to com.canonical.AppMenu.Registrar. // Advertises our menu bars to com.canonical.AppMenu.Registrar.
// //
// GlobalMenuBarRegistrarX11 is responsible for managing the dbus::Bus shared by // DbusAppmenuRegistrar is responsible for managing the dbus::Bus shared by
// each menu. We need a separate object to own the dbus channel and to // each menu. We need a separate object to own the dbus channel and to
// register/unregister the mapping between a menu and the com.canonical.dbusmenu // register/unregister the mapping between a menu and the com.canonical.dbusmenu
// instance we are offering. // instance we are offering.
class GlobalMenuBarRegistrarX11 { class DbusAppmenuRegistrar {
public: public:
static GlobalMenuBarRegistrarX11* GetInstance(); static DbusAppmenuRegistrar* GetInstance();
void OnMenuBarCreated(GlobalMenuBarX11* menu); void OnMenuBarCreated(DbusAppmenu* menu);
void OnMenuBarDestroyed(GlobalMenuBarX11* menu); void OnMenuBarDestroyed(DbusAppmenu* menu);
dbus::Bus* bus() { return bus_.get(); } dbus::Bus* bus() { return bus_.get(); }
private: private:
friend struct base::DefaultSingletonTraits<GlobalMenuBarRegistrarX11>; friend struct base::DefaultSingletonTraits<DbusAppmenuRegistrar>;
enum MenuState { enum MenuState {
// Initialize() hasn't been called. // Initialize() hasn't been called.
...@@ -56,15 +56,15 @@ class GlobalMenuBarRegistrarX11 { ...@@ -56,15 +56,15 @@ class GlobalMenuBarRegistrarX11 {
kRegistered, kRegistered,
}; };
GlobalMenuBarRegistrarX11(); DbusAppmenuRegistrar();
~GlobalMenuBarRegistrarX11(); ~DbusAppmenuRegistrar();
void InitializeMenu(GlobalMenuBarX11* menu); void InitializeMenu(DbusAppmenu* menu);
// Sends the actual message. // Sends the actual message.
void RegisterMenu(GlobalMenuBarX11* menu); void RegisterMenu(DbusAppmenu* menu);
void OnMenuInitialized(GlobalMenuBarX11* menu, bool success); void OnMenuInitialized(DbusAppmenu* menu, bool success);
void OnNameOwnerChanged(const std::string& service_owner); void OnNameOwnerChanged(const std::string& service_owner);
...@@ -74,11 +74,11 @@ class GlobalMenuBarRegistrarX11 { ...@@ -74,11 +74,11 @@ class GlobalMenuBarRegistrarX11 {
// Maps menus to flags that indicate if the menu has been successfully // Maps menus to flags that indicate if the menu has been successfully
// initialized. // initialized.
std::map<GlobalMenuBarX11*, MenuState> menus_; std::map<DbusAppmenu*, MenuState> menus_;
base::WeakPtrFactory<GlobalMenuBarRegistrarX11> weak_ptr_factory_{this}; base::WeakPtrFactory<DbusAppmenuRegistrar> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(GlobalMenuBarRegistrarX11); DISALLOW_COPY_AND_ASSIGN(DbusAppmenuRegistrar);
}; };
#endif // CHROME_BROWSER_UI_VIEWS_FRAME_GLOBAL_MENU_BAR_REGISTRAR_X11_H_ #endif // CHROME_BROWSER_UI_VIEWS_FRAME_DBUS_APPMENU_REGISTRAR_H_
...@@ -45,7 +45,7 @@ PrefNotifierImpl::~PrefNotifierImpl() { ...@@ -45,7 +45,7 @@ PrefNotifierImpl::~PrefNotifierImpl() {
// preferences which are known to have subscriptions outliving the // preferences which are known to have subscriptions outliving the
// profile. // profile.
if ( if (
// For GlobalMenuBarX11, crbug.com/946668 // For DbusAppmenu, crbug.com/946668
pref_name == "bookmark_bar.show_on_all_tabs" || pref_name == "bookmark_bar.show_on_all_tabs" ||
// For BrowserWindowPropertyManager, crbug.com/942491 // For BrowserWindowPropertyManager, crbug.com/942491
pref_name == "profile.icon_version" || pref_name == "profile.icon_version" ||
......
...@@ -181,8 +181,8 @@ src:*ui/gtk/unity_service.cc ...@@ -181,8 +181,8 @@ src:*ui/gtk/unity_service.cc
src:*components/cronet/native/* src:*components/cronet/native/*
src:*third_party/breakpad/breakpad/src/client/linux/handler/exception_handler_unittest.cc src:*third_party/breakpad/breakpad/src/client/linux/handler/exception_handler_unittest.cc
# chrome/browser/ui/views/frame/global_menu_bar_x11.cc # chrome/browser/ui/views/frame/dbus_appmenu.cc
fun:*GlobalMenuBarX11* fun:*dbus_appmenu*
# third_party/skia/include/gpu/gl/GrGLFunctions.h # third_party/skia/include/gpu/gl/GrGLFunctions.h
fun:*GrGLFunction* fun:*GrGLFunction*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment