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

Side by Side Diff: chrome/browser/ui/views/autofill/autofill_dialog_views.cc

Issue 135933003: rAc: split TestableAutofillDialogView implementation into its own class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix stuff, sync Created 6 years, 11 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 "chrome/browser/ui/views/autofill/autofill_dialog_views.h" 5 #include "chrome/browser/ui/views/autofill/autofill_dialog_views.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1434 1434
1435 void AutofillDialogViews::ModelChanged() { 1435 void AutofillDialogViews::ModelChanged() {
1436 menu_runner_.reset(); 1436 menu_runner_.reset();
1437 1437
1438 for (DetailGroupMap::const_iterator iter = detail_groups_.begin(); 1438 for (DetailGroupMap::const_iterator iter = detail_groups_.begin();
1439 iter != detail_groups_.end(); ++iter) { 1439 iter != detail_groups_.end(); ++iter) {
1440 UpdateDetailsGroupState(iter->second); 1440 UpdateDetailsGroupState(iter->second);
1441 } 1441 }
1442 } 1442 }
1443 1443
1444 TestableAutofillDialogView* AutofillDialogViews::GetTestableView() {
1445 return this;
1446 }
1447
1448 void AutofillDialogViews::OnSignInResize(const gfx::Size& pref_size) { 1444 void AutofillDialogViews::OnSignInResize(const gfx::Size& pref_size) {
1449 sign_in_web_view_->SetPreferredSize(pref_size); 1445 sign_in_web_view_->SetPreferredSize(pref_size);
1450 ContentsPreferredSizeChanged(); 1446 ContentsPreferredSizeChanged();
1451 } 1447 }
1452 1448
1453 void AutofillDialogViews::SubmitForTesting() {
1454 Accept();
1455 }
1456
1457 void AutofillDialogViews::CancelForTesting() {
1458 GetDialogClientView()->CancelWindow();
1459 }
1460
1461 base::string16 AutofillDialogViews::GetTextContentsOfInput(
1462 ServerFieldType type) {
1463 views::Textfield* textfield = TextfieldForType(type);
1464 if (textfield)
1465 return textfield->text();
1466
1467 views::Combobox* combobox = ComboboxForType(type);
1468 if (combobox)
1469 return combobox->model()->GetItemAt(combobox->selected_index());
1470
1471 NOTREACHED();
1472 return base::string16();
1473 }
1474
1475 void AutofillDialogViews::SetTextContentsOfInput(
1476 ServerFieldType type,
1477 const base::string16& contents) {
1478 views::Textfield* textfield = TextfieldForType(type);
1479 if (textfield) {
1480 textfield->SetText(contents);
1481 return;
1482 }
1483
1484 views::Combobox* combobox = ComboboxForType(type);
1485 if (combobox) {
1486 SelectComboboxValueOrSetToDefault(combobox, contents);
1487 return;
1488 }
1489
1490 NOTREACHED();
1491 }
1492
1493 void AutofillDialogViews::SetTextContentsOfSuggestionInput(
1494 DialogSection section,
1495 const base::string16& text) {
1496 GroupForSection(section)->suggested_info->decorated_textfield()->
1497 SetText(text);
1498 }
1499
1500 void AutofillDialogViews::ActivateInput(ServerFieldType type) {
1501 InputEditedOrActivated(type, gfx::Rect(), false);
1502 }
1503
1504 gfx::Size AutofillDialogViews::GetSize() const {
1505 return GetWidget() ? GetWidget()->GetRootView()->size() : gfx::Size();
1506 }
1507
1508 content::WebContents* AutofillDialogViews::GetSignInWebContents() {
1509 return sign_in_web_view_->web_contents();
1510 }
1511
1512 bool AutofillDialogViews::IsShowingOverlay() const {
1513 return overlay_view_->visible();
1514 }
1515
1516 gfx::Size AutofillDialogViews::GetPreferredSize() { 1449 gfx::Size AutofillDialogViews::GetPreferredSize() {
1517 if (preferred_size_.IsEmpty()) 1450 if (preferred_size_.IsEmpty())
1518 preferred_size_ = CalculatePreferredSize(false); 1451 preferred_size_ = CalculatePreferredSize(false);
1519 1452
1520 return preferred_size_; 1453 return preferred_size_;
1521 } 1454 }
1522 1455
1523 gfx::Size AutofillDialogViews::GetMinimumSize() { 1456 gfx::Size AutofillDialogViews::GetMinimumSize() {
1524 return CalculatePreferredSize(true); 1457 return CalculatePreferredSize(true);
1525 } 1458 }
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
2277 2210
2278 return all_valid; 2211 return all_valid;
2279 } 2212 }
2280 2213
2281 void AutofillDialogViews::InputEditedOrActivated(ServerFieldType type, 2214 void AutofillDialogViews::InputEditedOrActivated(ServerFieldType type,
2282 const gfx::Rect& bounds, 2215 const gfx::Rect& bounds,
2283 bool was_edit) { 2216 bool was_edit) {
2284 DCHECK_NE(UNKNOWN_TYPE, type); 2217 DCHECK_NE(UNKNOWN_TYPE, type);
2285 2218
2286 DecoratedTextfield* decorated = TextfieldForType(type); 2219 DecoratedTextfield* decorated = TextfieldForType(type);
2287 DetailsGroup* group = decorated ? 2220 views::Combobox* combobox = ComboboxForType(type);
2288 GroupForView(decorated) : GroupForView(ComboboxForType(type)); 2221 DCHECK_NE(!!combobox, !!decorated);
Dan Beam 2014/01/28 18:04:48 nit: DCHECK_NE(!combobox, !decorated) does the sam
Evan Stade 2014/01/28 18:45:26 easier to read as english imho
groby-ooo-7-16 2014/01/28 20:54:14 If you like English, DCHECK(combobox || decorated)
Evan Stade 2014/01/28 22:05:55 the intended operation is XOR
2222 DetailsGroup* group = decorated ? GroupForView(decorated) :
2223 GroupForView(combobox);
2224 base::string16 text = decorated ?
2225 decorated->text() :
2226 combobox->model()->GetItemAt(combobox->selected_index());
2289 DCHECK(group); 2227 DCHECK(group);
2290 2228
2291 delegate_->UserEditedOrActivatedInput(group->section, 2229 delegate_->UserEditedOrActivatedInput(group->section,
2292 type, 2230 type,
2293 GetWidget()->GetNativeView(), 2231 GetWidget()->GetNativeView(),
2294 bounds, 2232 bounds,
2295 GetTextContentsOfInput(type), 2233 text,
2296 was_edit); 2234 was_edit);
2297 2235
2298 // If the field is a textfield and is invalid, check if the text is now valid. 2236 // If the field is a textfield and is invalid, check if the text is now valid.
2299 // Many fields (i.e. CC#) are invalid for most of the duration of editing, 2237 // Many fields (i.e. CC#) are invalid for most of the duration of editing,
2300 // so flagging them as invalid prematurely is not helpful. However, 2238 // so flagging them as invalid prematurely is not helpful. However,
2301 // correcting a minor mistake (i.e. a wrong CC digit) should immediately 2239 // correcting a minor mistake (i.e. a wrong CC digit) should immediately
2302 // result in validation - positive user feedback. 2240 // result in validation - positive user feedback.
2303 if (decorated && decorated->invalid() && was_edit) { 2241 if (decorated && decorated->invalid() && was_edit) {
2304 SetValidityForInput( 2242 SetValidityForInput(
2305 decorated, 2243 decorated,
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
2513 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) 2451 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section)
2514 : section(section), 2452 : section(section),
2515 container(NULL), 2453 container(NULL),
2516 manual_input(NULL), 2454 manual_input(NULL),
2517 suggested_info(NULL), 2455 suggested_info(NULL),
2518 suggested_button(NULL) {} 2456 suggested_button(NULL) {}
2519 2457
2520 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} 2458 AutofillDialogViews::DetailsGroup::~DetailsGroup() {}
2521 2459
2522 } // namespace autofill 2460 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698