network_menu_button.h revision 731df977c0511bca2206b5f333555b1205ff1f43
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  virtual void CellularDataPlanChanged(NetworkLibrary* obj);
60
61  // Sets the badge icon.
62  void SetBadge(const SkBitmap& badge);
63  SkBitmap badge() const { return badge_; }
64
65 protected:
66  // StatusAreaButton implementation.
67  virtual void DrawPressed(gfx::Canvas* canvas);
68  virtual void DrawIcon(gfx::Canvas* canvas);
69
70  // NetworkMenu implementation:
71  virtual bool IsBrowserMode() const;
72  virtual gfx::NativeWindow GetNativeWindow() const;
73  virtual void OpenButtonOptions() const;
74  virtual bool ShouldOpenButtonOptions() const;
75
76 private:
77  // The status area host,
78  StatusAreaHost* host_;
79
80  // A badge icon displayed on top of the icon.
81  SkBitmap badge_;
82
83  // The throb animation that does the wifi connecting animation.
84  ThrobAnimation animation_connecting_;
85
86  // The duration of the icon throbbing in milliseconds.
87  static const int kThrobDuration;
88
89  DISALLOW_COPY_AND_ASSIGN(NetworkMenuButton);
90};
91
92}  // namespace chromeos
93
94#endif  // CHROME_BROWSER_CHROMEOS_STATUS_NETWORK_MENU_BUTTON_H_
95