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/chromeos/arc_support/background.js

Issue 2479633004: Split ShowPage message into two. (Closed)
Patch Set: Fix compile error. Created 4 years, 1 month 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/chromeos/arc/arc_support_host.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/chromeos/arc_support/background.js
diff --git a/chrome/browser/resources/chromeos/arc_support/background.js b/chrome/browser/resources/chromeos/arc_support/background.js
index f0e45f6fabd0b53f333a8a9c8736e5d629548ab4..57383a00b6cd23dbbc6cd53382aaf7770482c4a8 100644
--- a/chrome/browser/resources/chromeos/arc_support/background.js
+++ b/chrome/browser/resources/chromeos/arc_support/background.js
@@ -3,19 +3,6 @@
// found in the LICENSE file.
/**
- * UI Pages. Note the order must be in sync with the ArcAuthService::UIPage
- * enum.
- * @type {Array<string>}
- */
-var UI_PAGES = ['none',
- 'terms',
- 'lso-loading',
- 'lso',
- 'arc-loading',
- 'error',
- 'error-with-feedback'];
-
-/**
* Chrome window that hosts UI. Only one window is allowed.
* @type {chrome.app.window.AppWindow}
*/
@@ -374,9 +361,8 @@ class TermsOfServicePage {
console.error('TermsView loading is aborted: ' + reason);
// Mark ABORTED so that onTermsViewLoaded_() won't show the content view.
this.state_ = LoadState.ABORTED;
- setErrorMessage(
+ showErrorPage(
appWindow.contentWindow.loadTimeData.getString('serverError'));
- showPage('error');
}
/** Called when "AGREE" button is clicked. */
@@ -483,7 +469,17 @@ function onNativeMessage(message) {
appWindow.close();
}
} else if (message.action == 'showPage') {
- showPageWithStatus(message.page, message.status);
+ if (message.page != 'terms') {
+ // Explicit request to start not from start page. Assume terms are
+ // accepted in this case.
+ // TODO: this is only for controling "RETRY" button. Remove this.
+ termsAccepted = true;
+ }
+ showPage(message.page);
+ } else if (message.action == 'showErrorPage') {
+ // TODO: this is only for controling "RETRY" button. Remove this.
+ termsAccepted = true;
+ showErrorPage(message.errorMessage, message.shouldShowSendFeedback);
} else if (message.action == 'setWindowBounds') {
setWindowBounds();
}
@@ -511,14 +507,6 @@ function showPage(pageDivId) {
hideOverlay();
var doc = appWindow.contentWindow.document;
var pages = doc.getElementsByClassName('section');
- var sendFeedbackElement = doc.getElementById('button-send-feedback');
- if (pageDivId == 'error-with-feedback') {
- // Only show feedback button if the pageDivId is 'error-with-feedback'.
- sendFeedbackElement.hidden = false;
- pageDivId = 'error';
- } else {
- sendFeedbackElement.hidden = true;
- }
for (var i = 0; i < pages.length; i++) {
pages[i].hidden = pages[i].id != pageDivId;
}
@@ -538,16 +526,25 @@ function showPage(pageDivId) {
}
/**
- * Sets error message.
- * @param {string} error message.
+ * Shows an error page, with given errorMessage.
+ *
+ * @param {string} errorMessage Localized error message text.
+ * @param {?boolean} opt_shouldShowSendFeedback If set to true, show "Send
+ * feedback" button.
*/
-function setErrorMessage(error) {
+function showErrorPage(errorMessage, opt_shouldShowSendFeedback) {
if (!appWindow) {
return;
}
+
var doc = appWindow.contentWindow.document;
var messageElement = doc.getElementById('error-message');
- messageElement.innerText = error;
+ messageElement.innerText = errorMessage;
+
+ var sendFeedbackElement = doc.getElementById('button-send-feedback');
+ sendFeedbackElement.hidden = !opt_shouldShowSendFeedback;
+
+ showPage('error');
}
/**
@@ -608,32 +605,6 @@ function hideOverlay() {
overlayContainer.hidden = true;
}
-/**
- * Shows requested page.
- * @param {int} pageId Index of the page to show. Must be in the array range of
- * UI_PAGES.
- * @param {string} status associated with page string status, error message for
- * example.
- */
-function showPageWithStatus(pageId, status) {
- if (!appWindow) {
- return;
- }
-
- if (UI_PAGES[pageId] != 'terms') {
- // Explicit request to start not from start page. Assume terms are
- // accepted in this case.
- // TODO: this is only for controling "RETRY" button. Remove this.
- termsAccepted = true;
- }
-
- if (UI_PAGES[pageId] == 'error' ||
- UI_PAGES[pageId] == 'error-with-feedback') {
- setErrorMessage(status);
- }
- showPage(UI_PAGES[pageId]);
-}
-
function setWindowBounds() {
if (!appWindow) {
return;
@@ -689,9 +660,8 @@ chrome.app.runtime.onLaunched.addListener(function() {
};
var onLsoViewErrorOccurred = function(details) {
- setErrorMessage(appWindow.contentWindow.loadTimeData.getString(
- 'serverError'));
- showPage('error');
+ showErrorPage(
+ appWindow.contentWindow.loadTimeData.getString('serverError'));
lsoError = true;
};
@@ -717,9 +687,9 @@ chrome.app.runtime.onLaunched.addListener(function() {
var authCode = results[0].substring(authCodePrefix.length);
sendNativeMessage('onAuthSucceeded', {code: authCode});
} else {
- setErrorMessage(appWindow.contentWindow.loadTimeData.getString(
- 'authorizationFailed'));
- showPage('error');
+ showErrorMessage(
+ appWindow.contentWindow.loadTimeData.getString(
+ 'authorizationFailed'));
}
});
};
« no previous file with comments | « chrome/browser/chromeos/arc/arc_support_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698