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

Side by Side Diff: chrome/browser/chromeos/arc/arc_support_host.cc

Issue 2501013002: Refactor ArcSupportHost and ArcAuthService part2. (Closed)
Patch Set: rebase 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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/chromeos/arc/arc_support_host.h" 5 #include "chrome/browser/chromeos/arc/arc_support_host.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "ash/common/system/chromeos/devicetype_utils.h" 9 #include "ash/common/system/chromeos/devicetype_utils.h"
10 #include "base/i18n/timezone.h" 10 #include "base/i18n/timezone.h"
11 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
12 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
13 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/chromeos/arc/arc_auth_service.h"
17 #include "chrome/browser/chromeos/profiles/profile_helper.h" 16 #include "chrome/browser/chromeos/profiles/profile_helper.h"
17 #include "chrome/browser/extensions/extension_util.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 19 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
20 #include "chrome/browser/ui/extensions/app_launch_params.h"
21 #include "chrome/browser/ui/extensions/application_launch.h"
20 #include "chrome/grit/generated_resources.h" 22 #include "chrome/grit/generated_resources.h"
21 #include "components/user_manager/known_user.h" 23 #include "components/user_manager/known_user.h"
24 #include "extensions/browser/extension_registry.h"
22 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
23 #include "ui/base/webui/web_ui_util.h" 26 #include "ui/base/webui/web_ui_util.h"
24 #include "ui/display/screen.h" 27 #include "ui/display/screen.h"
25 28
26 namespace { 29 namespace {
27 constexpr char kAction[] = "action"; 30 constexpr char kAction[] = "action";
28 constexpr char kArcManaged[] = "arcManaged"; 31 constexpr char kArcManaged[] = "arcManaged";
29 constexpr char kData[] = "data"; 32 constexpr char kData[] = "data";
30 constexpr char kDeviceId[] = "deviceId"; 33 constexpr char kDeviceId[] = "deviceId";
31 constexpr char kActionInitialize[] = "initialize"; 34 constexpr char kActionInitialize[] = "initialize";
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 constexpr char kIsBackupRestoreEnabled[] = "isBackupRestoreEnabled"; 78 constexpr char kIsBackupRestoreEnabled[] = "isBackupRestoreEnabled";
76 constexpr char kIsLocationServiceEnabled[] = "isLocationServiceEnabled"; 79 constexpr char kIsLocationServiceEnabled[] = "isLocationServiceEnabled";
77 80
78 // "onRetryClicked" is fired when a user clicks "RETRY" button on the error 81 // "onRetryClicked" is fired when a user clicks "RETRY" button on the error
79 // page. 82 // page.
80 constexpr char kEventOnRetryClicked[] = "onRetryClicked"; 83 constexpr char kEventOnRetryClicked[] = "onRetryClicked";
81 84
82 // "onSendFeedbackClicked" is fired when a user clicks "Send Feedback" button. 85 // "onSendFeedbackClicked" is fired when a user clicks "Send Feedback" button.
83 constexpr char kEventOnSendFeedbackClicked[] = "onSendFeedbackClicked"; 86 constexpr char kEventOnSendFeedbackClicked[] = "onSendFeedbackClicked";
84 87
88 std::ostream& operator<<(std::ostream& os, ArcSupportHost::UIPage ui_page) {
89 switch (ui_page) {
90 case ArcSupportHost::UIPage::NO_PAGE:
91 return os << "NO_PAGE";
92 case ArcSupportHost::UIPage::TERMS:
93 return os << "TERMS";
94 case ArcSupportHost::UIPage::LSO:
95 return os << "LSO";
96 case ArcSupportHost::UIPage::ARC_LOADING:
97 return os << "ARC_LOADING";
98 case ArcSupportHost::UIPage::ERROR:
99 return os << "ERROR";
100 }
101
102 // Some compiler reports an error even if all values of an enum-class are
103 // covered indivisually in a switch statement.
104 NOTREACHED();
105 return os;
106 }
107
108 std::ostream& operator<<(std::ostream& os, ArcSupportHost::Error error) {
109 switch (error) {
110 case ArcSupportHost::Error::SIGN_IN_NETWORK_ERROR:
111 return os << "SIGN_IN_NETWORK_ERROR";
112 case ArcSupportHost::Error::SIGN_IN_SERVICE_UNAVAILABLE_ERROR:
113 return os << "SIGN_IN_SERVICE_UNAVAILABLE_ERROR";
114 case ArcSupportHost::Error::SIGN_IN_BAD_AUTHENTICATION_ERROR:
115 return os << "SIGN_IN_BAD_AUTHENTICATION_ERROR";
116 case ArcSupportHost::Error::SIGN_IN_GMS_NOT_AVAILABLE_ERROR:
117 return os << "SIGN_IN_GMS_NOT_AVAILABLE_ERROR";
118 case ArcSupportHost::Error::SIGN_IN_CLOUD_PROVISION_FLOW_FAIL_ERROR:
119 return os << "SIGN_IN_CLOUD_PROVISION_FLOW_FAIL_ERROR";
120 case ArcSupportHost::Error::SIGN_IN_UNKNOWN_ERROR:
121 return os << "SIGN_IN_UNKNOWN_ERROR";
122 case ArcSupportHost::Error::SERVER_COMMUNICATION_ERROR:
123 return os << "SERVER_COMMUNICATION_ERROR";
124 case ArcSupportHost::Error::ANDROID_MANAGEMENT_REQUIRED_ERROR:
125 return os << "ANDROID_MANAGEMENT_REQUIRED_ERROR";
126 }
127
128 // Some compiler reports an error even if all values of an enum-class are
129 // covered indivisually in a switch statement.
130 NOTREACHED();
131 return os;
132 }
133
85 } // namespace 134 } // namespace
86 135
87 // static 136 // static
88 const char ArcSupportHost::kHostAppId[] = "cnbgggchhmkkdmeppjobngjoejnihlei"; 137 const char ArcSupportHost::kHostAppId[] = "cnbgggchhmkkdmeppjobngjoejnihlei";
89 138
90 // static 139 // static
91 const char ArcSupportHost::kStorageId[] = "arc_support"; 140 const char ArcSupportHost::kStorageId[] = "arc_support";
92 141
93 ArcSupportHost::ArcSupportHost() = default; 142 ArcSupportHost::ArcSupportHost(Profile* profile) : profile_(profile) {}
94 143
95 ArcSupportHost::~ArcSupportHost() { 144 ArcSupportHost::~ArcSupportHost() {
96 if (message_host_) 145 if (message_host_)
97 DisconnectMessageHost(); 146 DisconnectMessageHost();
98 } 147 }
99 148
100 void ArcSupportHost::AddObserver(Observer* observer) { 149 void ArcSupportHost::AddObserver(Observer* observer) {
101 DCHECK(!observer_); 150 DCHECK(!observer_);
102 observer_ = observer; 151 observer_ = observer;
103 } 152 }
104 153
154 void ArcSupportHost::SetArcManaged(bool is_arc_managed) {
155 DCHECK(!message_host_);
156 is_arc_managed_ = is_arc_managed;
157 }
158
105 void ArcSupportHost::Close() { 159 void ArcSupportHost::Close() {
160 ui_page_ = UIPage::NO_PAGE;
106 if (!message_host_) { 161 if (!message_host_) {
107 VLOG(2) << "ArcSupportHost::Close() is called " 162 VLOG(2) << "ArcSupportHost::Close() is called "
108 << "but message_host_ is not available."; 163 << "but message_host_ is not available.";
109 return; 164 return;
110 } 165 }
111 166
112 base::DictionaryValue message; 167 base::DictionaryValue message;
113 message.SetString(kAction, kActionCloseWindow); 168 message.SetString(kAction, kActionCloseWindow);
114 message_host_->SendMessage(message); 169 message_host_->SendMessage(message);
115 170
116 // Disconnect immediately, so that onWindowClosed event will not be 171 // Disconnect immediately, so that onWindowClosed event will not be
117 // delivered to here. 172 // delivered to here.
118 DisconnectMessageHost(); 173 DisconnectMessageHost();
119 } 174 }
120 175
121 void ArcSupportHost::ShowPage(UIPage page, const base::string16& status) { 176 void ArcSupportHost::ShowTermsOfService() {
177 ShowPage(UIPage::TERMS);
178 }
179
180 void ArcSupportHost::ShowLso() {
181 ShowPage(UIPage::LSO);
182 }
183
184 void ArcSupportHost::ShowArcLoading() {
185 ShowPage(UIPage::ARC_LOADING);
186 }
187
188 void ArcSupportHost::ShowPage(UIPage ui_page) {
189 ui_page_ = ui_page;
Luis Héctor Chávez 2016/11/16 02:58:53 How about moving this to L191?
hidehiko 2016/11/16 17:52:21 Because ArcAuthService checks UIPage in some conte
Luis Héctor Chávez 2016/11/16 23:20:30 Acknowledged.
122 if (!message_host_) { 190 if (!message_host_) {
123 VLOG(2) << "ArcSupportHost::ShowPage() is called " 191 if (app_start_requested_) {
124 << "but message_host_ is not available."; 192 VLOG(2) << "ArcSupportHost::ShowPage(" << ui_page << ") is called "
193 << "before connection to ARC support Chrome app is established.";
Luis Héctor Chávez 2016/11/16 02:58:53 nit: s/is established/has finished establishing/ ?
hidehiko 2016/11/16 17:52:21 Done.
194 return;
195 }
196 RequestAppStart();
125 return; 197 return;
126 } 198 }
127 199
128 base::DictionaryValue message; 200 base::DictionaryValue message;
129 if (page == UIPage::ERROR || page == UIPage::ERROR_WITH_FEEDBACK) { 201 message.SetString(kAction, kActionShowPage);
130 message.SetString(kAction, kActionShowErrorPage); 202 switch (ui_page) {
131 message.SetString(kErrorMessage, status); 203 case UIPage::TERMS:
132 message.SetBoolean(kShouldShowSendFeedback, 204 message.SetString(kPage, "terms");
133 page == UIPage::ERROR_WITH_FEEDBACK); 205 break;
134 } else { 206 case UIPage::LSO:
135 message.SetString(kAction, kActionShowPage); 207 // TODO(hidehiko): Merge LSO and LSO_LOADING.
136 switch (page) { 208 message.SetString(kPage, "lso-loading");
137 case UIPage::NO_PAGE: 209 break;
138 message.SetString(kPage, "none"); 210 case UIPage::ARC_LOADING:
139 break; 211 message.SetString(kPage, "arc-loading");
140 case UIPage::TERMS: 212 break;
141 message.SetString(kPage, "terms"); 213 default:
142 break; 214 NOTREACHED();
143 case UIPage::LSO_PROGRESS: 215 return;
144 message.SetString(kPage, "lso-loading");
145 break;
146 // Skip LSO. LSO and LSO_LOADING should be merged well.
147 // TODO(hidehiko): Do it.
148 case UIPage::START_PROGRESS:
149 message.SetString(kPage, "arc-loading");
150 break;
151 default:
152 NOTREACHED();
153 return;
154 }
155 } 216 }
156 message_host_->SendMessage(message); 217 message_host_->SendMessage(message);
157 } 218 }
158 219
220 void ArcSupportHost::ShowError(Error error, bool should_show_send_feedback) {
221 ui_page_ = UIPage::ERROR;
Luis Héctor Chávez 2016/11/16 02:58:53 Given that you only need these if |!message_host_|
hidehiko 2016/11/16 17:52:21 Ditto.
222 error_ = error;
223 should_show_send_feedback_ = should_show_send_feedback;
224 if (!message_host_) {
225 if (app_start_requested_) {
226 VLOG(2) << "ArcSupportHost::ShowError(" << error << ", "
227 << should_show_send_feedback << ") is called before connection "
228 << "to ARC support Chrome app is established.";
229 return;
230 }
231 RequestAppStart();
232 return;
233 }
234
235 base::DictionaryValue message;
236 message.SetString(kAction, kActionShowErrorPage);
237 int message_id;
238 switch (error) {
239 case Error::SIGN_IN_NETWORK_ERROR:
240 message_id = IDS_ARC_SIGN_IN_NETWORK_ERROR;
241 break;
242 case Error::SIGN_IN_SERVICE_UNAVAILABLE_ERROR:
243 message_id = IDS_ARC_SIGN_IN_SERVICE_UNAVAILABLE_ERROR;
244 break;
245 case Error::SIGN_IN_BAD_AUTHENTICATION_ERROR:
246 message_id = IDS_ARC_SIGN_IN_BAD_AUTHENTICATION_ERROR;
247 break;
248 case Error::SIGN_IN_GMS_NOT_AVAILABLE_ERROR:
249 message_id = IDS_ARC_SIGN_IN_GMS_NOT_AVAILABLE_ERROR;
250 break;
251 case Error::SIGN_IN_CLOUD_PROVISION_FLOW_FAIL_ERROR:
252 message_id = IDS_ARC_SIGN_IN_CLOUD_PROVISION_FLOW_FAIL_ERROR;
253 break;
254 case Error::SIGN_IN_UNKNOWN_ERROR:
255 message_id = IDS_ARC_SIGN_IN_UNKNOWN_ERROR;
256 break;
257 case Error::SERVER_COMMUNICATION_ERROR:
258 message_id = IDS_ARC_SERVER_COMMUNICATION_ERROR;
259 break;
260 case Error::ANDROID_MANAGEMENT_REQUIRED_ERROR:
261 message_id = IDS_ARC_ANDROID_MANAGEMENT_REQUIRED_ERROR;
262 break;
263 }
264 message.SetString(kErrorMessage, l10n_util::GetStringUTF16(message_id));
265 message.SetBoolean(kShouldShowSendFeedback, should_show_send_feedback);
266 message_host_->SendMessage(message);
267 }
268
159 void ArcSupportHost::SetMetricsPreferenceCheckbox(bool is_enabled, 269 void ArcSupportHost::SetMetricsPreferenceCheckbox(bool is_enabled,
160 bool is_managed) { 270 bool is_managed) {
161 metrics_checkbox_ = PreferenceCheckboxData(is_enabled, is_managed); 271 metrics_checkbox_ = PreferenceCheckboxData(is_enabled, is_managed);
162 SendPreferenceCheckboxUpdate(kActionSetMetricsMode, metrics_checkbox_); 272 SendPreferenceCheckboxUpdate(kActionSetMetricsMode, metrics_checkbox_);
163 } 273 }
164 274
165 void ArcSupportHost::SetBackupAndRestorePreferenceCheckbox(bool is_enabled, 275 void ArcSupportHost::SetBackupAndRestorePreferenceCheckbox(bool is_enabled,
166 bool is_managed) { 276 bool is_managed) {
167 backup_and_restore_checkbox_ = PreferenceCheckboxData(is_enabled, is_managed); 277 backup_and_restore_checkbox_ = PreferenceCheckboxData(is_enabled, is_managed);
168 SendPreferenceCheckboxUpdate(kActionBackupAndRestoreMode, 278 SendPreferenceCheckboxUpdate(kActionBackupAndRestoreMode,
(...skipping 17 matching lines...) Expand all
186 message.SetString(kAction, action_name); 296 message.SetString(kAction, action_name);
187 message.SetBoolean(kEnabled, data.is_enabled); 297 message.SetBoolean(kEnabled, data.is_enabled);
188 message.SetBoolean(kManaged, data.is_managed); 298 message.SetBoolean(kManaged, data.is_managed);
189 message_host_->SendMessage(message); 299 message_host_->SendMessage(message);
190 } 300 }
191 301
192 void ArcSupportHost::SetMessageHost(arc::ArcSupportMessageHost* message_host) { 302 void ArcSupportHost::SetMessageHost(arc::ArcSupportMessageHost* message_host) {
193 if (message_host_ == message_host) 303 if (message_host_ == message_host)
194 return; 304 return;
195 305
306 app_start_requested_ = false;
196 if (message_host_) 307 if (message_host_)
197 DisconnectMessageHost(); 308 DisconnectMessageHost();
198 message_host_ = message_host; 309 message_host_ = message_host;
199 message_host_->SetObserver(this); 310 message_host_->SetObserver(this);
200 display::Screen::GetScreen()->AddObserver(this); 311 display::Screen::GetScreen()->AddObserver(this);
201 312
202 if (!Initialize()) { 313 if (!Initialize()) {
203 Close(); 314 Close();
204 return; 315 return;
205 } 316 }
206 317
318 // Hereafter, install the requested ui state into the ARC support Chrome app.
319
320 // Set preference checkbox state.
207 SendPreferenceCheckboxUpdate(kActionSetMetricsMode, metrics_checkbox_); 321 SendPreferenceCheckboxUpdate(kActionSetMetricsMode, metrics_checkbox_);
208 SendPreferenceCheckboxUpdate(kActionBackupAndRestoreMode, 322 SendPreferenceCheckboxUpdate(kActionBackupAndRestoreMode,
209 backup_and_restore_checkbox_); 323 backup_and_restore_checkbox_);
210 SendPreferenceCheckboxUpdate(kActionLocationServiceMode, 324 SendPreferenceCheckboxUpdate(kActionLocationServiceMode,
211 location_services_checkbox_); 325 location_services_checkbox_);
212 326
213 arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get(); 327 if (ui_page_ == UIPage::NO_PAGE) {
214 DCHECK(arc_auth_service); 328 // Close() is called before opening the window.
215 ShowPage(arc_auth_service->ui_page(), arc_auth_service->ui_page_status()); 329 Close();
330 } else if (ui_page_ == UIPage::ERROR) {
331 ShowError(error_, should_show_send_feedback_);
332 } else {
333 ShowPage(ui_page_);
334 }
216 } 335 }
217 336
218 void ArcSupportHost::UnsetMessageHost( 337 void ArcSupportHost::UnsetMessageHost(
219 arc::ArcSupportMessageHost* message_host) { 338 arc::ArcSupportMessageHost* message_host) {
220 if (message_host_ != message_host) 339 if (message_host_ != message_host)
221 return; 340 return;
222 DisconnectMessageHost(); 341 DisconnectMessageHost();
223 } 342 }
224 343
225 void ArcSupportHost::DisconnectMessageHost() { 344 void ArcSupportHost::DisconnectMessageHost() {
226 DCHECK(message_host_); 345 DCHECK(message_host_);
227 display::Screen::GetScreen()->RemoveObserver(this); 346 display::Screen::GetScreen()->RemoveObserver(this);
228 message_host_->SetObserver(nullptr); 347 message_host_->SetObserver(nullptr);
229 message_host_ = nullptr; 348 message_host_ = nullptr;
230 } 349 }
231 350
351 void ArcSupportHost::RequestAppStart() {
352 DCHECK(!message_host_);
353 DCHECK(!app_start_requested_);
354
355 app_start_requested_ = true;
356 const extensions::Extension* extension =
357 extensions::ExtensionRegistry::Get(profile_)->GetInstalledExtension(
358 kHostAppId);
359 CHECK(extension);
Luis Héctor Chávez 2016/11/16 02:58:53 According to dcheng@, CHECK should never be used o
hidehiko 2016/11/16 17:52:21 Done.
360 CHECK(extensions::util::IsAppLaunchable(kHostAppId, profile_));
361 OpenApplication(CreateAppLaunchParamsUserContainer(
362 profile_, extension, WindowOpenDisposition::NEW_WINDOW,
363 extensions::SOURCE_CHROME_INTERNAL));
364 }
365
232 bool ArcSupportHost::Initialize() { 366 bool ArcSupportHost::Initialize() {
233 DCHECK(message_host_); 367 DCHECK(message_host_);
234 arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get();
235 if (!arc_auth_service->IsAllowed())
236 return false;
237 368
238 std::unique_ptr<base::DictionaryValue> loadtime_data( 369 auto loadtime_data = base::MakeUnique<base::DictionaryValue>();
239 new base::DictionaryValue());
240 base::string16 device_name = ash::GetChromeOSDeviceName(); 370 base::string16 device_name = ash::GetChromeOSDeviceName();
241 loadtime_data->SetString( 371 loadtime_data->SetString(
242 "greetingHeader", 372 "greetingHeader",
243 l10n_util::GetStringFUTF16(IDS_ARC_OPT_IN_DIALOG_HEADER, device_name)); 373 l10n_util::GetStringFUTF16(IDS_ARC_OPT_IN_DIALOG_HEADER, device_name));
244 loadtime_data->SetString("greetingDescription", 374 loadtime_data->SetString("greetingDescription",
245 l10n_util::GetStringFUTF16( 375 l10n_util::GetStringFUTF16(
246 IDS_ARC_OPT_IN_DIALOG_DESCRIPTION, device_name)); 376 IDS_ARC_OPT_IN_DIALOG_DESCRIPTION, device_name));
247 loadtime_data->SetString( 377 loadtime_data->SetString(
248 "buttonAgree", 378 "buttonAgree",
249 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_BUTTON_AGREE)); 379 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_BUTTON_AGREE));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 loadtime_data->SetString( 431 loadtime_data->SetString(
302 "learnMoreLocationServices", 432 "learnMoreLocationServices",
303 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_LEARN_MORE_LOCATION_SERVICES)); 433 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_LEARN_MORE_LOCATION_SERVICES));
304 loadtime_data->SetString( 434 loadtime_data->SetString(
305 "overlayClose", 435 "overlayClose",
306 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_LEARN_MORE_CLOSE)); 436 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_LEARN_MORE_CLOSE));
307 loadtime_data->SetString( 437 loadtime_data->SetString(
308 "privacyPolicyLink", 438 "privacyPolicyLink",
309 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_PRIVACY_POLICY_LINK)); 439 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_PRIVACY_POLICY_LINK));
310 440
311 const std::string& app_locale = g_browser_process->GetApplicationLocale(); 441 loadtime_data->SetBoolean(kArcManaged, is_arc_managed_);
442 loadtime_data->SetBoolean("isOwnerProfile",
443 chromeos::ProfileHelper::IsOwnerProfile(profile_));
444
312 const std::string& country_code = base::CountryCodeForCurrentTimezone(); 445 const std::string& country_code = base::CountryCodeForCurrentTimezone();
313 loadtime_data->SetString("countryCode", country_code); 446 loadtime_data->SetString("countryCode", country_code);
314 loadtime_data->SetBoolean(kArcManaged, arc_auth_service->IsArcManaged());
315 447
448 const std::string& app_locale = g_browser_process->GetApplicationLocale();
316 webui::SetLoadTimeDataDefaults(app_locale, loadtime_data.get()); 449 webui::SetLoadTimeDataDefaults(app_locale, loadtime_data.get());
317 DCHECK(arc_auth_service);
318 const std::string device_id = user_manager::known_user::GetDeviceId(
319 multi_user_util::GetAccountIdFromProfile(arc_auth_service->profile()));
320 DCHECK(!device_id.empty());
321 loadtime_data->SetBoolean(
322 "isOwnerProfile",
323 chromeos::ProfileHelper::IsOwnerProfile(arc_auth_service->profile()));
324 450
325 base::DictionaryValue message; 451 base::DictionaryValue message;
326 message.SetString(kAction, kActionInitialize); 452 message.SetString(kAction, kActionInitialize);
327 message.Set(kData, std::move(loadtime_data)); 453 message.Set(kData, std::move(loadtime_data));
454
455 const std::string device_id = user_manager::known_user::GetDeviceId(
456 multi_user_util::GetAccountIdFromProfile(profile_));
457 DCHECK(!device_id.empty());
328 message.SetString(kDeviceId, device_id); 458 message.SetString(kDeviceId, device_id);
459
329 message_host_->SendMessage(message); 460 message_host_->SendMessage(message);
330 return true; 461 return true;
331 } 462 }
332 463
333 void ArcSupportHost::OnDisplayAdded(const display::Display& new_display) {} 464 void ArcSupportHost::OnDisplayAdded(const display::Display& new_display) {}
334 465
335 void ArcSupportHost::OnDisplayRemoved(const display::Display& old_display) {} 466 void ArcSupportHost::OnDisplayRemoved(const display::Display& old_display) {}
336 467
337 void ArcSupportHost::OnDisplayMetricsChanged(const display::Display& display, 468 void ArcSupportHost::OnDisplayMetricsChanged(const display::Display& display,
338 uint32_t changed_metrics) { 469 uint32_t changed_metrics) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 512 }
382 } else if (event == kEventOnRetryClicked) { 513 } else if (event == kEventOnRetryClicked) {
383 observer_->OnRetryClicked(); 514 observer_->OnRetryClicked();
384 } else if (event == kEventOnSendFeedbackClicked) { 515 } else if (event == kEventOnSendFeedbackClicked) {
385 observer_->OnSendFeedbackClicked(); 516 observer_->OnSendFeedbackClicked();
386 } else { 517 } else {
387 LOG(ERROR) << "Unknown message: " << event; 518 LOG(ERROR) << "Unknown message: " << event;
388 NOTREACHED(); 519 NOTREACHED();
389 } 520 }
390 } 521 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698