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

Unified Diff: chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h

Issue 2042283002: Postpone JS calls from CoreOobeHandler until the JS side gets initialized (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add forgotten include Created 4 years, 6 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/chromeos/login/core_oobe_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h
diff --git a/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h b/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h
index 879daa85aebb8a3fe537661f8d393d0f654ecd62..bbfdb5936f472789b375acb046afd288f39f3416 100644
--- a/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h
+++ b/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h
@@ -5,9 +5,13 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_CORE_OOBE_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_CORE_OOBE_HANDLER_H_
+#include <memory>
#include <string>
+#include <vector>
+#include "base/callback.h"
#include "base/macros.h"
+#include "base/values.h"
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chrome/browser/chromeos/login/screens/core_oobe_actor.h"
#include "chrome/browser/chromeos/login/version_info_updater.h"
@@ -70,6 +74,23 @@ class CoreOobeHandler : public BaseScreenHandler,
void UpdateShutdownAndRebootVisibility(bool reboot_on_shutdown);
private:
+ // Calls javascript method.
+ //
+ // Note that the Args template parameter pack should consist of types
+ // convertible to base::Value.
+ template <typename... Args>
+ void ExecuteDeferredJSCall(const std::string& function_name,
+ std::unique_ptr<Args>... args);
+
+ // Calls javascript method if the instance is already initialized, or defers
+ // the call until it gets initialized.
+ template <typename... Args>
+ void CallJSOrDefer(const std::string& function_name, const Args&... args);
+
+ // Executes javascript calls that were deferred while the instance was not
+ // initialized yet.
+ void ExecuteDeferredJSCalls();
+
// CoreOobeActor implementation:
void ShowSignInError(int login_attempts,
const std::string& error_text,
@@ -135,6 +156,16 @@ class CoreOobeHandler : public BaseScreenHandler,
void OnAccessibilityStatusChanged(
const AccessibilityStatusEventDetails& details);
+ // Whether the instance is initialized.
+ //
+ // The instance becomes initialized after the corresponding message is
+ // received from javascript side.
+ bool is_initialized_;
+
+ // Javascript calls that have been deferred while the instance was not
+ // initialized yet.
+ std::vector<base::Closure> deferred_js_calls_;
+
// Owner of this handler.
OobeUI* oobe_ui_;
« no previous file with comments | « no previous file | chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698