summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/views/avatar_menu_button.h
blob: 329d8fb55adf4bd2d95f80b74f4418314bdc05bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_
#define CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_
#pragma once

#include <string>

#include "base/compiler_specific.h"
#include "chrome/browser/ui/views/bubble/bubble.h"
#include "ui/base/models/simple_menu_model.h"
#include "views/controls/button/menu_button.h"
#include "views/controls/menu/view_menu_delegate.h"

namespace gfx {
class Canvas;
}
class Browser;

// AvatarMenuButton
//
// A button used to show either the incognito avatar or the profile avatar.
// The button can optionally have a menu attached to it.

class AvatarMenuButton : public views::MenuButton,
                         public views::ViewMenuDelegate,
                         public Bubble::Observer {
 public:
  // Creates a new button. If |has_menu| is true then clicking on the button
  // will cause the profile menu to be displayed.
  AvatarMenuButton(Browser* browser, bool has_menu);

  virtual ~AvatarMenuButton();

  // views::MenuButton
  virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
  virtual bool HitTest(const gfx::Point& point) const OVERRIDE;

  // views::TextButton
  virtual void SetIcon(const SkBitmap& icon) OVERRIDE;

 private:
  // views::ViewMenuDelegate
  virtual void RunMenu(views::View* source, const gfx::Point& pt) OVERRIDE;

  // Bubble::Observer implementation.
  virtual void OnBubbleClosing();

  Browser* browser_;
  Bubble* bubble_;
  bool has_menu_;
  bool set_taskbar_decoration_;
  scoped_ptr<ui::MenuModel> menu_model_;

  DISALLOW_COPY_AND_ASSIGN(AvatarMenuButton);
};

#endif  // CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_