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

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

Issue 2479633004: Split ShowPage message into two. (Closed)
Patch Set: Fix compile error. 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";
34 constexpr char kActionInitialize[] = "initialize"; 32 constexpr char kActionInitialize[] = "initialize";
35 constexpr char kActionSetMetricsMode[] = "setMetricsMode"; 33 constexpr char kActionSetMetricsMode[] = "setMetricsMode";
36 constexpr char kActionBackupAndRestoreMode[] = "setBackupAndRestoreMode"; 34 constexpr char kActionBackupAndRestoreMode[] = "setBackupAndRestoreMode";
37 constexpr char kActionLocationServiceMode[] = "setLocationServiceMode"; 35 constexpr char kActionLocationServiceMode[] = "setLocationServiceMode";
38 constexpr char kActionSetWindowBounds[] = "setWindowBounds"; 36 constexpr char kActionSetWindowBounds[] = "setWindowBounds";
39 constexpr char kActionCloseWindow[] = "closeWindow"; 37 constexpr char kActionCloseWindow[] = "closeWindow";
38
39 // Action to show a page. The message should have "page" field, which is one of
40 // IDs for section div elements.
40 constexpr char kActionShowPage[] = "showPage"; 41 constexpr char kActionShowPage[] = "showPage";
42 constexpr char kPage[] = "page";
43
44 // Action to show the error page. The message should have "errorMessage",
45 // which is a localized error text, and "shouldShowSendFeedback" boolean value.
46 constexpr char kActionShowErrorPage[] = "showErrorPage";
47 constexpr char kErrorMessage[] = "errorMessage";
48 constexpr char kShouldShowSendFeedback[] = "shouldShowSendFeedback";
41 49
42 // The preference update should have those two fields. 50 // The preference update should have those two fields.
43 constexpr char kEnabled[] = "enabled"; 51 constexpr char kEnabled[] = "enabled";
44 constexpr char kManaged[] = "managed"; 52 constexpr char kManaged[] = "managed";
45 53
46 // The JSON data sent from the extension should have at least "event" field. 54 // The JSON data sent from the extension should have at least "event" field.
47 // Each event data is defined below. 55 // Each event data is defined below.
48 // The key of the event type. 56 // The key of the event type.
49 constexpr char kEvent[] = "event"; 57 constexpr char kEvent[] = "event";
50 58
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 119
112 void ArcSupportHost::ShowPage(arc::ArcAuthService::UIPage page, 120 void ArcSupportHost::ShowPage(arc::ArcAuthService::UIPage page,
113 const base::string16& status) { 121 const base::string16& status) {
114 if (!message_host_) { 122 if (!message_host_) {
115 VLOG(2) << "ArcSupportHost::ShowPage() is called " 123 VLOG(2) << "ArcSupportHost::ShowPage() is called "
116 << "but message_host_ is not available."; 124 << "but message_host_ is not available.";
117 return; 125 return;
118 } 126 }
119 127
120 base::DictionaryValue message; 128 base::DictionaryValue message;
121 message.SetString(kAction, kActionShowPage); 129 if (page == arc::ArcAuthService::UIPage::ERROR ||
122 message.SetInteger(kPage, static_cast<int>(page)); 130 page == arc::ArcAuthService::UIPage::ERROR_WITH_FEEDBACK) {
123 message.SetString(kStatus, status); 131 message.SetString(kAction, kActionShowErrorPage);
132 message.SetString(kErrorMessage, status);
133 message.SetBoolean(
134 kShouldShowSendFeedback,
135 page == arc::ArcAuthService::UIPage::ERROR_WITH_FEEDBACK);
136 } else {
137 message.SetString(kAction, kActionShowPage);
138 switch (page) {
139 case arc::ArcAuthService::UIPage::NO_PAGE:
140 message.SetString(kPage, "none");
141 break;
142 case arc::ArcAuthService::UIPage::TERMS:
143 message.SetString(kPage, "terms");
144 break;
145 case arc::ArcAuthService::UIPage::LSO_PROGRESS:
146 message.SetString(kPage, "lso-loading");
147 break;
148 // Skip LSO. LSO and LSO_LOADING should be merged well.
149 // TODO(hidehiko): Do it.
150 case arc::ArcAuthService::UIPage::START_PROGRESS:
151 message.SetString(kPage, "arc-loading");
152 break;
153 default:
154 NOTREACHED();
155 return;
156 }
157 }
124 message_host_->SendMessage(message); 158 message_host_->SendMessage(message);
125 } 159 }
126 160
127 void ArcSupportHost::SetMessageHost(arc::ArcSupportMessageHost* message_host) { 161 void ArcSupportHost::SetMessageHost(arc::ArcSupportMessageHost* message_host) {
128 if (message_host_ == message_host) 162 if (message_host_ == message_host)
129 return; 163 return;
130 164
131 if (message_host_) 165 if (message_host_)
132 DisconnectMessageHost(); 166 DisconnectMessageHost();
133 message_host_ = message_host; 167 message_host_ = message_host;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } else { 377 } else {
344 NOTREACHED(); 378 NOTREACHED();
345 } 379 }
346 } else if (event == kEventOnSendFeedbackClicked) { 380 } else if (event == kEventOnSendFeedbackClicked) {
347 chrome::OpenFeedbackDialog(nullptr); 381 chrome::OpenFeedbackDialog(nullptr);
348 } else { 382 } else {
349 LOG(ERROR) << "Unknown message: " << event; 383 LOG(ERROR) << "Unknown message: " << event;
350 NOTREACHED(); 384 NOTREACHED();
351 } 385 }
352 } 386 }
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