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

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 <atlctrls.h>
8 #include <Shellapi.h> // Must appear before atlctrlx.h
9
10 // These seem to be required by atlctrlx?
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
7 #include "base/compiler_specific.h" 19 #include "base/compiler_specific.h"
20 #include "base/win/scoped_bstr.h"
21 #include "base/win/scoped_comptr.h"
8 #include "chrome_frame/ready_mode/internal/ready_mode_state.h" 22 #include "chrome_frame/ready_mode/internal/ready_mode_state.h"
23 #include "chrome_frame/ready_mode/internal/url_launcher.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 InfobarContent::Frame* frame, ReadyModeState* ready_mode_state,
29 UrlLauncher* url_launcher)
30 : frame_(frame),
31 ready_mode_state_(ready_mode_state),
32 url_launcher_(url_launcher),
12 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 33 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
13 } 34 }
35 ReadyPromptWindow::~ReadyPromptWindow() {
36 }
14 37
15 base::WeakPtr<ReadyPromptWindow> ReadyPromptWindow::Initialize( 38 base::WeakPtr<ReadyPromptWindow> ReadyPromptWindow::CreateInstance(
16 InfobarContent::Frame* frame, ReadyModeState* ready_mode_state) { 39 InfobarContent::Frame* frame, ReadyModeState* ready_mode_state,
40 UrlLauncher* url_launcher) {
17 DCHECK(frame != NULL); 41 DCHECK(frame != NULL);
18 DCHECK(frame_ == NULL);
19 DCHECK(ready_mode_state != NULL); 42 DCHECK(ready_mode_state != NULL);
20 DCHECK(ready_mode_state_ == NULL); 43 DCHECK(url_launcher != NULL);
21 44
22 frame_ = frame; 45 base::WeakPtr<ReadyPromptWindow> instance((new ReadyPromptWindow(
23 ready_mode_state_.reset(ready_mode_state); 46 frame, ready_mode_state, url_launcher))->weak_ptr_factory_.GetWeakPtr());
24 47
25 DCHECK(!IsWindow()); 48 DCHECK(!instance->IsWindow());
26 49
27 if (Create(frame->GetFrameWindow()) == NULL) { 50 if (instance->Create(frame->GetFrameWindow()) == NULL) {
28 DPLOG(ERROR) << "Failed to create HWND for ReadyPromptWindow."; 51 DPLOG(ERROR) << "Failed to create HWND for ReadyPromptWindow.";
29 delete this;
30 return base::WeakPtr<ReadyPromptWindow>(); 52 return base::WeakPtr<ReadyPromptWindow>();
31 } 53 }
32 54
33 return weak_ptr_factory_.GetWeakPtr(); 55 // Subclass the "Learn more." text to make it behave like a link. Clicks are
56 // routed to OnLearnMore().
57 CWindow rte = instance->GetDlgItem(IDC_PROMPT_LINK);
58 instance->link_.reset(new CHyperLink());
59 instance->link_->SubclassWindow(rte);
60 instance->link_->SetHyperLinkExtendedStyle(HLINK_NOTIFYBUTTON,
61 HLINK_NOTIFYBUTTON);
62
63 return instance;
34 } 64 }
35 65
36 void ReadyPromptWindow::OnDestroy() { 66 void ReadyPromptWindow::OnDestroy() {
37 frame_ = NULL; 67 frame_ = NULL;
38 } 68 }
39 69
40 BOOL ReadyPromptWindow::OnInitDialog(CWindow wndFocus, LPARAM lInitParam) { 70 BOOL ReadyPromptWindow::OnInitDialog(CWindow wndFocus, LPARAM lInitParam) {
41 DlgResize_Init(false); // false => 'no gripper' 71 DlgResize_Init(false); // false => 'no gripper'
42 return TRUE; 72 return TRUE;
43 } 73 }
(...skipping 18 matching lines...) Expand all
62 92
63 LRESULT ReadyPromptWindow::OnNo(WORD /*wNotifyCode*/, 93 LRESULT ReadyPromptWindow::OnNo(WORD /*wNotifyCode*/,
64 WORD /*wID*/, 94 WORD /*wID*/,
65 HWND /*hWndCtl*/, 95 HWND /*hWndCtl*/,
66 BOOL& /*bHandled*/) { 96 BOOL& /*bHandled*/) {
67 frame_->CloseInfobar(); 97 frame_->CloseInfobar();
68 ready_mode_state_->PermanentlyDeclineChromeFrame(); 98 ready_mode_state_->PermanentlyDeclineChromeFrame();
69 return 0; 99 return 0;
70 } 100 }
71 101
102 LRESULT ReadyPromptWindow::OnLearnMore(WORD /*wParam*/,
103 LPNMHDR /*lParam*/,
104 BOOL& /*bHandled*/) {
105 url_launcher_->LaunchUrl(SimpleResourceLoader::Get(
106 IDS_CHROME_FRAME_READY_MODE_LEARN_MORE_URL));
107 return 0;
108 }
109
72 void ReadyPromptWindow::OnFinalMessage(HWND) { 110 void ReadyPromptWindow::OnFinalMessage(HWND) {
73 delete this; 111 delete this;
74 } 112 }
OLDNEW
« no previous file with comments | « chrome_frame/ready_mode/internal/ready_prompt_window.h ('k') | chrome_frame/ready_mode/internal/url_launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698