OLD | NEW |
(Empty) | |
| 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 |
| 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/weak_ptr.h" |
| 15 #include "base/scoped_ptr.h" |
| 16 #include "chrome_frame/infobars/infobar_content.h" |
| 17 #include "chrome_frame/resource.h" |
| 18 #include "grit/generated_resources.h" |
| 19 |
| 20 class ReadyModeState; |
| 21 |
| 22 // Implements a dialog with text and buttons inviting the user to permanently |
| 23 // activate the product or temporarily/permanently disable Ready Mode. |
| 24 class ReadyPromptWindow |
| 25 : public CDialogImpl<ReadyPromptWindow, CWindow>, |
| 26 public CDialogResize<ReadyPromptWindow> { |
| 27 public: |
| 28 enum { IDD = IDD_CHROME_FRAME_READY_PROMPT }; |
| 29 |
| 30 ReadyPromptWindow(); |
| 31 ~ReadyPromptWindow() {} |
| 32 |
| 33 // Initializes the dialog for display in the provided frame. The |
| 34 // ReadyModeState will be invoked to capture the user's response, if any. |
| 35 // |
| 36 // Upon success, takes ownership of itself (to be deleted upon WM_DESTROY) and |
| 37 // returns a weak pointer to this dialog. Upon failure, returns a null weak |
| 38 // pointer and deletes self. |
| 39 // |
| 40 // In either case, takes ownership of the ReadyModeState, but not the frame. |
| 41 base::WeakPtr<ReadyPromptWindow> Initialize(InfobarContent::Frame* frame, |
| 42 ReadyModeState* ready_mode_state); |
| 43 |
| 44 BEGIN_MSG_MAP(InfobarWindow) |
| 45 MSG_WM_INITDIALOG(OnInitDialog) |
| 46 MSG_WM_DESTROY(OnDestroy) |
| 47 COMMAND_HANDLER(IDACTIVATE, BN_CLICKED, OnYes) |
| 48 COMMAND_HANDLER(IDLATER, BN_CLICKED, OnRemindMeLater) |
| 49 COMMAND_HANDLER(IDNEVER, BN_CLICKED, OnNo) |
| 50 CHAIN_MSG_MAP(CDialogResize<ReadyPromptWindow>) |
| 51 END_MSG_MAP() |
| 52 |
| 53 BEGIN_DLGRESIZE_MAP(InfobarWindow) |
| 54 DLGRESIZE_CONTROL(IDACTIVATE, DLSZ_CENTER_Y | DLSZ_MOVE_X) |
| 55 DLGRESIZE_CONTROL(IDLATER, DLSZ_CENTER_Y | DLSZ_MOVE_X) |
| 56 DLGRESIZE_CONTROL(IDNEVER, DLSZ_CENTER_Y | DLSZ_MOVE_X) |
| 57 DLGRESIZE_CONTROL(IDC_PROMPT_MESSAGE, DLSZ_SIZE_Y | DLSZ_SIZE_X) |
| 58 END_DLGRESIZE_MAP() |
| 59 |
| 60 virtual void OnFinalMessage(HWND); |
| 61 |
| 62 private: |
| 63 // Event handlers. |
| 64 void OnDestroy(); |
| 65 BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam); |
| 66 LRESULT OnYes(WORD wNotifyCode, |
| 67 WORD wID, |
| 68 HWND hWndCtl, |
| 69 BOOL& bHandled); |
| 70 LRESULT OnRemindMeLater(WORD wNotifyCode, |
| 71 WORD wID, |
| 72 HWND hWndCtl, |
| 73 BOOL& bHandled); |
| 74 LRESULT OnNo(WORD wNotifyCode, |
| 75 WORD wID, |
| 76 HWND hWndCtl, |
| 77 BOOL& bHandled); |
| 78 |
| 79 InfobarContent::Frame* frame_; // Not owned by this instance |
| 80 scoped_ptr<ReadyModeState> ready_mode_state_; |
| 81 |
| 82 base::WeakPtrFactory<ReadyPromptWindow> weak_ptr_factory_; |
| 83 DISALLOW_COPY_AND_ASSIGN(ReadyPromptWindow); |
| 84 }; // class ReadyPromptWindow |
| 85 |
| 86 #endif // CHROME_FRAME_READY_MODE_INTERNAL_READY_PROMPT_WINDOW_H_ |
OLD | NEW |