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

Side by Side 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, 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/signin/signin_error_handler.h"
6
7 #include "base/bind.h"
8 #include "chrome/browser/profiles/profile_attributes_entry.h"
9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/profiles/profile_window.h"
11 #include "chrome/browser/signin/signin_ui_util.h"
12 #include "chrome/browser/ui/browser_window.h"
13 #include "chrome/browser/ui/webui/signin/signin_utils.h"
14 #include "content/public/browser/web_ui.h"
15 #include "url/gurl.h"
16
17 void SigninErrorHandler::RegisterMessages() {
18 web_ui()->RegisterMessageCallback(
19 "confirm",
20 base::Bind(&SigninErrorHandler::HandleConfirm, base::Unretained(this)));
21 web_ui()->RegisterMessageCallback(
22 "switchToExistingProfile",
23 base::Bind(&SigninErrorHandler::HandleSwitchToExistingProfile,
24 base::Unretained(this)));
25 web_ui()->RegisterMessageCallback(
26 "learnMore",
27 base::Bind(&SigninErrorHandler::HandleLearnMore, base::Unretained(this)));
28 web_ui()->RegisterMessageCallback(
29 "initializedWithSize",
30 base::Bind(&SigninErrorHandler::HandleInitializedWithSize,
31 base::Unretained(this)));
32 }
33
34 void SigninErrorHandler::set_duplicate_profile_entry(
35 const ProfileAttributesEntry* duplicate_profile_entry) {
36 duplicate_profile_entry_ = duplicate_profile_entry;
37 }
38
39 void SigninErrorHandler::HandleSwitchToExistingProfile(
40 const base::ListValue* args) {
41 if (!duplicate_profile_entry_)
42 return;
43 CloseDialog();
44 // Switch to the existing duplicate profile. Do not create a new window when
45 // any existing ones can be reused.
46 profiles::SwitchToProfile(duplicate_profile_entry_->GetPath(), false,
47 ProfileManager::CreateCallback(),
48 ProfileMetrics::SWITCH_PROFILE_DUPLICATE);
49 }
50
51 void SigninErrorHandler::HandleConfirm(const base::ListValue* args) {
52 CloseDialog();
53 }
54
55 void SigninErrorHandler::HandleLearnMore(const base::ListValue* args) {
56 Browser* browser = signin::GetDesktopBrowser(web_ui());
57 DCHECK(browser);
58 browser->CloseModalSigninWindow();
59 signin_ui_util::ShowSigninErrorLearnMorePage(browser->profile());
60 }
61
62 void SigninErrorHandler::HandleInitializedWithSize(
63 const base::ListValue* args) {
64 if (!duplicate_profile_entry_)
65 web_ui()->CallJavascriptFunctionUnsafe("signin.error.removeSwitchButton");
66
67 signin::SetInitializedModalHeight(web_ui(), args);
68
69 // After the dialog is shown, some platforms might have an element focused.
70 // To be consistent, clear the focused element on all platforms.
71 // TODO(anthonyvd): Figure out why this is needed on Mac and not other
72 // platforms and if there's a way to start unfocused while avoiding this
73 // workaround.
74 web_ui()->CallJavascriptFunctionUnsafe("signin.error.clearFocus");
75 }
76
77 void SigninErrorHandler::CloseDialog() {
78 Browser* browser = signin::GetDesktopBrowser(web_ui());
79 DCHECK(browser);
80 browser->CloseModalSigninWindow();
81 }
OLDNEW
« 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