Upstream version 11.39.266.0
[platform/framework/web/crosswalk.git] / src / components / autofill / core / common / password_autofill_util.cc
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.
4
5 #include "components/autofill/core/common/password_autofill_util.h"
6
7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h"
9 #include "components/autofill/core/common/autofill_switches.h"
10
11 namespace autofill {
12
13 namespace {
14
15 const char kDisableIgnoreAutocompleteOffFieldTrialName[] =
16     "DisableIgnoreAutocompleteOff";
17 const char kEnablingGroup[] = "ENABLED";
18
19 bool InDisableIgnoreAutocompleteOffGroup() {
20   std::string group_name = base::FieldTrialList::FindFullName(
21       kDisableIgnoreAutocompleteOffFieldTrialName);
22
23   return group_name.compare(kEnablingGroup) == 0;
24 }
25
26 }  // namespace
27
28 // We ignore autocomplete='off' unless the user has specified the command line
29 // flag instructing otherwise or is in the field trial group specifying that
30 // ignore autocomplete='off' should be disabled.
31 bool ShouldIgnoreAutocompleteOffForPasswordFields() {
32   // TODO(jww): The field trial is scheduled to end 2014/9/1. At latest, we
33   // should remove the field trial and switch by then.
34   return !InDisableIgnoreAutocompleteOffGroup() &&
35          !CommandLine::ForCurrentProcess()->HasSwitch(
36               switches::kDisableIgnoreAutocompleteOff);
37 }
38
39 }  // namespace autofill