Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: chrome_frame/ready_mode/internal/ready_prompt_window.cc

Issue 6314016: Update the Ready Mode UI in response to feedback from UI leads, Chrome Frame ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
9
10 // 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
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/ready_mode/internal/url_launcher.h"
25 #include "chrome_frame/simple_resource_loader.h"
26 #include "grit/chromium_strings.h"
9 27
10 ReadyPromptWindow::ReadyPromptWindow() 28 ReadyPromptWindow::ReadyPromptWindow(
11 : frame_(NULL), 29 InfobarContent::Frame* frame, ReadyModeState* ready_mode_state,
30 UrlLauncher* url_launcher)
31 : frame_(frame),
32 ready_mode_state_(ready_mode_state),
33 url_launcher_(url_launcher),
12 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 34 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
13 } 35 }
36 ReadyPromptWindow::~ReadyPromptWindow() {
37 }
14 38
15 base::WeakPtr<ReadyPromptWindow> ReadyPromptWindow::Initialize( 39 base::WeakPtr<ReadyPromptWindow> ReadyPromptWindow::CreateInstance(
16 InfobarContent::Frame* frame, ReadyModeState* ready_mode_state) { 40 InfobarContent::Frame* frame, ReadyModeState* ready_mode_state,
41 UrlLauncher* url_launcher) {
17 DCHECK(frame != NULL); 42 DCHECK(frame != NULL);
18 DCHECK(frame_ == NULL);
19 DCHECK(ready_mode_state != NULL); 43 DCHECK(ready_mode_state != NULL);
20 DCHECK(ready_mode_state_ == NULL); 44 DCHECK(url_launcher != NULL);
21 45
22 frame_ = frame; 46 base::WeakPtr<ReadyPromptWindow> instance((new ReadyPromptWindow(
23 ready_mode_state_.reset(ready_mode_state); 47 frame, ready_mode_state, url_launcher))->weak_ptr_factory_.GetWeakPtr());
24 48
25 DCHECK(!IsWindow()); 49 DCHECK(!instance->IsWindow());
26 50
27 if (Create(frame->GetFrameWindow()) == NULL) { 51 if (instance->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;
30 return base::WeakPtr<ReadyPromptWindow>(); 53 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.
31 } 54 }
32 55
33 return weak_ptr_factory_.GetWeakPtr(); 56 // Subclass the "Learn more." text to make it behave like a link. Clicks are
57 // routed to OnLearnMore().
58 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.
59 instance->link_.reset(new WTL::CHyperLink());
60 instance->link_->SubclassWindow(rte);
61 instance->link_->SetHyperLinkExtendedStyle(HLINK_NOTIFYBUTTON,
62 HLINK_NOTIFYBUTTON);
63
64 return instance;
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;
43 } 74 }
(...skipping 18 matching lines...) Expand all
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*/,
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'
104 LPNMHDR /*lParam*/,
105 BOOL& /*bHandled*/) {
106 url_launcher_->LaunchUrl(SimpleResourceLoader::Get(
107 IDS_CHROME_FRAME_READY_MODE_LEARN_MORE_URL));
108 return 0;
109 }
110
72 void ReadyPromptWindow::OnFinalMessage(HWND) { 111 void ReadyPromptWindow::OnFinalMessage(HWND) {
73 delete this; 112 delete this;
74 } 113 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698