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

Side by Side Diff: chrome/browser/ui/input_window_dialog_win.cc

Issue 8590012: base::Bind migrations in chrome/browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/ui/login/login_prompt.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/input_window_dialog.h" 5 #include "chrome/browser/ui/input_window_dialog.h"
6 6
7 #include "base/bind.h"
7 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/weak_ptr.h"
8 #include "base/message_loop.h" 10 #include "base/message_loop.h"
9 #include "base/task.h"
10 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/ui/webui/chrome_web_ui.h" 12 #include "chrome/browser/ui/webui/chrome_web_ui.h"
12 #include "chrome/browser/ui/webui/input_window_dialog_webui.h" 13 #include "chrome/browser/ui/webui/input_window_dialog_webui.h"
13 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
14 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/views/window/dialog_delegate.h" 16 #include "ui/views/window/dialog_delegate.h"
16 #include "views/controls/label.h" 17 #include "views/controls/label.h"
17 #include "views/controls/textfield/textfield.h" 18 #include "views/controls/textfield/textfield.h"
18 #include "views/controls/textfield/textfield_controller.h" 19 #include "views/controls/textfield/textfield_controller.h"
19 #include "views/layout/grid_layout.h" 20 #include "views/layout/grid_layout.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 void FocusFirstFocusableControl(); 103 void FocusFirstFocusableControl();
103 104
104 // The Textfield that the user can type into. 105 // The Textfield that the user can type into.
105 views::Textfield* text_field_; 106 views::Textfield* text_field_;
106 107
107 // The delegate that the ContentView uses to communicate changes to the 108 // The delegate that the ContentView uses to communicate changes to the
108 // caller. 109 // caller.
109 InputWindowDialogWin* delegate_; 110 InputWindowDialogWin* delegate_;
110 111
111 // Helps us set focus to the first Textfield in the window. 112 // Helps us set focus to the first Textfield in the window.
112 ScopedRunnableMethodFactory<ContentView> focus_grabber_factory_; 113 base::WeakPtrFactory<ContentView> weak_factory_;
113 114
114 DISALLOW_COPY_AND_ASSIGN(ContentView); 115 DISALLOW_COPY_AND_ASSIGN(ContentView);
115 }; 116 };
116 117
117 /////////////////////////////////////////////////////////////////////////////// 118 ///////////////////////////////////////////////////////////////////////////////
118 // ContentView 119 // ContentView
119 ContentView::ContentView(InputWindowDialogWin* delegate) 120 ContentView::ContentView(InputWindowDialogWin* delegate)
120 : delegate_(delegate), 121 : delegate_(delegate),
121 ALLOW_THIS_IN_INITIALIZER_LIST(focus_grabber_factory_(this)) { 122 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
122 DCHECK(delegate_); 123 DCHECK(delegate_);
123 } 124 }
124 125
125 /////////////////////////////////////////////////////////////////////////////// 126 ///////////////////////////////////////////////////////////////////////////////
126 // ContentView, views::DialogDelegate implementation: 127 // ContentView, views::DialogDelegate implementation:
127 128
128 string16 ContentView::GetDialogButtonLabel(ui::DialogButton button) const { 129 string16 ContentView::GetDialogButtonLabel(ui::DialogButton button) const {
129 if (button == ui::DIALOG_BUTTON_OK) { 130 if (button == ui::DIALOG_BUTTON_OK) {
130 return l10n_util::GetStringUTF16( 131 return l10n_util::GetStringUTF16(
131 delegate_->type() == InputWindowDialog::BUTTON_TYPE_ADD ? IDS_ADD 132 delegate_->type() == InputWindowDialog::BUTTON_TYPE_ADD ? IDS_ADD
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 views::GridLayout::USE_PREF, 0, 0); 214 views::GridLayout::USE_PREF, 0, 0);
214 c1->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); 215 c1->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing);
215 c1->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 1, 216 c1->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 1,
216 views::GridLayout::USE_PREF, kTextfieldWidth, kTextfieldWidth); 217 views::GridLayout::USE_PREF, kTextfieldWidth, kTextfieldWidth);
217 218
218 layout->StartRow(0, 0); 219 layout->StartRow(0, 0);
219 views::Label* label = new views::Label(delegate_->label()); 220 views::Label* label = new views::Label(delegate_->label());
220 layout->AddView(label); 221 layout->AddView(label);
221 layout->AddView(text_field_); 222 layout->AddView(text_field_);
222 223
223 MessageLoop::current()->PostTask(FROM_HERE, 224 MessageLoop::current()->PostTask(
224 focus_grabber_factory_.NewRunnableMethod( 225 FROM_HERE, base::Bind(&ContentView::FocusFirstFocusableControl,
225 &ContentView::FocusFirstFocusableControl)); 226 weak_factory_.GetWeakPtr()));
226 } 227 }
227 228
228 void ContentView::FocusFirstFocusableControl() { 229 void ContentView::FocusFirstFocusableControl() {
229 text_field_->SelectAll(); 230 text_field_->SelectAll();
230 text_field_->RequestFocus(); 231 text_field_->RequestFocus();
231 } 232 }
232 233
233 InputWindowDialogWin::InputWindowDialogWin(gfx::NativeWindow parent, 234 InputWindowDialogWin::InputWindowDialogWin(gfx::NativeWindow parent,
234 const string16& window_title, 235 const string16& window_title,
235 const string16& label, 236 const string16& label,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } else { 273 } else {
273 DCHECK_EQ(1U, label_contents_pairs.size()); 274 DCHECK_EQ(1U, label_contents_pairs.size());
274 return new InputWindowDialogWin(parent, 275 return new InputWindowDialogWin(parent,
275 window_title, 276 window_title,
276 label_contents_pairs[0].first, 277 label_contents_pairs[0].first,
277 label_contents_pairs[0].second, 278 label_contents_pairs[0].second,
278 delegate, 279 delegate,
279 type); 280 type);
280 } 281 }
281 } 282 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/login/login_prompt.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698