| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_FRAME_READY_MODE_INTERNAL_READY_PROMPT_WINDOW_H_ | |
| 6 #define CHROME_FRAME_READY_MODE_INTERNAL_READY_PROMPT_WINDOW_H_ | |
| 7 | |
| 8 #include <atlbase.h> | |
| 9 #include <atlapp.h> | |
| 10 #include <atlcrack.h> | |
| 11 #include <atlframe.h> | |
| 12 #include <atlwin.h> | |
| 13 | |
| 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" | |
| 20 | |
| 21 class ReadyModeState; | |
| 22 class UrlLauncher; | |
| 23 | |
| 24 namespace WTL { | |
| 25 class CHyperLink; | |
| 26 } // namespace WTL | |
| 27 | |
| 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> { | |
| 33 public: | |
| 34 enum { IDD = IDD_CHROME_FRAME_READY_PROMPT }; | |
| 35 | |
| 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. | |
| 40 // | |
| 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. | |
| 44 // | |
| 45 // In either case, takes ownership of the ReadyModeState and UrlLauncher, but | |
| 46 // not the frame. | |
| 47 static base::WeakPtr<ReadyPromptWindow> CreateInstance( | |
| 48 InfobarContent::Frame* frame, | |
| 49 ReadyModeState* ready_mode_state, | |
| 50 UrlLauncher* url_launcher); | |
| 51 | |
| 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>) | |
| 59 END_MSG_MAP() | |
| 60 | |
| 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) | |
| 66 END_DLGRESIZE_MAP() | |
| 67 | |
| 68 virtual void OnFinalMessage(HWND); | |
| 69 | |
| 70 private: | |
| 71 // Call CreateInstance() to get an initialized ReadyPromptWindow. | |
| 72 ReadyPromptWindow(InfobarContent::Frame* frame, | |
| 73 ReadyModeState* ready_mode_state, | |
| 74 UrlLauncher* url_launcher); | |
| 75 | |
| 76 // The ReadyPromptWindow manages its own destruction. | |
| 77 virtual ~ReadyPromptWindow(); | |
| 78 | |
| 79 // Event handlers. | |
| 80 void OnDestroy(); | |
| 81 BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam); | |
| 82 LRESULT OnYes(WORD wNotifyCode, | |
| 83 WORD wID, | |
| 84 HWND hWndCtl, | |
| 85 BOOL& bHandled); | |
| 86 LRESULT OnRemindMeLater(WORD wNotifyCode, | |
| 87 WORD wID, | |
| 88 HWND hWndCtl, | |
| 89 BOOL& bHandled); | |
| 90 LRESULT OnLearnMore(WORD wParam, LPNMHDR lParam, BOOL& bHandled); // NOLINT | |
| 91 LRESULT OnNo(WORD wNotifyCode, | |
| 92 WORD wID, | |
| 93 HWND hWndCtl, | |
| 94 BOOL& bHandled); | |
| 95 | |
| 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_; | |
| 100 | |
| 101 HICON icon_; | |
| 102 base::WeakPtrFactory<ReadyPromptWindow> weak_ptr_factory_; | |
| 103 DISALLOW_COPY_AND_ASSIGN(ReadyPromptWindow); | |
| 104 }; // class ReadyPromptWindow | |
| 105 | |
| 106 #endif // CHROME_FRAME_READY_MODE_INTERNAL_READY_PROMPT_WINDOW_H_ | |
| OLD | NEW |