summaryrefslogtreecommitdiffstats
path: root/ceee/ie/plugin/bho/infobar_manager.h
blob: dead9244aa1c01a9b1ab72be99547e5343f50727 (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
// 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.
//
// @file
// Manager for infobar windows.

#ifndef CEEE_IE_PLUGIN_BHO_INFOBAR_MANAGER_H_
#define CEEE_IE_PLUGIN_BHO_INFOBAR_MANAGER_H_

#include "base/scoped_ptr.h"
#include "base/singleton.h"
#include "ceee/ie/plugin/bho/infobar_window.h"
#include "ceee/ie/plugin/bho/web_browser_events_source.h"

namespace infobar_api {

// InfobarManager creates and manages infobars, which are displayed at the top
// or bottom of IE content window.
class InfobarManager : public InfobarWindow::Delegate,
                       public WebBrowserEventsSource::Sink {
 public:
  explicit InfobarManager(HWND tab_window);

  // Shows the infobar of the specified type and navigates it to the specified
  // URL.
  HRESULT Show(InfobarType type, int max_height, const std::wstring& url,
               bool slide);
  // Hides the infobar of the specified type.
  HRESULT Hide(InfobarType type);
  // Hides all infobars.
  void HideAll();

  // Implementation of InfobarWindow::Delegate.
  // Finds the handle of the container window.
  virtual HWND GetContainerWindow();
  // Informs about window.close() event.
  virtual void OnWindowClose(InfobarType type);

 private:
  class ContainerWindow;

  // The HWND of the tab window the infobars are associated with.
  HWND tab_window_;

  // Parent window for IE content window.
  scoped_ptr<ContainerWindow> container_window_;

  // Infobar windows.
  scoped_ptr<InfobarWindow> infobars_[END_OF_INFOBAR_TYPE];

  // ContainerWindow callbacks.
  // Callback for WM_NCCALCSIZE.
  void OnContainerWindowNcCalcSize(RECT* rect);
  // Callback for messages on size or position change.
  void OnContainerWindowUpdatePosition();
  // Callback for message requesting closing the infobar.
  void OnContainerWindowDelayedCloseInfobar(InfobarType type);
  // Callback for WM_DESTROY.
  void OnContainerWindowDestroy();

  DISALLOW_COPY_AND_ASSIGN(InfobarManager);
};

}  // namespace infobar_api

#endif  // CEEE_IE_PLUGIN_BHO_INFOBAR_MANAGER_H_