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