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

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

Issue 126143005: Remove Chrome Frame code and resources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to r244038 Created 6 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
(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 // static
26 base::WeakPtr<TurndownPromptWindow> TurndownPromptWindow::CreateInstance(
27 InfobarContent::Frame* frame,
28 UrlLauncher* url_launcher,
29 const base::Closure& uninstall_callback) {
30 DCHECK(frame != NULL);
31 DCHECK(url_launcher != NULL);
32
33 base::WeakPtr<TurndownPromptWindow> instance(
34 (new TurndownPromptWindow(frame, url_launcher, uninstall_callback))
35 ->weak_ptr_factory_.GetWeakPtr());
36
37 DCHECK(!instance->IsWindow());
38
39 if (instance->Create(frame->GetFrameWindow()) == NULL) {
40 DPLOG(ERROR) << "Failed to create HWND for TurndownPromptWindow.";
41 return base::WeakPtr<TurndownPromptWindow>();
42 }
43
44 // Subclass the "Learn more." text to make it behave like a link. Clicks are
45 // routed to OnLearnMore().
46 CWindow rte = instance->GetDlgItem(IDC_TD_PROMPT_LINK);
47 instance->link_.reset(new CHyperLink());
48 instance->link_->SubclassWindow(rte);
49 instance->link_->SetHyperLinkExtendedStyle(HLINK_NOTIFYBUTTON,
50 HLINK_NOTIFYBUTTON);
51
52 // Substitute the proper text given the current IE version.
53 CWindow text = instance->GetDlgItem(IDC_TD_PROMPT_MESSAGE);
54 base::string16 prompt_text(GetPromptText());
55 if (!prompt_text.empty())
56 text.SetWindowText(prompt_text.c_str());
57
58 return instance;
59 }
60
61 TurndownPromptWindow::TurndownPromptWindow(
62 InfobarContent::Frame* frame,
63 UrlLauncher* url_launcher,
64 const base::Closure& uninstall_closure)
65 : frame_(frame),
66 url_launcher_(url_launcher),
67 uninstall_closure_(uninstall_closure),
68 weak_ptr_factory_(this) {
69 }
70
71 TurndownPromptWindow::~TurndownPromptWindow() {}
72
73 void TurndownPromptWindow::OnFinalMessage(HWND) {
74 delete this;
75 }
76
77 void TurndownPromptWindow::OnDestroy() {
78 frame_ = NULL;
79 }
80
81 BOOL TurndownPromptWindow::OnInitDialog(CWindow wndFocus, LPARAM lInitParam) {
82 DlgResize_Init(false); // false => 'no gripper'
83 return TRUE;
84 }
85
86 LRESULT TurndownPromptWindow::OnLearnMore(WORD /*wParam*/,
87 LPNMHDR /*lParam*/,
88 BOOL& /*bHandled*/) {
89 url_launcher_->LaunchUrl(SimpleResourceLoader::Get(
90 IDS_CHROME_FRAME_TURNDOWN_LEARN_MORE_URL));
91 return 0;
92 }
93
94 LRESULT TurndownPromptWindow::OnUninstall(WORD /*wNotifyCode*/,
95 WORD /*wID*/,
96 HWND /*hWndCtl*/,
97 BOOL& /*bHandled*/) {
98 frame_->CloseInfobar();
99 if (!uninstall_closure_.is_null())
100 uninstall_closure_.Run();
101 return 0;
102 }
103
104 // static
105 base::string16 TurndownPromptWindow::GetPromptText() {
106 IEVersion ie_version = GetIEVersion();
107 int message_id = IDS_CHROME_FRAME_TURNDOWN_TEXT_IE_NEWER;
108 if (ie_version == IE_6 || ie_version == IE_7 || ie_version == IE_8)
109 message_id = IDS_CHROME_FRAME_TURNDOWN_TEXT_IE_OLDER;
110 return SimpleResourceLoader::GetInstance()->Get(message_id);
111 }
OLDNEW
« no previous file with comments | « chrome_frame/turndown_prompt/turndown_prompt_window.h ('k') | chrome_frame/unittest_precompile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698