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

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

Issue 2479633004: Split ShowPage message into two. (Closed)
Patch Set: Address comments. 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
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/arc_support/background.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 11 matching lines...) Expand all
22 #include "components/user_manager/known_user.h" 22 #include "components/user_manager/known_user.h"
23 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/webui/web_ui_util.h" 24 #include "ui/base/webui/web_ui_util.h"
25 #include "ui/display/screen.h" 25 #include "ui/display/screen.h"
26 26
27 namespace { 27 namespace {
28 constexpr char kAction[] = "action"; 28 constexpr char kAction[] = "action";
29 constexpr char kArcManaged[] = "arcManaged"; 29 constexpr char kArcManaged[] = "arcManaged";
30 constexpr char kData[] = "data"; 30 constexpr char kData[] = "data";
31 constexpr char kDeviceId[] = "deviceId"; 31 constexpr char kDeviceId[] = "deviceId";
32 constexpr char kPage[] = "page";
33 constexpr char kStatus[] = "status"; 32 constexpr char kStatus[] = "status";
hidehiko 2016/11/04 22:28:38 Oops, I didn't hit this locally, and this was hidd
34 constexpr char kActionInitialize[] = "initialize"; 33 constexpr char kActionInitialize[] = "initialize";
35 constexpr char kActionSetMetricsMode[] = "setMetricsMode"; 34 constexpr char kActionSetMetricsMode[] = "setMetricsMode";
36 constexpr char kActionBackupAndRestoreMode[] = "setBackupAndRestoreMode"; 35 constexpr char kActionBackupAndRestoreMode[] = "setBackupAndRestoreMode";
37 constexpr char kActionLocationServiceMode[] = "setLocationServiceMode"; 36 constexpr char kActionLocationServiceMode[] = "setLocationServiceMode";
38 constexpr char kActionSetWindowBounds[] = "setWindowBounds"; 37 constexpr char kActionSetWindowBounds[] = "setWindowBounds";
39 constexpr char kActionCloseWindow[] = "closeWindow"; 38 constexpr char kActionCloseWindow[] = "closeWindow";
39
40 // Action to show a page. The message should have "page" field, which is one of
41 // IDs for section div elements.
40 constexpr char kActionShowPage[] = "showPage"; 42 constexpr char kActionShowPage[] = "showPage";
43 constexpr char kPage[] = "page";
44
45 // Action to show the error page. The message should have "errorMessage",
46 // which is a localized error text, and "shouldShowSendFeedback" boolean value.
47 constexpr char kActionShowErrorPage[] = "showErrorPage";
48 constexpr char kErrorMessage[] = "errorMessage";
49 constexpr char kShouldShowSendFeedback[] = "shouldShowSendFeedback";
41 50
42 // The preference update should have those two fields. 51 // The preference update should have those two fields.
43 constexpr char kEnabled[] = "enabled"; 52 constexpr char kEnabled[] = "enabled";
44 constexpr char kManaged[] = "managed"; 53 constexpr char kManaged[] = "managed";
45 54
46 // The JSON data sent from the extension should have at least "event" field. 55 // The JSON data sent from the extension should have at least "event" field.
47 // Each event data is defined below. 56 // Each event data is defined below.
48 // The key of the event type. 57 // The key of the event type.
49 constexpr char kEvent[] = "event"; 58 constexpr char kEvent[] = "event";
50 59
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 120
112 void ArcSupportHost::ShowPage(arc::ArcAuthService::UIPage page, 121 void ArcSupportHost::ShowPage(arc::ArcAuthService::UIPage page,
113 const base::string16& status) { 122 const base::string16& status) {
114 if (!message_host_) { 123 if (!message_host_) {
115 VLOG(2) << "ArcSupportHost::ShowPage() is called " 124 VLOG(2) << "ArcSupportHost::ShowPage() is called "
116 << "but message_host_ is not available."; 125 << "but message_host_ is not available.";
117 return; 126 return;
118 } 127 }
119 128
120 base::DictionaryValue message; 129 base::DictionaryValue message;
121 message.SetString(kAction, kActionShowPage); 130 if (page == arc::ArcAuthService::UIPage::ERROR ||
122 message.SetInteger(kPage, static_cast<int>(page)); 131 page == arc::ArcAuthService::UIPage::ERROR_WITH_FEEDBACK) {
123 message.SetString(kStatus, status); 132 message.SetString(kAction, kActionShowErrorPage);
133 message.SetString(kErrorMessage, status);
134 message.SetBoolean(
135 kShouldShowSendFeedback,
136 page == arc::ArcAuthService::UIPage::ERROR_WITH_FEEDBACK);
137 } else {
138 message.SetString(kAction, kActionShowPage);
139 switch (page) {
140 case arc::ArcAuthService::UIPage::NO_PAGE:
141 message.SetString(kPage, "none");
142 break;
143 case arc::ArcAuthService::UIPage::TERMS:
144 message.SetString(kPage, "terms");
145 break;
146 case arc::ArcAuthService::UIPage::LSO_PROGRESS:
147 message.SetString(kPage, "lso-loading");
148 break;
149 // Skip LSO. LSO and LSO_LOADING should be merged well.
150 // TODO(hidehiko): Do it.
151 case arc::ArcAuthService::UIPage::START_PROGRESS:
152 message.SetString(kPage, "arc-loading");
153 break;
154 default:
155 NOTREACHED();
156 return;
157 }
158 }
124 message_host_->SendMessage(message); 159 message_host_->SendMessage(message);
125 } 160 }
126 161
127 void ArcSupportHost::SetMessageHost(arc::ArcSupportMessageHost* message_host) { 162 void ArcSupportHost::SetMessageHost(arc::ArcSupportMessageHost* message_host) {
128 if (message_host_ == message_host) 163 if (message_host_ == message_host)
129 return; 164 return;
130 165
131 if (message_host_) 166 if (message_host_)
132 DisconnectMessageHost(); 167 DisconnectMessageHost();
133 message_host_ = message_host; 168 message_host_ = message_host;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } else { 378 } else {
344 NOTREACHED(); 379 NOTREACHED();
345 } 380 }
346 } else if (event == kEventOnSendFeedbackClicked) { 381 } else if (event == kEventOnSendFeedbackClicked) {
347 chrome::OpenFeedbackDialog(nullptr); 382 chrome::OpenFeedbackDialog(nullptr);
348 } else { 383 } else {
349 LOG(ERROR) << "Unknown message: " << event; 384 LOG(ERROR) << "Unknown message: " << event;
350 NOTREACHED(); 385 NOTREACHED();
351 } 386 }
352 } 387 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/arc_support/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698