Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ui / views / linux_ui / linux_ui.h
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.
4
5 #ifndef UI_VIEWS_LINUX_UI_LINUX_UI_H_
6 #define UI_VIEWS_LINUX_UI_LINUX_UI_H_
7
8 #include <string>
9
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"
17
18 // The main entrypoint into Linux toolkit specific code. GTK code should only
19 // be executed behind this interface.
20
21 namespace gfx {
22 class Image;
23 }
24
25 namespace ui {
26 class NativeTheme;
27 }
28
29 namespace views {
30 class Border;
31 class LabelButton;
32 class View;
33 class WindowButtonOrderObserver;
34
35 // Adapter class with targets to render like different toolkits. Set by any
36 // project that wants to do linux desktop native rendering.
37 //
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
41 // liuigtk3.so, etc.
42 class VIEWS_EXPORT LinuxUI : public ui::LinuxInputMethodContextFactory,
43                              public gfx::LinuxFontDelegate,
44                              public ui::LinuxShellDialog {
45  public:
46   virtual ~LinuxUI() {}
47
48   // Sets the dynamically loaded singleton that draws the desktop native UI.
49   static void SetInstance(LinuxUI* instance);
50
51   // Returns a LinuxUI instance for the toolkit used in the user's desktop
52   // environment.
53   //
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();
57
58   virtual void Initialize() = 0;
59
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;
64
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;
75
76   // Returns a NativeTheme that will provide system colors and draw system
77   // style widgets.
78   virtual ui::NativeTheme* GetNativeTheme() const = 0;
79
80   virtual void SetUseSystemTheme(bool use_system_theme) = 0;
81   virtual bool GetUseSystemTheme() const = 0;
82
83   // Returns whether we should be using the native theme provided by this
84   // object by default.
85   virtual bool GetDefaultUsesSystemTheme() const = 0;
86
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;
91
92   // Checks for platform support for status icons.
93   virtual bool IsStatusIconSupported() const = 0;
94
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;
99
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
102   // caches.
103   virtual gfx::Image GetIconForContentType(
104       const std::string& content_type, int size) const = 0;
105
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;
110
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;
116
117   // Removes the observer from the LinuxUI's list.
118   virtual void RemoveWindowButtonOrderObserver(
119       WindowButtonOrderObserver* observer) = 0;
120
121   // Determines whether the user's window manager is Unity.
122   virtual bool UnityIsRunning() = 0;
123
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;
129 };
130
131 }  // namespace views
132
133 #endif  // UI_VIEWS_LINUX_UI_LINUX_UI_H_