Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / components / autofill / core / browser / autofill_scanner.cc
blobc233c1d3ef7c9395d533d6305945846041169c20
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/autofill/core/browser/autofill_scanner.h"
7 #include "base/logging.h"
8 #include "components/autofill/core/browser/autofill_field.h"
10 namespace autofill {
12 AutofillScanner::AutofillScanner(std::vector<AutofillField*>& fields)
13 : cursor_(fields.begin()),
14 saved_cursor_(fields.begin()),
15 begin_(fields.begin()),
16 end_(fields.end()) {
19 AutofillScanner::~AutofillScanner() {
22 void AutofillScanner::Advance() {
23 DCHECK(!IsEnd());
24 ++cursor_;
27 AutofillField* AutofillScanner::Cursor() const {
28 if (IsEnd()) {
29 NOTREACHED();
30 return NULL;
33 return *cursor_;
36 bool AutofillScanner::IsEnd() const {
37 return cursor_ == end_;
40 void AutofillScanner::Rewind() {
41 DCHECK(saved_cursor_ != end_);
42 cursor_ = saved_cursor_;
43 saved_cursor_ = end_;
46 void AutofillScanner::RewindTo(size_t index) {
47 DCHECK(index < static_cast<size_t>(end_ - begin_));
48 cursor_ = begin_ + index;
49 saved_cursor_ = end_;
52 size_t AutofillScanner::SaveCursor() {
53 saved_cursor_ = cursor_;
54 return static_cast<size_t>(cursor_ - begin_);
57 } // namespace autofill