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

Unified Diff: chrome/browser/resources/print_preview/native_layer.js

Issue 14093016: Native api to get OAuth2 access tokens in Print Preview Web UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | « no previous file | chrome/browser/ui/webui/print_preview/print_preview_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/print_preview/native_layer.js
diff --git a/chrome/browser/resources/print_preview/native_layer.js b/chrome/browser/resources/print_preview/native_layer.js
index 988601f49b98f39033809c50a00b81ff8e2135b0..1d2c8635e6128c1a8d8fbb664f056d7fcd9f5630 100644
--- a/chrome/browser/resources/print_preview/native_layer.js
+++ b/chrome/browser/resources/print_preview/native_layer.js
@@ -39,6 +39,7 @@ cr.define('print_preview', function() {
global['updatePrintPreview'] = this.onUpdatePrintPreview_.bind(this);
global['printScalingDisabledForSourcePDF'] =
this.onPrintScalingDisabledForSourcePDF_.bind(this);
+ global['onDidGetAccessToken'] = this.onDidGetAccessToken_.bind(this);
};
/**
@@ -47,6 +48,7 @@ cr.define('print_preview', function() {
* @const
*/
NativeLayer.EventType = {
+ ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY',
CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET',
CLOUD_PRINT_ENABLE: 'print_preview.NativeLayer.CLOUD_PRINT_ENABLE',
DESTINATIONS_RELOAD: 'print_preview.NativeLayer.DESTINATIONS_RELOAD',
@@ -100,6 +102,14 @@ cr.define('print_preview', function() {
NativeLayer.prototype = {
__proto__: cr.EventTarget.prototype,
+ /**
+ * Requests access token for cloud print requests.
+ * @param {string} authType type of access token.
+ */
+ startGetAccessToken: function(authType) {
+ chrome.send('getAccessToken', [authType]);
+ },
+
/** Gets the initial settings to initialize the print preview with. */
startGetInitialSettings: function() {
chrome.send('getInitialSettings');
@@ -520,6 +530,20 @@ cr.define('print_preview', function() {
},
/**
+ * Notification that access token is ready.
+ * @param {string} authType Type of access token.
+ * @param {string} accessToken Access token.
+ * @private
+ */
+ onDidGetAccessToken_: function(authType, accessToken) {
+ var getAccessTokenEvent = new cr.Event(
+ NativeLayer.EventType.ACCESS_TOKEN_READY);
+ getAccessTokenEvent.authType = authType;
+ getAccessTokenEvent.accessToken = accessToken;
+ this.dispatchEvent(getAccessTokenEvent);
+ },
+
+ /**
* Update the print preview when new preview data is available.
* Create the PDF plugin as needed.
* Called from PrintPreviewUI::PreviewDataIsAvailable().
« no previous file with comments | « no previous file | chrome/browser/ui/webui/print_preview/print_preview_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698