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; |
22 | 23 |
24 namespace WTL { | |
25 class CHyperLink; | |
26 } // namespace WTL | |
27 | |
28 interface IWebBrowser2; | |
29 | |
23 // Implements a dialog with text and buttons inviting the user to permanently | 30 // Implements a dialog with text and buttons inviting the user to permanently |
24 // activate the product or temporarily/permanently disable Ready Mode. | 31 // activate the product or temporarily/permanently disable Ready Mode. |
25 class ReadyPromptWindow | 32 class ReadyPromptWindow |
26 : public CDialogImpl<ReadyPromptWindow, CWindow>, | 33 : public CDialogImpl<ReadyPromptWindow, CWindow>, |
27 public CDialogResize<ReadyPromptWindow> { | 34 public CDialogResize<ReadyPromptWindow> { |
28 public: | 35 public: |
29 enum { IDD = IDD_CHROME_FRAME_READY_PROMPT }; | 36 enum { IDD = IDD_CHROME_FRAME_READY_PROMPT }; |
30 | 37 |
31 ReadyPromptWindow(); | 38 ReadyPromptWindow(); |
32 ~ReadyPromptWindow() {} | 39 virtual ~ReadyPromptWindow(); |
robertshield
2011/01/24 16:10:21
It looks like this object shouldn't be created on
erikwright (departed)
2011/01/24 17:14:01
Done.
| |
33 | 40 |
34 // Initializes the dialog for display in the provided frame. The | 41 // Initializes the dialog for display in the provided frame. The |
35 // ReadyModeState will be invoked to capture the user's response, if any. | 42 // ReadyModeState will be invoked to capture the user's response, if any. |
43 // The IWebBrowser2 may be used to launch a new tab containing a | |
44 // knowledge-base article about Ready Mode. | |
36 // | 45 // |
37 // Upon success, takes ownership of itself (to be deleted upon WM_DESTROY) and | 46 // 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 | 47 // returns a weak pointer to this dialog. Upon failure, returns a null weak |
39 // pointer and deletes self. | 48 // pointer and deletes self. |
40 // | 49 // |
41 // In either case, takes ownership of the ReadyModeState, but not the frame. | 50 // In either case, takes ownership of the ReadyModeState, but not the frame. |
51 // Holds a reference to web_browser until destruction. | |
42 base::WeakPtr<ReadyPromptWindow> Initialize(InfobarContent::Frame* frame, | 52 base::WeakPtr<ReadyPromptWindow> Initialize(InfobarContent::Frame* frame, |
43 ReadyModeState* ready_mode_state); | 53 ReadyModeState* ready_mode_state, |
54 IWebBrowser2* web_browser); | |
robertshield
2011/01/24 16:10:21
I should have made this comment on an earlier revi
erikwright (departed)
2011/01/24 17:14:01
Done.
| |
44 | 55 |
45 BEGIN_MSG_MAP(InfobarWindow) | 56 BEGIN_MSG_MAP(InfobarWindow) |
46 MSG_WM_INITDIALOG(OnInitDialog) | 57 MSG_WM_INITDIALOG(OnInitDialog) |
47 MSG_WM_DESTROY(OnDestroy) | 58 MSG_WM_DESTROY(OnDestroy) |
59 NOTIFY_HANDLER(IDC_PROMPT_LINK, NM_CLICK, OnLearnMore) | |
48 COMMAND_HANDLER(IDACTIVATE, BN_CLICKED, OnYes) | 60 COMMAND_HANDLER(IDACTIVATE, BN_CLICKED, OnYes) |
49 COMMAND_HANDLER(IDLATER, BN_CLICKED, OnRemindMeLater) | |
50 COMMAND_HANDLER(IDNEVER, BN_CLICKED, OnNo) | 61 COMMAND_HANDLER(IDNEVER, BN_CLICKED, OnNo) |
51 CHAIN_MSG_MAP(CDialogResize<ReadyPromptWindow>) | 62 CHAIN_MSG_MAP(CDialogResize<ReadyPromptWindow>) |
52 END_MSG_MAP() | 63 END_MSG_MAP() |
53 | 64 |
54 BEGIN_DLGRESIZE_MAP(InfobarWindow) | 65 BEGIN_DLGRESIZE_MAP(InfobarWindow) |
55 DLGRESIZE_CONTROL(IDACTIVATE, DLSZ_CENTER_Y | DLSZ_MOVE_X) | 66 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) | 67 DLGRESIZE_CONTROL(IDNEVER, DLSZ_CENTER_Y | DLSZ_MOVE_X) |
58 DLGRESIZE_CONTROL(IDC_PROMPT_MESSAGE, DLSZ_SIZE_Y | DLSZ_SIZE_X) | 68 DLGRESIZE_CONTROL(IDC_PROMPT_MESSAGE, DLSZ_SIZE_Y | DLSZ_SIZE_X) |
69 DLGRESIZE_CONTROL(IDC_PROMPT_LINK, DLSZ_CENTER_Y | DLSZ_MOVE_X) | |
59 END_DLGRESIZE_MAP() | 70 END_DLGRESIZE_MAP() |
60 | 71 |
61 virtual void OnFinalMessage(HWND); | 72 virtual void OnFinalMessage(HWND); |
62 | 73 |
63 private: | 74 private: |
64 // Event handlers. | 75 // Event handlers. |
65 void OnDestroy(); | 76 void OnDestroy(); |
66 BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam); | 77 BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam); |
67 LRESULT OnYes(WORD wNotifyCode, | 78 LRESULT OnYes(WORD wNotifyCode, |
68 WORD wID, | 79 WORD wID, |
69 HWND hWndCtl, | 80 HWND hWndCtl, |
70 BOOL& bHandled); | 81 BOOL& bHandled); |
71 LRESULT OnRemindMeLater(WORD wNotifyCode, | 82 LRESULT OnRemindMeLater(WORD wNotifyCode, |
72 WORD wID, | 83 WORD wID, |
73 HWND hWndCtl, | 84 HWND hWndCtl, |
74 BOOL& bHandled); | 85 BOOL& bHandled); |
86 LRESULT OnLearnMore(WORD wParam, LPNMHDR lParam, BOOL& bHandled); // NOLINT | |
75 LRESULT OnNo(WORD wNotifyCode, | 87 LRESULT OnNo(WORD wNotifyCode, |
76 WORD wID, | 88 WORD wID, |
77 HWND hWndCtl, | 89 HWND hWndCtl, |
78 BOOL& bHandled); | 90 BOOL& bHandled); |
79 | 91 |
80 InfobarContent::Frame* frame_; // Not owned by this instance | 92 InfobarContent::Frame* frame_; // Not owned by this instance |
81 scoped_ptr<ReadyModeState> ready_mode_state_; | 93 scoped_ptr<ReadyModeState> ready_mode_state_; |
94 scoped_ptr<WTL::CHyperLink> link_; | |
95 base::win::ScopedComPtr<IWebBrowser2, NULL> web_browser_; | |
82 | 96 |
83 base::WeakPtrFactory<ReadyPromptWindow> weak_ptr_factory_; | 97 base::WeakPtrFactory<ReadyPromptWindow> weak_ptr_factory_; |
84 DISALLOW_COPY_AND_ASSIGN(ReadyPromptWindow); | 98 DISALLOW_COPY_AND_ASSIGN(ReadyPromptWindow); |
85 }; // class ReadyPromptWindow | 99 }; // class ReadyPromptWindow |
86 | 100 |
87 #endif // CHROME_FRAME_READY_MODE_INTERNAL_READY_PROMPT_WINDOW_H_ | 101 #endif // CHROME_FRAME_READY_MODE_INTERNAL_READY_PROMPT_WINDOW_H_ |
OLD | NEW |