| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/controls/message_box_view.h" | 5 #include "ui/views/controls/message_box_view.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 paragraphs->push_back(text.substr(start, text.length() - start)); | 59 paragraphs->push_back(text.substr(start, text.length() - start)); |
| 60 } | 60 } |
| 61 | 61 |
| 62 } // namespace | 62 } // namespace |
| 63 | 63 |
| 64 namespace views { | 64 namespace views { |
| 65 | 65 |
| 66 /////////////////////////////////////////////////////////////////////////////// | 66 /////////////////////////////////////////////////////////////////////////////// |
| 67 // MessageBoxView, public: | 67 // MessageBoxView, public: |
| 68 | 68 |
| 69 // static |
| 70 const char MessageBoxView::kViewClassName[] = "MessageBoxView"; |
| 71 |
| 69 MessageBoxView::InitParams::InitParams(const base::string16& message) | 72 MessageBoxView::InitParams::InitParams(const base::string16& message) |
| 70 : options(NO_OPTIONS), | 73 : options(NO_OPTIONS), |
| 71 message(message), | 74 message(message), |
| 72 message_width(kDefaultMessageWidth), | 75 message_width(kDefaultMessageWidth), |
| 73 inter_row_vertical_spacing(kRelatedControlVerticalSpacing) {} | 76 inter_row_vertical_spacing(kRelatedControlVerticalSpacing) {} |
| 74 | 77 |
| 75 MessageBoxView::InitParams::~InitParams() { | 78 MessageBoxView::InitParams::~InitParams() { |
| 76 } | 79 } |
| 77 | 80 |
| 78 MessageBoxView::MessageBoxView(const InitParams& params) | 81 MessageBoxView::MessageBoxView(const InitParams& params) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 return false; | 154 return false; |
| 152 | 155 |
| 153 ui::ScopedClipboardWriter scw(ui::CLIPBOARD_TYPE_COPY_PASTE); | 156 ui::ScopedClipboardWriter scw(ui::CLIPBOARD_TYPE_COPY_PASTE); |
| 154 base::string16 text = message_labels_[0]->text(); | 157 base::string16 text = message_labels_[0]->text(); |
| 155 for (size_t i = 1; i < message_labels_.size(); ++i) | 158 for (size_t i = 1; i < message_labels_.size(); ++i) |
| 156 text += message_labels_[i]->text(); | 159 text += message_labels_[i]->text(); |
| 157 scw.WriteText(text); | 160 scw.WriteText(text); |
| 158 return true; | 161 return true; |
| 159 } | 162 } |
| 160 | 163 |
| 164 const char* MessageBoxView::GetClassName() const { |
| 165 return kViewClassName; |
| 166 } |
| 167 |
| 161 /////////////////////////////////////////////////////////////////////////////// | 168 /////////////////////////////////////////////////////////////////////////////// |
| 162 // MessageBoxView, private: | 169 // MessageBoxView, private: |
| 163 | 170 |
| 164 void MessageBoxView::Init(const InitParams& params) { | 171 void MessageBoxView::Init(const InitParams& params) { |
| 165 if (params.options & DETECT_DIRECTIONALITY) { | 172 if (params.options & DETECT_DIRECTIONALITY) { |
| 166 std::vector<base::string16> texts; | 173 std::vector<base::string16> texts; |
| 167 SplitStringIntoParagraphs(params.message, &texts); | 174 SplitStringIntoParagraphs(params.message, &texts); |
| 168 for (size_t i = 0; i < texts.size(); ++i) { | 175 for (size_t i = 0; i < texts.size(); ++i) { |
| 169 Label* message_label = new Label(texts[i]); | 176 Label* message_label = new Label(texts[i]); |
| 170 // Avoid empty multi-line labels, which have a height of 0. | 177 // Avoid empty multi-line labels, which have a height of 0. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 } | 242 } |
| 236 | 243 |
| 237 if (link_) { | 244 if (link_) { |
| 238 layout->AddPaddingRow(0, inter_row_vertical_spacing_); | 245 layout->AddPaddingRow(0, inter_row_vertical_spacing_); |
| 239 layout->StartRow(0, extra_column_view_set_id); | 246 layout->StartRow(0, extra_column_view_set_id); |
| 240 layout->AddView(link_); | 247 layout->AddView(link_); |
| 241 } | 248 } |
| 242 } | 249 } |
| 243 | 250 |
| 244 } // namespace views | 251 } // namespace views |
| OLD | NEW |