summaryrefslogtreecommitdiffstats
path: root/athena
diff options
context:
space:
mode:
authordpolukhin <dpolukhin@chromium.org>2014-10-16 04:58:13 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-16 11:58:27 +0000
commit5b584d515a38c01b3d9d72d823688b67173c97cf (patch)
tree8c6ddc56d30dd9f3f7d0a7b39ef8542612576fb6 /athena
parentc2792b84932d3e1aaf6de2ca3040ae8407cd2665 (diff)
downloadchromium_src-5b584d515a38c01b3d9d72d823688b67173c97cf.zip
chromium_src-5b584d515a38c01b3d9d72d823688b67173c97cf.tar.gz
chromium_src-5b584d515a38c01b3d9d72d823688b67173c97cf.tar.bz2
Lock screen for Chrome-Athena
Screen lock activates with keyboard accelerator Ctrl+Shift+L and bower button. BUG=413926 TEST=manual Review URL: https://codereview.chromium.org/620663005 Cr-Commit-Position: refs/heads/master@{#299878}
Diffstat (limited to 'athena')
-rw-r--r--athena/athena.gyp6
-rw-r--r--athena/main/DEPS1
-rw-r--r--athena/main/athena_launcher.cc3
-rw-r--r--athena/screen/screen_manager_impl.cc14
-rw-r--r--athena/screen_lock/chrome/DEPS7
-rw-r--r--athena/screen_lock/chrome/chrome_screen_lock_manager.cc94
-rw-r--r--athena/screen_lock/public/DEPS4
-rw-r--r--athena/screen_lock/public/screen_lock_manager.h28
-rw-r--r--athena/screen_lock/screen_lock_manager_base.cc39
-rw-r--r--athena/screen_lock/screen_lock_manager_base.h29
-rw-r--r--athena/screen_lock/shell/shell_screen_lock_manager.cc14
-rw-r--r--athena/system/DEPS1
12 files changed, 237 insertions, 3 deletions
diff --git a/athena/athena.gyp b/athena/athena.gyp
index ee2f614..4084fb2 100644
--- a/athena/athena.gyp
+++ b/athena/athena.gyp
@@ -180,6 +180,9 @@
'extensions/pubilc/apps_search_controller_factory.h',
'extensions/public/extension_app_model_builder.h',
'extensions/public/extensions_delegate.h',
+ 'screen_lock/public/screen_lock_manager.h',
+ 'screen_lock/screen_lock_manager_base.cc',
+ 'screen_lock/screen_lock_manager_base.h',
'virtual_keyboard/public/virtual_keyboard_manager.h',
'virtual_keyboard/virtual_keyboard_manager_impl.cc',
],
@@ -189,6 +192,7 @@
'type': 'static_library',
'dependencies': [
'../components/components.gyp:component_metrics_proto',
+ '../chrome/chrome.gyp:browser_chromeos',
'../chrome/chrome.gyp:browser_extensions',
'../components/components.gyp:omnibox',
],
@@ -205,6 +209,7 @@
'extensions/chrome/chrome_search_controller_factory.cc',
'extensions/chrome/chrome_search_controller_factory.h',
'extensions/chrome/extensions_delegate_impl.cc',
+ 'screen_lock/chrome/chrome_screen_lock_manager.cc',
],
},
{
@@ -232,6 +237,7 @@
'extensions/shell/shell_search_controller_factory.h',
'extensions/shell/url_search_provider.cc',
'extensions/shell/url_search_provider.h',
+ 'screen_lock/shell/shell_screen_lock_manager.cc',
],
},
{
diff --git a/athena/main/DEPS b/athena/main/DEPS
index b836eac..d2d826a 100644
--- a/athena/main/DEPS
+++ b/athena/main/DEPS
@@ -8,6 +8,7 @@ include_rules = [
"+athena/resource_manager/public",
"+athena/resources/grit/athena_resources.h",
"+athena/screen/public",
+ "+athena/screen_lock/public",
"+athena/system/public",
"+athena/task/public",
"+athena/virtual_keyboard/public",
diff --git a/athena/main/athena_launcher.cc b/athena/main/athena_launcher.cc
index 77bf29e..2634489 100644
--- a/athena/main/athena_launcher.cc
+++ b/athena/main/athena_launcher.cc
@@ -20,6 +20,7 @@
#include "athena/main/placeholder.h"
#include "athena/resource_manager/public/resource_manager.h"
#include "athena/screen/public/screen_manager.h"
+#include "athena/screen_lock/public/screen_lock_manager.h"
#include "athena/system/public/system_ui.h"
#include "athena/virtual_keyboard/public/virtual_keyboard_manager.h"
#include "athena/wm/public/window_manager.h"
@@ -128,6 +129,7 @@ void CreateVirtualKeyboardWithContext(content::BrowserContext* context) {
}
void StartAthenaSessionWithContext(content::BrowserContext* context) {
+ athena::ScreenLockManager::Create();
athena::ExtensionsDelegate::CreateExtensionsDelegate(context);
StartAthenaSession(
athena::CreateContentActivityFactory(),
@@ -160,6 +162,7 @@ void ShutdownAthena() {
athena::ActivityManager::Shutdown();
athena::HomeCard::Shutdown();
athena::ExtensionsDelegate::Shutdown();
+ athena::ScreenLockManager::Shutdown();
session_started = false;
}
athena::AppRegistry::ShutDown();
diff --git a/athena/screen/screen_manager_impl.cc b/athena/screen/screen_manager_impl.cc
index 771f939..3ece198 100644
--- a/athena/screen/screen_manager_impl.cc
+++ b/athena/screen/screen_manager_impl.cc
@@ -154,6 +154,10 @@ class AthenaEventTargeter : public aura::WindowTargeter,
container_->RemoveObserver(this);
}
+ void SetPreviousEventTargeter(scoped_ptr<ui::EventTargeter> targeter) {
+ previous_root_event_targeter_ = targeter.Pass();
+ }
+
private:
// aura::WindowTargeter:
virtual bool SubtreeCanAcceptEvent(
@@ -183,10 +187,11 @@ class AthenaEventTargeter : public aura::WindowTargeter,
container_ = NULL;
// This will remove myself.
- root_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>());
+ root_window->SetEventTargeter(previous_root_event_targeter_.Pass());
}
aura::Window* container_;
+ scoped_ptr<ui::EventTargeter> previous_root_event_targeter_;
DISALLOW_COPY_AND_ASSIGN(AthenaEventTargeter);
};
@@ -325,8 +330,11 @@ aura::Window* ScreenManagerImpl::CreateContainer(
DCHECK(std::find_if(children.begin(), children.end(), &GrabsInput)
== children.end())
<< "input has already been grabbed by another container";
- root_window_->SetEventTargeter(
- scoped_ptr<ui::EventTargeter>(new AthenaEventTargeter(container)));
+ AthenaEventTargeter* athena_event_targeter =
+ new AthenaEventTargeter(container);
+ athena_event_targeter->SetPreviousEventTargeter(
+ root_window_->SetEventTargeter(
+ scoped_ptr<ui::EventTargeter>(athena_event_targeter)));
}
root_window_->AddChild(container);
diff --git a/athena/screen_lock/chrome/DEPS b/athena/screen_lock/chrome/DEPS
new file mode 100644
index 0000000..fd35419
--- /dev/null
+++ b/athena/screen_lock/chrome/DEPS
@@ -0,0 +1,7 @@
+include_rules = [
+ "+athena/input/public",
+ "+base",
+
+ # TODO(dpolukhin): move lock screen to component, see crbug.com/370175
+ "+chrome/browser/chromeos/login/lock",
+]
diff --git a/athena/screen_lock/chrome/chrome_screen_lock_manager.cc b/athena/screen_lock/chrome/chrome_screen_lock_manager.cc
new file mode 100644
index 0000000..628b0d8
--- /dev/null
+++ b/athena/screen_lock/chrome/chrome_screen_lock_manager.cc
@@ -0,0 +1,94 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "athena/input/public/accelerator_manager.h"
+#include "athena/input/public/input_manager.h"
+#include "athena/screen_lock/screen_lock_manager_base.h"
+#include "base/logging.h"
+#include "chrome/browser/chromeos/login/lock/screen_locker.h"
+
+namespace athena {
+namespace {
+
+enum Command {
+ CMD_LOCK_SCREEN
+};
+
+const AcceleratorData accelerator_data[] = {
+ { TRIGGER_ON_PRESS, ui::VKEY_L, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN,
+ CMD_LOCK_SCREEN, AF_NONE }};
+
+class ChromeScreenLockManager : public ScreenLockManagerBase,
+ public AcceleratorHandler,
+ public PowerButtonObserver {
+ public:
+ ChromeScreenLockManager() {}
+
+ void Init();
+
+ protected:
+ virtual ~ChromeScreenLockManager();
+
+ private:
+ // ScreenLockManager:
+ virtual void LockScreen() override;
+
+ // AcceleratorHandler:
+ virtual bool IsCommandEnabled(int command_id) const override;
+ virtual bool OnAcceleratorFired(int command_id,
+ const ui::Accelerator& accelerator) override;
+
+ // PowerButtonObserver:
+ virtual void OnPowerButtonStateChanged(State state) override;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeScreenLockManager);
+};
+
+ChromeScreenLockManager::~ChromeScreenLockManager() {
+ InputManager::Get()->RemovePowerButtonObserver(this);
+}
+
+void ChromeScreenLockManager::Init() {
+ AcceleratorManager::Get()->RegisterAccelerators(
+ accelerator_data, arraysize(accelerator_data), this);
+ InputManager::Get()->AddPowerButtonObserver(this);
+}
+
+void ChromeScreenLockManager::LockScreen() {
+ chromeos::ScreenLocker::HandleLockScreenRequest();
+}
+
+bool ChromeScreenLockManager::IsCommandEnabled(int command_id) const {
+ return true;
+}
+
+bool ChromeScreenLockManager::OnAcceleratorFired(
+ int command_id,
+ const ui::Accelerator& accelerator) {
+ switch (command_id) {
+ case CMD_LOCK_SCREEN:
+ LockScreen();
+ return true;
+
+ default:
+ NOTREACHED();
+ }
+ return false;
+}
+
+void ChromeScreenLockManager::OnPowerButtonStateChanged(State state) {
+ if (state == PRESSED)
+ LockScreen();
+}
+
+} // namespace
+
+// static
+ScreenLockManager* ScreenLockManager::Create() {
+ ChromeScreenLockManager* instance = new ChromeScreenLockManager();
+ instance->Init();
+ return instance;
+}
+
+} // namespace athena
diff --git a/athena/screen_lock/public/DEPS b/athena/screen_lock/public/DEPS
new file mode 100644
index 0000000..f9aae2f
--- /dev/null
+++ b/athena/screen_lock/public/DEPS
@@ -0,0 +1,4 @@
+include_rules = [
+ "-athena/screen_lock",
+ "+athena/athena_export.h",
+]
diff --git a/athena/screen_lock/public/screen_lock_manager.h b/athena/screen_lock/public/screen_lock_manager.h
new file mode 100644
index 0000000..bde787d
--- /dev/null
+++ b/athena/screen_lock/public/screen_lock_manager.h
@@ -0,0 +1,28 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ATHENA_SCREEN_LOCK_PUBLIC_SCREEN_LOCK_MANAGER_H_
+#define ATHENA_SCREEN_LOCK_PUBLIC_SCREEN_LOCK_MANAGER_H_
+
+namespace athena {
+
+// Manages screen lock and register keyboard shortcuts.
+class ScreenLockManager {
+ public:
+ // Creates, returns and deletes the singleton object of the ScreenLockManager
+ // implementation.
+ static ScreenLockManager* Create();
+ static ScreenLockManager* Get();
+ static void Shutdown();
+
+ virtual void LockScreen() = 0;
+
+ protected:
+ // Make d-tor protected to prevent destruction without calling Shutdown.
+ virtual ~ScreenLockManager() {}
+};
+
+} // namespace athena
+
+#endif // ATHENA_SCREEN_LOCK_PUBLIC_SCREEN_LOCK_MANAGER_H_
diff --git a/athena/screen_lock/screen_lock_manager_base.cc b/athena/screen_lock/screen_lock_manager_base.cc
new file mode 100644
index 0000000..80a847b
--- /dev/null
+++ b/athena/screen_lock/screen_lock_manager_base.cc
@@ -0,0 +1,39 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "athena/screen_lock/screen_lock_manager_base.h"
+
+#include "base/logging.h"
+
+namespace athena {
+namespace {
+
+ScreenLockManager* instance = NULL;
+
+} // namespace
+
+ScreenLockManagerBase::ScreenLockManagerBase() {
+ DCHECK(!instance);
+ instance = this;
+}
+
+ScreenLockManagerBase::~ScreenLockManagerBase() {
+ DCHECK_EQ(instance, this);
+ instance = NULL;
+}
+
+// static
+ScreenLockManager* ScreenLockManager::Get() {
+ return instance;
+}
+
+// static
+void ScreenLockManager::Shutdown() {
+ if (instance) {
+ delete instance;
+ DCHECK(!instance);
+ }
+}
+
+} // namespace athena
diff --git a/athena/screen_lock/screen_lock_manager_base.h b/athena/screen_lock/screen_lock_manager_base.h
new file mode 100644
index 0000000..d202dda
--- /dev/null
+++ b/athena/screen_lock/screen_lock_manager_base.h
@@ -0,0 +1,29 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ATHENA_SCREEN_LOCK_SCREEN_LOCK_MANAGER_BASE_H_
+#define ATHENA_SCREEN_LOCK_SCREEN_LOCK_MANAGER_BASE_H_
+
+#include "athena/screen_lock/public/screen_lock_manager.h"
+#include "base/macros.h"
+
+namespace athena {
+
+// Base class for ScreenLockManager implementations. Its c-tors remembers
+// instance pointer in global static variable for ScreenLockManager::Get
+// implementation and d-tor clears that global variable.
+class ScreenLockManagerBase : public ScreenLockManager {
+ public:
+ ScreenLockManagerBase();
+
+ protected:
+ virtual ~ScreenLockManagerBase();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ScreenLockManagerBase);
+};
+
+} // namespace athena
+
+#endif // ATHENA_SCREEN_LOCK_SCREEN_LOCK_MANAGER_BASE_H_
diff --git a/athena/screen_lock/shell/shell_screen_lock_manager.cc b/athena/screen_lock/shell/shell_screen_lock_manager.cc
new file mode 100644
index 0000000..bb9c235
--- /dev/null
+++ b/athena/screen_lock/shell/shell_screen_lock_manager.cc
@@ -0,0 +1,14 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "athena/screen_lock/screen_lock_manager_base.h"
+#include "base/macros.h"
+
+namespace athena {
+
+ScreenLockManager* ScreenLockManager::Create() {
+ return NULL;
+}
+
+} // namespace athena \ No newline at end of file
diff --git a/athena/system/DEPS b/athena/system/DEPS
index 270b81f..a82ae8f 100644
--- a/athena/system/DEPS
+++ b/athena/system/DEPS
@@ -1,6 +1,7 @@
include_rules = [
"+athena/resources",
"+athena/screen/public",
+ "+athena/screen_lock/public",
"+athena/strings/grit/athena_strings.h",
"+athena/system/public",
"+athena/input/public",