OLD | NEW |
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/app_mode/app_session_lifetime.h" | 5 #include "chrome/browser/chromeos/app_mode/app_session_lifetime.h" |
6 | 6 |
7 #include "apps/shell_window.h" | 7 #include "apps/app_window.h" |
8 #include "apps/shell_window_registry.h" | 8 #include "apps/app_window_registry.h" |
9 #include "ash/wm/window_state.h" | 9 #include "ash/wm/window_state.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/chromeos/app_mode/kiosk_app_update_service.h" | 16 #include "chrome/browser/chromeos/app_mode/kiosk_app_update_service.h" |
17 #include "chrome/browser/chromeos/app_mode/kiosk_mode_idle_app_name_notification
.h" | 17 #include "chrome/browser/chromeos/app_mode/kiosk_mode_idle_app_name_notification
.h" |
18 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 18 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
19 #include "chrome/browser/lifetime/application_lifetime.h" | 19 #include "chrome/browser/lifetime/application_lifetime.h" |
20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/browser_list.h" | 22 #include "chrome/browser/ui/browser_list.h" |
23 #include "chrome/browser/ui/browser_list_observer.h" | 23 #include "chrome/browser/ui/browser_list_observer.h" |
24 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
25 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
27 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
28 | 28 |
29 using apps::ShellWindowRegistry; | 29 using apps::AppWindowRegistry; |
30 | 30 |
31 namespace chromeos { | 31 namespace chromeos { |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 // AppWindowHandler watches for app window and exits the session when the | 35 // AppWindowHandler watches for app window and exits the session when the |
36 // last app window is closed. It also initializes the kiosk app window so | 36 // last app window is closed. It also initializes the kiosk app window so |
37 // that it receives all function keys as a temp solution before underlying | 37 // that it receives all function keys as a temp solution before underlying |
38 // http:://crbug.com/166928 is fixed.. | 38 // http:://crbug.com/166928 is fixed.. |
39 class AppWindowHandler : public ShellWindowRegistry::Observer { | 39 class AppWindowHandler : public AppWindowRegistry::Observer { |
40 public: | 40 public: |
41 AppWindowHandler() : window_registry_(NULL) {} | 41 AppWindowHandler() : window_registry_(NULL) {} |
42 virtual ~AppWindowHandler() {} | 42 virtual ~AppWindowHandler() {} |
43 | 43 |
44 void Init(Profile* profile) { | 44 void Init(Profile* profile) { |
45 DCHECK(!window_registry_); | 45 DCHECK(!window_registry_); |
46 window_registry_ = ShellWindowRegistry::Get(profile); | 46 window_registry_ = AppWindowRegistry::Get(profile); |
47 if (window_registry_) | 47 if (window_registry_) |
48 window_registry_->AddObserver(this); | 48 window_registry_->AddObserver(this); |
49 } | 49 } |
50 | 50 |
51 private: | 51 private: |
52 // apps::ShellWindowRegistry::Observer overrides: | 52 // apps::AppWindowRegistry::Observer overrides: |
53 virtual void OnShellWindowAdded(apps::ShellWindow* shell_window) OVERRIDE { | 53 virtual void OnAppWindowAdded(apps::AppWindow* app_window) OVERRIDE { |
54 // Set flags to allow kiosk app to receive all function keys. | 54 // Set flags to allow kiosk app to receive all function keys. |
55 // TODO(xiyuan): Remove this after http:://crbug.com/166928. | 55 // TODO(xiyuan): Remove this after http:://crbug.com/166928. |
56 ash::wm::WindowState* window_state = | 56 ash::wm::WindowState* window_state = |
57 ash::wm::GetWindowState(shell_window->GetNativeWindow()); | 57 ash::wm::GetWindowState(app_window->GetNativeWindow()); |
58 window_state->set_top_row_keys_are_function_keys(true); | 58 window_state->set_top_row_keys_are_function_keys(true); |
59 } | 59 } |
60 virtual void OnShellWindowIconChanged(apps::ShellWindow* shell_window) | 60 virtual void OnAppWindowIconChanged(apps::AppWindow* app_window) OVERRIDE {} |
61 OVERRIDE {} | 61 virtual void OnAppWindowRemoved(apps::AppWindow* app_window) OVERRIDE { |
62 virtual void OnShellWindowRemoved(apps::ShellWindow* shell_window) OVERRIDE { | 62 if (window_registry_->app_windows().empty()) { |
63 if (window_registry_->shell_windows().empty()) { | |
64 chrome::AttemptUserExit(); | 63 chrome::AttemptUserExit(); |
65 window_registry_->RemoveObserver(this); | 64 window_registry_->RemoveObserver(this); |
66 } | 65 } |
67 } | 66 } |
68 | 67 |
69 apps::ShellWindowRegistry* window_registry_; | 68 apps::AppWindowRegistry* window_registry_; |
70 | 69 |
71 DISALLOW_COPY_AND_ASSIGN(AppWindowHandler); | 70 DISALLOW_COPY_AND_ASSIGN(AppWindowHandler); |
72 }; | 71 }; |
73 | 72 |
74 base::LazyInstance<AppWindowHandler> app_window_handler | 73 base::LazyInstance<AppWindowHandler> app_window_handler |
75 = LAZY_INSTANCE_INITIALIZER; | 74 = LAZY_INSTANCE_INITIALIZER; |
76 | 75 |
77 // BrowserWindowHandler monitors Browser object being created during | 76 // BrowserWindowHandler monitors Browser object being created during |
78 // a kiosk session, log info such as URL so that the code path could be | 77 // a kiosk session, log info such as URL so that the code path could be |
79 // fixed and closes the just opened browser window. | 78 // fixed and closes the just opened browser window. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 policy::BrowserPolicyConnectorChromeOS* connector = | 135 policy::BrowserPolicyConnectorChromeOS* connector = |
137 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 136 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
138 if (!connector->IsEnterpriseManaged()) { | 137 if (!connector->IsEnterpriseManaged()) { |
139 PrefService* local_state = g_browser_process->local_state(); | 138 PrefService* local_state = g_browser_process->local_state(); |
140 local_state->SetBoolean(prefs::kRebootAfterUpdate, true); | 139 local_state->SetBoolean(prefs::kRebootAfterUpdate, true); |
141 KioskModeIdleAppNameNotification::Initialize(); | 140 KioskModeIdleAppNameNotification::Initialize(); |
142 } | 141 } |
143 } | 142 } |
144 | 143 |
145 } // namespace chromeos | 144 } // namespace chromeos |
OLD | NEW |