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

Side by Side Diff: chrome_frame/turndown_prompt/turndown_prompt_window.h

Issue 17153006: Chrome Frame turndown prompt. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months 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
(Empty)
1 // Copyright 2013 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 #ifndef CHROME_FRAME_TURNDOWN_PROMPT_TURNDOWN_PROMPT_WINDOW_H_
6 #define CHROME_FRAME_TURNDOWN_PROMPT_TURNDOWN_PROMPT_WINDOW_H_
7
8 #include <windows.h>
9 #include <atlbase.h>
10 #include <atlapp.h>
11 #include <atlcrack.h>
12 #include <atlframe.h>
13 #include <atltheme.h>
14 #include <atlwin.h>
15
16 #include "base/debug/debugger.h"
17 #include "base/callback.h"
18 #include "base/memory/scoped_ptr.h"
19 #include "base/memory/weak_ptr.h"
20 #include "base/win/scoped_comptr.h"
21 #include "base/win/scoped_handle.h"
22 #include "chrome_frame/infobars/infobar_content.h"
23 #include "chrome_frame/resource.h"
24 #include "grit/chrome_frame_dialogs.h"
25
26 class UrlLauncher;
27
28 namespace WTL {
29 class CHyperLink;
30 } // namespace WTL
31
32 // Implements a dialog with text and buttons notifying the user that Chrome
33 // Frame is being turned down, offering them a link to learn more about moving
34 // to a modern browser.
35 class TurndownPromptWindow
36 : public CDialogImpl<TurndownPromptWindow, CWindow>,
37 public CDialogResize<TurndownPromptWindow>,
38 public CThemeImpl<TurndownPromptWindow> {
39 public:
40 enum { IDD = IDD_CHROME_FRAME_TURNDOWN_PROMPT };
41
42 // Creates and initializes a dialog for display in the provided frame. The
43 // UrlLauncher may be used to launch a new tab containing a knowledge-base
44 // article about the turndown.
45 //
46 // Upon success, takes ownership of itself (to be deleted upon WM_DESTROY) and
47 // returns a weak pointer to this dialog. Upon failure, returns a null weak
48 // pointer and deletes self.
49 //
50 // In either case, takes ownership of the UrlLauncher but not the frame.
51 // |uninstall_closure| is invoked if/when the Uninstall button is activated.
52 static base::WeakPtr<TurndownPromptWindow> CreateInstance(
53 InfobarContent::Frame* frame,
54 UrlLauncher* url_launcher,
55 const base::Closure& uninstall_closure);
56
57 BEGIN_MSG_MAP(InfobarWindow)
58 CHAIN_MSG_MAP(CThemeImpl<TurndownPromptWindow>)
59 MSG_WM_CTLCOLORDLG(OnCtlColorDlg)
60 MSG_WM_DESTROY(OnDestroy)
61 MSG_WM_INITDIALOG(OnInitDialog)
62 MSG_WM_THEMECHANGED(OnThemeChanged)
63 NOTIFY_HANDLER(IDC_TD_PROMPT_LINK, NM_CLICK, OnLearnMore)
64 COMMAND_HANDLER(IDUNINSTALL, BN_CLICKED, OnUninstall)
65 COMMAND_HANDLER(IDDISMISS, BN_CLICKED, OnDismiss)
66 CHAIN_MSG_MAP(CDialogResize<TurndownPromptWindow>)
67 END_MSG_MAP()
68
69 BEGIN_DLGRESIZE_MAP(InfobarWindow)
70 DLGRESIZE_CONTROL(IDDISMISS, DLSZ_CENTER_Y | DLSZ_MOVE_X)
71 DLGRESIZE_CONTROL(IDUNINSTALL, DLSZ_CENTER_Y | DLSZ_MOVE_X)
72 DLGRESIZE_CONTROL(IDC_TD_PROMPT_MESSAGE, DLSZ_SIZE_Y | DLSZ_SIZE_X)
73 DLGRESIZE_CONTROL(IDC_TD_PROMPT_LINK, DLSZ_CENTER_Y | DLSZ_MOVE_X)
74 END_DLGRESIZE_MAP()
75
76 virtual void OnFinalMessage(HWND);
77
78 private:
79 template<class GDIHANDLE>
80 struct GdiObjectTraits {
81 typedef GDIHANDLE Handle;
82 static bool CloseHandle(GDIHANDLE handle) {
83 return ::DeleteObject(handle) != FALSE;
84 }
85 static bool IsHandleValid(GDIHANDLE handle) {
86 return handle != NULL;
87 }
88 static GDIHANDLE NullHandle() {
89 return NULL;
90 }
91 };
92 typedef base::win::GenericScopedHandle<GdiObjectTraits<HBRUSH>,
93 base::win::DummyVerifierTraits>
94 ScopedBrushHandle;
95
96 // Call CreateInstance() to get an initialized TurndownPromptWindow.
97 TurndownPromptWindow(InfobarContent::Frame* frame,
98 UrlLauncher* url_launcher,
99 const base::Closure& uninstall_closure);
100
101 // The TurndownPromptWindow manages its own destruction.
102 virtual ~TurndownPromptWindow();
103
104 // Event handlers.
105 HBRUSH OnCtlColorDlg(HDC device_context, HWND window);
106 void OnDestroy();
107 BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam);
108 void OnThemeChanged();
109 LRESULT OnLearnMore(WORD wParam, LPNMHDR lParam, BOOL& bHandled); // NOLINT
110 LRESULT OnUninstall(WORD wNotifyCode,
111 WORD wID,
112 HWND hWndCtl,
113 BOOL& bHandled);
114 LRESULT OnDismiss(WORD wNotifyCode,
115 WORD wID,
116 HWND hWndCtl,
117 BOOL& bHandled);
118
119 InfobarContent::Frame* frame_; // Not owned by this instance
120 scoped_ptr<WTL::CHyperLink> link_;
121 scoped_ptr<UrlLauncher> url_launcher_;
122 base::Closure uninstall_closure_;
123 ScopedBrushHandle brush_;
124
125 base::WeakPtrFactory<TurndownPromptWindow> weak_ptr_factory_;
126 DISALLOW_COPY_AND_ASSIGN(TurndownPromptWindow);
127 }; // class TurndownPromptWindow
128
129 #endif // CHROME_FRAME_TURNDOWN_PROMPT_TURNDOWN_PROMPT_WINDOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698