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

Side by Side Diff: chrome/browser/chromeos/app_mode/app_session_lifetime.cc

Issue 444903002: [cros] user_manager component - move UserManagerBase and UserManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 | Annotate | Revision Log
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/app_mode/app_session_lifetime.h" 5 #include "chrome/browser/chromeos/app_mode/app_session_lifetime.h"
6 6
7 #include "apps/app_window.h" 7 #include "apps/app_window.h"
8 #include "apps/app_window_registry.h" 8 #include "apps/app_window_registry.h"
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chromeos/app_mode/kiosk_app_update_service.h" 15 #include "chrome/browser/chromeos/app_mode/kiosk_app_update_service.h"
16 #include "chrome/browser/chromeos/app_mode/kiosk_mode_idle_app_name_notification .h" 16 #include "chrome/browser/chromeos/app_mode/kiosk_mode_idle_app_name_notification .h"
17 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" 17 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h"
18 #include "chrome/browser/chromeos/login/users/user_manager.h"
19 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 18 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
20 #include "chrome/browser/lifetime/application_lifetime.h" 19 #include "chrome/browser/lifetime/application_lifetime.h"
21 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
23 #include "chrome/browser/ui/browser_list.h" 22 #include "chrome/browser/ui/browser_list.h"
24 #include "chrome/browser/ui/browser_list_observer.h" 23 #include "chrome/browser/ui/browser_list_observer.h"
25 #include "chrome/browser/ui/browser_window.h" 24 #include "chrome/browser/ui/browser_window.h"
26 #include "chrome/browser/ui/tabs/tab_strip_model.h" 25 #include "chrome/browser/ui/tabs/tab_strip_model.h"
27 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
28 #include "chromeos/network/network_state.h" 27 #include "chromeos/network/network_state.h"
29 #include "chromeos/network/network_state_handler.h" 28 #include "chromeos/network/network_state_handler.h"
29 #include "components/user_manager/user_manager.h"
30 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
31 31
32 using apps::AppWindowRegistry; 32 using apps::AppWindowRegistry;
33 33
34 namespace chromeos { 34 namespace chromeos {
35 35
36 namespace { 36 namespace {
37 37
38 // AppWindowHandler watches for app window and exits the session when the 38 // AppWindowHandler watches for app window and exits the session when the
39 // last app window is closed. 39 // last app window is closed.
40 class AppWindowHandler : public AppWindowRegistry::Observer { 40 class AppWindowHandler : public AppWindowRegistry::Observer {
41 public: 41 public:
42 AppWindowHandler() : window_registry_(NULL) {} 42 AppWindowHandler() : window_registry_(NULL) {}
43 virtual ~AppWindowHandler() {} 43 virtual ~AppWindowHandler() {}
44 44
45 void Init(Profile* profile) { 45 void Init(Profile* profile) {
46 DCHECK(!window_registry_); 46 DCHECK(!window_registry_);
47 window_registry_ = AppWindowRegistry::Get(profile); 47 window_registry_ = AppWindowRegistry::Get(profile);
48 if (window_registry_) 48 if (window_registry_)
49 window_registry_->AddObserver(this); 49 window_registry_->AddObserver(this);
50 } 50 }
51 51
52 private: 52 private:
53 // apps::AppWindowRegistry::Observer overrides: 53 // apps::AppWindowRegistry::Observer overrides:
54 virtual void OnAppWindowRemoved(apps::AppWindow* app_window) OVERRIDE { 54 virtual void OnAppWindowRemoved(apps::AppWindow* app_window) OVERRIDE {
55 if (window_registry_->app_windows().empty()) { 55 if (window_registry_->app_windows().empty()) {
56 if (DemoAppLauncher::IsDemoAppSession( 56 if (DemoAppLauncher::IsDemoAppSession(
57 chromeos::UserManager::Get()->GetActiveUser()->email())) { 57 user_manager::UserManager::Get()->GetActiveUser()->email())) {
58 // If we were in demo mode, we disabled all our network technologies, 58 // If we were in demo mode, we disabled all our network technologies,
59 // re-enable them. 59 // re-enable them.
60 NetworkStateHandler* handler = 60 NetworkStateHandler* handler =
61 NetworkHandler::Get()->network_state_handler(); 61 NetworkHandler::Get()->network_state_handler();
62 handler->SetTechnologyEnabled( 62 handler->SetTechnologyEnabled(
63 NetworkTypePattern::NonVirtual(), 63 NetworkTypePattern::NonVirtual(),
64 true, 64 true,
65 chromeos::network_handler::ErrorCallback()); 65 chromeos::network_handler::ErrorCallback());
66 } 66 }
67 chrome::AttemptUserExit(); 67 chrome::AttemptUserExit();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // Binds the session lifetime with app window counts. 122 // Binds the session lifetime with app window counts.
123 CHECK(app_window_handler == NULL); 123 CHECK(app_window_handler == NULL);
124 app_window_handler.Get().Init(profile); 124 app_window_handler.Get().Init(profile);
125 125
126 CHECK(browser_window_handler == NULL); 126 CHECK(browser_window_handler == NULL);
127 browser_window_handler.Get(); 127 browser_window_handler.Get();
128 128
129 // For a demo app, we don't need to either setup the update service or 129 // For a demo app, we don't need to either setup the update service or
130 // the idle app name notification. 130 // the idle app name notification.
131 if (DemoAppLauncher::IsDemoAppSession( 131 if (DemoAppLauncher::IsDemoAppSession(
132 chromeos::UserManager::Get()->GetActiveUser()->email())) 132 user_manager::UserManager::Get()->GetActiveUser()->email()))
133 return; 133 return;
134 134
135 // Set the app_id for the current instance of KioskAppUpdateService. 135 // Set the app_id for the current instance of KioskAppUpdateService.
136 KioskAppUpdateService* update_service = 136 KioskAppUpdateService* update_service =
137 KioskAppUpdateServiceFactory::GetForProfile(profile); 137 KioskAppUpdateServiceFactory::GetForProfile(profile);
138 DCHECK(update_service); 138 DCHECK(update_service);
139 if (update_service) 139 if (update_service)
140 update_service->set_app_id(app_id); 140 update_service->set_app_id(app_id);
141 141
142 // If the device is not enterprise managed, set prefs to reboot after update 142 // If the device is not enterprise managed, set prefs to reboot after update
143 // and create a user security message which shows the user the application 143 // and create a user security message which shows the user the application
144 // name and author after some idle timeout. 144 // name and author after some idle timeout.
145 policy::BrowserPolicyConnectorChromeOS* connector = 145 policy::BrowserPolicyConnectorChromeOS* connector =
146 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 146 g_browser_process->platform_part()->browser_policy_connector_chromeos();
147 if (!connector->IsEnterpriseManaged()) { 147 if (!connector->IsEnterpriseManaged()) {
148 PrefService* local_state = g_browser_process->local_state(); 148 PrefService* local_state = g_browser_process->local_state();
149 local_state->SetBoolean(prefs::kRebootAfterUpdate, true); 149 local_state->SetBoolean(prefs::kRebootAfterUpdate, true);
150 KioskModeIdleAppNameNotification::Initialize(); 150 KioskModeIdleAppNameNotification::Initialize();
151 } 151 }
152 } 152 }
153 153
154 } // namespace chromeos 154 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698