summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorgavinp@chromium.org <gavinp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-17 14:47:48 +0000
committergavinp@chromium.org <gavinp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-17 14:47:48 +0000
commitf2192efaf719d6e54459fde8ef38093e08e194e0 (patch)
tree26b06fa106a8ab701dcda5e4c00f959d9d82a700 /chrome/browser
parentb0b94f5c503e44cc2190a9c7c4d20425f77e6a42 (diff)
downloadchromium_src-f2192efaf719d6e54459fde8ef38093e08e194e0.zip
chromium_src-f2192efaf719d6e54459fde8ef38093e08e194e0.tar.gz
chromium_src-f2192efaf719d6e54459fde8ef38093e08e194e0.tar.bz2
Revert 194578 "Add ash SessionStateDelegate"
> Add ash SessionStateDelegate > > This CL refactors the ShellDelegate by adding a SessionStateDelegate to > which methods dealing with the session state can be moved. This cleans up > the huge ShellDelegate interface and paves the way for further Chrome OS > multiprofile work which will need to add several new methods related to > the session state. > > This CL is only the first step. Several other methods should also move to > SessionStateDelegate but I do not want to overburden a single CL. > > BUG=None > TEST=Manual and browser/unit tests > > TBR=sky (for c/b/idle_chromeos.cc and c/chrome_browser_ui.gypi) > > Review URL: https://codereview.chromium.org/14295008 TBR=bartfab@google.com Review URL: https://codereview.chromium.org/14200034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194589 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/chromeos/dbus/printer_service_provider.cc7
-rw-r--r--chrome/browser/idle_chromeos.cc3
-rw-r--r--chrome/browser/ui/ash/chrome_shell_delegate.cc11
-rw-r--r--chrome/browser/ui/ash/chrome_shell_delegate.h8
-rw-r--r--chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc48
-rw-r--r--chrome/browser/ui/ash/chrome_shell_delegate_views.cc24
-rw-r--r--chrome/browser/ui/ash/session_state_delegate.h29
-rw-r--r--chrome/browser/ui/ash/session_state_delegate_chromeos.cc49
-rw-r--r--chrome/browser/ui/ash/session_state_delegate_views.cc33
9 files changed, 88 insertions, 124 deletions
diff --git a/chrome/browser/chromeos/dbus/printer_service_provider.cc b/chrome/browser/chromeos/dbus/printer_service_provider.cc
index c6d4d74..3db81cd 100644
--- a/chrome/browser/chromeos/dbus/printer_service_provider.cc
+++ b/chrome/browser/chromeos/dbus/printer_service_provider.cc
@@ -4,8 +4,8 @@
#include "chrome/browser/chromeos/dbus/printer_service_provider.h"
-#include "ash/session_state_delegate.h"
#include "ash/shell.h"
+#include "ash/shell_delegate.h"
#include "ash/wm/window_util.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
@@ -60,9 +60,8 @@ void FindOrOpenCloudPrintPage(const std::string& /* vendor */,
const std::string& /* product */) {
UMA_HISTOGRAM_ENUMERATION("PrinterService.PrinterServiceEvent", PRINTER_ADDED,
PRINTER_SERVICE_EVENT_MAX);
- if (!ash::Shell::GetInstance()->session_state_delegate()->
- IsActiveUserSessionStarted() ||
- ash::Shell::GetInstance()->session_state_delegate()->IsScreenLocked()) {
+ if (!ash::Shell::GetInstance()->delegate()->IsSessionStarted() ||
+ ash::Shell::GetInstance()->delegate()->IsScreenLocked()) {
return;
}
diff --git a/chrome/browser/idle_chromeos.cc b/chrome/browser/idle_chromeos.cc
index 9bb2f12..7977c41 100644
--- a/chrome/browser/idle_chromeos.cc
+++ b/chrome/browser/idle_chromeos.cc
@@ -4,7 +4,6 @@
#include "chrome/browser/idle.h"
-#include "ash/session_state_delegate.h"
#include "ash/shell.h"
#include "ash/wm/user_activity_detector.h"
#include "base/time.h"
@@ -16,5 +15,5 @@ void CalculateIdleTime(IdleTimeCallback notify) {
}
bool CheckIdleStateIsLocked() {
- return ash::Shell::GetInstance()->session_state_delegate()->IsScreenLocked();
+ return ash::Shell::GetInstance()->IsScreenLocked();
}
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.cc b/chrome/browser/ui/ash/chrome_shell_delegate.cc
index 1fd4f9a..2ecb35a 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate.cc
+++ b/chrome/browser/ui/ash/chrome_shell_delegate.cc
@@ -8,7 +8,6 @@
#include "ash/host/root_window_host_factory.h"
#include "ash/launcher/launcher_types.h"
#include "ash/magnifier/magnifier_constants.h"
-#include "ash/session_state_delegate.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/system/tray/system_tray_delegate.h"
#include "ash/wm/window_properties.h"
@@ -27,7 +26,6 @@
#include "chrome/browser/ui/ash/ash_keyboard_controller_proxy.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/ash/launcher/launcher_context_menu.h"
-#include "chrome/browser/ui/ash/session_state_delegate.h"
#include "chrome/browser/ui/ash/user_action_handler.h"
#include "chrome/browser/ui/ash/window_positioner.h"
#include "chrome/browser/ui/browser.h"
@@ -81,6 +79,11 @@ bool ChromeShellDelegate::IsRunningInForcedAppMode() const {
return chrome::IsRunningInForcedAppMode();
}
+void ChromeShellDelegate::UnlockScreen() {
+ // This is used only for testing thus far.
+ NOTIMPLEMENTED();
+}
+
void ChromeShellDelegate::Exit() {
chrome::AttemptUserExit();
}
@@ -195,10 +198,6 @@ ash::LauncherDelegate* ChromeShellDelegate::CreateLauncherDelegate(
return launcher_delegate_;
}
-ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() {
- return new SessionStateDelegate;
-}
-
aura::client::UserActionClient* ChromeShellDelegate::CreateUserActionClient() {
return new UserActionHandler;
}
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.h b/chrome/browser/ui/ash/chrome_shell_delegate.h
index 4158f21..bbe922d 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate.h
+++ b/chrome/browser/ui/ash/chrome_shell_delegate.h
@@ -47,9 +47,16 @@ class ChromeShellDelegate : public ash::ShellDelegate,
}
// ash::ShellDelegate overrides;
+ virtual bool IsUserLoggedIn() const OVERRIDE;
+ virtual bool IsSessionStarted() const OVERRIDE;
+ virtual bool IsGuestSession() const OVERRIDE;
virtual bool IsFirstRunAfterBoot() const OVERRIDE;
virtual bool IsMultiProfilesEnabled() const OVERRIDE;
virtual bool IsRunningInForcedAppMode() const OVERRIDE;
+ virtual bool CanLockScreen() const OVERRIDE;
+ virtual void LockScreen() OVERRIDE;
+ virtual void UnlockScreen() OVERRIDE;
+ virtual bool IsScreenLocked() const OVERRIDE;
virtual void PreInit() OVERRIDE;
virtual void Shutdown() OVERRIDE;
virtual void Exit() OVERRIDE;
@@ -82,7 +89,6 @@ class ChromeShellDelegate : public ash::ShellDelegate,
virtual ash::SystemTrayDelegate* CreateSystemTrayDelegate() OVERRIDE;
virtual ash::UserWallpaperDelegate* CreateUserWallpaperDelegate() OVERRIDE;
virtual ash::CapsLockDelegate* CreateCapsLockDelegate() OVERRIDE;
- virtual ash::SessionStateDelegate* CreateSessionStateDelegate() OVERRIDE;
virtual aura::client::UserActionClient* CreateUserActionClient() OVERRIDE;
virtual void OpenFeedbackPage() OVERRIDE;
virtual void RecordUserMetricsAction(ash::UserMetricsAction action) OVERRIDE;
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc b/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc
index 5745189..3440703 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc
+++ b/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc
@@ -8,6 +8,7 @@
#include "ash/system/chromeos/network/network_observer.h"
#include "ash/system/tray/system_tray_notifier.h"
#include "ash/wm/window_util.h"
+#include "base/chromeos/chromeos_version.h"
#include "base/command_line.h"
#include "base/prefs/pref_service.h"
#include "base/utf_string_conversions.h"
@@ -23,6 +24,7 @@
#include "chrome/browser/chromeos/input_method/input_method_configuration.h"
#include "chrome/browser/chromeos/input_method/input_method_manager.h"
#include "chrome/browser/chromeos/login/screen_locker.h"
+#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/webui_login_display_host.h"
#include "chrome/browser/chromeos/system/ash_system_tray_delegate.h"
#include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h"
@@ -41,17 +43,60 @@
#include "chromeos/chromeos_switches.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power_manager_client.h"
+#include "chromeos/dbus/session_manager_client.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
+bool ChromeShellDelegate::IsUserLoggedIn() const {
+ // When running a Chrome OS build outside of a device (i.e. on a developer's
+ // workstation) and not running as login-manager, pretend like we're always
+ // logged in.
+ if (!base::chromeos::IsRunningOnChromeOS() &&
+ !CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kLoginManager)) {
+ return true;
+ }
+
+ return chromeos::UserManager::Get()->IsUserLoggedIn();
+}
+
+bool ChromeShellDelegate::IsSessionStarted() const {
+ // Returns true if we're logged in and browser has been started
+ return chromeos::UserManager::Get()->IsSessionStarted();
+}
+
+bool ChromeShellDelegate::IsGuestSession() const {
+ return CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kGuestSession);
+}
+
bool ChromeShellDelegate::IsFirstRunAfterBoot() const {
return CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kFirstBoot);
}
+bool ChromeShellDelegate::CanLockScreen() const {
+ return chromeos::UserManager::Get()->CanCurrentUserLock();
+}
+
+void ChromeShellDelegate::LockScreen() {
+ if (CanLockScreen()) {
+ // TODO(antrim) : additional logging for crbug/173178
+ LOG(WARNING) << "Requesting screen lock from ChromeShellDelegate";
+ chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->
+ RequestLockScreen();
+ }
+}
+
+bool ChromeShellDelegate::IsScreenLocked() const {
+ if (!chromeos::ScreenLocker::default_screen_locker())
+ return false;
+ return chromeos::ScreenLocker::default_screen_locker()->locked();
+}
+
void ChromeShellDelegate::PreInit() {
chromeos::LoadDisplayPreferences(IsFirstRunAfterBoot());
}
@@ -202,6 +247,9 @@ void ChromeShellDelegate::ShowKeyboardOverlay() {
}
bool ChromeShellDelegate::ShouldAlwaysShowAccessibilityMenu() const {
+ if (!IsUserLoggedIn())
+ return true;
+
Profile* profile = ProfileManager::GetDefaultProfile();
if (!profile)
return false;
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate_views.cc b/chrome/browser/ui/ash/chrome_shell_delegate_views.cc
index 8bf7dca..7d4d1ea 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate_views.cc
+++ b/chrome/browser/ui/ash/chrome_shell_delegate_views.cc
@@ -8,10 +8,34 @@
#include "chrome/browser/ui/ash/caps_lock_delegate_views.h"
#include "chrome/browser/ui/ash/window_positioner.h"
+bool ChromeShellDelegate::IsUserLoggedIn() const {
+ return true;
+}
+
+// Returns true if we're logged in and browser has been started
+bool ChromeShellDelegate::IsSessionStarted() const {
+ return true;
+}
+
+bool ChromeShellDelegate::IsGuestSession() const {
+ return false;
+}
+
bool ChromeShellDelegate::IsFirstRunAfterBoot() const {
return false;
}
+bool ChromeShellDelegate::CanLockScreen() const {
+ return false;
+}
+
+void ChromeShellDelegate::LockScreen() {
+}
+
+bool ChromeShellDelegate::IsScreenLocked() const {
+ return false;
+}
+
void ChromeShellDelegate::PreInit() {
}
diff --git a/chrome/browser/ui/ash/session_state_delegate.h b/chrome/browser/ui/ash/session_state_delegate.h
deleted file mode 100644
index 9209c45..0000000
--- a/chrome/browser/ui/ash/session_state_delegate.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2013 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 CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_H_
-#define CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_H_
-
-#include "ash/session_state_delegate.h"
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-
-class SessionStateDelegate : public ash::SessionStateDelegate {
- public:
- SessionStateDelegate();
- virtual ~SessionStateDelegate();
-
- // ash::SessionStateDelegate:
- virtual bool HasActiveUser() const OVERRIDE;
- virtual bool IsActiveUserSessionStarted() const OVERRIDE;
- virtual bool CanLockScreen() const OVERRIDE;
- virtual bool IsScreenLocked() const OVERRIDE;
- virtual void LockScreen() OVERRIDE;
- virtual void UnlockScreen() OVERRIDE;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(SessionStateDelegate);
-};
-
-#endif // CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_H_
diff --git a/chrome/browser/ui/ash/session_state_delegate_chromeos.cc b/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
deleted file mode 100644
index 24936e9..0000000
--- a/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) 2013 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 "chrome/browser/ui/ash/session_state_delegate.h"
-
-#include "base/logging.h"
-#include "chrome/browser/chromeos/login/screen_locker.h"
-#include "chrome/browser/chromeos/login/user_manager.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/session_manager_client.h"
-
-SessionStateDelegate::SessionStateDelegate() {
-}
-
-SessionStateDelegate::~SessionStateDelegate() {
-}
-
-bool SessionStateDelegate::HasActiveUser() const {
- return chromeos::UserManager::Get()->IsUserLoggedIn();
-}
-
-bool SessionStateDelegate::IsActiveUserSessionStarted() const {
- return chromeos::UserManager::Get()->IsSessionStarted();
-}
-
-bool SessionStateDelegate::CanLockScreen() const {
- return chromeos::UserManager::Get()->CanCurrentUserLock();
-}
-
-bool SessionStateDelegate::IsScreenLocked() const {
- return chromeos::ScreenLocker::default_screen_locker() &&
- chromeos::ScreenLocker::default_screen_locker()->locked();
-}
-
-void SessionStateDelegate::LockScreen() {
- if (!CanLockScreen())
- return;
-
- // TODO(antrim): Additional logging for http://crbug.com/173178.
- LOG(WARNING) << "Requesting screen lock from SessionStateDelegate";
- chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->
- RequestLockScreen();
-}
-
-void SessionStateDelegate::UnlockScreen() {
- // This is used only for testing thus far.
- NOTIMPLEMENTED();
-}
diff --git a/chrome/browser/ui/ash/session_state_delegate_views.cc b/chrome/browser/ui/ash/session_state_delegate_views.cc
deleted file mode 100644
index e8e4e51..0000000
--- a/chrome/browser/ui/ash/session_state_delegate_views.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2013 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 "chrome/browser/ui/ash/session_state_delegate.h"
-
-SessionStateDelegate::SessionStateDelegate() {
-}
-
-SessionStateDelegate::~SessionStateDelegate() {
-}
-
-bool SessionStateDelegate::HasActiveUser() const {
- return true;
-}
-
-bool SessionStateDelegate::IsActiveUserSessionStarted() const {
- return true;
-}
-
-bool SessionStateDelegate::CanLockScreen() const {
- return false;
-}
-
-bool SessionStateDelegate::IsScreenLocked() const {
- return false;
-}
-
-void SessionStateDelegate::LockScreen() {
-}
-
-void SessionStateDelegate::UnlockScreen() {
-}