OLD | NEW |
| (Empty) |
1 // Copyright (c) 2006-2008 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/browser/js_before_unload_handler_win.h" | |
6 | |
7 #include "chrome/browser/app_modal_dialog_queue.h" | |
8 #include "chrome/common/l10n_util.h" | |
9 #include "chrome/common/message_box_flags.h" | |
10 #include "grit/generated_resources.h" | |
11 | |
12 void RunBeforeUnloadDialog(WebContents* web_contents, | |
13 const GURL& frame_url, | |
14 const std::wstring& message_text, | |
15 IPC::Message* reply_msg) { | |
16 std::wstring full_message = | |
17 message_text + L"\n\n" + | |
18 l10n_util::GetString(IDS_BEFOREUNLOAD_MESSAGEBOX_FOOTER); | |
19 JavascriptBeforeUnloadHandler* handler = | |
20 new JavascriptBeforeUnloadHandler(web_contents, frame_url, full_message, | |
21 reply_msg); | |
22 AppModalDialogQueue::AddDialog(handler); | |
23 } | |
24 | |
25 // JavascriptBeforeUnloadHandler ----------------------------------------------- | |
26 | |
27 JavascriptBeforeUnloadHandler::JavascriptBeforeUnloadHandler( | |
28 WebContents* web_contents, | |
29 const GURL& frame_url, | |
30 const std::wstring& message_text, | |
31 IPC::Message* reply_msg) | |
32 : JavascriptMessageBoxHandler(web_contents, | |
33 frame_url, | |
34 MessageBox::kIsJavascriptConfirm, | |
35 message_text, | |
36 std::wstring(), | |
37 false, | |
38 reply_msg) { | |
39 } | |
40 | |
41 std::wstring JavascriptBeforeUnloadHandler::GetWindowTitle() const { | |
42 return l10n_util::GetString(IDS_BEFOREUNLOAD_MESSAGEBOX_TITLE); | |
43 } | |
44 | |
45 std::wstring JavascriptBeforeUnloadHandler::GetDialogButtonLabel( | |
46 DialogButton button) const { | |
47 if (button == DialogDelegate::DIALOGBUTTON_OK) { | |
48 return l10n_util::GetString(IDS_BEFOREUNLOAD_MESSAGEBOX_OK_BUTTON_LABEL); | |
49 } else if (button == DialogDelegate::DIALOGBUTTON_CANCEL) { | |
50 return l10n_util::GetString( | |
51 IDS_BEFOREUNLOAD_MESSAGEBOX_CANCEL_BUTTON_LABEL); | |
52 } | |
53 return L""; | |
54 } | |
OLD | NEW |