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

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

Issue 494033002: Move AppWindow to extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unneeded include in chrome_shell_delegate.cc Created 6 years, 3 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"
8 #include "apps/app_window_registry.h"
9 #include "base/basictypes.h" 7 #include "base/basictypes.h"
10 #include "base/bind.h" 8 #include "base/bind.h"
11 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
12 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
13 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
14 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chromeos/app_mode/kiosk_app_update_service.h" 13 #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" 14 #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" 15 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h"
18 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 16 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
19 #include "chrome/browser/lifetime/application_lifetime.h" 17 #include "chrome/browser/lifetime/application_lifetime.h"
20 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
22 #include "chrome/browser/ui/browser_list.h" 20 #include "chrome/browser/ui/browser_list.h"
23 #include "chrome/browser/ui/browser_list_observer.h" 21 #include "chrome/browser/ui/browser_list_observer.h"
24 #include "chrome/browser/ui/browser_window.h" 22 #include "chrome/browser/ui/browser_window.h"
25 #include "chrome/browser/ui/tabs/tab_strip_model.h" 23 #include "chrome/browser/ui/tabs/tab_strip_model.h"
26 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
27 #include "chromeos/network/network_state.h" 25 #include "chromeos/network/network_state.h"
28 #include "chromeos/network/network_state_handler.h" 26 #include "chromeos/network/network_state_handler.h"
29 #include "components/user_manager/user_manager.h" 27 #include "components/user_manager/user_manager.h"
30 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
29 #include "extensions/browser/app_window/app_window.h"
30 #include "extensions/browser/app_window/app_window_registry.h"
31 31
32 using apps::AppWindowRegistry; 32 using extensions::AppWindow;
33 using extensions::AppWindowRegistry;
33 34
34 namespace chromeos { 35 namespace chromeos {
35 36
36 namespace { 37 namespace {
37 38
38 // AppWindowHandler watches for app window and exits the session when the 39 // AppWindowHandler watches for app window and exits the session when the
39 // last app window is closed. 40 // last app window is closed.
40 class AppWindowHandler : public AppWindowRegistry::Observer { 41 class AppWindowHandler : public AppWindowRegistry::Observer {
41 public: 42 public:
42 AppWindowHandler() : window_registry_(NULL) {} 43 AppWindowHandler() : window_registry_(NULL) {}
43 virtual ~AppWindowHandler() {} 44 virtual ~AppWindowHandler() {}
44 45
45 void Init(Profile* profile) { 46 void Init(Profile* profile) {
46 DCHECK(!window_registry_); 47 DCHECK(!window_registry_);
47 window_registry_ = AppWindowRegistry::Get(profile); 48 window_registry_ = AppWindowRegistry::Get(profile);
48 if (window_registry_) 49 if (window_registry_)
49 window_registry_->AddObserver(this); 50 window_registry_->AddObserver(this);
50 } 51 }
51 52
52 private: 53 private:
53 // apps::AppWindowRegistry::Observer overrides: 54 // extensions::AppWindowRegistry::Observer overrides:
54 virtual void OnAppWindowRemoved(apps::AppWindow* app_window) OVERRIDE { 55 virtual void OnAppWindowRemoved(AppWindow* app_window) OVERRIDE {
55 if (window_registry_->app_windows().empty()) { 56 if (window_registry_->app_windows().empty()) {
56 if (DemoAppLauncher::IsDemoAppSession( 57 if (DemoAppLauncher::IsDemoAppSession(
57 user_manager::UserManager::Get()->GetActiveUser()->email())) { 58 user_manager::UserManager::Get()->GetActiveUser()->email())) {
58 // If we were in demo mode, we disabled all our network technologies, 59 // If we were in demo mode, we disabled all our network technologies,
59 // re-enable them. 60 // re-enable them.
60 NetworkStateHandler* handler = 61 NetworkStateHandler* handler =
61 NetworkHandler::Get()->network_state_handler(); 62 NetworkHandler::Get()->network_state_handler();
62 handler->SetTechnologyEnabled( 63 handler->SetTechnologyEnabled(
63 NetworkTypePattern::NonVirtual(), 64 NetworkTypePattern::NonVirtual(),
64 true, 65 true,
65 chromeos::network_handler::ErrorCallback()); 66 chromeos::network_handler::ErrorCallback());
66 } 67 }
67 chrome::AttemptUserExit(); 68 chrome::AttemptUserExit();
68 window_registry_->RemoveObserver(this); 69 window_registry_->RemoveObserver(this);
69 } 70 }
70 } 71 }
71 72
72 apps::AppWindowRegistry* window_registry_; 73 AppWindowRegistry* window_registry_;
73 74
74 DISALLOW_COPY_AND_ASSIGN(AppWindowHandler); 75 DISALLOW_COPY_AND_ASSIGN(AppWindowHandler);
75 }; 76 };
76 77
77 base::LazyInstance<AppWindowHandler> app_window_handler 78 base::LazyInstance<AppWindowHandler> app_window_handler
78 = LAZY_INSTANCE_INITIALIZER; 79 = LAZY_INSTANCE_INITIALIZER;
79 80
80 // BrowserWindowHandler monitors Browser object being created during 81 // BrowserWindowHandler monitors Browser object being created during
81 // a kiosk session, log info such as URL so that the code path could be 82 // a kiosk session, log info such as URL so that the code path could be
82 // fixed and closes the just opened browser window. 83 // fixed and closes the just opened browser window.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 policy::BrowserPolicyConnectorChromeOS* connector = 146 policy::BrowserPolicyConnectorChromeOS* connector =
146 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 147 g_browser_process->platform_part()->browser_policy_connector_chromeos();
147 if (!connector->IsEnterpriseManaged()) { 148 if (!connector->IsEnterpriseManaged()) {
148 PrefService* local_state = g_browser_process->local_state(); 149 PrefService* local_state = g_browser_process->local_state();
149 local_state->SetBoolean(prefs::kRebootAfterUpdate, true); 150 local_state->SetBoolean(prefs::kRebootAfterUpdate, true);
150 KioskModeIdleAppNameNotification::Initialize(); 151 KioskModeIdleAppNameNotification::Initialize();
151 } 152 }
152 } 153 }
153 154
154 } // namespace chromeos 155 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/browser_process_impl.cc ('k') | chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698