Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_STATUS_ICONS_STATUS_ICON_H_ | 5 #ifndef CHROME_BROWSER_STATUS_ICONS_STATUS_ICON_H_ |
| 6 #define CHROME_BROWSER_STATUS_ICONS_STATUS_ICON_H_ | 6 #define CHROME_BROWSER_STATUS_ICONS_STATUS_ICON_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "chrome/browser/status_icons/status_icon_menu_model.h" | 12 #include "chrome/browser/status_icons/status_icon_menu_model.h" |
| 13 | 13 |
| 14 namespace gfx { | 14 namespace gfx { |
| 15 class ImageSkia; | 15 class ImageSkia; |
| 16 } | 16 } |
| 17 | 17 |
| 18 class StatusIconObserver; | 18 class StatusIconObserver; |
| 19 | 19 |
| 20 #if defined(OS_WIN) | |
| 21 class StatusIconWin; | |
| 22 #endif // defined(OS_WIN) | |
| 23 | |
| 20 class StatusIcon { | 24 class StatusIcon { |
| 21 public: | 25 public: |
| 22 StatusIcon(); | 26 StatusIcon(); |
| 23 virtual ~StatusIcon(); | 27 virtual ~StatusIcon(); |
| 24 | 28 |
| 25 // Sets the image associated with this status icon. | 29 // Sets the image associated with this status icon. |
| 26 virtual void SetImage(const gfx::ImageSkia& image) = 0; | 30 virtual void SetImage(const gfx::ImageSkia& image) = 0; |
| 27 | 31 |
| 28 // Sets the image associated with this status icon when pressed. | 32 // Sets the image associated with this status icon when pressed. |
| 29 virtual void SetPressedImage(const gfx::ImageSkia& image) = 0; | 33 virtual void SetPressedImage(const gfx::ImageSkia& image) = 0; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 49 // being called, otherwise, both left and right clicks will display the | 53 // being called, otherwise, both left and right clicks will display the |
| 50 // context menu (if any). | 54 // context menu (if any). |
| 51 void AddObserver(StatusIconObserver* observer); | 55 void AddObserver(StatusIconObserver* observer); |
| 52 void RemoveObserver(StatusIconObserver* observer); | 56 void RemoveObserver(StatusIconObserver* observer); |
| 53 | 57 |
| 54 // Returns true if there are registered click observers. | 58 // Returns true if there are registered click observers. |
| 55 bool HasObservers() const; | 59 bool HasObservers() const; |
| 56 | 60 |
| 57 // Dispatches a click event to the observers. | 61 // Dispatches a click event to the observers. |
| 58 void DispatchClickEvent(); | 62 void DispatchClickEvent(); |
| 63 | |
| 59 #if defined(OS_WIN) | 64 #if defined(OS_WIN) |
| 65 // Dispatches a balloon click event to the observers. | |
| 60 void DispatchBalloonClickEvent(); | 66 void DispatchBalloonClickEvent(); |
| 67 | |
| 68 // Available on Windows so clients can access Windows-specific functionality | |
| 69 // like the backing HWND. | |
| 70 StatusIconWin* AsStatusIconWin(); | |
|
sky
2014/03/19 22:26:39
This means the parent class knows about a UI speci
dewittj
2014/03/20 19:31:08
Perhaps atwilson can suggest a better way. In ear
sky
2014/03/20 20:59:38
If you can't actually have your code take a Status
| |
| 61 #endif | 71 #endif |
| 62 | 72 |
| 63 protected: | 73 protected: |
| 64 // Invoked after a call to SetContextMenu() to let the platform-specific | 74 // Invoked after a call to SetContextMenu() to let the platform-specific |
| 65 // subclass update the native context menu based on the new model. If NULL is | 75 // subclass update the native context menu based on the new model. If NULL is |
| 66 // passed, subclass should destroy the native context menu. | 76 // passed, subclass should destroy the native context menu. |
| 67 virtual void UpdatePlatformContextMenu(StatusIconMenuModel* model) = 0; | 77 virtual void UpdatePlatformContextMenu(StatusIconMenuModel* model) = 0; |
| 68 | 78 |
| 69 private: | 79 private: |
| 70 ObserverList<StatusIconObserver> observers_; | 80 ObserverList<StatusIconObserver> observers_; |
| 71 | 81 |
| 72 // Context menu, if any. | 82 // Context menu, if any. |
| 73 scoped_ptr<StatusIconMenuModel> context_menu_contents_; | 83 scoped_ptr<StatusIconMenuModel> context_menu_contents_; |
| 74 | 84 |
| 75 DISALLOW_COPY_AND_ASSIGN(StatusIcon); | 85 DISALLOW_COPY_AND_ASSIGN(StatusIcon); |
| 76 }; | 86 }; |
| 77 | 87 |
| 78 #endif // CHROME_BROWSER_STATUS_ICONS_STATUS_ICON_H_ | 88 #endif // CHROME_BROWSER_STATUS_ICONS_STATUS_ICON_H_ |
| OLD | NEW |