Index: chrome_frame/ready_mode/internal/ready_prompt_window.cc |
=================================================================== |
--- chrome_frame/ready_mode/internal/ready_prompt_window.cc (revision 72310) |
+++ chrome_frame/ready_mode/internal/ready_prompt_window.cc (working copy) |
@@ -4,33 +4,64 @@ |
#include "chrome_frame/ready_mode/internal/ready_prompt_window.h" |
+#include <Shellapi.h> // Must appear before atlctrlx.h |
+#include <atlctrls.h> |
+ |
+// These seem to be required by atlctrlx? |
tommi (sloooow) - chröme
2011/01/24 17:54:23
include atlbase first?
erikwright (departed)
2011/01/24 18:55:19
It's done transitively in ready_prompt_window.h
|
+template<class A> |
+A min(A const& a, A const& b) { return a < b ? a : b; } |
+ |
+template<class A> |
+A max(A const& a, A const& b) { return a > b ? a : b; } |
+ |
+#include <atlctrlx.h> |
+#include <Exdisp.h> |
+ |
#include "base/compiler_specific.h" |
+#include "base/win/scoped_bstr.h" |
+#include "base/win/scoped_comptr.h" |
#include "chrome_frame/ready_mode/internal/ready_mode_state.h" |
+#include "chrome_frame/ready_mode/internal/url_launcher.h" |
+#include "chrome_frame/simple_resource_loader.h" |
+#include "grit/chromium_strings.h" |
-ReadyPromptWindow::ReadyPromptWindow() |
- : frame_(NULL), |
+ReadyPromptWindow::ReadyPromptWindow( |
+ InfobarContent::Frame* frame, ReadyModeState* ready_mode_state, |
+ UrlLauncher* url_launcher) |
+ : frame_(frame), |
+ ready_mode_state_(ready_mode_state), |
+ url_launcher_(url_launcher), |
weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
} |
+ReadyPromptWindow::~ReadyPromptWindow() { |
+} |
-base::WeakPtr<ReadyPromptWindow> ReadyPromptWindow::Initialize( |
- InfobarContent::Frame* frame, ReadyModeState* ready_mode_state) { |
+base::WeakPtr<ReadyPromptWindow> ReadyPromptWindow::CreateInstance( |
+ InfobarContent::Frame* frame, ReadyModeState* ready_mode_state, |
+ UrlLauncher* url_launcher) { |
DCHECK(frame != NULL); |
- DCHECK(frame_ == NULL); |
DCHECK(ready_mode_state != NULL); |
- DCHECK(ready_mode_state_ == NULL); |
+ DCHECK(url_launcher != NULL); |
- frame_ = frame; |
- ready_mode_state_.reset(ready_mode_state); |
+ base::WeakPtr<ReadyPromptWindow> instance((new ReadyPromptWindow( |
+ frame, ready_mode_state, url_launcher))->weak_ptr_factory_.GetWeakPtr()); |
- DCHECK(!IsWindow()); |
+ DCHECK(!instance->IsWindow()); |
- if (Create(frame->GetFrameWindow()) == NULL) { |
+ if (instance->Create(frame->GetFrameWindow()) == NULL) { |
DPLOG(ERROR) << "Failed to create HWND for ReadyPromptWindow."; |
- delete this; |
return base::WeakPtr<ReadyPromptWindow>(); |
tommi (sloooow) - chröme
2011/01/24 17:54:23
will instance get deleted?
erikwright (departed)
2011/01/24 18:55:19
Yes - it's a weak ptr with no other references.
|
} |
- return weak_ptr_factory_.GetWeakPtr(); |
+ // Subclass the "Learn more." text to make it behave like a link. Clicks are |
+ // routed to OnLearnMore(). |
+ ATL::CWindow rte = instance->GetDlgItem(IDC_PROMPT_LINK); |
tommi (sloooow) - chröme
2011/01/24 17:54:23
I don't think you need the ATL:: prefix
erikwright (departed)
2011/01/24 18:55:19
Done.
|
+ instance->link_.reset(new WTL::CHyperLink()); |
+ instance->link_->SubclassWindow(rte); |
+ instance->link_->SetHyperLinkExtendedStyle(HLINK_NOTIFYBUTTON, |
+ HLINK_NOTIFYBUTTON); |
+ |
+ return instance; |
} |
void ReadyPromptWindow::OnDestroy() { |
@@ -69,6 +100,14 @@ |
return 0; |
} |
+LRESULT ReadyPromptWindow::OnLearnMore(WORD /*wParam*/, |
tommi (sloooow) - chröme
2011/01/24 17:54:23
uncomment arguments and remove hungarian (for othe
erikwright (departed)
2011/01/24 18:55:19
The names correspond to the function 'prototypes'
|
+ LPNMHDR /*lParam*/, |
+ BOOL& /*bHandled*/) { |
+ url_launcher_->LaunchUrl(SimpleResourceLoader::Get( |
+ IDS_CHROME_FRAME_READY_MODE_LEARN_MORE_URL)); |
+ return 0; |
+} |
+ |
void ReadyPromptWindow::OnFinalMessage(HWND) { |
delete this; |
} |