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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome_frame/infobar_manager.h
===================================================================
--- chrome_frame/infobar_manager.h (revision 0)
+++ chrome_frame/infobar_manager.h (revision 0)
@@ -0,0 +1,88 @@
+// 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 CHROME_FRAME_INFOBAR_MANAGER_H_
+#define CHROME_FRAME_INFOBAR_MANAGER_H_
+
+#include "base/scoped_ptr.h"
+#include "base/singleton.h"
+#include "base/task_queue.h"
+#include "chrome_frame/infobar_window.h"
+
+// InfobarManager creates and manages infobars, which are displayed at the top
+// or bottom of IE content window.
+class InfobarManager {
+ public:
+ class DisplacedWindowManager;
+
+ // Constructs an InfobarManager for the specified browser (IE6) or browser
+ // tab (IE7+).
+ //
+ // At most one InfobarManager should be constructed per tab or browser.
+ explicit InfobarManager(HWND tab_window);
+
+ // Shows the supplied content in an infobar of the specified type.
+ // Normally, content->InstallInFrame will be called with an interface the
+ // content may use to interact with the Infobar facility.
+ //
+ // IFF Show() returns success, content->Reset() is guaranteed to be called
+ // when the Infobar is no longer visible. The InfobarContent implementation is
+ // responsible for freeing itself and its resources at any time during or
+ // after the call to Reset().
+ HRESULT Show(InfobarContent *content, InfobarType type, int max_height);
+ // Hides the infobar of the specified type.
+ HRESULT Hide(InfobarType type);
+ // Hides all infobars.
+ void HideAll();
+
+ private:
+ // This callback class encapsulates the communication between InfobarWindow
+ // instances and the InfobarManager.
+ class InfobarHostImpl : public InfobarWindow::InfobarHost {
+ public:
+ InfobarHostImpl(InfobarManager *manager);
+ // Implementation of InfobarWindow::InfobarHost.
+ virtual HWND GetContainerWindow();
+ virtual bool UpdateLayout();
+ private:
+ // Not owned by this instance.
+ InfobarManager *manager_;
+ };
+
+ friend class InfobarHostImpl;
+ friend class DisplacedWindowManager;
+
+ // Finds the window to be displaced and instantiate a DisplacedWindowManager
+ // for it if one does not already exist. Returns true if there is a valid
+ // DisplacedWindowManager instance at the end of the call.
+ bool FindDisplacedWindow();
+
+ // These functions are called by the InfobarHostImpl
+ //
+ // Causes a (deferred) re-layout of the Infobars. ReserveSpace will be invoked
+ // on each InfobarWindow instance and the on-screen dimensions of the
+ // displaced window updated accordingly. Returns true if successful, in which
+ // case either a subsequent Hide() or ReserveSpace() is guaranteed.
+ bool UpdateLayout();
+
+ // Receive notifications from DisplacedWindowManager
+ void AdjustDisplacedWindowDimensions(RECT* rect);
+ void OnDisplacedWindowDestroyed();
+
+ // Delegate for InfobarWindow
+ InfobarHostImpl infobar_host_impl_;
+ // The HWND of the tab window the infobars are associated with.
+ HWND container_window_;
+ // Subclasses and observes changes to the displaced window.
+ DisplacedWindowManager* displaced_window_manager_;
+ // Infobar windows.
+ scoped_ptr<InfobarWindow> infobars_[END_OF_INFOBAR_TYPE];
+
+ DISALLOW_COPY_AND_ASSIGN(InfobarManager);
+};
+
+#endif // CHROME_FRAME_INFOBAR_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698