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

Side by Side Diff: chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc

Issue 2922383002: [Merge M60] arc: Provide metric to monitor Play Store window is shown time. (Closed)
Patch Set: Created 3 years, 6 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 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" 4 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h"
5 5
6 #include <string> 6 #include <string>
7 7
8 #include "ash/display/screen_orientation_controller_chromeos.h" 8 #include "ash/display/screen_orientation_controller_chromeos.h"
9 #include "ash/public/cpp/window_properties.h" 9 #include "ash/public/cpp/window_properties.h"
10 #include "ash/shared/app_types.h" 10 #include "ash/shared/app_types.h"
11 #include "ash/shelf/shelf_model.h" 11 #include "ash/shelf/shelf_model.h"
12 #include "ash/shell.h" 12 #include "ash/shell.h"
13 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 13 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
14 #include "ash/wm/window_state.h" 14 #include "ash/wm/window_state.h"
15 #include "ash/wm/window_util.h" 15 #include "ash/wm/window_util.h"
16 #include "ash/wm_window.h" 16 #include "ash/wm_window.h"
17 #include "base/bind.h" 17 #include "base/bind.h"
18 #include "base/memory/ptr_util.h" 18 #include "base/memory/ptr_util.h"
19 #include "chrome/browser/chromeos/arc/arc_optin_uma.h"
19 #include "chrome/browser/chromeos/arc/arc_util.h" 20 #include "chrome/browser/chromeos/arc/arc_util.h"
21 #include "chrome/browser/chromeos/arc/policy/arc_policy_util.h"
20 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 23 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
22 #include "chrome/browser/ui/ash/launcher/arc_app_window.h" 24 #include "chrome/browser/ui/ash/launcher/arc_app_window.h"
23 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller .h" 25 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller .h"
24 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 26 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
25 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 27 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
26 #include "components/arc/arc_bridge_service.h" 28 #include "components/arc/arc_bridge_service.h"
27 #include "components/exo/shell_surface.h" 29 #include "components/exo/shell_surface.h"
28 #include "components/signin/core/account_id/account_id.h" 30 #include "components/signin/core/account_id/account_id.h"
29 #include "components/user_manager/user_manager.h" 31 #include "components/user_manager/user_manager.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 145
144 DISALLOW_COPY_AND_ASSIGN(AppWindowInfo); 146 DISALLOW_COPY_AND_ASSIGN(AppWindowInfo);
145 }; 147 };
146 148
147 ArcAppWindowLauncherController::ArcAppWindowLauncherController( 149 ArcAppWindowLauncherController::ArcAppWindowLauncherController(
148 ChromeLauncherController* owner) 150 ChromeLauncherController* owner)
149 : AppWindowLauncherController(owner) { 151 : AppWindowLauncherController(owner) {
150 if (arc::IsArcAllowedForProfile(owner->profile())) { 152 if (arc::IsArcAllowedForProfile(owner->profile())) {
151 observed_profile_ = owner->profile(); 153 observed_profile_ = owner->profile();
152 StartObserving(observed_profile_); 154 StartObserving(observed_profile_);
155
156 arc::ArcSessionManager::Get()->AddObserver(this);
153 } 157 }
154 } 158 }
155 159
156 ArcAppWindowLauncherController::~ArcAppWindowLauncherController() { 160 ArcAppWindowLauncherController::~ArcAppWindowLauncherController() {
157 if (observed_profile_) 161 if (observed_profile_)
158 StopObserving(observed_profile_); 162 StopObserving(observed_profile_);
159 if (observing_shell_) 163 if (observing_shell_)
160 ash::Shell::Get()->RemoveShellObserver(this); 164 ash::Shell::Get()->RemoveShellObserver(this);
165 if (arc::ArcSessionManager::Get())
166 arc::ArcSessionManager::Get()->RemoveObserver(this);
161 } 167 }
162 168
163 void ArcAppWindowLauncherController::ActiveUserChanged( 169 void ArcAppWindowLauncherController::ActiveUserChanged(
164 const std::string& user_email) { 170 const std::string& user_email) {
165 const std::string& primary_user_email = user_manager::UserManager::Get() 171 const std::string& primary_user_email = user_manager::UserManager::Get()
166 ->GetPrimaryUser() 172 ->GetPrimaryUser()
167 ->GetAccountId() 173 ->GetAccountId()
168 .GetUserEmail(); 174 .GetUserEmail();
169 if (user_email == primary_user_email) { 175 if (user_email == primary_user_email) {
170 // Restore existing ARC window and create controllers for them. 176 // Restore existing ARC window and create controllers for them.
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 if (app_window && 490 if (app_window &&
485 app_window->widget() == 491 app_window->widget() ==
486 views::Widget::GetWidgetForNativeWindow(window)) { 492 views::Widget::GetWidgetForNativeWindow(window)) {
487 return it.second->app_window()->controller(); 493 return it.second->app_window()->controller();
488 } 494 }
489 } 495 }
490 496
491 return nullptr; 497 return nullptr;
492 } 498 }
493 499
500 void ArcAppWindowLauncherController::OnArcOptInManagementCheckStarted() {
501 // In case of retry this time is updated and we measure only successful run.
502 opt_in_management_check_start_time_ = base::Time::Now();
503 }
504
505 void ArcAppWindowLauncherController::OnArcSessionStopped(
506 arc::ArcStopReason stop_reason) {
507 opt_in_management_check_start_time_ = base::Time();
508 }
509
494 void ArcAppWindowLauncherController::OnWindowActivated( 510 void ArcAppWindowLauncherController::OnWindowActivated(
495 aura::client::ActivationChangeObserver::ActivationReason reason, 511 aura::client::ActivationChangeObserver::ActivationReason reason,
496 aura::Window* gained_active, 512 aura::Window* gained_active,
497 aura::Window* lost_active) { 513 aura::Window* lost_active) {
498 AppWindowLauncherController::OnWindowActivated(reason, gained_active, 514 AppWindowLauncherController::OnWindowActivated(reason, gained_active,
499 lost_active); 515 lost_active);
500 OnTaskSetActive(active_task_id_); 516 OnTaskSetActive(active_task_id_);
501 } 517 }
502 518
503 void ArcAppWindowLauncherController::OnMaximizeModeStarted() { 519 void ArcAppWindowLauncherController::OnMaximizeModeStarted() {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 ArcAppWindowLauncherItemController* controller = 585 ArcAppWindowLauncherItemController* controller =
570 AttachControllerToTask(app_window->task_id(), *app_window_info); 586 AttachControllerToTask(app_window->task_id(), *app_window_info);
571 DCHECK(!controller->app_id().empty()); 587 DCHECK(!controller->app_id().empty());
572 const ash::ShelfID shelf_id(controller->app_id()); 588 const ash::ShelfID shelf_id(controller->app_id());
573 DCHECK(owner()->GetItem(shelf_id)); 589 DCHECK(owner()->GetItem(shelf_id));
574 590
575 controller->AddWindow(app_window); 591 controller->AddWindow(app_window);
576 owner()->SetItemStatus(shelf_id, ash::STATUS_RUNNING); 592 owner()->SetItemStatus(shelf_id, ash::STATUS_RUNNING);
577 app_window->SetController(controller); 593 app_window->SetController(controller);
578 app_window->set_shelf_id(shelf_id); 594 app_window->set_shelf_id(shelf_id);
595
596 if (!opt_in_management_check_start_time_.is_null() &&
597 app_window_info->app_shelf_id().app_id() == arc::kPlayStoreAppId) {
598 arc::UpdatePlayStoreShowTime(
599 base::Time::Now() - opt_in_management_check_start_time_,
600 arc::policy_util::IsAccountManaged(owner()->profile()));
601 opt_in_management_check_start_time_ = base::Time();
602 }
579 } 603 }
580 604
581 void ArcAppWindowLauncherController::UnregisterApp( 605 void ArcAppWindowLauncherController::UnregisterApp(
582 AppWindowInfo* app_window_info) { 606 AppWindowInfo* app_window_info) {
583 ArcAppWindow* app_window = app_window_info->app_window(); 607 ArcAppWindow* app_window = app_window_info->app_window();
584 if (!app_window) 608 if (!app_window)
585 return; 609 return;
586 610
587 ArcAppWindowLauncherItemController* controller = app_window->controller(); 611 ArcAppWindowLauncherItemController* controller = app_window->controller();
588 if (controller) 612 if (controller)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 const std::string arc_app_id = exo::ShellSurface::GetApplicationId(window); 652 const std::string arc_app_id = exo::ShellSurface::GetApplicationId(window);
629 if (arc_app_id.empty()) 653 if (arc_app_id.empty())
630 return -1; 654 return -1;
631 655
632 int task_id = -1; 656 int task_id = -1;
633 if (sscanf(arc_app_id.c_str(), "org.chromium.arc.%d", &task_id) != 1) 657 if (sscanf(arc_app_id.c_str(), "org.chromium.arc.%d", &task_id) != 1)
634 return -1; 658 return -1;
635 659
636 return task_id; 660 return task_id;
637 } 661 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698