Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Unified Diff: tools/chrome_remote_control/chrome_remote_control/credentials_backend.py

Issue 10914237: Port perf.py's _LoginToGoogleAccount to chrome_remote_control (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/chrome_remote_control/chrome_remote_control/credentials_backend.py
diff --git a/tools/chrome_remote_control/chrome_remote_control/credentials_backend.py b/tools/chrome_remote_control/chrome_remote_control/credentials_backend.py
new file mode 100644
index 0000000000000000000000000000000000000000..c446e184d684b4e7657b81df283945f9c8a1e7ec
--- /dev/null
+++ b/tools/chrome_remote_control/chrome_remote_control/credentials_backend.py
@@ -0,0 +1,48 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from chrome_remote_control import util
+
+class CredentialsBackend(object):
+ label = None
+
+ def __init__(self, browser_credentials):
+ self.browser_credentials = browser_credentials
+
+ def LoginNeeded(self, tab):
+ raise NotImplementedError()
+
+ def LoginNoLongerNeeded(self, tab):
+ raise NotImplementedError()
+
+ @staticmethod
+ def SubmitForm(form_id, tab):
+ """Submits the given form ID, and returns after it has been submitted.
+
+ Args:
+ form_id: the id attribute of the form to submit.
+ """
+ js = 'document.getElementById("%s").submit();' % form_id
+
+ tab.runtime.Execute(js)
+
+ @staticmethod
+ def WaitForFormToLoad(form_id, tab):
+ def IsFormLoaded():
+ return tab.runtime.Evaluate(
+ 'document.querySelector("#%s")!== null' % form_id)
+
+ # Wait until the form is submitted and the page completes loading.
+ util.WaitFor(lambda: IsFormLoaded(), 60) # pylint: disable=W0108
+
+ @classmethod
+ def SubmitFormAndWait(cls, form_id, tab):
+ cls.SubmitForm(form_id, tab)
+
+ def IsLoginStillHappening():
+ return tab.runtime.Evaluate(
+ 'document.querySelector("#%s")!== null' % form_id)
+
+ # Wait until the form is submitted and the page completes loading.
+ util.WaitFor(lambda: not IsLoginStillHappening(), 60)

Powered by Google App Engine
This is Rietveld 408576698