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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome_frame/infobars/internal/infobar_window.h
===================================================================
--- chrome_frame/infobars/internal/infobar_window.h (revision 0)
+++ chrome_frame/infobars/internal/infobar_window.h (revision 0)
@@ -0,0 +1,113 @@
+// 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_FRAME_INFOBARS_INTERNAL_INFOBAR_WINDOW_H_
+#define CHROME_FRAME_INFOBARS_INTERNAL_INFOBAR_WINDOW_H_
+
+#include <atlbase.h>
+#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)
+#include <atlcrack.h>
+
+#include "base/basictypes.h"
+#include "base/time.h"
+
+#include "chrome_frame/infobars/content.h"
+#include "chrome_frame/infobars/manager.h"
+
+// 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
+// window that contains the web browser window.
+class InfobarWindow : public CWindowImpl<InfobarWindow, CWindow> {
+ public:
+ // Implementations of InfobarHost manage the integration of an InfobarWindow
+ // with its environment.
+ class InfobarHost {
+ public:
+ virtual ~InfobarHost() {}
+ // Returns a handle to the window in which this InfobarWindow should be
+ // created.
+ virtual HWND GetContainerWindow() = 0;
+ // Requests that the host initiate a deferred layout sequence (calling
+ // ReserveSpace on each of its infobars). Returns true if the request
+ // succeeded and will be honoured.
+ virtual bool UpdateLayout() = 0;
+ };
+
+ InfobarWindow(InfobarType type, InfobarHost* host);
+ ~InfobarWindow();
+
+ BEGIN_MSG_MAP(InfobarWindow)
+ MSG_WM_TIMER(OnTimer)
+ END_MSG_MAP()
+
+ // Shows the infobar. The height of the infobar is calculated to fit the
+ // content.
+ //
+ // Normally, InfobarContent::InstallInFrame will be called before Show
+ // returns. InfobarContent::Reset() is guaranteed to be called when the
+ // InfobarWindow is done displaying the content (either due to failure or
+ // when successfully hidden).
+ //
+ // The InfobarContent implementation is responsible for freeing itself and its
+ // resources during or after the call to Reset.
+ bool Show(InfobarContent *content);
+ // 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.
+ void Hide();
+ // Receives the total space requested by the displaced window and reserves
+ // any space required by this infobar. Resizes the InfobarWindow to fill the
+ // reserved space.
+ void ReserveSpace(RECT* rect);
+
+ private:
+ // An implementation of ContentFrame that connects the Content to this
+ // InfobarWindow.
+ class FrameImpl : public InfobarContent::ContentFrame {
+ public:
+ explicit FrameImpl(InfobarWindow* infobar_window)
+ : infobar_window_(infobar_window) { }
tommi (sloooow) - chröme 2010/11/24 16:08:24 indent
erikwright (departed) 2010/12/01 20:05:52 Done.
+
+ // ContentFrame implementation
+ 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,
+ virtual void CloseInfobar() { infobar_window_->Hide(); }
+
+ private:
+ InfobarWindow* infobar_window_;
+ DISALLOW_COPY_AND_ASSIGN(FrameImpl);
+ };
+
+ // Sets up our state to show or hide and calls InfobarHost::UpdateLayout to
+ // cause an eventual call to ReserveSpace. Sets up a timer to periodically
+ // call UpdateLayout.
+ bool StartSlidingTowards(int height);
+ // Based on the initial height, how long (and if) we have been sliding, and
+ // the target height, decides what the current height should be.
+ int CalculateHeight();
+ // Implement a timer callback for sliding effect.
+ LRESULT OnTimer(UINT_PTR nIDEvent);
+
+ // Utility methods
+ bool InitializeWindow();
+ bool InstallContent(InfobarContent* content);
+ void ResetContent();
+
+ // Delegate for the InfobarContent to access us.
+ FrameImpl frame_impl_;
+ // Type of the infobar - whether it is displayed at the top or at the bottom
+ // of the IE content window.
+ InfobarType type_;
+ // Our host environment
+ InfobarHost* host_;
+ // The content we are displaying
+ InfobarContent* content_;
+ // When we started sliding, or the null time if we are not sliding.
+ base::Time slide_start_;
+ // Where we started sliding from
+ int initial_height_;
+ // Where we are sliding to
+ int target_height_;
+ int infobar_window_width_;
+
+ DISALLOW_COPY_AND_ASSIGN(InfobarWindow);
+};
+
+#endif // CHROME_FRAME_INFOBARS_INTERNAL_INFOBAR_WINDOW_H_
Property changes on: chrome_frame\infobars\internal\infobar_window.h
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698