| OLD | NEW | 
|   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/app_mode/arc/arc_kiosk_app_launcher.h> |   5 #include <chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_launcher.h> | 
|   6  |   6  | 
|   7 #include <memory> |   7 #include <memory> | 
|   8 #include <string> |   8 #include <string> | 
|   9  |   9  | 
|  10 #include "ash/wm/window_util.h" |  10 #include "ash/wm/window_util.h" | 
|  11 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |  11 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 
|  12 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" |  12 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" | 
|  13 #include "ui/aura/env.h" |  13 #include "ui/aura/env.h" | 
|  14 #include "ui/events/event_constants.h" |  14 #include "ui/events/event_constants.h" | 
|  15  |  15  | 
|  16 namespace chromeos { |  16 namespace chromeos { | 
|  17  |  17  | 
|  18 ArcKioskAppLauncher::ArcKioskAppLauncher(content::BrowserContext* context, |  18 ArcKioskAppLauncher::ArcKioskAppLauncher(content::BrowserContext* context, | 
|  19                                          ArcAppListPrefs* prefs, |  19                                          ArcAppListPrefs* prefs, | 
|  20                                          const std::string& app_id) |  20                                          const std::string& app_id, | 
|  21     : app_id_(app_id), prefs_(prefs) { |  21                                          Delegate* delegate) | 
 |  22     : app_id_(app_id), prefs_(prefs), delegate_(delegate) { | 
|  22   prefs_->AddObserver(this); |  23   prefs_->AddObserver(this); | 
|  23   aura::Env::GetInstance()->AddObserver(this); |  24   aura::Env::GetInstance()->AddObserver(this); | 
|  24   // Launching the app by app id in landscape mode and in non-touch mode. |  25   // Launching the app by app id in landscape mode and in non-touch mode. | 
|  25   arc::LaunchApp(context, app_id_, ui::EF_NONE); |  26   arc::LaunchApp(context, app_id_, ui::EF_NONE); | 
|  26 } |  27 } | 
|  27  |  28  | 
|  28 ArcKioskAppLauncher::~ArcKioskAppLauncher() { |  29 ArcKioskAppLauncher::~ArcKioskAppLauncher() { | 
|  29   StopObserving(); |  30   StopObserving(); | 
|  30 } |  31 } | 
|  31  |  32  | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  71   windows_.erase(window); |  72   windows_.erase(window); | 
|  72 } |  73 } | 
|  73  |  74  | 
|  74 bool ArcKioskAppLauncher::CheckAndPinWindow(aura::Window* const window) { |  75 bool ArcKioskAppLauncher::CheckAndPinWindow(aura::Window* const window) { | 
|  75   DCHECK_GE(task_id_, 0); |  76   DCHECK_GE(task_id_, 0); | 
|  76   if (ArcAppWindowLauncherController::GetWindowTaskId(window) != task_id_) |  77   if (ArcAppWindowLauncherController::GetWindowTaskId(window) != task_id_) | 
|  77     return false; |  78     return false; | 
|  78   // Stop observing as target window is already found. |  79   // Stop observing as target window is already found. | 
|  79   StopObserving(); |  80   StopObserving(); | 
|  80   ash::wm::PinWindow(window, true /* trusted */); |  81   ash::wm::PinWindow(window, true /* trusted */); | 
 |  82   if (delegate_) | 
 |  83     delegate_->OnAppWindowLaunched(); | 
|  81   return true; |  84   return true; | 
|  82 } |  85 } | 
|  83  |  86  | 
|  84 void ArcKioskAppLauncher::StopObserving() { |  87 void ArcKioskAppLauncher::StopObserving() { | 
|  85   aura::Env::GetInstance()->RemoveObserver(this); |  88   aura::Env::GetInstance()->RemoveObserver(this); | 
|  86   for (auto* window : windows_) |  89   for (auto* window : windows_) | 
|  87     window->RemoveObserver(this); |  90     window->RemoveObserver(this); | 
|  88   windows_.clear(); |  91   windows_.clear(); | 
|  89   prefs_->RemoveObserver(this); |  92   prefs_->RemoveObserver(this); | 
|  90 } |  93 } | 
|  91  |  94  | 
|  92 }  // namespace chromeos |  95 }  // namespace chromeos | 
| OLD | NEW |