| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 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/browser/jsmessage_box_handler_win.h" | 5 #include "chrome/browser/jsmessage_box_handler_win.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "chrome/browser/app_modal_dialog_queue.h" | 8 #include "chrome/browser/app_modal_dialog_queue.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| 11 #include "chrome/browser/tab_contents/web_contents.h" | 11 #include "chrome/browser/tab_contents/web_contents.h" |
| 12 #include "chrome/common/gfx/text_elider.h" | 12 #include "chrome/common/gfx/text_elider.h" |
| 13 #include "chrome/common/l10n_util.h" | 13 #include "chrome/common/l10n_util.h" |
| 14 #include "chrome/common/message_box_flags.h" |
| 14 #include "chrome/common/notification_service.h" | 15 #include "chrome/common/notification_service.h" |
| 15 #include "chrome/common/notification_type.h" | 16 #include "chrome/common/notification_type.h" |
| 16 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 17 #include "chrome/common/pref_service.h" | 18 #include "chrome/common/pref_service.h" |
| 18 #include "chrome/views/controls/message_box_view.h" | 19 #include "chrome/views/controls/message_box_view.h" |
| 19 #include "chrome/views/window/window.h" | 20 #include "chrome/views/window/window.h" |
| 20 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
| 21 | 22 |
| 22 void RunJavascriptMessageBox(WebContents* web_contents, | 23 void RunJavascriptMessageBox(WebContents* web_contents, |
| 23 const GURL& frame_url, | 24 const GURL& frame_url, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 40 const std::wstring& message_text, | 41 const std::wstring& message_text, |
| 41 const std::wstring& default_prompt_text, | 42 const std::wstring& default_prompt_text, |
| 42 bool display_suppress_checkbox, | 43 bool display_suppress_checkbox, |
| 43 IPC::Message* reply_msg) | 44 IPC::Message* reply_msg) |
| 44 : web_contents_(web_contents), | 45 : web_contents_(web_contents), |
| 45 frame_url_(frame_url), | 46 frame_url_(frame_url), |
| 46 reply_msg_(reply_msg), | 47 reply_msg_(reply_msg), |
| 47 dialog_flags_(dialog_flags), | 48 dialog_flags_(dialog_flags), |
| 48 dialog_(NULL), | 49 dialog_(NULL), |
| 49 message_box_view_(new MessageBoxView( | 50 message_box_view_(new MessageBoxView( |
| 50 dialog_flags | MessageBoxView::kAutoDetectAlignment, | 51 dialog_flags | MessageBox::kAutoDetectAlignment, |
| 51 message_text, default_prompt_text)) { | 52 message_text, default_prompt_text)) { |
| 52 DCHECK(message_box_view_); | 53 DCHECK(message_box_view_); |
| 53 DCHECK(reply_msg_); | 54 DCHECK(reply_msg_); |
| 54 | 55 |
| 55 if (display_suppress_checkbox) { | 56 if (display_suppress_checkbox) { |
| 56 message_box_view_->SetCheckBoxLabel( | 57 message_box_view_->SetCheckBoxLabel( |
| 57 l10n_util::GetString(IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION)); | 58 l10n_util::GetString(IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION)); |
| 58 } | 59 } |
| 59 | 60 |
| 60 // Make sure we get navigation notifications so we know when our parent | 61 // Make sure we get navigation notifications so we know when our parent |
| 61 // contents will disappear or navigate to a different page. | 62 // contents will disappear or navigate to a different page. |
| 62 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, | 63 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, |
| 63 NotificationService::AllSources()); | 64 NotificationService::AllSources()); |
| 64 registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED, | 65 registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED, |
| 65 NotificationService::AllSources()); | 66 NotificationService::AllSources()); |
| 66 } | 67 } |
| 67 | 68 |
| 68 JavascriptMessageBoxHandler::~JavascriptMessageBoxHandler() { | 69 JavascriptMessageBoxHandler::~JavascriptMessageBoxHandler() { |
| 69 } | 70 } |
| 70 | 71 |
| 71 ////////////////////////////////////////////////////////////////////////////// | 72 ////////////////////////////////////////////////////////////////////////////// |
| 72 // JavascriptMessageBoxHandler, views::DialogDelegate implementation: | 73 // JavascriptMessageBoxHandler, views::DialogDelegate implementation: |
| 73 | 74 |
| 74 int JavascriptMessageBoxHandler::GetDialogButtons() const { | 75 int JavascriptMessageBoxHandler::GetDialogButtons() const { |
| 75 int dialog_buttons = 0; | 76 int dialog_buttons = 0; |
| 76 if (dialog_flags_ & MessageBoxView::kFlagHasOKButton) | 77 if (dialog_flags_ & MessageBox::kFlagHasOKButton) |
| 77 dialog_buttons = DIALOGBUTTON_OK; | 78 dialog_buttons = DIALOGBUTTON_OK; |
| 78 | 79 |
| 79 if (dialog_flags_ & MessageBoxView::kFlagHasCancelButton) | 80 if (dialog_flags_ & MessageBox::kFlagHasCancelButton) |
| 80 dialog_buttons |= DIALOGBUTTON_CANCEL; | 81 dialog_buttons |= DIALOGBUTTON_CANCEL; |
| 81 | 82 |
| 82 return dialog_buttons; | 83 return dialog_buttons; |
| 83 } | 84 } |
| 84 | 85 |
| 85 std::wstring JavascriptMessageBoxHandler::GetWindowTitle() const { | 86 std::wstring JavascriptMessageBoxHandler::GetWindowTitle() const { |
| 86 if (!frame_url_.has_host()) | 87 if (!frame_url_.has_host()) |
| 87 return l10n_util::GetString(IDS_JAVASCRIPT_MESSAGEBOX_DEFAULT_TITLE); | 88 return l10n_util::GetString(IDS_JAVASCRIPT_MESSAGEBOX_DEFAULT_TITLE); |
| 88 | 89 |
| 89 // We really only want the scheme, hostname, and port. | 90 // We really only want the scheme, hostname, and port. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 web_contents_gone = true; | 203 web_contents_gone = true; |
| 203 | 204 |
| 204 if (web_contents_gone) { | 205 if (web_contents_gone) { |
| 205 web_contents_ = NULL; | 206 web_contents_ = NULL; |
| 206 | 207 |
| 207 // If the dialog is visible close it. | 208 // If the dialog is visible close it. |
| 208 if (dialog_) | 209 if (dialog_) |
| 209 dialog_->Close(); | 210 dialog_->Close(); |
| 210 } | 211 } |
| 211 } | 212 } |
| OLD | NEW |