| 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 <atlctrls.h> | 7 #include <atlctrls.h> |
| 8 #include <Shellapi.h> | 8 #include <Shellapi.h> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // file. | 21 // file. |
| 22 #include <minmax.h> // NOLINT | 22 #include <minmax.h> // NOLINT |
| 23 #include <atlctrlx.h> // NOLINT | 23 #include <atlctrlx.h> // NOLINT |
| 24 | 24 |
| 25 ReadyPromptWindow::ReadyPromptWindow( | 25 ReadyPromptWindow::ReadyPromptWindow( |
| 26 InfobarContent::Frame* frame, ReadyModeState* ready_mode_state, | 26 InfobarContent::Frame* frame, ReadyModeState* ready_mode_state, |
| 27 UrlLauncher* url_launcher) | 27 UrlLauncher* url_launcher) |
| 28 : frame_(frame), | 28 : frame_(frame), |
| 29 ready_mode_state_(ready_mode_state), | 29 ready_mode_state_(ready_mode_state), |
| 30 url_launcher_(url_launcher), | 30 url_launcher_(url_launcher), |
| 31 icon_(NULL), |
| 31 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 32 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 32 } | 33 } |
| 33 ReadyPromptWindow::~ReadyPromptWindow() { | 34 ReadyPromptWindow::~ReadyPromptWindow() { |
| 35 if (icon_) |
| 36 ::DestroyIcon(icon_); |
| 34 } | 37 } |
| 35 | 38 |
| 36 base::WeakPtr<ReadyPromptWindow> ReadyPromptWindow::CreateInstance( | 39 base::WeakPtr<ReadyPromptWindow> ReadyPromptWindow::CreateInstance( |
| 37 InfobarContent::Frame* frame, ReadyModeState* ready_mode_state, | 40 InfobarContent::Frame* frame, ReadyModeState* ready_mode_state, |
| 38 UrlLauncher* url_launcher) { | 41 UrlLauncher* url_launcher) { |
| 39 DCHECK(frame != NULL); | 42 DCHECK(frame != NULL); |
| 40 DCHECK(ready_mode_state != NULL); | 43 DCHECK(ready_mode_state != NULL); |
| 41 DCHECK(url_launcher != NULL); | 44 DCHECK(url_launcher != NULL); |
| 42 | 45 |
| 43 base::WeakPtr<ReadyPromptWindow> instance((new ReadyPromptWindow( | 46 base::WeakPtr<ReadyPromptWindow> instance((new ReadyPromptWindow( |
| 44 frame, ready_mode_state, url_launcher))->weak_ptr_factory_.GetWeakPtr()); | 47 frame, ready_mode_state, url_launcher))->weak_ptr_factory_.GetWeakPtr()); |
| 45 | 48 |
| 46 DCHECK(!instance->IsWindow()); | 49 DCHECK(!instance->IsWindow()); |
| 47 | 50 |
| 48 if (instance->Create(frame->GetFrameWindow()) == NULL) { | 51 if (instance->Create(frame->GetFrameWindow()) == NULL) { |
| 49 DPLOG(ERROR) << "Failed to create HWND for ReadyPromptWindow."; | 52 DPLOG(ERROR) << "Failed to create HWND for ReadyPromptWindow."; |
| 50 return base::WeakPtr<ReadyPromptWindow>(); | 53 return base::WeakPtr<ReadyPromptWindow>(); |
| 51 } | 54 } |
| 52 | 55 |
| 53 // Subclass the "Learn more." text to make it behave like a link. Clicks are | 56 // Subclass the "Learn more." text to make it behave like a link. Clicks are |
| 54 // routed to OnLearnMore(). | 57 // routed to OnLearnMore(). |
| 55 CWindow rte = instance->GetDlgItem(IDC_PROMPT_LINK); | 58 CWindow rte = instance->GetDlgItem(IDC_PROMPT_LINK); |
| 56 instance->link_.reset(new CHyperLink()); | 59 instance->link_.reset(new CHyperLink()); |
| 57 instance->link_->SubclassWindow(rte); | 60 instance->link_->SubclassWindow(rte); |
| 58 instance->link_->SetHyperLinkExtendedStyle(HLINK_NOTIFYBUTTON, | 61 instance->link_->SetHyperLinkExtendedStyle(HLINK_NOTIFYBUTTON, |
| 59 HLINK_NOTIFYBUTTON); | 62 HLINK_NOTIFYBUTTON); |
| 60 | 63 |
| 64 CStatic icon_control(instance->GetDlgItem(IDC_PROMPT_ICON)); |
| 65 |
| 66 instance->icon_ = static_cast<HICON>( |
| 67 ::LoadImage(_AtlBaseModule.GetResourceInstance(), |
| 68 MAKEINTRESOURCE(IDI_CHROME_FRAME_ICON), |
| 69 IMAGE_ICON, 16, 16, 0)); |
| 70 |
| 71 if (instance->icon_) |
| 72 icon_control.SetIcon(instance->icon_); |
| 73 |
| 61 return instance; | 74 return instance; |
| 62 } | 75 } |
| 63 | 76 |
| 64 void ReadyPromptWindow::OnDestroy() { | 77 void ReadyPromptWindow::OnDestroy() { |
| 65 frame_ = NULL; | 78 frame_ = NULL; |
| 66 } | 79 } |
| 67 | 80 |
| 68 BOOL ReadyPromptWindow::OnInitDialog(CWindow wndFocus, LPARAM lInitParam) { | 81 BOOL ReadyPromptWindow::OnInitDialog(CWindow wndFocus, LPARAM lInitParam) { |
| 69 DlgResize_Init(false); // false => 'no gripper' | 82 DlgResize_Init(false); // false => 'no gripper' |
| 70 return TRUE; | 83 return TRUE; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 101 LPNMHDR /*lParam*/, | 114 LPNMHDR /*lParam*/, |
| 102 BOOL& /*bHandled*/) { | 115 BOOL& /*bHandled*/) { |
| 103 url_launcher_->LaunchUrl(SimpleResourceLoader::Get( | 116 url_launcher_->LaunchUrl(SimpleResourceLoader::Get( |
| 104 IDS_CHROME_FRAME_READY_MODE_LEARN_MORE_URL)); | 117 IDS_CHROME_FRAME_READY_MODE_LEARN_MORE_URL)); |
| 105 return 0; | 118 return 0; |
| 106 } | 119 } |
| 107 | 120 |
| 108 void ReadyPromptWindow::OnFinalMessage(HWND) { | 121 void ReadyPromptWindow::OnFinalMessage(HWND) { |
| 109 delete this; | 122 delete this; |
| 110 } | 123 } |
| OLD | NEW |