network_menu_button.h revision 3345a6884c488ff3a535c2c9acdd33d74b37e311
1// Copyright (c) 2006-2008 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 CHROME_BROWSER_CHROMEOS_STATUS_NETWORK_MENU_BUTTON_H_
6#define CHROME_BROWSER_CHROMEOS_STATUS_NETWORK_MENU_BUTTON_H_
7#pragma once
8
9#include "app/throb_animation.h"
10#include "base/timer.h"
11#include "chrome/browser/chromeos/cros/network_library.h"
12#include "chrome/browser/chromeos/status/network_menu.h"
13#include "chrome/browser/chromeos/status/status_area_button.h"
14
15namespace gfx {
16class Canvas;
17}
18
19namespace chromeos {
20
21class StatusAreaHost;
22
23// The network menu button in the status area.
24// This class will handle getting the wifi networks and populating the menu.
25// It will also handle the status icon changing and connecting to another
26// wifi/cellular network.
27//
28// The network menu looks like this:
29//
30// <icon>  Ethernet
31// <icon>  Wifi Network A
32// <icon>  Wifi Network B
33// <icon>  Wifi Network C
34// <icon>  Cellular Network A
35// <icon>  Cellular Network B
36// <icon>  Cellular Network C
37// <icon>  Other...
38// --------------------------------
39//         Disable Wifi
40//         Disable Celluar
41// --------------------------------
42//         <IP Address>
43//         Network settings...
44//
45// <icon> will show the strength of the wifi/cellular networks.
46// The label will be BOLD if the network is currently connected.
47class NetworkMenuButton : public StatusAreaButton,
48                          public NetworkMenu,
49                          public NetworkLibrary::Observer {
50 public:
51  explicit NetworkMenuButton(StatusAreaHost* host);
52  virtual ~NetworkMenuButton();
53
54  // AnimationDelegate implementation.
55  virtual void AnimationProgressed(const Animation* animation);
56
57  // NetworkLibrary::Observer implementation.
58  virtual void NetworkChanged(NetworkLibrary* obj);
59
60  // Sets the badge icon.
61  void SetBadge(const SkBitmap& badge);
62  SkBitmap badge() const { return badge_; }
63
64 protected:
65  // StatusAreaButton implementation.
66  virtual void DrawPressed(gfx::Canvas* canvas);
67  virtual void DrawIcon(gfx::Canvas* canvas);
68
69  // NetworkMenu implementation:
70  virtual bool IsBrowserMode() const;
71  virtual gfx::NativeWindow GetNativeWindow() const;
72  virtual void OpenButtonOptions() const;
73  virtual bool ShouldOpenButtonOptions() const;
74
75 private:
76  // The status area host,
77  StatusAreaHost* host_;
78
79  // A badge icon displayed on top of the icon.
80  SkBitmap badge_;
81
82  // The throb animation that does the wifi connecting animation.
83  ThrobAnimation animation_connecting_;
84
85  // The duration of the icon throbbing in milliseconds.
86  static const int kThrobDuration;
87
88  DISALLOW_COPY_AND_ASSIGN(NetworkMenuButton);
89};
90
91}  // namespace chromeos
92
93#endif  // CHROME_BROWSER_CHROMEOS_STATUS_NETWORK_MENU_BUTTON_H_
94