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

Unified Diff: chrome_frame/infobars/manager.cc

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
« chrome_frame/infobars/manager.h ('K') | « chrome_frame/infobars/manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_frame/infobars/manager.cc
===================================================================
--- chrome_frame/infobars/manager.cc (revision 0)
+++ chrome_frame/infobars/manager.cc (revision 0)
@@ -0,0 +1,87 @@
+// 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.
+
+#include "chrome_frame/infobars/manager.h"
+
+#include "base/logging.h"
+#include "base/scoped_ptr.h"
+
+#include "chrome_frame/infobars/internal/host_window.h"
+#include "chrome_frame/infobars/internal/infobar_window.h"
+
+// Connect InfobarWindow to HostWindowManager, and expose the result as an
+// InfobarManager
+class InfobarManagerImpl
+ : public InfobarManager,
+ public InfobarWindow::InfobarHost,
+ public HostWindowManager::Delegate {
+ public:
+ explicit InfobarManagerImpl(HostWindowManager *manager) : manager_(manager) {
tommi (sloooow) - chröme 2010/11/24 16:08:24 ...Manager* manager
erikwright (departed) 2010/12/01 20:05:52 Done.
+ for (int index = 0; index < END_OF_INFOBAR_TYPE; ++index) {
+ infobars_[index].reset(
+ new InfobarWindow(static_cast<InfobarType>(index), this));
+ }
+ }
+
+ // Implementation of InfobarManager
+ virtual bool Show(InfobarContent *content, InfobarType type) {
grt (UTC plus 2) 2010/11/25 18:00:13 InfobarContent*
erikwright (departed) 2010/12/01 20:05:52 Done.
+ DCHECK(type >= FIRST_INFOBAR_TYPE && type < END_OF_INFOBAR_TYPE);
+
+ return infobars_[type]->Show(content);
+ }
+
+ void Hide(InfobarType type) {
+ DCHECK(type >= FIRST_INFOBAR_TYPE && type < END_OF_INFOBAR_TYPE);
+ infobars_[type]->Hide();
+ }
+
+ void HideAll() {
+ for (int index = 0; index < END_OF_INFOBAR_TYPE; ++index)
+ Hide(static_cast<InfobarType>(index));
+ }
+
+ // Implementation of HostWindowManager::Delegate
+ virtual void AdjustDisplacedWindowDimensions(RECT* rect) {
+ for (int index = 0; index < END_OF_INFOBAR_TYPE; ++index) {
+ if (infobars_[index] != NULL)
+ infobars_[index]->ReserveSpace(rect);
+ }
+ }
+
+ // Implementation of InfobarWindow::InfobarHost
+ virtual HWND GetContainerWindow() {
+ return *manager_;
+ }
+ virtual bool UpdateLayout() {
+ return manager_->UpdateLayout();
+ }
+
+ private:
+ // Not owned by this instance.
+ HostWindowManager *manager_;
grt (UTC plus 2) 2010/11/25 18:00:13 HostWindowManager*
erikwright (departed) 2010/12/01 20:05:52 Done.
+ // Infobar windows.
+ scoped_ptr<InfobarWindow> infobars_[END_OF_INFOBAR_TYPE];
+ DISALLOW_COPY_AND_ASSIGN(InfobarManagerImpl);
+};
+
+InfobarManager* InfobarManager::Get(HWND tab_window) {
+ HostWindowManager::Delegate* delegate =
+ HostWindowManager::GetDelegateForHostHwnd(tab_window);
+
+ if (delegate != NULL)
+ return static_cast<InfobarManagerImpl*>(delegate);
+
+ scoped_ptr<HostWindowManager> host_manager(new HostWindowManager());
+
+ // transferred to new_host_manager in Initialize
+ InfobarManagerImpl* infobar_manager = new InfobarManagerImpl(
+ host_manager.get());
+
+ if (host_manager->Initialize(tab_window, infobar_manager)) {
+ host_manager.release(); // takes ownership of itself
+ return infobar_manager;
+ }
+
+ return NULL;
+}
Property changes on: chrome_frame\infobars\manager.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« chrome_frame/infobars/manager.h ('K') | « chrome_frame/infobars/manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698