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

Unified Diff: chrome/browser/ui/webui/signin/signin_error_handler.cc

Issue 2275883003: [Signin Error Dialog] (2/3) Added handlers and UI constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@error-modal-web
Patch Set: Final nit from tommycli Created 4 years, 4 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: chrome/browser/ui/webui/signin/signin_error_handler.cc
diff --git a/chrome/browser/ui/webui/signin/signin_error_handler.cc b/chrome/browser/ui/webui/signin/signin_error_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3de0d21aeb00816470839a5d0d1b60d214f6c540
--- /dev/null
+++ b/chrome/browser/ui/webui/signin/signin_error_handler.cc
@@ -0,0 +1,81 @@
+// Copyright 2016 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.
+
+#include "chrome/browser/ui/webui/signin/signin_error_handler.h"
+
+#include "base/bind.h"
+#include "chrome/browser/profiles/profile_attributes_entry.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/profiles/profile_window.h"
+#include "chrome/browser/signin/signin_ui_util.h"
+#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/webui/signin/signin_utils.h"
+#include "content/public/browser/web_ui.h"
+#include "url/gurl.h"
+
+void SigninErrorHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "confirm",
+ base::Bind(&SigninErrorHandler::HandleConfirm, base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "switchToExistingProfile",
+ base::Bind(&SigninErrorHandler::HandleSwitchToExistingProfile,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "learnMore",
+ base::Bind(&SigninErrorHandler::HandleLearnMore, base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "initializedWithSize",
+ base::Bind(&SigninErrorHandler::HandleInitializedWithSize,
+ base::Unretained(this)));
+}
+
+void SigninErrorHandler::set_duplicate_profile_entry(
+ const ProfileAttributesEntry* duplicate_profile_entry) {
+ duplicate_profile_entry_ = duplicate_profile_entry;
+}
+
+void SigninErrorHandler::HandleSwitchToExistingProfile(
+ const base::ListValue* args) {
+ if (!duplicate_profile_entry_)
+ return;
+ CloseDialog();
+ // Switch to the existing duplicate profile. Do not create a new window when
+ // any existing ones can be reused.
+ profiles::SwitchToProfile(duplicate_profile_entry_->GetPath(), false,
+ ProfileManager::CreateCallback(),
+ ProfileMetrics::SWITCH_PROFILE_DUPLICATE);
+}
+
+void SigninErrorHandler::HandleConfirm(const base::ListValue* args) {
+ CloseDialog();
+}
+
+void SigninErrorHandler::HandleLearnMore(const base::ListValue* args) {
+ Browser* browser = signin::GetDesktopBrowser(web_ui());
+ DCHECK(browser);
+ browser->CloseModalSigninWindow();
+ signin_ui_util::ShowSigninErrorLearnMorePage(browser->profile());
+}
+
+void SigninErrorHandler::HandleInitializedWithSize(
+ const base::ListValue* args) {
+ if (!duplicate_profile_entry_)
+ web_ui()->CallJavascriptFunctionUnsafe("signin.error.removeSwitchButton");
+
+ signin::SetInitializedModalHeight(web_ui(), args);
+
+ // After the dialog is shown, some platforms might have an element focused.
+ // To be consistent, clear the focused element on all platforms.
+ // TODO(anthonyvd): Figure out why this is needed on Mac and not other
+ // platforms and if there's a way to start unfocused while avoiding this
+ // workaround.
+ web_ui()->CallJavascriptFunctionUnsafe("signin.error.clearFocus");
+}
+
+void SigninErrorHandler::CloseDialog() {
+ Browser* browser = signin::GetDesktopBrowser(web_ui());
+ DCHECK(browser);
+ browser->CloseModalSigninWindow();
+}
« no previous file with comments | « chrome/browser/ui/webui/signin/signin_error_handler.h ('k') | chrome/browser/ui/webui/signin/signin_error_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698