Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(782)

Side by Side Diff: chrome_frame/infobar_manager.h

Issue 4766003: Preview CL for adding an Infobar facility to Google Chrome Frame.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 // @file
6 // Manager for infobar windows.
7
8 #ifndef CHROME_FRAME_INFOBAR_MANAGER_H_
9 #define CHROME_FRAME_INFOBAR_MANAGER_H_
10
11 #include "base/scoped_ptr.h"
12 #include "base/singleton.h"
13 #include "base/task_queue.h"
14 #include "chrome_frame/infobar_window.h"
15
16 // InfobarManager creates and manages infobars, which are displayed at the top
17 // or bottom of IE content window.
18 class InfobarManager {
19 public:
20 class DisplacedWindowManager;
21
22 // Constructs an InfobarManager for the specified browser (IE6) or browser
23 // tab (IE7+).
24 //
25 // At most one InfobarManager should be constructed per tab or browser.
26 explicit InfobarManager(HWND tab_window);
27
28 // Shows the supplied content in an infobar of the specified type.
29 // Normally, content->InstallInFrame will be called with an interface the
30 // content may use to interact with the Infobar facility.
31 //
32 // IFF Show() returns success, content->Reset() is guaranteed to be called
33 // when the Infobar is no longer visible. The InfobarContent implementation is
34 // responsible for freeing itself and its resources at any time during or
35 // after the call to Reset().
36 HRESULT Show(InfobarContent *content, InfobarType type, int max_height);
37 // Hides the infobar of the specified type.
38 HRESULT Hide(InfobarType type);
39 // Hides all infobars.
40 void HideAll();
41
42 private:
43 // This callback class encapsulates the communication between InfobarWindow
44 // instances and the InfobarManager.
45 class InfobarHostImpl : public InfobarWindow::InfobarHost {
46 public:
47 InfobarHostImpl(InfobarManager *manager);
48 // Implementation of InfobarWindow::InfobarHost.
49 virtual HWND GetContainerWindow();
50 virtual bool UpdateLayout();
51 private:
52 // Not owned by this instance.
53 InfobarManager *manager_;
54 };
55
56 friend class InfobarHostImpl;
57 friend class DisplacedWindowManager;
58
59 // Finds the window to be displaced and instantiate a DisplacedWindowManager
60 // for it if one does not already exist. Returns true if there is a valid
61 // DisplacedWindowManager instance at the end of the call.
62 bool FindDisplacedWindow();
63
64 // These functions are called by the InfobarHostImpl
65 //
66 // Causes a (deferred) re-layout of the Infobars. ReserveSpace will be invoked
67 // on each InfobarWindow instance and the on-screen dimensions of the
68 // displaced window updated accordingly. Returns true if successful, in which
69 // case either a subsequent Hide() or ReserveSpace() is guaranteed.
70 bool UpdateLayout();
71
72 // Receive notifications from DisplacedWindowManager
73 void AdjustDisplacedWindowDimensions(RECT* rect);
74 void OnDisplacedWindowDestroyed();
75
76 // Delegate for InfobarWindow
77 InfobarHostImpl infobar_host_impl_;
78 // The HWND of the tab window the infobars are associated with.
79 HWND container_window_;
80 // Subclasses and observes changes to the displaced window.
81 DisplacedWindowManager* displaced_window_manager_;
82 // Infobar windows.
83 scoped_ptr<InfobarWindow> infobars_[END_OF_INFOBAR_TYPE];
84
85 DISALLOW_COPY_AND_ASSIGN(InfobarManager);
86 };
87
88 #endif // CHROME_FRAME_INFOBAR_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698