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

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

Issue 2142933006: arc: Implement scrollable OptIn window content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: style changes Created 4 years, 5 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
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/profiles/profile_helper.h" 16 #include "chrome/browser/chromeos/profiles/profile_helper.h"
17 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" 17 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
18 #include "chrome/browser/metrics/metrics_reporting_state.h" 18 #include "chrome/browser/metrics/metrics_reporting_state.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 20 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
21 #include "chrome/browser/ui/browser_commands.h" 21 #include "chrome/browser/ui/browser_commands.h"
22 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
23 #include "chrome/grit/generated_resources.h" 23 #include "chrome/grit/generated_resources.h"
24 #include "components/metrics/metrics_pref_names.h" 24 #include "components/metrics/metrics_pref_names.h"
25 #include "components/prefs/pref_service.h" 25 #include "components/prefs/pref_service.h"
26 #include "components/user_manager/known_user.h" 26 #include "components/user_manager/known_user.h"
27 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
28 #include "ui/base/webui/web_ui_util.h" 28 #include "ui/base/webui/web_ui_util.h"
29 #include "ui/display/screen.h"
29 30
30 namespace { 31 namespace {
31 const char kAction[] = "action"; 32 const char kAction[] = "action";
32 const char kBackupRestoreEnabled[] = "backupRestoreEnabled"; 33 const char kBackupRestoreEnabled[] = "backupRestoreEnabled";
33 const char kCanEnable[] = "canEnable"; 34 const char kCanEnable[] = "canEnable";
34 const char kCode[] = "code"; 35 const char kCode[] = "code";
35 const char kData[] = "data"; 36 const char kData[] = "data";
36 const char kDeviceId[] = "deviceId"; 37 const char kDeviceId[] = "deviceId";
37 const char kEnabled[] = "enabled"; 38 const char kEnabled[] = "enabled";
38 const char kOn[] = "on"; 39 const char kOn[] = "on";
39 const char kPage[] = "page"; 40 const char kPage[] = "page";
40 const char kStatus[] = "status"; 41 const char kStatus[] = "status";
41 const char kText[] = "text"; 42 const char kText[] = "text";
42 const char kActionInitialize[] = "initialize"; 43 const char kActionInitialize[] = "initialize";
43 const char kActionSetMetricsMode[] = "setMetricsMode"; 44 const char kActionSetMetricsMode[] = "setMetricsMode";
45 const char kActionSetWindowBounds[] = "setWindowBounds";
44 const char kActionStartLso[] = "startLso"; 46 const char kActionStartLso[] = "startLso";
45 const char kActionCancelAuthCode[] = "cancelAuthCode"; 47 const char kActionCancelAuthCode[] = "cancelAuthCode";
46 const char kActionSetAuthCode[] = "setAuthCode"; 48 const char kActionSetAuthCode[] = "setAuthCode";
47 const char kActionEnableMetrics[] = "enableMetrics"; 49 const char kActionEnableMetrics[] = "enableMetrics";
48 const char kActionSendFeedback[] = "sendFeedback"; 50 const char kActionSendFeedback[] = "sendFeedback";
49 const char kActionSetBackupRestore[] = "setBackupRestore"; 51 const char kActionSetBackupRestore[] = "setBackupRestore";
50 const char kActionCloseUI[] = "closeUI"; 52 const char kActionCloseUI[] = "closeUI";
51 const char kActionShowPage[] = "showPage"; 53 const char kActionShowPage[] = "showPage";
52 } // namespace 54 } // namespace
53 55
(...skipping 12 matching lines...) Expand all
66 68
67 // static 69 // static
68 std::unique_ptr<extensions::NativeMessageHost> ArcSupportHost::Create() { 70 std::unique_ptr<extensions::NativeMessageHost> ArcSupportHost::Create() {
69 return std::unique_ptr<NativeMessageHost>(new ArcSupportHost()); 71 return std::unique_ptr<NativeMessageHost>(new ArcSupportHost());
70 } 72 }
71 73
72 ArcSupportHost::ArcSupportHost() { 74 ArcSupportHost::ArcSupportHost() {
73 arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get(); 75 arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get();
74 DCHECK(arc_auth_service); 76 DCHECK(arc_auth_service);
75 arc_auth_service->AddObserver(this); 77 arc_auth_service->AddObserver(this);
78 display::Screen::GetScreen()->AddObserver(this);
76 79
77 pref_change_registrar_.Init(g_browser_process->local_state()); 80 pref_change_registrar_.Init(g_browser_process->local_state());
78 pref_change_registrar_.Add( 81 pref_change_registrar_.Add(
79 metrics::prefs::kMetricsReportingEnabled, 82 metrics::prefs::kMetricsReportingEnabled,
80 base::Bind(&ArcSupportHost::OnMetricsPreferenceChanged, 83 base::Bind(&ArcSupportHost::OnMetricsPreferenceChanged,
81 base::Unretained(this))); 84 base::Unretained(this)));
82 } 85 }
83 86
84 ArcSupportHost::~ArcSupportHost() { 87 ArcSupportHost::~ArcSupportHost() {
88 display::Screen::GetScreen()->RemoveObserver(this);
85 arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get(); 89 arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get();
86 if (arc_auth_service) 90 if (arc_auth_service)
87 arc_auth_service->RemoveObserver(this); 91 arc_auth_service->RemoveObserver(this);
88 } 92 }
89 93
90 void ArcSupportHost::Start(Client* client) { 94 void ArcSupportHost::Start(Client* client) {
91 DCHECK(!client_); 95 DCHECK(!client_);
92 client_ = client; 96 client_ = client;
93 97
94 Initialize(); 98 Initialize();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 164
161 base::DictionaryValue request; 165 base::DictionaryValue request;
162 std::string request_string; 166 std::string request_string;
163 request.SetString(kAction, kActionInitialize); 167 request.SetString(kAction, kActionInitialize);
164 request.Set(kData, std::move(loadtime_data)); 168 request.Set(kData, std::move(loadtime_data));
165 request.SetString(kDeviceId, device_id); 169 request.SetString(kDeviceId, device_id);
166 base::JSONWriter::Write(request, &request_string); 170 base::JSONWriter::Write(request, &request_string);
167 client_->PostMessageFromNativeHost(request_string); 171 client_->PostMessageFromNativeHost(request_string);
168 } 172 }
169 173
174 void ArcSupportHost::OnDisplayAdded(const display::Display& new_display) {}
175
176 void ArcSupportHost::OnDisplayRemoved(const display::Display& old_display) {}
177
178 void ArcSupportHost::OnDisplayMetricsChanged(const display::Display& display,
179 uint32_t changed_metrics) {
180 base::DictionaryValue request;
181 std::string request_string;
182 request.SetString(kAction, kActionSetWindowBounds);
183 base::JSONWriter::Write(request, &request_string);
184 client_->PostMessageFromNativeHost(request_string);
185 }
186
170 void ArcSupportHost::OnMetricsPreferenceChanged() { 187 void ArcSupportHost::OnMetricsPreferenceChanged() {
171 SendMetricsMode(); 188 SendMetricsMode();
172 } 189 }
173 190
174 void ArcSupportHost::SendMetricsMode() { 191 void ArcSupportHost::SendMetricsMode() {
175 arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get(); 192 arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get();
176 DCHECK(arc_auth_service); 193 DCHECK(arc_auth_service);
177 const Profile* profile = arc_auth_service->profile(); 194 const Profile* profile = arc_auth_service->profile();
178 195
179 const bool metrics_managed = IsMetricsReportingPolicyManaged(); 196 const bool metrics_managed = IsMetricsReportingPolicyManaged();
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 EnableBackupRestore(is_enabled); 300 EnableBackupRestore(is_enabled);
284 } else { 301 } else {
285 NOTREACHED(); 302 NOTREACHED();
286 } 303 }
287 } 304 }
288 305
289 scoped_refptr<base::SingleThreadTaskRunner> ArcSupportHost::task_runner() 306 scoped_refptr<base::SingleThreadTaskRunner> ArcSupportHost::task_runner()
290 const { 307 const {
291 return base::ThreadTaskRunnerHandle::Get(); 308 return base::ThreadTaskRunnerHandle::Get();
292 } 309 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_support_host.h ('k') | chrome/browser/resources/chromeos/arc_support/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698