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 #include "chrome_frame/ready_mode/internal/ready_prompt_window.h" | 5 #include "chrome_frame/ready_mode/internal/ready_prompt_window.h" |
| 6 | 6 |
| 7 #include <Shellapi.h> // Must appear before atlctrlx.h | |
| 8 #include <atlctrls.h> | |
|
robertshield
2011/01/24 16:10:21
I think you want to include atlapp.h and atlwin.h
erikwright (departed)
2011/01/24 17:14:01
They are already in ready_prompt_window.h (the dec
| |
| 9 | |
| 10 // These seem to be required by atlctrlx? | |
|
erikwright (departed)
2011/01/24 06:58:39
Anyone know why atlctrlx.h is requiring min and ma
robertshield
2011/01/24 16:10:21
Follow the above comment, and probably won't need
erikwright (departed)
2011/01/24 17:14:01
Sadly, I still get the following:
1>s:\src\chrom
| |
| 11 template<class A> | |
| 12 A min(A const& a, A const& b) { return a < b ? a : b; } | |
| 13 | |
| 14 template<class A> | |
| 15 A max(A const& a, A const& b) { return a > b ? a : b; } | |
| 16 | |
| 17 #include <atlctrlx.h> | |
| 18 #include <Exdisp.h> | |
| 19 | |
| 7 #include "base/compiler_specific.h" | 20 #include "base/compiler_specific.h" |
| 21 #include "base/win/scoped_bstr.h" | |
| 22 #include "base/win/scoped_comptr.h" | |
| 8 #include "chrome_frame/ready_mode/internal/ready_mode_state.h" | 23 #include "chrome_frame/ready_mode/internal/ready_mode_state.h" |
| 24 #include "chrome_frame/simple_resource_loader.h" | |
| 25 #include "grit/chromium_strings.h" | |
| 9 | 26 |
| 10 ReadyPromptWindow::ReadyPromptWindow() | 27 ReadyPromptWindow::ReadyPromptWindow() |
| 11 : frame_(NULL), | 28 : frame_(NULL), |
| 12 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 29 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 13 } | 30 } |
| 31 ReadyPromptWindow::~ReadyPromptWindow() { | |
| 32 } | |
| 14 | 33 |
| 15 base::WeakPtr<ReadyPromptWindow> ReadyPromptWindow::Initialize( | 34 base::WeakPtr<ReadyPromptWindow> ReadyPromptWindow::Initialize( |
| 16 InfobarContent::Frame* frame, ReadyModeState* ready_mode_state) { | 35 InfobarContent::Frame* frame, ReadyModeState* ready_mode_state, |
| 36 IWebBrowser2* web_browser) { | |
| 17 DCHECK(frame != NULL); | 37 DCHECK(frame != NULL); |
| 18 DCHECK(frame_ == NULL); | 38 DCHECK(frame_ == NULL); |
| 19 DCHECK(ready_mode_state != NULL); | 39 DCHECK(ready_mode_state != NULL); |
| 20 DCHECK(ready_mode_state_ == NULL); | 40 DCHECK(ready_mode_state_ == NULL); |
| 41 DCHECK(web_browser != NULL); | |
| 42 DCHECK(web_browser_ == NULL); | |
|
robertshield
2011/01/24 16:10:21
if Initialize can't be called twice, consider havi
erikwright (departed)
2011/01/24 17:14:01
I think this is resolved with the change to factor
| |
| 21 | 43 |
| 22 frame_ = frame; | 44 frame_ = frame; |
| 23 ready_mode_state_.reset(ready_mode_state); | 45 ready_mode_state_.reset(ready_mode_state); |
| 46 web_browser->AddRef(); | |
| 47 web_browser_.Attach(web_browser); | |
| 24 | 48 |
| 25 DCHECK(!IsWindow()); | 49 DCHECK(!IsWindow()); |
| 26 | 50 |
| 27 if (Create(frame->GetFrameWindow()) == NULL) { | 51 if (Create(frame->GetFrameWindow()) == NULL) { |
| 28 DPLOG(ERROR) << "Failed to create HWND for ReadyPromptWindow."; | 52 DPLOG(ERROR) << "Failed to create HWND for ReadyPromptWindow."; |
| 29 delete this; | 53 delete this; |
| 30 return base::WeakPtr<ReadyPromptWindow>(); | 54 return base::WeakPtr<ReadyPromptWindow>(); |
| 31 } | 55 } |
| 32 | 56 |
| 57 // Subclass the "Learn more." text to make it behave like a link. Clicks are | |
| 58 // routed to OnLearnMore(). | |
| 59 ATL::CWindow rte = GetDlgItem(IDC_PROMPT_LINK); | |
| 60 link_.reset(new WTL::CHyperLink()); | |
| 61 link_->SubclassWindow(rte); | |
| 62 link_->SetHyperLinkExtendedStyle(HLINK_NOTIFYBUTTON, HLINK_NOTIFYBUTTON); | |
| 63 | |
| 33 return weak_ptr_factory_.GetWeakPtr(); | 64 return weak_ptr_factory_.GetWeakPtr(); |
| 34 } | 65 } |
| 35 | 66 |
| 36 void ReadyPromptWindow::OnDestroy() { | 67 void ReadyPromptWindow::OnDestroy() { |
| 37 frame_ = NULL; | 68 frame_ = NULL; |
| 38 } | 69 } |
| 39 | 70 |
| 40 BOOL ReadyPromptWindow::OnInitDialog(CWindow wndFocus, LPARAM lInitParam) { | 71 BOOL ReadyPromptWindow::OnInitDialog(CWindow wndFocus, LPARAM lInitParam) { |
| 41 DlgResize_Init(false); // false => 'no gripper' | 72 DlgResize_Init(false); // false => 'no gripper' |
| 42 return TRUE; | 73 return TRUE; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 62 | 93 |
| 63 LRESULT ReadyPromptWindow::OnNo(WORD /*wNotifyCode*/, | 94 LRESULT ReadyPromptWindow::OnNo(WORD /*wNotifyCode*/, |
| 64 WORD /*wID*/, | 95 WORD /*wID*/, |
| 65 HWND /*hWndCtl*/, | 96 HWND /*hWndCtl*/, |
| 66 BOOL& /*bHandled*/) { | 97 BOOL& /*bHandled*/) { |
| 67 frame_->CloseInfobar(); | 98 frame_->CloseInfobar(); |
| 68 ready_mode_state_->PermanentlyDeclineChromeFrame(); | 99 ready_mode_state_->PermanentlyDeclineChromeFrame(); |
| 69 return 0; | 100 return 0; |
| 70 } | 101 } |
| 71 | 102 |
| 103 LRESULT ReadyPromptWindow::OnLearnMore(WORD /*wParam*/, | |
| 104 LPNMHDR /*lParam*/, | |
| 105 BOOL& /*bHandled*/) { | |
| 106 VARIANT flags = { VT_I4 }; | |
| 107 V_I4(&flags) = navOpenInNewWindow; | |
| 108 base::win::ScopedBstr location(SimpleResourceLoader::Get( | |
| 109 IDS_CHROME_FRAME_READY_MODE_LEARN_MORE_URL).c_str()); | |
| 110 | |
| 111 HRESULT hr = web_browser_->Navigate(location, &flags, NULL, NULL, NULL); | |
| 112 DLOG_IF(ERROR, FAILED(hr)) << "Failed to invoke Navigate on IWebBrowser2. " | |
| 113 << "Error: " << hr; | |
| 114 return 0; | |
| 115 } | |
| 116 | |
| 72 void ReadyPromptWindow::OnFinalMessage(HWND) { | 117 void ReadyPromptWindow::OnFinalMessage(HWND) { |
| 73 delete this; | 118 delete this; |
| 74 } | 119 } |
| OLD | NEW |