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 #include "chrome_frame/ready_mode/internal/ready_prompt_window.h" |
| 6 |
| 7 #include "base/compiler_specific.h" |
| 8 #include "chrome_frame/ready_mode/internal/ready_mode_state.h" |
| 9 |
| 10 ReadyPromptWindow::ReadyPromptWindow() |
| 11 : frame_(NULL), |
| 12 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 13 } |
| 14 |
| 15 base::WeakPtr<ReadyPromptWindow> ReadyPromptWindow::Initialize( |
| 16 InfobarContent::Frame* frame, ReadyModeState* ready_mode_state) { |
| 17 DCHECK(frame != NULL); |
| 18 DCHECK(frame_ == NULL); |
| 19 DCHECK(ready_mode_state != NULL); |
| 20 DCHECK(ready_mode_state_ == NULL); |
| 21 |
| 22 frame_ = frame; |
| 23 ready_mode_state_.reset(ready_mode_state); |
| 24 |
| 25 DCHECK(!IsWindow()); |
| 26 |
| 27 if (Create(frame->GetFrameWindow()) == NULL) { |
| 28 DPLOG(ERROR) << "Failed to create HWND for ReadyPromptWindow."; |
| 29 delete this; |
| 30 return base::WeakPtr<ReadyPromptWindow>(); |
| 31 } |
| 32 |
| 33 return weak_ptr_factory_.GetWeakPtr(); |
| 34 } |
| 35 |
| 36 void ReadyPromptWindow::OnDestroy() { |
| 37 frame_ = NULL; |
| 38 } |
| 39 |
| 40 BOOL ReadyPromptWindow::OnInitDialog(CWindow wndFocus, LPARAM lInitParam) { |
| 41 DlgResize_Init(false); // false => 'no gripper' |
| 42 return TRUE; |
| 43 } |
| 44 |
| 45 LRESULT ReadyPromptWindow::OnYes(WORD /*wNotifyCode*/, |
| 46 WORD /*wID*/, |
| 47 HWND /*hWndCtl*/, |
| 48 BOOL& /*bHandled*/) { |
| 49 frame_->CloseInfobar(); |
| 50 ready_mode_state_->AcceptChromeFrame(); |
| 51 return 0; |
| 52 } |
| 53 |
| 54 LRESULT ReadyPromptWindow::OnRemindMeLater(WORD /*wNotifyCode*/, |
| 55 WORD /*wID*/, |
| 56 HWND /*hWndCtl*/, |
| 57 BOOL& /*bHandled*/) { |
| 58 frame_->CloseInfobar(); |
| 59 ready_mode_state_->TemporarilyDeclineChromeFrame(); |
| 60 return 0; |
| 61 } |
| 62 |
| 63 LRESULT ReadyPromptWindow::OnNo(WORD /*wNotifyCode*/, |
| 64 WORD /*wID*/, |
| 65 HWND /*hWndCtl*/, |
| 66 BOOL& /*bHandled*/) { |
| 67 frame_->CloseInfobar(); |
| 68 ready_mode_state_->PermanentlyDeclineChromeFrame(); |
| 69 return 0; |
| 70 } |
| 71 |
| 72 void ReadyPromptWindow::OnFinalMessage(HWND) { |
| 73 delete this; |
| 74 } |
OLD | NEW |