| 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 #ifndef CHROME_BROWSER_UI_LIBGTK2UI_APP_INDICATOR_ICON_H_ | 5 #ifndef CHROME_BROWSER_UI_LIBGTK2UI_APP_INDICATOR_ICON_H_ |
| 6 #define CHROME_BROWSER_UI_LIBGTK2UI_APP_INDICATOR_ICON_H_ | 6 #define CHROME_BROWSER_UI_LIBGTK2UI_APP_INDICATOR_ICON_H_ |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" | 11 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" |
| 12 #include "ui/views/linux_ui/status_icon_linux.h" | 12 #include "ui/views/linux_ui/status_icon_linux.h" |
| 13 | 13 |
| 14 typedef struct _AppIndicator AppIndicator; | 14 typedef struct _AppIndicator AppIndicator; |
| 15 typedef struct _GtkWidget GtkWidget; | 15 typedef struct _GtkWidget GtkWidget; |
| 16 | 16 |
| 17 class SkBitmap; |
| 18 |
| 17 namespace gfx { | 19 namespace gfx { |
| 18 class ImageSkia; | 20 class ImageSkia; |
| 19 } | 21 } |
| 20 | 22 |
| 21 namespace ui { | 23 namespace ui { |
| 22 class MenuModel; | 24 class MenuModel; |
| 23 } | 25 } |
| 24 | 26 |
| 25 namespace libgtk2ui { | 27 namespace libgtk2ui { |
| 26 class AppIndicatorIconMenu; | 28 class AppIndicatorIconMenu; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 38 // Indicates whether libappindicator so could be opened. | 40 // Indicates whether libappindicator so could be opened. |
| 39 static bool CouldOpen(); | 41 static bool CouldOpen(); |
| 40 | 42 |
| 41 // Overridden from views::StatusIconLinux: | 43 // Overridden from views::StatusIconLinux: |
| 42 void SetImage(const gfx::ImageSkia& image) override; | 44 void SetImage(const gfx::ImageSkia& image) override; |
| 43 void SetToolTip(const base::string16& tool_tip) override; | 45 void SetToolTip(const base::string16& tool_tip) override; |
| 44 void UpdatePlatformContextMenu(ui::MenuModel* menu) override; | 46 void UpdatePlatformContextMenu(ui::MenuModel* menu) override; |
| 45 void RefreshPlatformContextMenu() override; | 47 void RefreshPlatformContextMenu() override; |
| 46 | 48 |
| 47 private: | 49 private: |
| 48 void SetImageFromFile(const base::FilePath& icon_file_path); | 50 struct SetImageFromFileParams { |
| 51 // The temporary directory in which the icon(s) were written. |
| 52 base::FilePath parent_temp_dir; |
| 53 |
| 54 // The icon theme path to pass to libappindicator. |
| 55 std::string icon_theme_path; |
| 56 |
| 57 // The icon name to pass to libappindicator. |
| 58 std::string icon_name; |
| 59 }; |
| 60 |
| 61 // Writes |bitmap| to a temporary directory on a worker thread. The temporary |
| 62 // directory is selected based on KDE's quirks. |
| 63 static SetImageFromFileParams WriteKDE4TempImageOnWorkerThread( |
| 64 const SkBitmap& bitmap, |
| 65 const base::FilePath& existing_temp_dir); |
| 66 |
| 67 // Writes |bitmap| to a temporary directory on a worker thread. The temporary |
| 68 // directory is selected based on Unity's quirks. |
| 69 static SetImageFromFileParams WriteUnityTempImageOnWorkerThread( |
| 70 const SkBitmap& bitmap, |
| 71 int icon_change_count, |
| 72 const std::string& id); |
| 73 |
| 74 void SetImageFromFile(const SetImageFromFileParams& params); |
| 49 void SetMenu(); | 75 void SetMenu(); |
| 50 | 76 |
| 51 // Sets a menu item at the top of the menu as a replacement for the status | 77 // Sets a menu item at the top of the menu as a replacement for the status |
| 52 // icon click action. Clicking on this menu item should simulate a status icon | 78 // icon click action. Clicking on this menu item should simulate a status icon |
| 53 // click by despatching a click event. | 79 // click by despatching a click event. |
| 54 void UpdateClickActionReplacementMenuItem(); | 80 void UpdateClickActionReplacementMenuItem(); |
| 55 | 81 |
| 56 // Callback for when the status icon click replacement menu item is activated. | 82 // Callback for when the status icon click replacement menu item is activated. |
| 57 void OnClickActionReplacementMenuItemActivated(); | 83 void OnClickActionReplacementMenuItemActivated(); |
| 58 | 84 |
| 59 std::string id_; | 85 std::string id_; |
| 60 std::string tool_tip_; | 86 std::string tool_tip_; |
| 61 | 87 |
| 62 // Whether the user is using KDE. | 88 // Whether the user is using KDE. |
| 63 bool using_kde4_; | 89 bool using_kde4_; |
| 64 | 90 |
| 65 // Gtk status icon wrapper | 91 // Gtk status icon wrapper |
| 66 AppIndicator* icon_; | 92 AppIndicator* icon_; |
| 67 | 93 |
| 68 scoped_ptr<AppIndicatorIconMenu> menu_; | 94 scoped_ptr<AppIndicatorIconMenu> menu_; |
| 69 ui::MenuModel* menu_model_; | 95 ui::MenuModel* menu_model_; |
| 70 | 96 |
| 71 base::FilePath icon_file_path_; | 97 base::FilePath temp_dir_; |
| 72 int icon_change_count_; | 98 int icon_change_count_; |
| 73 | 99 |
| 74 base::WeakPtrFactory<AppIndicatorIcon> weak_factory_; | 100 base::WeakPtrFactory<AppIndicatorIcon> weak_factory_; |
| 75 | 101 |
| 76 DISALLOW_COPY_AND_ASSIGN(AppIndicatorIcon); | 102 DISALLOW_COPY_AND_ASSIGN(AppIndicatorIcon); |
| 77 }; | 103 }; |
| 78 | 104 |
| 79 } // namespace libgtk2ui | 105 } // namespace libgtk2ui |
| 80 | 106 |
| 81 #endif // CHROME_BROWSER_UI_LIBGTK2UI_APP_INDICATOR_ICON_H_ | 107 #endif // CHROME_BROWSER_UI_LIBGTK2UI_APP_INDICATOR_ICON_H_ |
| OLD | NEW |