15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file. 45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "components/autofill/core/common/password_autofill_util.h" 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/command_line.h" 8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/metrics/field_trial.h" 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "components/autofill/core/common/autofill_switches.h" 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace autofill { 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace { 14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)const char kDisableIgnoreAutocompleteOffFieldTrialName[] = 16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "DisableIgnoreAutocompleteOff"; 17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)const char kEnablingGroup[] = "ENABLED"; 18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool InDisableIgnoreAutocompleteOffGroup() { 20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) std::string group_name = base::FieldTrialList::FindFullName( 21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) kDisableIgnoreAutocompleteOffFieldTrialName); 22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return group_name.compare(kEnablingGroup) == 0; 24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 25a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} // namespace 27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// We ignore autocomplete='off' unless the user has specified the command line 29a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// flag instructing otherwise or is in the field trial group specifying that 30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// ignore autocomplete='off' should be disabled. 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool ShouldIgnoreAutocompleteOffForPasswordFields() { 32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // TODO(jww): The field trial is scheduled to end 2014/9/1. At latest, we 33a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // should remove the field trial and switch by then. 34a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return !InDisableIgnoreAutocompleteOffGroup() && 35a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) !CommandLine::ForCurrentProcess()->HasSwitch( 36a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) switches::kDisableIgnoreAutocompleteOff); 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace autofill 40