summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/infobars/extension_infobar.h
blob: 9b9b98729da59eef92b0a2a243a7a101b191f48e (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
61
62
63
64
65
66
67
68
69
70
71
// Copyright (c) 2010 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_VIEWS_INFOBARS_EXTENSION_INFOBAR_H_
#define CHROME_BROWSER_VIEWS_INFOBARS_EXTENSION_INFOBAR_H_

#include "chrome/browser/views/infobars/infobars.h"

#include "chrome/browser/extensions/extension_infobar_delegate.h"
#include "chrome/browser/extensions/image_loading_tracker.h"
#include "chrome/browser/views/extensions/extension_view.h"
#include "views/controls/menu/view_menu_delegate.h"

class ExtensionContextMenuModel;
class ExtensionInfoBarDelegate;

namespace views {
  class MenuButton;
  class Menu2;
}

// This class implements InfoBars for Extensions.
class ExtensionInfoBar : public InfoBar,
                         public ExtensionView::Container,
                         public ImageLoadingTracker::Observer,
                         public ExtensionInfoBarDelegate::DelegateObserver,
                         public views::ViewMenuDelegate {
 public:
  explicit ExtensionInfoBar(ExtensionInfoBarDelegate* delegate);
  virtual ~ExtensionInfoBar();

  // Overridden from ExtensionView::Container:
  virtual void OnExtensionMouseEvent(ExtensionView* view) {}
  virtual void OnExtensionMouseLeave(ExtensionView* view) {}
  virtual void OnExtensionPreferredSizeChanged(ExtensionView* view);

  // Overridden from views::View:
  virtual void Layout();

  // Overridden from ImageLoadingTracker::Observer:
  virtual void OnImageLoaded(
      SkBitmap* image, ExtensionResource resource, int index);

  // Overridden from ExtensionInfoBarDelegate::DelegateObserver:
  virtual void OnDelegateDeleted();

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

 private:
  // Setup the menu button showing the small extension icon and its dropdown
  // menu.
  void SetupIconAndMenu();

  NotificationRegistrar notification_registrar_;

  ExtensionInfoBarDelegate* delegate_;

  // The dropdown menu for accessing the contextual extension actions.
  scoped_refptr<ExtensionContextMenuModel> options_menu_contents_;
  scoped_ptr<views::Menu2> options_menu_menu_;
  views::MenuButton* menu_;

  // Keeps track of images being loaded on the File thread.
  ImageLoadingTracker tracker_;

  DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBar);
};

#endif  // CHROME_BROWSER_VIEWS_INFOBARS_EXTENSION_INFOBAR_H_