gpu: Tweak Android WebGL test expectations
[chromium-blink-merge.git] / chrome_frame / turndown_prompt / turndown_prompt_window.h
blob342e38a7ff8779474481aee6c15e0623f437f9bb
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.
5 #ifndef CHROME_FRAME_TURNDOWN_PROMPT_TURNDOWN_PROMPT_WINDOW_H_
6 #define CHROME_FRAME_TURNDOWN_PROMPT_TURNDOWN_PROMPT_WINDOW_H_
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>
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/strings/string16.h"
21 #include "base/win/scoped_comptr.h"
22 #include "base/win/scoped_handle.h"
23 #include "chrome_frame/infobars/infobar_content.h"
24 #include "chrome_frame/resource.h"
25 #include "grit/chrome_frame_dialogs.h"
27 class UrlLauncher;
29 namespace WTL {
30 class CHyperLink;
31 class CBitmapButton;
32 } // namespace WTL
34 class CFBitmapButton;
36 // Implements a dialog with text and buttons notifying the user that Chrome
37 // Frame is being turned down, offering them a link to learn more about moving
38 // to a modern browser.
39 class TurndownPromptWindow
40 : public CDialogImpl<TurndownPromptWindow, CWindow>,
41 public CDialogResize<TurndownPromptWindow>,
42 public CThemeImpl<TurndownPromptWindow> {
43 public:
44 enum { IDD = IDD_CHROME_FRAME_TURNDOWN_PROMPT };
46 // Creates and initializes a dialog for display in the provided frame. The
47 // UrlLauncher may be used to launch a new tab containing a knowledge-base
48 // article about the turndown.
50 // Upon success, takes ownership of itself (to be deleted upon WM_DESTROY) and
51 // returns a weak pointer to this dialog. Upon failure, returns a null weak
52 // pointer and deletes self.
54 // In either case, takes ownership of the UrlLauncher but not the frame.
55 // |uninstall_closure| is invoked if/when the Uninstall button is activated.
56 static base::WeakPtr<TurndownPromptWindow> CreateInstance(
57 InfobarContent::Frame* frame,
58 UrlLauncher* url_launcher,
59 const base::Closure& uninstall_closure);
61 BEGIN_MSG_MAP(InfobarWindow)
62 CHAIN_MSG_MAP(CThemeImpl<TurndownPromptWindow>)
63 MSG_WM_DESTROY(OnDestroy)
64 MSG_WM_INITDIALOG(OnInitDialog)
65 NOTIFY_HANDLER(IDC_TD_PROMPT_LINK, NM_CLICK, OnLearnMore)
66 COMMAND_HANDLER(IDUNINSTALL, BN_CLICKED, OnUninstall)
67 COMMAND_HANDLER(IDDISMISS, BN_CLICKED, OnDismiss)
68 CHAIN_MSG_MAP(CDialogResize<TurndownPromptWindow>)
69 END_MSG_MAP()
71 BEGIN_DLGRESIZE_MAP(InfobarWindow)
72 DLGRESIZE_CONTROL(IDDISMISS, DLSZ_CENTER_Y | DLSZ_MOVE_X)
73 DLGRESIZE_CONTROL(IDUNINSTALL, DLSZ_CENTER_Y | DLSZ_MOVE_X)
74 DLGRESIZE_CONTROL(IDC_TD_PROMPT_LINK, DLSZ_CENTER_Y | DLSZ_MOVE_X)
75 DLGRESIZE_CONTROL(IDC_TD_PROMPT_MESSAGE, DLSZ_SIZE_Y | DLSZ_SIZE_X)
76 END_DLGRESIZE_MAP()
78 virtual void OnFinalMessage(HWND);
80 private:
81 // Call CreateInstance() to get an initialized TurndownPromptWindow.
82 TurndownPromptWindow(InfobarContent::Frame* frame,
83 UrlLauncher* url_launcher,
84 const base::Closure& uninstall_closure);
86 // The TurndownPromptWindow manages its own destruction.
87 virtual ~TurndownPromptWindow();
89 // Performs the necessary configuration to initialize a bitmap button.
90 static void SetupBitmapButton(TurndownPromptWindow* window);
92 // Event handlers.
93 void OnDestroy();
94 BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam);
95 LRESULT OnLearnMore(WORD wParam, LPNMHDR lParam, BOOL& bHandled); // NOLINT
96 LRESULT OnUninstall(WORD wNotifyCode,
97 WORD wID,
98 HWND hWndCtl,
99 BOOL& bHandled);
100 LRESULT OnDismiss(WORD wNotifyCode,
101 WORD wID,
102 HWND hWndCtl,
103 BOOL& bHandled);
105 // Returns the prompt text for the current version of IE.
106 static string16 GetPromptText();
108 InfobarContent::Frame* frame_; // Not owned by this instance
109 scoped_ptr<WTL::CHyperLink> link_;
110 scoped_ptr<CFBitmapButton> close_button_;
111 scoped_ptr<UrlLauncher> url_launcher_;
112 base::Closure uninstall_closure_;
114 base::WeakPtrFactory<TurndownPromptWindow> weak_ptr_factory_;
115 DISALLOW_COPY_AND_ASSIGN(TurndownPromptWindow);
116 }; // class TurndownPromptWindow
118 #endif // CHROME_FRAME_TURNDOWN_PROMPT_TURNDOWN_PROMPT_WINDOW_H_