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
5from telemetry.internal.backends import form_based_credentials_backend
6
7
8class GoogleCredentialsBackend(
9    form_based_credentials_backend.FormBasedCredentialsBackend):
10
11  @property
12  def logged_in_javascript(self):
13    """Evaluates to true iff already logged in."""
14    return 'document.getElementById("gb")!== null'
15
16  @property
17  def credentials_type(self):
18    return 'google'
19
20  @property
21  def url(self):
22    # pylint: disable=line-too-long
23    # WPR doesn't support having 2 responses for the same URL (with/without
24    # session cookie), so after login behaviour differs with/without wpr.
25    # Sign-in URL is specified directly to overcome this.
26    return 'https://accounts.google.com/ServiceLogin?continue=https%3A%2F%2Faccounts.google.com%2FManageAccount'
27
28  @property
29  def login_form_id(self):
30    return 'gaia_loginform'
31
32  @property
33  def login_input_id(self):
34    return 'Email'
35
36  @property
37  def password_input_id(self):
38    return 'Passwd'
39
40
41class GoogleCredentialsBackend2(GoogleCredentialsBackend):
42  """ Google credential backend for google2 credential. """
43
44  @property
45  def credentials_type(self):
46    return 'google2'
47