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
3 // found in the LICENSE file.
5 #ifndef UI_VIEWS_LINUX_UI_LINUX_UI_H_
6 #define UI_VIEWS_LINUX_UI_LINUX_UI_H_
10 #include "third_party/skia/include/core/SkColor.h"
11 #include "ui/base/ime/linux/linux_input_method_context_factory.h"
12 #include "ui/gfx/linux_font_delegate.h"
13 #include "ui/shell_dialogs/linux_shell_dialog.h"
14 #include "ui/views/controls/button/button.h"
15 #include "ui/views/linux_ui/status_icon_linux.h"
16 #include "ui/views/views_export.h"
18 // The main entrypoint into Linux toolkit specific code. GTK code should only
19 // be executed behind this interface.
33 class WindowButtonOrderObserver;
35 // Adapter class with targets to render like different toolkits. Set by any
36 // project that wants to do linux desktop native rendering.
38 // TODO(erg): We're hardcoding GTK2, when we'll need to have backends for (at
39 // minimum) GTK2 and GTK3. LinuxUI::instance() should actually be a very
40 // complex method that pokes around with dlopen against a libuigtk2.so, a
42 class VIEWS_EXPORT LinuxUI : public ui::LinuxInputMethodContextFactory,
43 public gfx::LinuxFontDelegate,
44 public ui::LinuxShellDialog {
48 // Sets the dynamically loaded singleton that draws the desktop native UI.
49 static void SetInstance(LinuxUI* instance);
51 // Returns a LinuxUI instance for the toolkit used in the user's desktop
54 // Can return NULL, in case no toolkit has been set. (For example, if we're
55 // running with the "--ash" flag.)
56 static LinuxUI* instance();
58 virtual void Initialize() = 0;
60 // Returns a themed image per theme_provider.h
61 virtual gfx::Image GetThemeImageNamed(int id) const = 0;
62 virtual bool GetColor(int id, SkColor* color) const = 0;
63 virtual bool HasCustomImage(int id) const = 0;
65 // Returns the preferences that we pass to WebKit.
66 virtual SkColor GetFocusRingColor() const = 0;
67 virtual SkColor GetThumbActiveColor() const = 0;
68 virtual SkColor GetThumbInactiveColor() const = 0;
69 virtual SkColor GetTrackColor() const = 0;
70 virtual SkColor GetActiveSelectionBgColor() const = 0;
71 virtual SkColor GetActiveSelectionFgColor() const = 0;
72 virtual SkColor GetInactiveSelectionBgColor() const = 0;
73 virtual SkColor GetInactiveSelectionFgColor() const = 0;
74 virtual double GetCursorBlinkInterval() const = 0;
76 // Returns a NativeTheme that will provide system colors and draw system
78 virtual ui::NativeTheme* GetNativeTheme() const = 0;
80 virtual void SetUseSystemTheme(bool use_system_theme) = 0;
81 virtual bool GetUseSystemTheme() const = 0;
83 // Returns whether we should be using the native theme provided by this
85 virtual bool GetDefaultUsesSystemTheme() const = 0;
87 // Sets visual properties in the desktop environment related to download
88 // progress, if available.
89 virtual void SetDownloadCount(int count) const = 0;
90 virtual void SetProgressFraction(float percentage) const = 0;
92 // Checks for platform support for status icons.
93 virtual bool IsStatusIconSupported() const = 0;
95 // Create a native status icon.
96 virtual scoped_ptr<StatusIconLinux> CreateLinuxStatusIcon(
97 const gfx::ImageSkia& image,
98 const base::string16& tool_tip) const = 0;
100 // Returns the icon for a given content type from the icon theme.
101 // TODO(davidben): Add an observer for the theme changing, so we can drop the
103 virtual gfx::Image GetIconForContentType(
104 const std::string& content_type, int size) const = 0;
106 // Builds a Border which paints the native button style.
107 virtual scoped_ptr<Border> CreateNativeBorder(
108 views::LabelButton* owning_button,
109 scoped_ptr<views::Border> border) = 0;
111 // Notifies the observer about changes about how window buttons should be
112 // laid out. If the order is anything other than the default min,max,close on
113 // the right, will immediately send a button change event to the observer.
114 virtual void AddWindowButtonOrderObserver(
115 WindowButtonOrderObserver* observer) = 0;
117 // Removes the observer from the LinuxUI's list.
118 virtual void RemoveWindowButtonOrderObserver(
119 WindowButtonOrderObserver* observer) = 0;
121 // Determines whether the user's window manager is Unity.
122 virtual bool UnityIsRunning() = 0;
124 // Notifies the window manager that start up has completed.
125 // Normally Chromium opens a new window on startup and GTK does this
126 // automatically. In case Chromium does not open a new window on startup,
127 // e.g. an existing browser window already exists, this should be called.
128 virtual void NotifyWindowManagerStartupComplete() = 0;
133 #endif // UI_VIEWS_LINUX_UI_LINUX_UI_H_