Commit 02832fc2 authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

StatusIcon: Rename StatusIconLinuxX11 to StatusIconButtonLinux

To reflect the real functionality of that class, rename it to
the StatusIconButtonLinux instead.

Bug: 1043089
Change-Id: I14089a95dd7c71ed42585fab5dbb36865df0250f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2015088Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#735231}
parent f0aca2de
...@@ -2577,8 +2577,8 @@ jumbo_static_library("ui") { ...@@ -2577,8 +2577,8 @@ jumbo_static_library("ui") {
"views/javascript_app_modal_dialog_views_x11.h", "views/javascript_app_modal_dialog_views_x11.h",
"views/javascript_app_modal_event_blocker_x11.cc", "views/javascript_app_modal_event_blocker_x11.cc",
"views/javascript_app_modal_event_blocker_x11.h", "views/javascript_app_modal_event_blocker_x11.h",
"views/status_icons/status_icon_linux_x11.cc", "views/status_icons/status_icon_button_linux.cc",
"views/status_icons/status_icon_linux_x11.h", "views/status_icons/status_icon_button_linux.h",
] ]
configs += [ "//build/config/linux:x11" ] configs += [ "//build/config/linux:x11" ]
deps += [ deps += [
......
...@@ -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/status_icons/status_icon_linux_x11.h" #include "chrome/browser/ui/views/status_icons/status_icon_button_linux.h"
#include <limits> #include <limits>
#include <memory> #include <memory>
...@@ -35,23 +35,23 @@ class StatusIconWidget : public views::Widget { ...@@ -35,23 +35,23 @@ class StatusIconWidget : public views::Widget {
} // namespace } // namespace
StatusIconLinuxX11::StatusIconLinuxX11() : Button(this) {} StatusIconButtonLinux::StatusIconButtonLinux() : Button(this) {}
StatusIconLinuxX11::~StatusIconLinuxX11() = default; StatusIconButtonLinux::~StatusIconButtonLinux() = default;
void StatusIconLinuxX11::SetIcon(const gfx::ImageSkia& image) { void StatusIconButtonLinux::SetIcon(const gfx::ImageSkia& image) {
SchedulePaint(); SchedulePaint();
} }
void StatusIconLinuxX11::SetToolTip(const base::string16& tool_tip) { void StatusIconButtonLinux::SetToolTip(const base::string16& tool_tip) {
SetTooltipText(tool_tip); SetTooltipText(tool_tip);
} }
void StatusIconLinuxX11::UpdatePlatformContextMenu(ui::MenuModel* model) { void StatusIconButtonLinux::UpdatePlatformContextMenu(ui::MenuModel* model) {
// Nothing to do. // Nothing to do.
} }
void StatusIconLinuxX11::OnSetDelegate() { void StatusIconButtonLinux::OnSetDelegate() {
widget_ = std::make_unique<StatusIconWidget>(); widget_ = std::make_unique<StatusIconWidget>();
auto native_widget = auto native_widget =
...@@ -102,7 +102,7 @@ void StatusIconLinuxX11::OnSetDelegate() { ...@@ -102,7 +102,7 @@ void StatusIconLinuxX11::OnSetDelegate() {
set_context_menu_controller(this); set_context_menu_controller(this);
} }
void StatusIconLinuxX11::ShowContextMenuForViewImpl( void StatusIconButtonLinux::ShowContextMenuForViewImpl(
View* source, View* source,
const gfx::Point& point, const gfx::Point& point,
ui::MenuSourceType source_type) { ui::MenuSourceType source_type) {
...@@ -116,11 +116,12 @@ void StatusIconLinuxX11::ShowContextMenuForViewImpl( ...@@ -116,11 +116,12 @@ void StatusIconLinuxX11::ShowContextMenuForViewImpl(
views::MenuAnchorPosition::kTopLeft, source_type); views::MenuAnchorPosition::kTopLeft, source_type);
} }
void StatusIconLinuxX11::ButtonPressed(Button* sender, const ui::Event& event) { void StatusIconButtonLinux::ButtonPressed(Button* sender,
const ui::Event& event) {
delegate_->OnClick(); delegate_->OnClick();
} }
void StatusIconLinuxX11::PaintButtonContents(gfx::Canvas* canvas) { void StatusIconButtonLinux::PaintButtonContents(gfx::Canvas* canvas) {
gfx::ScopedCanvas scoped_canvas(canvas); gfx::ScopedCanvas scoped_canvas(canvas);
canvas->UndoDeviceScaleFactor(); canvas->UndoDeviceScaleFactor();
...@@ -146,11 +147,11 @@ void StatusIconLinuxX11::PaintButtonContents(gfx::Canvas* canvas) { ...@@ -146,11 +147,11 @@ void StatusIconLinuxX11::PaintButtonContents(gfx::Canvas* canvas) {
image.width(), image.height(), true, flags); image.width(), image.height(), true, flags);
} }
void StatusIconLinuxX11::OnWindowMapped(unsigned long xid) { void StatusIconButtonLinux::OnWindowMapped(unsigned long xid) {
// The window gets mapped by the system tray implementation. Show() the // The window gets mapped by the system tray implementation. Show() the
// window (which will be a no-op) so aura is convinced the window is mapped // window (which will be a no-op) so aura is convinced the window is mapped
// and will begin drawing frames. // and will begin drawing frames.
widget_->Show(); widget_->Show();
} }
void StatusIconLinuxX11::OnWindowUnmapped(unsigned long xid) {} void StatusIconButtonLinux::OnWindowUnmapped(unsigned long xid) {}
...@@ -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_STATUS_ICONS_STATUS_ICON_LINUX_X11_H_ #ifndef CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_ICON_BUTTON_LINUX_H_
#define CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_ICON_LINUX_X11_H_ #define CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_ICON_BUTTON_LINUX_H_
#include <memory> #include <memory>
...@@ -19,16 +19,17 @@ namespace aura { ...@@ -19,16 +19,17 @@ namespace aura {
class WindowTreeHost; class WindowTreeHost;
} }
// A status icon that uses the XEmbed protocol. // A button that is internally mapped as a status icon if the underlaying
// https://standards.freedesktop.org/xembed-spec/xembed-spec-latest.html // platform supports that kind of windows. Otherwise, calls
class StatusIconLinuxX11 : public views::StatusIconLinux, // OnImplInitializationFailed.
public views::Button, class StatusIconButtonLinux : public views::StatusIconLinux,
public views::ContextMenuController, public views::Button,
public views::ButtonListener, public views::ContextMenuController,
public views::DesktopWindowTreeHostObserverX11 { public views::ButtonListener,
public views::DesktopWindowTreeHostObserverX11 {
public: public:
StatusIconLinuxX11(); StatusIconButtonLinux();
~StatusIconLinuxX11() override; ~StatusIconButtonLinux() override;
// views::StatusIcon: // views::StatusIcon:
void SetIcon(const gfx::ImageSkia& image) override; void SetIcon(const gfx::ImageSkia& image) override;
...@@ -58,7 +59,7 @@ class StatusIconLinuxX11 : public views::StatusIconLinux, ...@@ -58,7 +59,7 @@ class StatusIconLinuxX11 : public views::StatusIconLinux,
std::unique_ptr<views::MenuRunner> menu_runner_; std::unique_ptr<views::MenuRunner> menu_runner_;
DISALLOW_COPY_AND_ASSIGN(StatusIconLinuxX11); DISALLOW_COPY_AND_ASSIGN(StatusIconButtonLinux);
}; };
#endif // CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_ICON_LINUX_X11_H_ #endif // CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_ICON_BUTTON_LINUX_H_
...@@ -16,8 +16,10 @@ ...@@ -16,8 +16,10 @@
#include "chrome/browser/ui/views/status_icons/status_icon_linux_dbus.h" #include "chrome/browser/ui/views/status_icons/status_icon_linux_dbus.h"
#endif #endif
// TODO(msisov): remove USE_X11 when the StatusIconButtonLinux stops using
// DesktopWindowTreeHostObserverX11.
#if defined(USE_X11) #if defined(USE_X11)
#include "chrome/browser/ui/views/status_icons/status_icon_linux_x11.h" #include "chrome/browser/ui/views/status_icons/status_icon_button_linux.h"
#endif #endif
namespace { namespace {
...@@ -122,10 +124,12 @@ void StatusIconLinuxWrapper::OnImplInitializationFailed() { ...@@ -122,10 +124,12 @@ void StatusIconLinuxWrapper::OnImplInitializationFailed() {
switch (status_icon_type_) { switch (status_icon_type_) {
case kTypeDbus: case kTypeDbus:
#if defined(USE_X11) #if defined(USE_X11)
#if defined(USE_DBUS)
status_icon_dbus_.reset(); status_icon_dbus_.reset();
status_icon_linux_ = std::make_unique<StatusIconLinuxX11>(); #endif
status_icon_linux_ = std::make_unique<StatusIconButtonLinux>();
status_icon_ = status_icon_linux_.get(); status_icon_ = status_icon_linux_.get();
status_icon_type_ = kTypeX11; status_icon_type_ = kTypeWindowed;
status_icon_->SetDelegate(this); status_icon_->SetDelegate(this);
return; return;
#else #else
...@@ -133,7 +137,7 @@ void StatusIconLinuxWrapper::OnImplInitializationFailed() { ...@@ -133,7 +137,7 @@ void StatusIconLinuxWrapper::OnImplInitializationFailed() {
// complain about an unreachable fallthrough. // complain about an unreachable fallthrough.
FALLTHROUGH; FALLTHROUGH;
#endif #endif
case kTypeX11: case kTypeWindowed:
status_icon_linux_.reset(); status_icon_linux_.reset();
status_icon_ = nullptr; status_icon_ = nullptr;
status_icon_type_ = kTypeNone; status_icon_type_ = kTypeNone;
...@@ -159,8 +163,9 @@ StatusIconLinuxWrapper::CreateWrappedStatusIcon( ...@@ -159,8 +163,9 @@ StatusIconLinuxWrapper::CreateWrappedStatusIcon(
return base::WrapUnique(new StatusIconLinuxWrapper( return base::WrapUnique(new StatusIconLinuxWrapper(
base::MakeRefCounted<StatusIconLinuxDbus>(), image, tool_tip)); base::MakeRefCounted<StatusIconLinuxDbus>(), image, tool_tip));
#elif defined(USE_X11) #elif defined(USE_X11)
return base::WrapUnique(new StatusIconLinuxWrapper( return base::WrapUnique(
std::make_unique<StatusIconLinuxX11>(), kTypeX11, image, tool_tip)); new StatusIconLinuxWrapper(std::make_unique<StatusIconButtonLinux>(),
kTypeWindowed, image, tool_tip));
#else #else
return nullptr; return nullptr;
#endif #endif
......
...@@ -56,7 +56,7 @@ class StatusIconLinuxWrapper : public StatusIcon, ...@@ -56,7 +56,7 @@ class StatusIconLinuxWrapper : public StatusIcon,
private: private:
enum StatusIconType { enum StatusIconType {
kTypeDbus, kTypeDbus,
kTypeX11, kTypeWindowed,
kTypeNone, kTypeNone,
}; };
......
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