OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/options/managed_user_create_confirm_handler.h" | 5 #include "chrome/browser/ui/webui/options/supervised_user_create_confirm_handler
.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/value_conversions.h" | 9 #include "base/value_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
14 #include "chrome/browser/profiles/profile_window.h" | 14 #include "chrome/browser/profiles/profile_window.h" |
15 #include "chrome/browser/signin/signin_manager_factory.h" | 15 #include "chrome/browser/signin/signin_manager_factory.h" |
16 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
17 #include "chrome/browser/ui/host_desktop.h" | 17 #include "chrome/browser/ui/host_desktop.h" |
18 #include "chrome/browser/ui/startup/startup_types.h" | 18 #include "chrome/browser/ui/startup/startup_types.h" |
19 #include "components/signin/core/browser/signin_manager.h" | 19 #include "components/signin/core/browser/signin_manager.h" |
20 #include "components/signin/core/browser/signin_manager_base.h" | 20 #include "components/signin/core/browser/signin_manager_base.h" |
21 #include "content/public/browser/web_ui.h" | 21 #include "content/public/browser/web_ui.h" |
22 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
24 | 24 |
25 namespace options { | 25 namespace options { |
26 | 26 |
27 ManagedUserCreateConfirmHandler::ManagedUserCreateConfirmHandler() { | 27 SupervisedUserCreateConfirmHandler::SupervisedUserCreateConfirmHandler() { |
28 } | 28 } |
29 | 29 |
30 ManagedUserCreateConfirmHandler::~ManagedUserCreateConfirmHandler() { | 30 SupervisedUserCreateConfirmHandler::~SupervisedUserCreateConfirmHandler() { |
31 } | 31 } |
32 | 32 |
33 void ManagedUserCreateConfirmHandler::GetLocalizedValues( | 33 void SupervisedUserCreateConfirmHandler::GetLocalizedValues( |
34 base::DictionaryValue* localized_strings) { | 34 base::DictionaryValue* localized_strings) { |
35 DCHECK(localized_strings); | 35 DCHECK(localized_strings); |
36 | 36 |
37 static OptionsStringResource resources[] = { | 37 static OptionsStringResource resources[] = { |
38 { "managedUserCreatedTitle", IDS_SUPERVISED_USER_CREATED_TITLE }, | 38 { "managedUserCreatedTitle", IDS_SUPERVISED_USER_CREATED_TITLE }, |
39 { "managedUserCreatedText", IDS_SUPERVISED_USER_CREATED_TEXT }, | 39 { "managedUserCreatedText", IDS_SUPERVISED_USER_CREATED_TEXT }, |
40 { "managedUserCreatedDone", IDS_SUPERVISED_USER_CREATED_DONE_BUTTON }, | 40 { "managedUserCreatedDone", IDS_SUPERVISED_USER_CREATED_DONE_BUTTON }, |
41 { "managedUserCreatedSwitch", IDS_SUPERVISED_USER_CREATED_SWITCH_BUTTON }, | 41 { "managedUserCreatedSwitch", IDS_SUPERVISED_USER_CREATED_SWITCH_BUTTON }, |
42 }; | 42 }; |
43 | 43 |
44 SigninManagerBase* signin = | 44 SigninManagerBase* signin = |
45 SigninManagerFactory::GetForProfile(Profile::FromWebUI(web_ui())); | 45 SigninManagerFactory::GetForProfile(Profile::FromWebUI(web_ui())); |
46 if (signin) { | 46 if (signin) { |
47 localized_strings->SetString("custodianEmail", | 47 localized_strings->SetString("custodianEmail", |
48 signin->GetAuthenticatedUsername()); | 48 signin->GetAuthenticatedUsername()); |
49 } else { | 49 } else { |
50 localized_strings->SetString("custodianEmail", std::string()); | 50 localized_strings->SetString("custodianEmail", std::string()); |
51 } | 51 } |
52 | 52 |
53 RegisterStrings(localized_strings, resources, arraysize(resources)); | 53 RegisterStrings(localized_strings, resources, arraysize(resources)); |
54 } | 54 } |
55 | 55 |
56 void ManagedUserCreateConfirmHandler::RegisterMessages() { | 56 void SupervisedUserCreateConfirmHandler::RegisterMessages() { |
57 web_ui()->RegisterMessageCallback("switchToProfile", | 57 web_ui()->RegisterMessageCallback("switchToProfile", |
58 base::Bind(&ManagedUserCreateConfirmHandler::SwitchToProfile, | 58 base::Bind(&SupervisedUserCreateConfirmHandler::SwitchToProfile, |
59 base::Unretained(this))); | 59 base::Unretained(this))); |
60 } | 60 } |
61 | 61 |
62 void ManagedUserCreateConfirmHandler::SwitchToProfile( | 62 void SupervisedUserCreateConfirmHandler::SwitchToProfile( |
63 const base::ListValue* args) { | 63 const base::ListValue* args) { |
64 DCHECK(args); | 64 DCHECK(args); |
65 const base::Value* file_path_value; | 65 const base::Value* file_path_value; |
66 if (!args->Get(0, &file_path_value)) | 66 if (!args->Get(0, &file_path_value)) |
67 return; | 67 return; |
68 | 68 |
69 base::FilePath profile_file_path; | 69 base::FilePath profile_file_path; |
70 if (!base::GetValueAsFilePath(*file_path_value, &profile_file_path)) | 70 if (!base::GetValueAsFilePath(*file_path_value, &profile_file_path)) |
71 return; | 71 return; |
72 | 72 |
73 Profile* profile = g_browser_process->profile_manager()-> | 73 Profile* profile = g_browser_process->profile_manager()-> |
74 GetProfileByPath(profile_file_path); | 74 GetProfileByPath(profile_file_path); |
75 DCHECK(profile); | 75 DCHECK(profile); |
76 | 76 |
77 Browser* browser = | 77 Browser* browser = |
78 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()); | 78 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()); |
79 chrome::HostDesktopType desktop_type = chrome::HOST_DESKTOP_TYPE_NATIVE; | 79 chrome::HostDesktopType desktop_type = chrome::HOST_DESKTOP_TYPE_NATIVE; |
80 if (browser) | 80 if (browser) |
81 desktop_type = browser->host_desktop_type(); | 81 desktop_type = browser->host_desktop_type(); |
82 | 82 |
83 profiles::FindOrCreateNewWindowForProfile( | 83 profiles::FindOrCreateNewWindowForProfile( |
84 profile, | 84 profile, |
85 chrome::startup::IS_PROCESS_STARTUP, | 85 chrome::startup::IS_PROCESS_STARTUP, |
86 chrome::startup::IS_FIRST_RUN, | 86 chrome::startup::IS_FIRST_RUN, |
87 desktop_type, | 87 desktop_type, |
88 false); | 88 false); |
89 } | 89 } |
90 | 90 |
91 } // namespace options | 91 } // namespace options |
OLD | NEW |