summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrjkroege@google.com <rjkroege@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-28 17:56:35 +0000
committerrjkroege@google.com <rjkroege@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-28 17:56:35 +0000
commit9c1d9aba7411fe5196e32e908528592d19237908 (patch)
tree5b7b940499cfd5adbc8530f41a563e5e3d23d997
parentf58d600f0eb61710184c13f0e15478864d06e4bf (diff)
downloadchromium_src-9c1d9aba7411fe5196e32e908528592d19237908.zip
chromium_src-9c1d9aba7411fe5196e32e908528592d19237908.tar.gz
chromium_src-9c1d9aba7411fe5196e32e908528592d19237908.tar.bz2
Add system shutdown functionality to DOM Login.
Added functionality to LoginUI to support ShutdownSystem and added link to call function from login page. This patch also reenables chrome://login on touchui non-chromeos builds, since that is used for interface testing development. Patch from Ryan Harrison <rharrison@chromium.org> BUG=none TEST=none Review URL: http://codereview.chromium.org/6282010 Patch from Ryan Harrison <rharrison@chromium.org>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72972 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/dom_ui/login/login_ui.cc19
-rw-r--r--chrome/browser/chromeos/dom_ui/login/login_ui.h1
-rw-r--r--chrome/browser/dom_ui/dom_ui_factory.cc7
-rw-r--r--chrome/browser/resources/login.html19
4 files changed, 36 insertions, 10 deletions
diff --git a/chrome/browser/chromeos/dom_ui/login/login_ui.cc b/chrome/browser/chromeos/dom_ui/login/login_ui.cc
index cf9d3f5..fe14d5e 100644
--- a/chrome/browser/chromeos/dom_ui/login/login_ui.cc
+++ b/chrome/browser/chromeos/dom_ui/login/login_ui.cc
@@ -15,6 +15,8 @@
#include "chrome/common/url_constants.h"
#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/cros/cros_library.h"
+#include "chrome/browser/chromeos/cros/power_library.h"
#include "chrome/browser/chromeos/dom_ui/login/authenticator_facade_cros.h"
#else
#include "chrome/browser/chromeos/dom_ui/login/authenticator_facade_stub.h"
@@ -83,6 +85,10 @@ void LoginUIHandler::RegisterMessages() {
"AuthenticateUser",
NewCallback(this,
&LoginUIHandler::HandleAuthenticateUser));
+ dom_ui_->RegisterMessageCallback(
+ "ShutdownSystem",
+ NewCallback(this,
+ &LoginUIHandler::HandleShutdownSystem));
}
void LoginUIHandler::HandleAuthenticateUser(const ListValue* args) {
@@ -115,6 +121,19 @@ void LoginUIHandler::HandleLaunchIncognito(const ListValue* args) {
login_browser->CloseWindow();
}
+void LoginUIHandler::HandleShutdownSystem(const ListValue* args) {
+#if defined(OS_CHROMEOS)
+ DCHECK(CrosLibrary::Get()->EnsureLoaded());
+ CrosLibrary::Get()->GetPowerLibrary()->RequestShutdown();
+#else
+ // When were are not running in cros we are just shutting the browser instead
+ // of trying to shutdown the system
+ Profile* profile = profile_operations_->GetDefaultProfileByPath();
+ Browser* browser = browser_operations_->GetLoginBrowser(profile);
+ browser->CloseWindow();
+#endif
+}
+
void LoginUIHandler::OnLoginFailure(const LoginFailure& failure) {
Profile* profile = profile_operations_->GetDefaultProfileByPath();
Browser* login_browser = browser_operations_->GetLoginBrowser(profile);
diff --git a/chrome/browser/chromeos/dom_ui/login/login_ui.h b/chrome/browser/chromeos/dom_ui/login/login_ui.h
index b19699e..6d0d550 100644
--- a/chrome/browser/chromeos/dom_ui/login/login_ui.h
+++ b/chrome/browser/chromeos/dom_ui/login/login_ui.h
@@ -57,6 +57,7 @@ class LoginUIHandler : public DOMMessageHandler,
void HandleAuthenticateUser(const ListValue* args);
void HandleLaunchIncognito(const ListValue* args);
+ void HandleShutdownSystem(const ListValue* args);
// Overridden from LoginStatusConsumer.
virtual void OnLoginFailure(const chromeos::LoginFailure& failure);
diff --git a/chrome/browser/dom_ui/dom_ui_factory.cc b/chrome/browser/dom_ui/dom_ui_factory.cc
index 2546253..39751c1 100644
--- a/chrome/browser/dom_ui/dom_ui_factory.cc
+++ b/chrome/browser/dom_ui/dom_ui_factory.cc
@@ -158,6 +158,8 @@ static DOMUIFactoryFunction GetDOMUIFactoryFunction(Profile* profile,
#if defined(TOUCH_UI)
if (url.host() == chrome::kChromeUIKeyboardHost)
return &NewDOMUI<KeyboardUI>;
+ if (url.host() == chrome::kChromeUILoginHost)
+ return &NewDOMUI<chromeos::LoginUI>;
#endif
if (url.host() == chrome::kChromeUIGpuInternalsHost)
return &NewDOMUI<GpuInternalsUI>;
@@ -216,11 +218,6 @@ static DOMUIFactoryFunction GetDOMUIFactoryFunction(Profile* profile,
}
#endif // defined(OS_CHROMEOS)
-#if defined(OS_CHROMEOS) && defined(TOUCH_UI)
- if (url.host() == chrome::kChromeUILoginHost)
- return &NewDOMUI<chromeos::LoginUI>;
-#endif
-
if (url.spec() == chrome::kChromeUIConstrainedHTMLTestURL)
return &NewDOMUI<ConstrainedHtmlUI>;
diff --git a/chrome/browser/resources/login.html b/chrome/browser/resources/login.html
index 4238a25..6056a5a 100644
--- a/chrome/browser/resources/login.html
+++ b/chrome/browser/resources/login.html
@@ -28,16 +28,14 @@
<a id="login-incognito" onclick="callLoginIncognito();">
Browse without signing in
</a>
+ <a id="shutdown-system" onclick="callShutdownSystem();">
+ Shutdown System
+ </a>
</div>
</div>
</body>
<script>
-function callLoginIncognito() {
- loginStarted();
- chrome.send('LaunchIncognito', []);
-}
-
function callLogin() {
var user = document.getElementById('user-text').value;
var pass = document.getElementById('pass-text').value;
@@ -56,8 +54,19 @@ function loginFinished(result) {
function setLock(on) {
document.getElementById('login-button').disabled = on;
document.getElementById('login-incognito').disabled = on;
+ document.getElementById('shutdown-system').disabled = on;
document.getElementById('user-text').disabled = on;
document.getElementById('pass-text').disabled = on;
}
+
+function callLoginIncognito() {
+ loginStarted();
+ chrome.send('LaunchIncognito', []);
+}
+
+function callShutdownSystem() {
+ chrome.send('ShutdownSystem', []);
+}
+
</script>
</html>