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

Unified Diff: chrome/browser/resources/gaia_auth/saml_injected.js

Issue 258123002: Implement a second version of the credentials passing API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One more s/requested_version/requestedVersion/ I had missed. Thank you for catching this, browser_t… Created 6 years, 7 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
« no previous file with comments | « chrome/browser/resources/gaia_auth/main.js ('k') | chrome/test/data/login/saml_api_login.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/gaia_auth/saml_injected.js
diff --git a/chrome/browser/resources/gaia_auth/saml_injected.js b/chrome/browser/resources/gaia_auth/saml_injected.js
index 62857b4c8849bdde2af98f1bd4a08426f8ea563d..e41dfebec624bf6fc801f6e391ee305f76d5174a 100644
--- a/chrome/browser/resources/gaia_auth/saml_injected.js
+++ b/chrome/browser/resources/gaia_auth/saml_injected.js
@@ -20,8 +20,9 @@
/**
* The credential passing API is used by sending messages to the SAML page's
- * |window| object. This class forwards the calls to a background script via a
- * |Channel|.
+ * |window| object. This class forwards API calls from the SAML page to a
+ * background script and API responses from the background script to the SAML
+ * page. Communication with the background script occurs via a |Channel|.
*/
APICallForwarder.prototype = {
// Channel to which API calls are forwarded.
@@ -33,6 +34,9 @@
*/
init: function(channel) {
this.channel_ = channel;
+ this.channel_.registerMessage('apiResponse',
+ this.onAPIResponse_.bind(this));
+
window.addEventListener('message', this.onMessage_.bind(this));
},
@@ -43,15 +47,14 @@
event.data.type != 'gaia_saml_api') {
return;
}
- if (event.data.call.method == 'initialize') {
- // Respond to the |initialize| call directly.
- event.source.postMessage({
- type: 'gaia_saml_api_reply',
- response: {result: 'initialized', version: 1}}, '/');
- } else {
- // Forward all other calls.
- this.channel_.send({name: 'apiCall', call: event.data.call});
- }
+ // Forward API calls to the background script.
+ this.channel_.send({name: 'apiCall', call: event.data.call});
+ },
+
+ onAPIResponse_: function(msg) {
+ // Forward API responses to the SAML page.
+ window.postMessage({type: 'gaia_saml_api_reply', response: msg.response},
+ '/');
}
};
« no previous file with comments | « chrome/browser/resources/gaia_auth/main.js ('k') | chrome/test/data/login/saml_api_login.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698