| 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 namespace chromeos { | 36 namespace chromeos { |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 // AppWindowHandler watches for app window and exits the session when the | 40 // AppWindowHandler watches for app window and exits the session when the |
| 41 // last app window is closed. | 41 // last app window is closed. |
| 42 class AppWindowHandler : public AppWindowRegistry::Observer { | 42 class AppWindowHandler : public AppWindowRegistry::Observer { |
| 43 public: | 43 public: |
| 44 AppWindowHandler() : window_registry_(NULL) {} | 44 AppWindowHandler() : window_registry_(NULL) {} |
| 45 virtual ~AppWindowHandler() {} | 45 ~AppWindowHandler() override {} |
| 46 | 46 |
| 47 void Init(Profile* profile) { | 47 void Init(Profile* profile) { |
| 48 DCHECK(!window_registry_); | 48 DCHECK(!window_registry_); |
| 49 window_registry_ = AppWindowRegistry::Get(profile); | 49 window_registry_ = AppWindowRegistry::Get(profile); |
| 50 if (window_registry_) | 50 if (window_registry_) |
| 51 window_registry_->AddObserver(this); | 51 window_registry_->AddObserver(this); |
| 52 } | 52 } |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 // extensions::AppWindowRegistry::Observer overrides: | 55 // extensions::AppWindowRegistry::Observer overrides: |
| 56 virtual void OnAppWindowRemoved(AppWindow* app_window) override { | 56 void OnAppWindowRemoved(AppWindow* app_window) override { |
| 57 if (window_registry_->app_windows().empty()) { | 57 if (window_registry_->app_windows().empty()) { |
| 58 if (DemoAppLauncher::IsDemoAppSession( | 58 if (DemoAppLauncher::IsDemoAppSession( |
| 59 user_manager::UserManager::Get()->GetActiveUser()->email())) { | 59 user_manager::UserManager::Get()->GetActiveUser()->email())) { |
| 60 // If we were in demo mode, we disabled all our network technologies, | 60 // If we were in demo mode, we disabled all our network technologies, |
| 61 // re-enable them. | 61 // re-enable them. |
| 62 NetworkStateHandler* handler = | 62 NetworkStateHandler* handler = |
| 63 NetworkHandler::Get()->network_state_handler(); | 63 NetworkHandler::Get()->network_state_handler(); |
| 64 handler->SetTechnologyEnabled( | 64 handler->SetTechnologyEnabled( |
| 65 NetworkTypePattern::NonVirtual(), | 65 NetworkTypePattern::NonVirtual(), |
| 66 true, | 66 true, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 80 = LAZY_INSTANCE_INITIALIZER; | 80 = LAZY_INSTANCE_INITIALIZER; |
| 81 | 81 |
| 82 // BrowserWindowHandler monitors Browser object being created during | 82 // BrowserWindowHandler monitors Browser object being created during |
| 83 // a kiosk session, log info such as URL so that the code path could be | 83 // a kiosk session, log info such as URL so that the code path could be |
| 84 // fixed and closes the just opened browser window. | 84 // fixed and closes the just opened browser window. |
| 85 class BrowserWindowHandler : public chrome::BrowserListObserver { | 85 class BrowserWindowHandler : public chrome::BrowserListObserver { |
| 86 public: | 86 public: |
| 87 BrowserWindowHandler() { | 87 BrowserWindowHandler() { |
| 88 BrowserList::AddObserver(this); | 88 BrowserList::AddObserver(this); |
| 89 } | 89 } |
| 90 virtual ~BrowserWindowHandler() { | 90 ~BrowserWindowHandler() override { BrowserList::RemoveObserver(this); } |
| 91 BrowserList::RemoveObserver(this); | |
| 92 } | |
| 93 | 91 |
| 94 private: | 92 private: |
| 95 void HandleBrowser(Browser* browser) { | 93 void HandleBrowser(Browser* browser) { |
| 96 content::WebContents* active_tab = | 94 content::WebContents* active_tab = |
| 97 browser->tab_strip_model()->GetActiveWebContents(); | 95 browser->tab_strip_model()->GetActiveWebContents(); |
| 98 std::string url_string = | 96 std::string url_string = |
| 99 active_tab ? active_tab->GetURL().spec() : std::string(); | 97 active_tab ? active_tab->GetURL().spec() : std::string(); |
| 100 LOG(WARNING) << "Browser opened in kiosk session" | 98 LOG(WARNING) << "Browser opened in kiosk session" |
| 101 << ", url=" << url_string; | 99 << ", url=" << url_string; |
| 102 | 100 |
| 103 browser->window()->Close(); | 101 browser->window()->Close(); |
| 104 } | 102 } |
| 105 | 103 |
| 106 // chrome::BrowserListObserver overrides: | 104 // chrome::BrowserListObserver overrides: |
| 107 virtual void OnBrowserAdded(Browser* browser) override { | 105 void OnBrowserAdded(Browser* browser) override { |
| 108 base::MessageLoop::current()->PostTask( | 106 base::MessageLoop::current()->PostTask( |
| 109 FROM_HERE, | 107 FROM_HERE, |
| 110 base::Bind(&BrowserWindowHandler::HandleBrowser, | 108 base::Bind(&BrowserWindowHandler::HandleBrowser, |
| 111 base::Unretained(this), // LazyInstance, always valid | 109 base::Unretained(this), // LazyInstance, always valid |
| 112 browser)); | 110 browser)); |
| 113 } | 111 } |
| 114 | 112 |
| 115 DISALLOW_COPY_AND_ASSIGN(BrowserWindowHandler); | 113 DISALLOW_COPY_AND_ASSIGN(BrowserWindowHandler); |
| 116 }; | 114 }; |
| 117 | 115 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 policy::BrowserPolicyConnectorChromeOS* connector = | 148 policy::BrowserPolicyConnectorChromeOS* connector = |
| 151 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 149 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 152 if (!connector->IsEnterpriseManaged()) { | 150 if (!connector->IsEnterpriseManaged()) { |
| 153 PrefService* local_state = g_browser_process->local_state(); | 151 PrefService* local_state = g_browser_process->local_state(); |
| 154 local_state->SetBoolean(prefs::kRebootAfterUpdate, true); | 152 local_state->SetBoolean(prefs::kRebootAfterUpdate, true); |
| 155 KioskModeIdleAppNameNotification::Initialize(); | 153 KioskModeIdleAppNameNotification::Initialize(); |
| 156 } | 154 } |
| 157 } | 155 } |
| 158 | 156 |
| 159 } // namespace chromeos | 157 } // namespace chromeos |
| OLD | NEW |