OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <windows.h> | 5 #include <windows.h> |
6 #include <mshtmhst.h> | 6 #include <mshtmhst.h> |
7 #include <urlmon.h> | 7 #include <urlmon.h> |
8 | 8 |
9 #include "base/win/scoped_variant.h" | 9 #include "base/win/scoped_variant.h" |
10 #include "chrome/installer/util/html_dialog.h" | 10 #include "chrome/installer/util/html_dialog.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 // window.returnValue = 2; <-- this matches HTML_DLG_DECLINE | 33 // window.returnValue = 2; <-- this matches HTML_DLG_DECLINE |
34 // } | 34 // } |
35 // window.close(); | 35 // window.close(); |
36 // } | 36 // } |
37 // | 37 // |
38 // Note that on the submit handler you need to set window.returnValue to one of | 38 // Note that on the submit handler you need to set window.returnValue to one of |
39 // the values of DialogResult and call window.close(). | 39 // the values of DialogResult and call window.close(). |
40 | 40 |
41 class HTMLDialogWin : public HTMLDialog { | 41 class HTMLDialogWin : public HTMLDialog { |
42 public: | 42 public: |
43 HTMLDialogWin(const std::wstring& url, const std::wstring& param) | 43 HTMLDialogWin(const base::string16& url, const base::string16& param) |
44 : url_(url), param_(param) { | 44 : url_(url), param_(param) { |
45 if (!mshtml_) | 45 if (!mshtml_) |
46 mshtml_ = LoadLibrary(L"MSHTML.DLL"); | 46 mshtml_ = LoadLibrary(L"MSHTML.DLL"); |
47 } | 47 } |
48 | 48 |
49 DialogResult ShowModal(void* parent_window, | 49 DialogResult ShowModal(void* parent_window, |
50 CustomizationCallback* callback) override { | 50 CustomizationCallback* callback) override { |
51 int result = HTML_DLG_DECLINE; | 51 int result = HTML_DLG_DECLINE; |
52 if (!InternalDoDialog(callback, &result)) | 52 if (!InternalDoDialog(callback, &result)) |
53 return HTML_DLG_ERROR; | 53 return HTML_DLG_ERROR; |
54 return static_cast<DialogResult>(result); | 54 return static_cast<DialogResult>(result); |
55 } | 55 } |
56 | 56 |
57 std::wstring GetExtraResult() override { return extra_result_; } | 57 base::string16 GetExtraResult() override { return extra_result_; } |
58 | 58 |
59 private: | 59 private: |
60 bool InternalDoDialog(CustomizationCallback* callback, int* result); | 60 bool InternalDoDialog(CustomizationCallback* callback, int* result); |
61 static LRESULT CALLBACK MsgFilter(int code, WPARAM wParam, LPARAM lParam); | 61 static LRESULT CALLBACK MsgFilter(int code, WPARAM wParam, LPARAM lParam); |
62 | 62 |
63 std::wstring url_; | 63 base::string16 url_; |
64 std::wstring param_; | 64 base::string16 param_; |
65 static HHOOK hook_; | 65 static HHOOK hook_; |
66 static HINSTANCE mshtml_; | 66 static HINSTANCE mshtml_; |
67 static CustomizationCallback* callback_; | 67 static CustomizationCallback* callback_; |
68 std::wstring extra_result_; | 68 base::string16 extra_result_; |
69 }; | 69 }; |
70 | 70 |
71 HTMLDialog* CreateNativeHTMLDialog(const std::wstring& url, | 71 HTMLDialog* CreateNativeHTMLDialog(const base::string16& url, |
72 const std::wstring& param) { | 72 const base::string16& param) { |
73 return new HTMLDialogWin(url, param); | 73 return new HTMLDialogWin(url, param); |
74 } | 74 } |
75 | 75 |
76 HHOOK HTMLDialogWin::hook_ = NULL; | 76 HHOOK HTMLDialogWin::hook_ = NULL; |
77 HINSTANCE HTMLDialogWin::mshtml_ = NULL; | 77 HINSTANCE HTMLDialogWin::mshtml_ = NULL; |
78 HTMLDialogWin::CustomizationCallback* HTMLDialogWin::callback_ = NULL; | 78 HTMLDialogWin::CustomizationCallback* HTMLDialogWin::callback_ = NULL; |
79 | 79 |
80 // This hook function gets called for messages bound to the windows that | 80 // This hook function gets called for messages bound to the windows that |
81 // ShowHTMLDialog creates. We tell apart the top window because it has the | 81 // ShowHTMLDialog creates. We tell apart the top window because it has the |
82 // system menu style. | 82 // system menu style. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 if (!window) | 164 if (!window) |
165 return; | 165 return; |
166 HWND top_window = static_cast<HWND>(window); | 166 HWND top_window = static_cast<HWND>(window); |
167 LONG_PTR style = ::GetWindowLongPtrW(top_window, GWL_STYLE); | 167 LONG_PTR style = ::GetWindowLongPtrW(top_window, GWL_STYLE); |
168 ::SetWindowLongPtrW(top_window, GWL_STYLE, style & ~WS_SYSMENU); | 168 ::SetWindowLongPtrW(top_window, GWL_STYLE, style & ~WS_SYSMENU); |
169 HICON ico = ::LoadIcon(NULL, IDI_INFORMATION); | 169 HICON ico = ::LoadIcon(NULL, IDI_INFORMATION); |
170 ::SendMessageW(top_window, WM_SETICON, ICON_SMALL, | 170 ::SendMessageW(top_window, WM_SETICON, ICON_SMALL, |
171 reinterpret_cast<LPARAM>(ico)); | 171 reinterpret_cast<LPARAM>(ico)); |
172 } | 172 } |
173 | 173 |
174 EulaHTMLDialog::EulaHTMLDialog(const std::wstring& file, | 174 EulaHTMLDialog::EulaHTMLDialog(const base::string16& file, |
175 const std::wstring& param) { | 175 const base::string16& param) { |
176 dialog_ = CreateNativeHTMLDialog(file, param); | 176 dialog_ = CreateNativeHTMLDialog(file, param); |
177 } | 177 } |
178 | 178 |
179 EulaHTMLDialog::~EulaHTMLDialog() { | 179 EulaHTMLDialog::~EulaHTMLDialog() { |
180 delete dialog_; | 180 delete dialog_; |
181 } | 181 } |
182 | 182 |
183 EulaHTMLDialog::Outcome EulaHTMLDialog::ShowModal() { | 183 EulaHTMLDialog::Outcome EulaHTMLDialog::ShowModal() { |
184 Customizer customizer; | 184 Customizer customizer; |
185 HTMLDialog::DialogResult dr = dialog_->ShowModal(NULL, &customizer); | 185 HTMLDialog::DialogResult dr = dialog_->ShowModal(NULL, &customizer); |
186 if (HTMLDialog::HTML_DLG_ACCEPT == dr) | 186 if (HTMLDialog::HTML_DLG_ACCEPT == dr) |
187 return EulaHTMLDialog::ACCEPTED; | 187 return EulaHTMLDialog::ACCEPTED; |
188 else if (HTMLDialog::HTML_DLG_EXTRA == dr) | 188 else if (HTMLDialog::HTML_DLG_EXTRA == dr) |
189 return EulaHTMLDialog::ACCEPTED_OPT_IN; | 189 return EulaHTMLDialog::ACCEPTED_OPT_IN; |
190 else | 190 else |
191 return EulaHTMLDialog::REJECTED; | 191 return EulaHTMLDialog::REJECTED; |
192 } | 192 } |
193 | 193 |
194 } // namespace installer | 194 } // namespace installer |
OLD | NEW |