Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_FRAME_READY_MODE_INTERNAL_READY_PROMPT_WINDOW_H_ | 5 #ifndef CHROME_FRAME_READY_MODE_INTERNAL_READY_PROMPT_WINDOW_H_ |
| 6 #define CHROME_FRAME_READY_MODE_INTERNAL_READY_PROMPT_WINDOW_H_ | 6 #define CHROME_FRAME_READY_MODE_INTERNAL_READY_PROMPT_WINDOW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <atlbase.h> | 9 #include <atlbase.h> |
| 10 #include <atlapp.h> | 10 #include <atlapp.h> |
| 11 #include <atlcrack.h> | 11 #include <atlcrack.h> |
| 12 #include <atlframe.h> | 12 #include <atlframe.h> |
| 13 #include <atlwin.h> | 13 #include <atlwin.h> |
| 14 | 14 |
| 15 #include "base/weak_ptr.h" | 15 #include "base/weak_ptr.h" |
| 16 #include "base/scoped_ptr.h" | 16 #include "base/scoped_ptr.h" |
| 17 #include "base/win/scoped_comptr.h" | |
| 17 #include "chrome_frame/infobars/infobar_content.h" | 18 #include "chrome_frame/infobars/infobar_content.h" |
| 18 #include "chrome_frame/resource.h" | 19 #include "chrome_frame/resource.h" |
| 19 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
| 20 | 21 |
| 21 class ReadyModeState; | 22 class ReadyModeState; |
| 23 class UrlLauncher; | |
| 24 | |
| 25 namespace WTL { | |
| 26 class CHyperLink; | |
| 27 } // namespace WTL | |
| 22 | 28 |
| 23 // Implements a dialog with text and buttons inviting the user to permanently | 29 // Implements a dialog with text and buttons inviting the user to permanently |
| 24 // activate the product or temporarily/permanently disable Ready Mode. | 30 // activate the product or temporarily/permanently disable Ready Mode. |
| 25 class ReadyPromptWindow | 31 class ReadyPromptWindow |
| 26 : public CDialogImpl<ReadyPromptWindow, CWindow>, | 32 : public CDialogImpl<ReadyPromptWindow, CWindow>, |
| 27 public CDialogResize<ReadyPromptWindow> { | 33 public CDialogResize<ReadyPromptWindow> { |
| 28 public: | 34 public: |
| 29 enum { IDD = IDD_CHROME_FRAME_READY_PROMPT }; | 35 enum { IDD = IDD_CHROME_FRAME_READY_PROMPT }; |
| 30 | 36 |
| 31 ReadyPromptWindow(); | 37 // Creates and initializes a dialog for display in the provided frame. The |
| 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. | 38 // ReadyModeState will be invoked to capture the user's response, if any. |
| 39 // The UrlLauncher may be used to launch a new tab containing a | |
| 40 // knowledge-base article about Ready Mode. | |
| 36 // | 41 // |
| 37 // Upon success, takes ownership of itself (to be deleted upon WM_DESTROY) and | 42 // 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 | 43 // returns a weak pointer to this dialog. Upon failure, returns a null weak |
| 39 // pointer and deletes self. | 44 // pointer and deletes self. |
| 40 // | 45 // |
| 41 // In either case, takes ownership of the ReadyModeState, but not the frame. | 46 // In either case, takes ownership of the ReadyModeState and UrlLauncher, but |
| 42 base::WeakPtr<ReadyPromptWindow> Initialize(InfobarContent::Frame* frame, | 47 // not the frame. |
| 43 ReadyModeState* ready_mode_state); | 48 static base::WeakPtr<ReadyPromptWindow> CreateInstance( |
| 49 InfobarContent::Frame* frame, | |
| 50 ReadyModeState* ready_mode_state, | |
| 51 UrlLauncher* url_launcher); | |
| 44 | 52 |
| 45 BEGIN_MSG_MAP(InfobarWindow) | 53 BEGIN_MSG_MAP(InfobarWindow) |
| 46 MSG_WM_INITDIALOG(OnInitDialog) | 54 MSG_WM_INITDIALOG(OnInitDialog) |
| 47 MSG_WM_DESTROY(OnDestroy) | 55 MSG_WM_DESTROY(OnDestroy) |
| 56 NOTIFY_HANDLER(IDC_PROMPT_LINK, NM_CLICK, OnLearnMore) | |
| 48 COMMAND_HANDLER(IDACTIVATE, BN_CLICKED, OnYes) | 57 COMMAND_HANDLER(IDACTIVATE, BN_CLICKED, OnYes) |
| 49 COMMAND_HANDLER(IDLATER, BN_CLICKED, OnRemindMeLater) | |
| 50 COMMAND_HANDLER(IDNEVER, BN_CLICKED, OnNo) | 58 COMMAND_HANDLER(IDNEVER, BN_CLICKED, OnNo) |
| 51 CHAIN_MSG_MAP(CDialogResize<ReadyPromptWindow>) | 59 CHAIN_MSG_MAP(CDialogResize<ReadyPromptWindow>) |
| 52 END_MSG_MAP() | 60 END_MSG_MAP() |
| 53 | 61 |
| 54 BEGIN_DLGRESIZE_MAP(InfobarWindow) | 62 BEGIN_DLGRESIZE_MAP(InfobarWindow) |
| 55 DLGRESIZE_CONTROL(IDACTIVATE, DLSZ_CENTER_Y | DLSZ_MOVE_X) | 63 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) | 64 DLGRESIZE_CONTROL(IDNEVER, DLSZ_CENTER_Y | DLSZ_MOVE_X) |
| 58 DLGRESIZE_CONTROL(IDC_PROMPT_MESSAGE, DLSZ_SIZE_Y | DLSZ_SIZE_X) | 65 DLGRESIZE_CONTROL(IDC_PROMPT_MESSAGE, DLSZ_SIZE_Y | DLSZ_SIZE_X) |
| 66 DLGRESIZE_CONTROL(IDC_PROMPT_LINK, DLSZ_CENTER_Y | DLSZ_MOVE_X) | |
| 59 END_DLGRESIZE_MAP() | 67 END_DLGRESIZE_MAP() |
| 60 | 68 |
| 61 virtual void OnFinalMessage(HWND); | 69 virtual void OnFinalMessage(HWND); |
| 62 | 70 |
| 63 private: | 71 private: |
| 72 // Call CreateInstance() to get an initialized ReadyPromptWindow. | |
| 73 ReadyPromptWindow(InfobarContent::Frame* frame, | |
| 74 ReadyModeState* ready_mode_state, | |
| 75 UrlLauncher* url_launcher); | |
| 76 | |
| 77 // The ReadyPromptWindow manages its own destruction. | |
| 78 virtual ~ReadyPromptWindow(); | |
| 79 | |
| 64 // Event handlers. | 80 // Event handlers. |
| 65 void OnDestroy(); | 81 void OnDestroy(); |
| 66 BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam); | 82 BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam); |
| 67 LRESULT OnYes(WORD wNotifyCode, | 83 LRESULT OnYes(WORD wNotifyCode, |
| 68 WORD wID, | 84 WORD wID, |
| 69 HWND hWndCtl, | 85 HWND hWndCtl, |
| 70 BOOL& bHandled); | 86 BOOL& bHandled); |
| 71 LRESULT OnRemindMeLater(WORD wNotifyCode, | 87 LRESULT OnRemindMeLater(WORD wNotifyCode, |
| 72 WORD wID, | 88 WORD wID, |
| 73 HWND hWndCtl, | 89 HWND hWndCtl, |
| 74 BOOL& bHandled); | 90 BOOL& bHandled); |
| 91 LRESULT OnLearnMore(WORD wParam, LPNMHDR lParam, BOOL& bHandled); // NOLINT | |
|
tommi (sloooow) - chröme
2011/01/24 17:54:23
remove all hungarian
erikwright (departed)
2011/01/24 18:55:19
See comment in the implementation file.
| |
| 75 LRESULT OnNo(WORD wNotifyCode, | 92 LRESULT OnNo(WORD wNotifyCode, |
| 76 WORD wID, | 93 WORD wID, |
| 77 HWND hWndCtl, | 94 HWND hWndCtl, |
| 78 BOOL& bHandled); | 95 BOOL& bHandled); |
| 79 | 96 |
| 80 InfobarContent::Frame* frame_; // Not owned by this instance | 97 InfobarContent::Frame* frame_; // Not owned by this instance |
| 81 scoped_ptr<ReadyModeState> ready_mode_state_; | 98 scoped_ptr<ReadyModeState> ready_mode_state_; |
| 99 scoped_ptr<WTL::CHyperLink> link_; | |
| 100 scoped_ptr<UrlLauncher> url_launcher_; | |
| 82 | 101 |
| 83 base::WeakPtrFactory<ReadyPromptWindow> weak_ptr_factory_; | 102 base::WeakPtrFactory<ReadyPromptWindow> weak_ptr_factory_; |
| 84 DISALLOW_COPY_AND_ASSIGN(ReadyPromptWindow); | 103 DISALLOW_COPY_AND_ASSIGN(ReadyPromptWindow); |
| 85 }; // class ReadyPromptWindow | 104 }; // class ReadyPromptWindow |
| 86 | 105 |
| 87 #endif // CHROME_FRAME_READY_MODE_INTERNAL_READY_PROMPT_WINDOW_H_ | 106 #endif // CHROME_FRAME_READY_MODE_INTERNAL_READY_PROMPT_WINDOW_H_ |
| OLD | NEW |