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

Side by Side 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 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 #include "chrome_frame/infobars/manager.h"
6
7 #include "base/logging.h"
8 #include "base/scoped_ptr.h"
9
10 #include "chrome_frame/infobars/internal/host_window.h"
11 #include "chrome_frame/infobars/internal/infobar_window.h"
12
13 // Connects InfobarWindow to HostWindowManager, and exposes the result as an
14 // InfobarManager
grt (UTC plus 2) 2010/12/02 16:27:52 nit: end the sentence w/ '.'
15 class InfobarManagerImpl
16 : public InfobarManager,
17 public InfobarWindow::Host,
18 public HostWindowManager::Delegate {
19 public:
20 explicit InfobarManagerImpl(HostWindowManager* manager);
21
22 // Implementation of InfobarManager
23 virtual bool Show(InfobarContent* content, InfobarType type);
24 virtual void Hide(InfobarType type);
25 virtual void HideAll();
26
27 // Implementation of HostWindowManager::Delegate
28 virtual void AdjustDisplacedWindowDimensions(RECT* rect);
29
30 // Implementation of InfobarWindow::Host
31 virtual HWND GetContainerWindow();
32 virtual void UpdateLayout();
33
34 private:
35 // Not owned by this instance.
36 HostWindowManager* manager_;
37 // Infobar windows.
38 scoped_ptr<InfobarWindow> infobars_[END_OF_INFOBAR_TYPE];
39 DISALLOW_COPY_AND_ASSIGN(InfobarManagerImpl);
40 }; // class InfobarManagerImpl
41
42 InfobarManagerImpl::InfobarManagerImpl(HostWindowManager* manager)
43 : manager_(manager) {
44 for (int index = 0; index < END_OF_INFOBAR_TYPE; ++index) {
45 infobars_[index].reset(
46 new InfobarWindow(static_cast<InfobarType>(index)));
47 infobars_[index]->SetHost(this);
48 }
49 }
50
51 bool InfobarManagerImpl::Show(InfobarContent* content, InfobarType type) {
52 DCHECK(type >= FIRST_INFOBAR_TYPE && type < END_OF_INFOBAR_TYPE);
53 return infobars_[type]->Show(content);
54 }
55
56 void InfobarManagerImpl::Hide(InfobarType type) {
57 DCHECK(type >= FIRST_INFOBAR_TYPE && type < END_OF_INFOBAR_TYPE);
58 infobars_[type]->Hide();
59 }
60
61 void InfobarManagerImpl::HideAll() {
62 for (int index = 0; index < END_OF_INFOBAR_TYPE; ++index)
63 Hide(static_cast<InfobarType>(index));
64 }
65
66 void InfobarManagerImpl::AdjustDisplacedWindowDimensions(RECT* rect) {
67 for (int index = 0; index < END_OF_INFOBAR_TYPE; ++index) {
68 if (infobars_[index] != NULL)
69 infobars_[index]->ReserveSpace(rect);
70 }
71 }
72
73 HWND InfobarManagerImpl::GetContainerWindow() {
74 return *manager_;
75 }
76
77 void InfobarManagerImpl::UpdateLayout() {
78 manager_->UpdateLayout();
79 }
80
81 InfobarManager::~InfobarManager() {
82 }
83
84 InfobarManager* InfobarManager::Get(HWND tab_window) {
85 HostWindowManager::Delegate* delegate =
86 HostWindowManager::GetDelegateForHwnd(tab_window);
87
88 if (delegate != NULL)
89 return static_cast<InfobarManagerImpl*>(delegate);
90
91 scoped_ptr<HostWindowManager> host_manager(new HostWindowManager());
92
93 // Transferred to host_manager in call to Initialize
grt (UTC plus 2) 2010/12/02 16:27:52 nit: end the sentence w/ '.'
94 InfobarManagerImpl* infobar_manager = new InfobarManagerImpl(
95 host_manager.get());
96
97 if (host_manager->Initialize(tab_window, infobar_manager)) {
98 host_manager.release(); // takes ownership of itself
99 return infobar_manager;
100 }
101
102 return NULL;
103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698