Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / status_icons / status_icon.h
blobb35af0e0eb5a24ce7ae35b6a2ef0c5a83a88227f
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_STATUS_ICONS_STATUS_ICON_H_
6 #define CHROME_BROWSER_STATUS_ICONS_STATUS_ICON_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/observer_list.h"
11 #include "base/strings/string16.h"
12 #include "chrome/browser/status_icons/status_icon_menu_model.h"
14 namespace gfx {
15 class ImageSkia;
18 class StatusIconObserver;
20 class StatusIcon {
21 public:
22 StatusIcon();
23 virtual ~StatusIcon();
25 // Sets the image associated with this status icon.
26 virtual void SetImage(const gfx::ImageSkia& image) = 0;
28 // Sets the hover text for this status icon. This is also used as the label
29 // for the menu item which is created as a replacement for the status icon
30 // click action on platforms that do not support custom click actions for the
31 // status icon (e.g. Ubuntu Unity).
32 virtual void SetToolTip(const base::string16& tool_tip) = 0;
34 // Displays a notification balloon with the specified contents.
35 // Depending on the platform it might not appear by the icon tray.
36 virtual void DisplayBalloon(const gfx::ImageSkia& icon,
37 const base::string16& title,
38 const base::string16& contents) = 0;
40 // Set the context menu for this icon. The icon takes ownership of the passed
41 // context menu. Passing NULL results in no menu at all.
42 void SetContextMenu(scoped_ptr<StatusIconMenuModel> menu);
44 // Adds/Removes an observer for clicks on the status icon. If an observer is
45 // registered, then left clicks on the status icon will result in the observer
46 // being called, otherwise, both left and right clicks will display the
47 // context menu (if any).
48 void AddObserver(StatusIconObserver* observer);
49 void RemoveObserver(StatusIconObserver* observer);
51 // Returns true if there are registered click observers.
52 bool HasObservers() const;
54 // Dispatches a click event to the observers.
55 void DispatchClickEvent();
56 #if defined(OS_WIN)
57 void DispatchBalloonClickEvent();
58 #endif
60 // Attempts to make the status icon directly visible on system UI. Currently
61 // this only applies to Windows, where status icons are hidden by default
62 // inside an overflow window.
63 // WARNING: This currently uses undocumented Windows APIs and spawns a worker
64 // thread to do it. Use sparingly.
65 virtual void ForceVisible();
67 protected:
68 // Invoked after a call to SetContextMenu() to let the platform-specific
69 // subclass update the native context menu based on the new model. If NULL is
70 // passed, subclass should destroy the native context menu.
71 virtual void UpdatePlatformContextMenu(StatusIconMenuModel* model) = 0;
73 private:
74 ObserverList<StatusIconObserver> observers_;
76 // Context menu, if any.
77 scoped_ptr<StatusIconMenuModel> context_menu_contents_;
79 DISALLOW_COPY_AND_ASSIGN(StatusIcon);
82 #endif // CHROME_BROWSER_STATUS_ICONS_STATUS_ICON_H_