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

Side by Side Diff: ceee/ie/plugin/bho/infobar_manager.h

Issue 4991002: New unittests for infobar. (Closed) Base URL: http://src.chromium.org/svn/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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // @file 5 // @file
6 // Manager for infobar windows. 6 // Manager for infobar windows.
7 7
8 #ifndef CEEE_IE_PLUGIN_BHO_INFOBAR_MANAGER_H_ 8 #ifndef CEEE_IE_PLUGIN_BHO_INFOBAR_MANAGER_H_
9 #define CEEE_IE_PLUGIN_BHO_INFOBAR_MANAGER_H_ 9 #define CEEE_IE_PLUGIN_BHO_INFOBAR_MANAGER_H_
10 10
11 #include "base/scoped_ptr.h" 11 #include "base/scoped_ptr.h"
12 #include "base/singleton.h" 12 #include "base/singleton.h"
13 #include "ceee/ie/plugin/bho/infobar_window.h" 13 #include "ceee/ie/plugin/bho/infobar_window.h"
14 #include "ceee/ie/plugin/bho/web_browser_events_source.h" 14 #include "ceee/ie/plugin/bho/web_browser_events_source.h"
15 15
16 namespace infobar_api { 16 namespace infobar_api {
17 17
18 // InfobarManager creates and manages infobars, which are displayed at the top 18 // InfobarManager creates and manages infobars, which are displayed at the top
19 // or bottom of IE content window. 19 // or bottom of IE content window.
20 class InfobarManager : public InfobarWindow::Delegate, 20 class InfobarManager : public InfobarWindow::Delegate,
21 public WebBrowserEventsSource::Sink { 21 public WebBrowserEventsSource::Sink {
22 public: 22 public:
23 explicit InfobarManager(HWND tab_window); 23 explicit InfobarManager(HWND tab_window);
24 24
25 // Shows the infobar of the specified type and navigates it to the specified 25 // Shows the infobar of the specified type and navigates it to the specified
26 // URL. 26 // URL.
27 HRESULT Show(InfobarType type, int max_height, const std::wstring& url, 27 virtual HRESULT Show(InfobarType type, int max_height,
28 bool slide); 28 const std::wstring& url, bool slide);
29 // Hides the infobar of the specified type. 29 // Hides the infobar of the specified type.
30 HRESULT Hide(InfobarType type); 30 virtual HRESULT Hide(InfobarType type);
31 // Hides all infobars. 31 // Hides all infobars.
32 void HideAll(); 32 virtual void HideAll();
33 33
34 // Implementation of InfobarWindow::Delegate. 34 // Implementation of InfobarWindow::Delegate.
35 // Finds the handle of the container window. 35 // Finds the handle of the container window.
36 virtual HWND GetContainerWindow(); 36 virtual HWND GetContainerWindow();
37 // Informs about window.close() event. 37 // Informs about window.close() event.
38 virtual void OnWindowClose(InfobarType type); 38 virtual void OnWindowClose(InfobarType type);
39 39
40 private: 40 protected:
41 class ContainerWindow; 41 class ContainerWindow;
42 class ContainerWindowInterface {
43 public:
44 virtual ~ContainerWindowInterface() {}
45 virtual bool IsDestroyed() const = 0;
46 virtual HWND GetWindowHandle() const = 0;
47 virtual bool PostWindowsMessage(UINT msg, WPARAM wparam, LPARAM lparam) = 0;
48 };
49
50 // Lazy initialization of InfobarWindow object.
51 void LazyInitialize(InfobarType type);
52
53 // Creates container window. Separated for the unit testing.
54 virtual ContainerWindowInterface* CreateContainerWindow(
55 HWND container, InfobarManager* manager);
42 56
43 // The HWND of the tab window the infobars are associated with. 57 // The HWND of the tab window the infobars are associated with.
44 HWND tab_window_; 58 HWND tab_window_;
45 59
46 // Parent window for IE content window. 60 // Parent window for IE content window.
47 scoped_ptr<ContainerWindow> container_window_; 61 scoped_ptr<ContainerWindowInterface> container_window_;
48 62
49 // Infobar windows. 63 // Infobar windows.
50 scoped_ptr<InfobarWindow> infobars_[END_OF_INFOBAR_TYPE]; 64 scoped_ptr<InfobarWindow> infobars_[END_OF_INFOBAR_TYPE];
51 65
52 // ContainerWindow callbacks. 66 // ContainerWindow callbacks.
53 // Callback for WM_NCCALCSIZE. 67 // Callback for WM_NCCALCSIZE.
54 void OnContainerWindowNcCalcSize(RECT* rect); 68 void OnContainerWindowNcCalcSize(RECT* rect);
55 // Callback for messages on size or position change. 69 // Callback for messages on size or position change.
56 void OnContainerWindowUpdatePosition(); 70 void OnContainerWindowUpdatePosition();
57 // Callback for message requesting closing the infobar. 71 // Callback for message requesting closing the infobar.
58 void OnContainerWindowDelayedCloseInfobar(InfobarType type); 72 void OnContainerWindowDelayedCloseInfobar(InfobarType type);
59 // Callback for WM_DESTROY. 73 // Callback for WM_DESTROY.
60 void OnContainerWindowDestroy(); 74 void OnContainerWindowDestroy();
61 75
62 DISALLOW_COPY_AND_ASSIGN(InfobarManager); 76 DISALLOW_COPY_AND_ASSIGN(InfobarManager);
63 }; 77 };
64 78
65 } // namespace infobar_api 79 } // namespace infobar_api
66 80
67 #endif // CEEE_IE_PLUGIN_BHO_INFOBAR_MANAGER_H_ 81 #endif // CEEE_IE_PLUGIN_BHO_INFOBAR_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698