Chromium Code Reviews| 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 "chrome/browser/autofill/autofill_popup_view.h" | 5 #include "chrome/browser/autofill/autofill_popup_view.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/autofill/autofill_external_delegate.h" | 9 #include "chrome/browser/autofill/autofill_external_delegate.h" |
| 10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 | 131 |
| 132 void AutofillPopupView::ClearSelectedLine() { | 132 void AutofillPopupView::ClearSelectedLine() { |
| 133 SetSelectedLine(kNoSelection); | 133 SetSelectedLine(kNoSelection); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void AutofillPopupView::SelectNextLine() { | 136 void AutofillPopupView::SelectNextLine() { |
| 137 int new_selected_line = selected_line_ + 1; | 137 int new_selected_line = selected_line_ + 1; |
| 138 | 138 |
| 139 while (static_cast<size_t>(new_selected_line) < autofill_values_.size() && | |
|
Ilya Sherman
2012/10/20 03:38:24
nit: Please add a comment describing this block.
csharp
2012/10/22 13:29:20
Done.
| |
| 140 !CanAccept(autofill_unique_ids()[new_selected_line])) | |
|
Ilya Sherman
2012/10/20 03:38:24
Optional nit: I prefer to always include curly bra
csharp
2012/10/22 13:29:20
Done.
| |
| 141 ++new_selected_line; | |
| 142 | |
| 139 if (new_selected_line == static_cast<int>(autofill_values_.size())) | 143 if (new_selected_line == static_cast<int>(autofill_values_.size())) |
| 140 new_selected_line = 0; | 144 new_selected_line = 0; |
| 141 | 145 |
| 142 SetSelectedLine(new_selected_line); | 146 SetSelectedLine(new_selected_line); |
| 143 } | 147 } |
| 144 | 148 |
| 145 void AutofillPopupView::SelectPreviousLine() { | 149 void AutofillPopupView::SelectPreviousLine() { |
| 146 int new_selected_line = selected_line_ - 1; | 150 int new_selected_line = selected_line_ - 1; |
| 147 | 151 |
| 152 while (kNoSelection < new_selected_line && | |
|
Ilya Sherman
2012/10/20 03:38:24
Optional nit: I think this would be slightly clear
csharp
2012/10/22 13:29:20
Done.
| |
| 153 !CanAccept(autofill_unique_ids()[new_selected_line])) | |
| 154 --new_selected_line; | |
|
Ilya Sherman
2012/10/20 03:38:24
nit: Ditto on both counts.
csharp
2012/10/22 13:29:20
Done.
| |
| 155 | |
| 148 if (new_selected_line <= kNoSelection) | 156 if (new_selected_line <= kNoSelection) |
| 149 new_selected_line = autofill_values_.size() - 1; | 157 new_selected_line = autofill_values_.size() - 1; |
| 150 | 158 |
| 151 SetSelectedLine(new_selected_line); | 159 SetSelectedLine(new_selected_line); |
| 152 } | 160 } |
| 153 | 161 |
| 154 bool AutofillPopupView::AcceptSelectedLine() { | 162 bool AutofillPopupView::AcceptSelectedLine() { |
| 155 if (selected_line_ == kNoSelection) | 163 if (selected_line_ == kNoSelection) |
| 156 return false; | 164 return false; |
| 157 | 165 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 void AutofillPopupView::Observe(int type, | 328 void AutofillPopupView::Observe(int type, |
| 321 const content::NotificationSource& source, | 329 const content::NotificationSource& source, |
| 322 const content::NotificationDetails& details) { | 330 const content::NotificationDetails& details) { |
| 323 if (type == content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED) { | 331 if (type == content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED) { |
| 324 if (!*content::Details<bool>(details).ptr()) | 332 if (!*content::Details<bool>(details).ptr()) |
| 325 Hide(); | 333 Hide(); |
| 326 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { | 334 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { |
| 327 Hide(); | 335 Hide(); |
| 328 } | 336 } |
| 329 } | 337 } |
| OLD | NEW |