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

Side by Side Diff: chrome/browser/chromeos/login/app_launch_controller.cc

Issue 1765273002: kiosk: Add kiosk launch type UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 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/chromeos/login/app_launch_controller.h" 5 #include "chrome/browser/chromeos/login/app_launch_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/json/json_file_value_serializer.h" 10 #include "base/json/json_file_value_serializer.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/metrics/histogram.h"
Ilya Sherman 2016/03/05 00:30:26 nit: Please include histogram_macros instead
xiyuan 2016/03/07 15:41:21 Done.
15 #include "base/time/time.h" 16 #include "base/time/time.h"
16 #include "base/values.h" 17 #include "base/values.h"
17 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/chrome_notification_types.h" 19 #include "chrome/browser/chrome_notification_types.h"
19 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" 20 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
20 #include "chrome/browser/chromeos/app_mode/startup_app_launcher.h" 21 #include "chrome/browser/chromeos/app_mode/startup_app_launcher.h"
21 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 22 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
22 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 23 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
23 #include "chrome/browser/chromeos/login/ui/oobe_display.h" 24 #include "chrome/browser/chromeos/login/ui/oobe_display.h"
24 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" 25 #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
25 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 26 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
26 #include "chrome/browser/chromeos/settings/cros_settings.h" 27 #include "chrome/browser/chromeos/settings/cros_settings.h"
27 #include "chrome/browser/lifetime/application_lifetime.h" 28 #include "chrome/browser/lifetime/application_lifetime.h"
28 #include "chrome/browser/profiles/profile.h" 29 #include "chrome/browser/profiles/profile.h"
29 #include "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handle r.h" 30 #include "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handle r.h"
30 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" 31 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
31 #include "chromeos/settings/cros_settings_names.h" 32 #include "chromeos/settings/cros_settings_names.h"
32 #include "components/user_manager/known_user.h" 33 #include "components/user_manager/known_user.h"
33 #include "components/user_manager/user_manager.h" 34 #include "components/user_manager/user_manager.h"
34 #include "content/public/browser/notification_service.h" 35 #include "content/public/browser/notification_service.h"
35 #include "extensions/browser/app_window/app_window.h" 36 #include "extensions/browser/app_window/app_window.h"
36 #include "extensions/browser/app_window/app_window_registry.h" 37 #include "extensions/browser/app_window/app_window_registry.h"
37 #include "net/base/network_change_notifier.h" 38 #include "net/base/network_change_notifier.h"
38 39
39 namespace chromeos { 40 namespace chromeos {
40 41
41 namespace { 42 namespace {
42 43
44 // Enum types for Kiosk.LaunchType UMA so don't change its values.
45 // KioskLaunchType in histogram.xml must be updated when making changes here.
46 enum KioskLaunchType {
47 KIOSK_LAUNCH_ENTERPRISE_AUTO_LAUNCH = 0,
48 KIOKS_LAUNCH_ENTERPRISE_MANUAL_LAUNCH = 1,
49 KIOSK_LAUNCH_CONSUMER_AUTO_LAUNCH = 2,
50 KIOSK_LAUNCH_CONSUMER_MANUAL_LAUNCH = 3,
51
52 KIOSK_LAUNCH_TYPE_MAX // This must be the last entry.
Ilya Sherman 2016/03/05 00:30:26 nit: s/MAX/COUNT
xiyuan 2016/03/07 15:41:21 Done.
53 };
54
43 // Application install splash screen minimum show time in milliseconds. 55 // Application install splash screen minimum show time in milliseconds.
44 const int kAppInstallSplashScreenMinTimeMS = 3000; 56 const int kAppInstallSplashScreenMinTimeMS = 3000;
45 57
58 bool IsEnterpriseManaged() {
59 policy::BrowserPolicyConnectorChromeOS* connector =
60 g_browser_process->platform_part()->browser_policy_connector_chromeos();
61 return connector->IsEnterpriseManaged();
62 }
63
64 void RecordKioskLaunchUMA(bool is_auto_launch) {
65 const KioskLaunchType launch_type =
66 IsEnterpriseManaged()
67 ? (is_auto_launch ? KIOSK_LAUNCH_ENTERPRISE_AUTO_LAUNCH
68 : KIOKS_LAUNCH_ENTERPRISE_MANUAL_LAUNCH)
69 : (is_auto_launch ? KIOSK_LAUNCH_CONSUMER_AUTO_LAUNCH
70 : KIOSK_LAUNCH_CONSUMER_MANUAL_LAUNCH);
71
72 UMA_HISTOGRAM_ENUMERATION("Kiosk.LaunchType", launch_type,
73 KIOSK_LAUNCH_TYPE_MAX);
74 }
75
46 } // namespace 76 } // namespace
47 77
48 // static 78 // static
49 bool AppLaunchController::skip_splash_wait_ = false; 79 bool AppLaunchController::skip_splash_wait_ = false;
50 int AppLaunchController::network_wait_time_ = 10; 80 int AppLaunchController::network_wait_time_ = 10;
51 base::Closure* AppLaunchController::network_timeout_callback_ = NULL; 81 base::Closure* AppLaunchController::network_timeout_callback_ = NULL;
52 AppLaunchController::ReturnBoolCallback* 82 AppLaunchController::ReturnBoolCallback*
53 AppLaunchController::can_configure_network_callback_ = NULL; 83 AppLaunchController::can_configure_network_callback_ = NULL;
54 AppLaunchController::ReturnBoolCallback* 84 AppLaunchController::ReturnBoolCallback*
55 AppLaunchController::need_owner_auth_to_configure_network_callback_ = NULL; 85 AppLaunchController::need_owner_auth_to_configure_network_callback_ = NULL;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 launch_splash_start_time_(0) { 153 launch_splash_start_time_(0) {
124 } 154 }
125 155
126 AppLaunchController::~AppLaunchController() { 156 AppLaunchController::~AppLaunchController() {
127 app_launch_splash_screen_actor_->SetDelegate(NULL); 157 app_launch_splash_screen_actor_->SetDelegate(NULL);
128 } 158 }
129 159
130 void AppLaunchController::StartAppLaunch(bool is_auto_launch) { 160 void AppLaunchController::StartAppLaunch(bool is_auto_launch) {
131 DVLOG(1) << "Starting kiosk mode..."; 161 DVLOG(1) << "Starting kiosk mode...";
132 162
163 RecordKioskLaunchUMA(is_auto_launch);
164
133 // Ensure WebUILoginView is enabled so that bailout shortcut key works. 165 // Ensure WebUILoginView is enabled so that bailout shortcut key works.
134 host_->GetWebUILoginView()->SetUIEnabled(true); 166 host_->GetWebUILoginView()->SetUIEnabled(true);
135 167
136 webui_visible_ = host_->GetWebUILoginView()->webui_visible(); 168 webui_visible_ = host_->GetWebUILoginView()->webui_visible();
137 if (!webui_visible_) { 169 if (!webui_visible_) {
138 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, 170 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
139 content::NotificationService::AllSources()); 171 content::NotificationService::AllSources());
140 } 172 }
141 launch_splash_start_time_ = base::TimeTicks::Now().ToInternalValue(); 173 launch_splash_start_time_ = base::TimeTicks::Now().ToInternalValue();
142 174
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 333
302 void AppLaunchController::OnAppWindowCreated() { 334 void AppLaunchController::OnAppWindowCreated() {
303 DVLOG(1) << "App window created, closing splash screen."; 335 DVLOG(1) << "App window created, closing splash screen.";
304 CleanUp(); 336 CleanUp();
305 } 337 }
306 338
307 bool AppLaunchController::CanConfigureNetwork() { 339 bool AppLaunchController::CanConfigureNetwork() {
308 if (can_configure_network_callback_) 340 if (can_configure_network_callback_)
309 return can_configure_network_callback_->Run(); 341 return can_configure_network_callback_->Run();
310 342
311 policy::BrowserPolicyConnectorChromeOS* connector = 343 if (IsEnterpriseManaged()) {
312 g_browser_process->platform_part()->browser_policy_connector_chromeos();
313 if (connector->IsEnterpriseManaged()) {
314 bool should_prompt; 344 bool should_prompt;
315 if (CrosSettings::Get()->GetBoolean( 345 if (CrosSettings::Get()->GetBoolean(
316 kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline, 346 kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline,
317 &should_prompt)) { 347 &should_prompt)) {
318 return should_prompt; 348 return should_prompt;
319 } 349 }
320 350
321 // Default to true to allow network configuration if the policy is missing. 351 // Default to true to allow network configuration if the policy is missing.
322 return true; 352 return true;
323 } 353 }
324 354
325 return user_manager::UserManager::Get()->GetOwnerAccountId().is_valid(); 355 return user_manager::UserManager::Get()->GetOwnerAccountId().is_valid();
326 } 356 }
327 357
328 bool AppLaunchController::NeedOwnerAuthToConfigureNetwork() { 358 bool AppLaunchController::NeedOwnerAuthToConfigureNetwork() {
329 if (need_owner_auth_to_configure_network_callback_) 359 if (need_owner_auth_to_configure_network_callback_)
330 return need_owner_auth_to_configure_network_callback_->Run(); 360 return need_owner_auth_to_configure_network_callback_->Run();
331 361
332 policy::BrowserPolicyConnectorChromeOS* connector = 362 return !IsEnterpriseManaged();
333 g_browser_process->platform_part()->browser_policy_connector_chromeos();
334 return !connector->IsEnterpriseManaged();
335 } 363 }
336 364
337 void AppLaunchController::MaybeShowNetworkConfigureUI() { 365 void AppLaunchController::MaybeShowNetworkConfigureUI() {
338 if (CanConfigureNetwork()) { 366 if (CanConfigureNetwork()) {
339 if (NeedOwnerAuthToConfigureNetwork()) { 367 if (NeedOwnerAuthToConfigureNetwork()) {
340 if (network_config_requested_) 368 if (network_config_requested_)
341 OnConfigureNetwork(); 369 OnConfigureNetwork();
342 else 370 else
343 app_launch_splash_screen_actor_->ToggleNetworkConfig(true); 371 app_launch_splash_screen_actor_->ToggleNetworkConfig(true);
344 } else { 372 } else {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 KioskAppLaunchError::Save(error); 474 KioskAppLaunchError::Save(error);
447 chrome::AttemptUserExit(); 475 chrome::AttemptUserExit();
448 CleanUp(); 476 CleanUp();
449 } 477 }
450 478
451 bool AppLaunchController::IsShowingNetworkConfigScreen() { 479 bool AppLaunchController::IsShowingNetworkConfigScreen() {
452 return network_config_requested_; 480 return network_config_requested_;
453 } 481 }
454 482
455 } // namespace chromeos 483 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698