1 // Copyright (c) 2011 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_READY_MODE_INTERNAL_READY_PROMPT_WINDOW_H_
6 #define CHROME_FRAME_READY_MODE_INTERNAL_READY_PROMPT_WINDOW_H_
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
16 #include "base/win/scoped_comptr.h"
17 #include "chrome_frame/infobars/infobar_content.h"
18 #include "chrome_frame/resource.h"
19 #include "grit/chrome_frame_dialogs.h"
28 // Implements a dialog with text and buttons inviting the user to permanently
29 // activate the product or temporarily/permanently disable Ready Mode.
30 class ReadyPromptWindow
31 : public CDialogImpl<ReadyPromptWindow, CWindow>,
32 public CDialogResize<ReadyPromptWindow> {
34 enum { IDD = IDD_CHROME_FRAME_READY_PROMPT };
36 // Creates and initializes a dialog for display in the provided frame. The
37 // ReadyModeState will be invoked to capture the user's response, if any.
38 // The UrlLauncher may be used to launch a new tab containing a
39 // knowledge-base article about Ready Mode.
41 // Upon success, takes ownership of itself (to be deleted upon WM_DESTROY) and
42 // returns a weak pointer to this dialog. Upon failure, returns a null weak
43 // pointer and deletes self.
45 // In either case, takes ownership of the ReadyModeState and UrlLauncher, but
47 static base::WeakPtr<ReadyPromptWindow> CreateInstance(
48 InfobarContent::Frame* frame,
49 ReadyModeState* ready_mode_state,
50 UrlLauncher* url_launcher);
52 BEGIN_MSG_MAP(InfobarWindow)
53 MSG_WM_INITDIALOG(OnInitDialog)
54 MSG_WM_DESTROY(OnDestroy)
55 NOTIFY_HANDLER(IDC_PROMPT_LINK, NM_CLICK, OnLearnMore)
56 COMMAND_HANDLER(IDACTIVATE, BN_CLICKED, OnYes)
57 COMMAND_HANDLER(IDNEVER, BN_CLICKED, OnNo)
58 CHAIN_MSG_MAP(CDialogResize<ReadyPromptWindow>)
61 BEGIN_DLGRESIZE_MAP(InfobarWindow)
62 DLGRESIZE_CONTROL(IDACTIVATE, DLSZ_CENTER_Y | DLSZ_MOVE_X)
63 DLGRESIZE_CONTROL(IDNEVER, DLSZ_CENTER_Y | DLSZ_MOVE_X)
64 DLGRESIZE_CONTROL(IDC_PROMPT_MESSAGE, DLSZ_SIZE_Y | DLSZ_SIZE_X)
65 DLGRESIZE_CONTROL(IDC_PROMPT_LINK, DLSZ_CENTER_Y | DLSZ_MOVE_X)
68 virtual void OnFinalMessage(HWND);
71 // Call CreateInstance() to get an initialized ReadyPromptWindow.
72 ReadyPromptWindow(InfobarContent::Frame* frame,
73 ReadyModeState* ready_mode_state,
74 UrlLauncher* url_launcher);
76 // The ReadyPromptWindow manages its own destruction.
77 virtual ~ReadyPromptWindow();
81 BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam);
82 LRESULT OnYes(WORD wNotifyCode,
86 LRESULT OnRemindMeLater(WORD wNotifyCode,
90 LRESULT OnLearnMore(WORD wParam, LPNMHDR lParam, BOOL& bHandled); // NOLINT
91 LRESULT OnNo(WORD wNotifyCode,
96 InfobarContent::Frame* frame_; // Not owned by this instance
97 scoped_ptr<ReadyModeState> ready_mode_state_;
98 scoped_ptr<WTL::CHyperLink> link_;
99 scoped_ptr<UrlLauncher> url_launcher_;
102 base::WeakPtrFactory<ReadyPromptWindow> weak_ptr_factory_;
103 DISALLOW_COPY_AND_ASSIGN(ReadyPromptWindow);
104 }; // class ReadyPromptWindow
106 #endif // CHROME_FRAME_READY_MODE_INTERNAL_READY_PROMPT_WINDOW_H_