Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: ui/views/controls/message_box_view.cc

Issue 10916214: Try 2 - Change how ui::Clipboard is accessed so there's only one per thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved to BrowserThreadsStarted Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.h" 8 #include "base/message_loop.h"
9 #include "base/string_split.h" 9 #include "base/string_split.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "ui/base/accessibility/accessible_view_state.h" 11 #include "ui/base/accessibility/accessible_view_state.h"
12 #include "ui/base/clipboard/clipboard.h" 12 #include "ui/base/clipboard/clipboard.h"
13 #include "ui/base/clipboard/scoped_clipboard_writer.h" 13 #include "ui/base/clipboard/scoped_clipboard_writer.h"
14 #include "ui/views/controls/button/checkbox.h" 14 #include "ui/views/controls/button/checkbox.h"
15 #include "ui/views/controls/image_view.h" 15 #include "ui/views/controls/image_view.h"
16 #include "ui/views/controls/label.h" 16 #include "ui/views/controls/label.h"
17 #include "ui/views/controls/textfield/textfield.h" 17 #include "ui/views/controls/textfield/textfield.h"
18 #include "ui/views/layout/grid_layout.h" 18 #include "ui/views/layout/grid_layout.h"
19 #include "ui/views/layout/layout_constants.h" 19 #include "ui/views/layout/layout_constants.h"
20 #include "ui/views/views_delegate.h"
21 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
22 #include "ui/views/window/client_view.h" 21 #include "ui/views/window/client_view.h"
23 22
24 namespace { 23 namespace {
25 24
26 const int kDefaultMessageWidth = 320; 25 const int kDefaultMessageWidth = 320;
27 26
28 // Paragraph separators are defined in 27 // Paragraph separators are defined in
29 // http://www.unicode.org/Public/6.0.0/ucd/extracted/DerivedBidiClass.txt 28 // http://www.unicode.org/Public/6.0.0/ucd/extracted/DerivedBidiClass.txt
30 // 29 //
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 132 }
134 133
135 bool MessageBoxView::AcceleratorPressed(const ui::Accelerator& accelerator) { 134 bool MessageBoxView::AcceleratorPressed(const ui::Accelerator& accelerator) {
136 // We only accepts Ctrl-C. 135 // We only accepts Ctrl-C.
137 DCHECK(accelerator.key_code() == 'C' && accelerator.IsCtrlDown()); 136 DCHECK(accelerator.key_code() == 'C' && accelerator.IsCtrlDown());
138 137
139 // We must not intercept Ctrl-C when we have a text box and it's focused. 138 // We must not intercept Ctrl-C when we have a text box and it's focused.
140 if (prompt_field_ && prompt_field_->HasFocus()) 139 if (prompt_field_ && prompt_field_->HasFocus())
141 return false; 140 return false;
142 141
143 if (!ViewsDelegate::views_delegate) 142 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
144 return false;
145
146 ui::Clipboard* clipboard = ViewsDelegate::views_delegate->GetClipboard();
147 if (!clipboard) 143 if (!clipboard)
148 return false; 144 return false;
149 145
150 ui::ScopedClipboardWriter scw(clipboard, ui::Clipboard::BUFFER_STANDARD); 146 ui::ScopedClipboardWriter scw(clipboard, ui::Clipboard::BUFFER_STANDARD);
151 string16 text = message_labels_[0]->text(); 147 string16 text = message_labels_[0]->text();
152 for (size_t i = 1; i < message_labels_.size(); ++i) 148 for (size_t i = 1; i < message_labels_.size(); ++i)
153 text += message_labels_[i]->text(); 149 text += message_labels_[i]->text();
154 scw.WriteText(text); 150 scw.WriteText(text);
155 return true; 151 return true;
156 } 152 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 if (checkbox_) { 257 if (checkbox_) {
262 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); 258 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
263 layout->StartRow(0, checkbox_column_view_set_id); 259 layout->StartRow(0, checkbox_column_view_set_id);
264 layout->AddView(checkbox_); 260 layout->AddView(checkbox_);
265 } 261 }
266 262
267 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); 263 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
268 } 264 }
269 265
270 } // namespace views 266 } // namespace views
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_unittest.cc ('k') | ui/views/controls/textfield/native_textfield_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698