| 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/views/controls/message_box_view.h" | 5 #include "chrome/views/controls/message_box_view.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/scoped_clipboard_writer.h" |
| 8 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/views/standard_layout.h" | 11 #include "chrome/browser/views/standard_layout.h" |
| 12 #include "chrome/common/clipboard_service.h" |
| 10 #include "chrome/common/l10n_util.h" | 13 #include "chrome/common/l10n_util.h" |
| 11 #include "chrome/common/message_box_flags.h" | 14 #include "chrome/common/message_box_flags.h" |
| 12 #include "chrome/views/controls/button/checkbox.h" | 15 #include "chrome/views/controls/button/checkbox.h" |
| 13 #include "chrome/views/window/client_view.h" | 16 #include "chrome/views/window/client_view.h" |
| 14 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 15 | 18 |
| 16 static const int kDefaultMessageWidth = 320; | 19 static const int kDefaultMessageWidth = 320; |
| 17 | 20 |
| 18 /////////////////////////////////////////////////////////////////////////////// | 21 /////////////////////////////////////////////////////////////////////////////// |
| 19 // MessageBoxView, public: | 22 // MessageBoxView, public: |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 83 |
| 81 void MessageBoxView::ViewHierarchyChanged(bool is_add, | 84 void MessageBoxView::ViewHierarchyChanged(bool is_add, |
| 82 views::View* parent, | 85 views::View* parent, |
| 83 views::View* child) { | 86 views::View* child) { |
| 84 if (child == this && is_add) { | 87 if (child == this && is_add) { |
| 85 if (prompt_field_) | 88 if (prompt_field_) |
| 86 prompt_field_->SelectAll(); | 89 prompt_field_->SelectAll(); |
| 87 } | 90 } |
| 88 } | 91 } |
| 89 | 92 |
| 93 bool MessageBoxView::AcceleratorPressed( |
| 94 const views::Accelerator& accelerator) { |
| 95 // We only accepts Ctrl-C. |
| 96 DCHECK(accelerator.GetKeyCode() == 'C' && accelerator.IsCtrlDown()); |
| 97 |
| 98 ClipboardService* clipboard = g_browser_process->clipboard_service(); |
| 99 if (!clipboard) |
| 100 return false; |
| 101 |
| 102 ScopedClipboardWriter scw(clipboard); |
| 103 scw.WriteText(message_label_->GetText()); |
| 104 return true; |
| 105 } |
| 106 |
| 90 /////////////////////////////////////////////////////////////////////////////// | 107 /////////////////////////////////////////////////////////////////////////////// |
| 91 // MessageBoxView, private: | 108 // MessageBoxView, private: |
| 92 | 109 |
| 93 void MessageBoxView::Init(int dialog_flags, | 110 void MessageBoxView::Init(int dialog_flags, |
| 94 const std::wstring& default_prompt) { | 111 const std::wstring& default_prompt) { |
| 95 message_label_->SetMultiLine(true); | 112 message_label_->SetMultiLine(true); |
| 96 if (dialog_flags & MessageBoxFlags::kAutoDetectAlignment) { | 113 if (dialog_flags & MessageBoxFlags::kAutoDetectAlignment) { |
| 97 // Determine the alignment and directionality based on the first character | 114 // Determine the alignment and directionality based on the first character |
| 98 // with strong directionality. | 115 // with strong directionality. |
| 99 l10n_util::TextDirection direction = | 116 l10n_util::TextDirection direction = |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 199 } |
| 183 | 200 |
| 184 if (checkbox_) { | 201 if (checkbox_) { |
| 185 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 202 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
| 186 layout->StartRow(0, checkbox_column_view_set_id); | 203 layout->StartRow(0, checkbox_column_view_set_id); |
| 187 layout->AddView(checkbox_); | 204 layout->AddView(checkbox_); |
| 188 } | 205 } |
| 189 | 206 |
| 190 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 207 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
| 191 } | 208 } |
| OLD | NEW |