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

Side by Side Diff: chrome_frame/infobars/internal/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
Property Changes:
Added: svn:eol-style
+ LF
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_INFOBARS_INTERNAL_INFOBAR_WINDOW_H_
6 #define CHROME_FRAME_INFOBARS_INTERNAL_INFOBAR_WINDOW_H_
7
8 #include <atlbase.h>
9 #include <atlapp.h> // Must be included AFTER base.
tommi (sloooow) - chröme 2010/11/24 16:08:24 same comment for atlapp as before (and I believe f
erikwright (departed) 2010/12/01 20:05:52 Done. (Moved to subclassing_window.h)
10 #include <atlcrack.h>
11
12 #include "base/basictypes.h"
13 #include "base/time.h"
14
15 #include "chrome_frame/infobars/content.h"
16 #include "chrome_frame/infobars/manager.h"
17
18 // InfobarWindow is the window created on the top or bottom of the browser tab
grt (UTC plus 2) 2010/11/25 18:00:13 Technically speaking, is the InfobarWindow _in_ th
erikwright (departed) 2010/12/01 20:05:52 Comment revised. Please let me know if it does not
19 // window that contains the web browser window.
20 class InfobarWindow : public CWindowImpl<InfobarWindow, CWindow> {
21 public:
22 // Implementations of InfobarHost manage the integration of an InfobarWindow
23 // with its environment.
24 class InfobarHost {
25 public:
26 virtual ~InfobarHost() {}
27 // Returns a handle to the window in which this InfobarWindow should be
28 // created.
29 virtual HWND GetContainerWindow() = 0;
30 // Requests that the host initiate a deferred layout sequence (calling
31 // ReserveSpace on each of its infobars). Returns true if the request
32 // succeeded and will be honoured.
33 virtual bool UpdateLayout() = 0;
34 };
35
36 InfobarWindow(InfobarType type, InfobarHost* host);
37 ~InfobarWindow();
38
39 BEGIN_MSG_MAP(InfobarWindow)
40 MSG_WM_TIMER(OnTimer)
41 END_MSG_MAP()
42
43 // Shows the infobar. The height of the infobar is calculated to fit the
44 // content.
45 //
46 // Normally, InfobarContent::InstallInFrame will be called before Show
47 // returns. InfobarContent::Reset() is guaranteed to be called when the
48 // InfobarWindow is done displaying the content (either due to failure or
49 // when successfully hidden).
50 //
51 // The InfobarContent implementation is responsible for freeing itself and its
52 // resources during or after the call to Reset.
53 bool Show(InfobarContent *content);
54 // Hides the infobar.
tommi (sloooow) - chröme 2010/11/24 16:08:24 I prefer spaces between functions for readability
erikwright (departed) 2010/12/01 20:05:52 Done.
55 void Hide();
56 // Receives the total space requested by the displaced window and reserves
57 // any space required by this infobar. Resizes the InfobarWindow to fill the
58 // reserved space.
59 void ReserveSpace(RECT* rect);
60
61 private:
62 // An implementation of ContentFrame that connects the Content to this
63 // InfobarWindow.
64 class FrameImpl : public InfobarContent::ContentFrame {
65 public:
66 explicit FrameImpl(InfobarWindow* infobar_window)
67 : infobar_window_(infobar_window) { }
tommi (sloooow) - chröme 2010/11/24 16:08:24 indent
erikwright (departed) 2010/12/01 20:05:52 Done.
68
69 // ContentFrame implementation
70 virtual HWND GetFrameWindow() { return *infobar_window_; }
grt (UTC plus 2) 2010/11/25 18:00:13 Just a note: Chrome style guide says not to inline
erikwright (departed) 2010/12/01 20:05:52 Thanks! Given that they can't normally be inlined,
71 virtual void CloseInfobar() { infobar_window_->Hide(); }
72
73 private:
74 InfobarWindow* infobar_window_;
75 DISALLOW_COPY_AND_ASSIGN(FrameImpl);
76 };
77
78 // Sets up our state to show or hide and calls InfobarHost::UpdateLayout to
79 // cause an eventual call to ReserveSpace. Sets up a timer to periodically
80 // call UpdateLayout.
81 bool StartSlidingTowards(int height);
82 // Based on the initial height, how long (and if) we have been sliding, and
83 // the target height, decides what the current height should be.
84 int CalculateHeight();
85 // Implement a timer callback for sliding effect.
86 LRESULT OnTimer(UINT_PTR nIDEvent);
87
88 // Utility methods
89 bool InitializeWindow();
90 bool InstallContent(InfobarContent* content);
91 void ResetContent();
92
93 // Delegate for the InfobarContent to access us.
94 FrameImpl frame_impl_;
95 // Type of the infobar - whether it is displayed at the top or at the bottom
96 // of the IE content window.
97 InfobarType type_;
98 // Our host environment
99 InfobarHost* host_;
100 // The content we are displaying
101 InfobarContent* content_;
102 // When we started sliding, or the null time if we are not sliding.
103 base::Time slide_start_;
104 // Where we started sliding from
105 int initial_height_;
106 // Where we are sliding to
107 int target_height_;
108 int infobar_window_width_;
109
110 DISALLOW_COPY_AND_ASSIGN(InfobarWindow);
111 };
112
113 #endif // CHROME_FRAME_INFOBARS_INTERNAL_INFOBAR_WINDOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698