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

Side by Side Diff: chrome_frame/infobar_window.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 #ifndef CHROME_FRAME_INFOBAR_WINDOW_H_
6 #define CHROME_FRAME_INFOBAR_WINDOW_H_
7
8 #include "base/singleton.h"
9 #include "base/scoped_ptr.h"
10 #include "base/time.h"
11
12 #include <atlbase.h>
13 #include <atlapp.h> // Must be included AFTER base.
14 #include <atlcrack.h>
15 #include <atlframe.h>
16 #include <atlmisc.h>
17 #include <atlgdi.h>
18 #include <atlwin.h>
19
20 #include "chrome_frame/resource1.h"
21 #include "chrome_frame/infobar_content.h"
22
23 enum InfobarType {
24 FIRST_INFOBAR_TYPE = 0,
25 TOP_INFOBAR = 0, // Infobar at the top.
26 BOTTOM_INFOBAR = 1, // Infobar at the bottom.
27 END_OF_INFOBAR_TYPE = 2
grt (UTC plus 2) 2010/11/10 17:59:29 The way this value is used, I would find it more n
erikwright (departed) 2010/11/24 06:24:56 Hope to get rid of it altogether.
28 };
29
30 // InfobarWindow is the window created on the top or bottom of the browser tab
31 // window that contains the web browser window.
32 class InfobarWindow
33 : public CWindowImpl<InfobarWindow, CWindow> {
34 public:
35 BEGIN_MSG_MAP(InfobarWindow)
36 MSG_WM_TIMER(OnTimer)
37 MSG_WM_DESTROY(OnDestroy)
38 END_MSG_MAP()
39
40 // Implementations of InfobarHost manage the integration of an InfobarWindow
41 // with its environment.
42 class InfobarHost {
43 public:
44 virtual ~InfobarHost() {}
45 // Returns a handle to the window in which this InfobarWindow should be
46 // created.
47 virtual HWND GetContainerWindow() = 0;
48 // Requests that the host update the layout of all infobars. Returns true
49 // if the request is successful.
50 virtual bool UpdateLayout() = 0;
51 };
52
53 InfobarWindow(InfobarType type, InfobarHost* host);
54 ~InfobarWindow();
55
56 // Shows the infobar.
57 // The height of the infobar is calculated to fit the content (limited to
58 // max_height if the content is too high; no limit if max_height is set to 0).
59 // slide indicates whether to show sliding effect.
60 // Normally, content->InstallInFrame will be called before Show returns.
61 // IFF successful, content->Reset is guaranteed to be called when the content
62 // is no longer visible. The InfobarContent implementation is responsible for
63 // freeing itself and its resources during or after the call to Reset.
64 HRESULT Show(InfobarContent *content, int max_height);
65 // Hides the infobar.
66 HRESULT Hide();
67 // Receives the total space requested by the displaced window and reserves
68 // any space required by this infobar. Resizes the InfobarWindow to fill the
69 // reserved space.
70 void ReserveSpace(RECT* rect);
71
72 private:
73 // An implementation of ContentFrame that connects the Content to this
74 // InfobarWindow.
75 class FrameImpl : public InfobarContent::ContentFrame {
76 public:
77 FrameImpl(InfobarWindow* infobar_window)
grt (UTC plus 2) 2010/11/10 17:59:29 explicit
erikwright (departed) 2010/11/24 06:24:56 Thanks.
78 : infobar_window_(infobar_window) { }
79
80 // ContentFrame implementation
81 virtual HWND GetFrameWindow() { return *infobar_window_; }
82 virtual void CloseInfobar() { infobar_window_->Hide(); }
83
84 private:
85 InfobarWindow* infobar_window_;
grt (UTC plus 2) 2010/11/10 17:59:29 DISALLOW_COPY_AND_ASSIGN?
erikwright (departed) 2010/11/24 06:24:56 Thanks.
86 };
87
88 // Sets up our state to show or hide and calls InfobarHost::UpdateLayout to
89 // cause an eventual call to ReserveSpace. If sliding, also sets up a timer to
90 // periodically call UpdateLayout.
91 void StartUpdatingLayout(bool show, int max_height, bool slide);
92
93 // Based on the initial height, how long (and if) we have been sliding, and
94 // the target height, decides what the current height should be.
95 int CalculateHeight();
96
97 // Implement a timer callback for sliding effect.
98 LRESULT OnTimer(UINT_PTR nIDEvent);
99
100 // Calls content_->Reset() when the InfobarWindow is destroyed (most likely
101 // because the browser/tab is going away).
102 void OnDestroy();
103
104 // Delegate for the InfobarContent to access us.
105 FrameImpl frame_impl_;
106 // Type of the infobar - whether it is displayed at the top or at the bottom
107 // of the IE content window.
108 InfobarType type_;
109 // Our host environment
110 InfobarHost* host_;
111 // The content we are displaying
112 InfobarContent* content_;
113 // Whether the infobar is shown or not.
114 bool show_;
115 // When we started sliding, or the NULL time if we are not sliding.
116 base::Time slide_start_;
117 // Where we started sliding from
118 int initial_height_;
119 // Where we are sliding to
120 int target_height_;
121
122 DISALLOW_COPY_AND_ASSIGN(InfobarWindow);
123 };
124
125 #endif // CHROME_FRAME_INFOBAR_WINDOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698