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

Side by Side Diff: chrome_frame/turndown_prompt/turndown_prompt_window.cc

Issue 17153006: Chrome Frame turndown prompt. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase to r208076 Created 7 years, 6 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
« no previous file with comments | « chrome_frame/turndown_prompt/turndown_prompt_window.h ('k') | chrome_frame/utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 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/turndown_prompt/turndown_prompt_window.h"
6
7 #include <atlctrls.h>
8 #include <commctrl.h>
9 #include <shellapi.h>
10
11 #include "base/compiler_specific.h"
12 #include "chrome_frame/ready_mode/internal/url_launcher.h"
13 #include "chrome_frame/simple_resource_loader.h"
14 #include "chrome_frame/utils.h"
15 #include "grit/chrome_frame_dialogs.h"
16 #include "grit/chromium_strings.h"
17
18 // atlctrlx.h requires 'min' and 'max' macros, the definition of which conflicts
19 // with STL headers. Hence we include them out of the order defined by style
20 // guidelines. As a result you may not refer to std::min or std::max in this
21 // file.
22 #include <minmax.h> // NOLINT
23 #include <atlctrlx.h> // NOLINT
24
25 base::WeakPtr<TurndownPromptWindow> TurndownPromptWindow::CreateInstance(
26 InfobarContent::Frame* frame,
27 UrlLauncher* url_launcher,
28 const base::Closure& uninstall_callback) {
29 DCHECK(frame != NULL);
30 DCHECK(url_launcher != NULL);
31
32 base::WeakPtr<TurndownPromptWindow> instance(
33 (new TurndownPromptWindow(frame, url_launcher, uninstall_callback))
34 ->weak_ptr_factory_.GetWeakPtr());
35
36 DCHECK(!instance->IsWindow());
37
38 if (instance->Create(frame->GetFrameWindow()) == NULL) {
39 DPLOG(ERROR) << "Failed to create HWND for TurndownPromptWindow.";
40 return base::WeakPtr<TurndownPromptWindow>();
41 }
42
43 // Subclass the "Learn more." text to make it behave like a link. Clicks are
44 // routed to OnLearnMore().
45 CWindow rte = instance->GetDlgItem(IDC_TD_PROMPT_LINK);
46 instance->link_.reset(new CHyperLink());
47 instance->link_->SubclassWindow(rte);
48 instance->link_->SetHyperLinkExtendedStyle(HLINK_NOTIFYBUTTON,
49 HLINK_NOTIFYBUTTON);
50
51 // Substitute the proper text given the current IE version.
52 CWindow text = instance->GetDlgItem(IDC_TD_PROMPT_MESSAGE);
53 string16 prompt_text(GetPromptText());
54 if (!prompt_text.empty())
55 text.SetWindowText(prompt_text.c_str());
56
57 return instance;
58 }
59
60 TurndownPromptWindow::TurndownPromptWindow(
61 InfobarContent::Frame* frame,
62 UrlLauncher* url_launcher,
63 const base::Closure& uninstall_closure)
64 : frame_(frame),
65 url_launcher_(url_launcher),
66 uninstall_closure_(uninstall_closure),
67 weak_ptr_factory_(this) {
68 }
69
70 TurndownPromptWindow::~TurndownPromptWindow() {}
71
72 void TurndownPromptWindow::OnFinalMessage(HWND) {
73 delete this;
74 }
75
76 void TurndownPromptWindow::OnDestroy() {
77 frame_ = NULL;
78 }
79
80 BOOL TurndownPromptWindow::OnInitDialog(CWindow wndFocus, LPARAM lInitParam) {
81 DlgResize_Init(false); // false => 'no gripper'
82 return TRUE;
83 }
84
85 LRESULT TurndownPromptWindow::OnLearnMore(WORD /*wParam*/,
86 LPNMHDR /*lParam*/,
87 BOOL& /*bHandled*/) {
88 url_launcher_->LaunchUrl(SimpleResourceLoader::Get(
89 IDS_CHROME_FRAME_TURNDOWN_LEARN_MORE_URL));
90 return 0;
91 }
92
93 LRESULT TurndownPromptWindow::OnUninstall(WORD /*wNotifyCode*/,
94 WORD /*wID*/,
95 HWND /*hWndCtl*/,
96 BOOL& /*bHandled*/) {
97 frame_->CloseInfobar();
98 if (!uninstall_closure_.is_null())
99 uninstall_closure_.Run();
100 return 0;
101 }
102
103 LRESULT TurndownPromptWindow::OnDismiss(WORD /*wNotifyCode*/,
104 WORD /*wID*/,
105 HWND /*hWndCtl*/,
106 BOOL& /*bHandled*/) {
107 frame_->CloseInfobar();
108 return 0;
109 }
110
111 // static
112 string16 TurndownPromptWindow::GetPromptText() {
113 IEVersion ie_version = GetIEVersion();
114 int message_id = IDS_CHROME_FRAME_TURNDOWN_TEXT_IE_NEWER;
115 if (ie_version == IE_6 || ie_version == IE_7 || ie_version == IE_8)
116 message_id = IDS_CHROME_FRAME_TURNDOWN_TEXT_IE_OLDER;
117 return SimpleResourceLoader::GetInstance()->Get(message_id);
118 }
OLDNEW
« no previous file with comments | « chrome_frame/turndown_prompt/turndown_prompt_window.h ('k') | chrome_frame/utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698