diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/ui/views/ash/chrome_shell_delegate.cc | 40 | ||||
-rw-r--r-- | chrome/browser/ui/views/ash/chrome_shell_delegate.h | 13 |
2 files changed, 52 insertions, 1 deletions
diff --git a/chrome/browser/ui/views/ash/chrome_shell_delegate.cc b/chrome/browser/ui/views/ash/chrome_shell_delegate.cc index 7982438..bbf82ae 100644 --- a/chrome/browser/ui/views/ash/chrome_shell_delegate.cc +++ b/chrome/browser/ui/views/ash/chrome_shell_delegate.cc @@ -15,12 +15,16 @@ #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h" #include "chrome/browser/ui/views/ash/status_area_host_aura.h" #include "chrome/browser/ui/views/frame/browser_view.h" +#include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_switches.h" +#include "content/public/browser/notification_service.h" #include "ui/aura/window.h" #if defined(OS_CHROMEOS) +#include "base/chromeos/chromeos_version.h" #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" #include "chrome/browser/chromeos/dbus/power_manager_client.h" +#include "chrome/browser/chromeos/login/user_manager.h" #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h" #endif namespace { @@ -45,6 +49,12 @@ ChromeShellDelegate* ChromeShellDelegate::instance_ = NULL; ChromeShellDelegate::ChromeShellDelegate() { instance_ = this; +#if defined(OS_CHROMEOS) + registrar_.Add( + this, + chrome::NOTIFICATION_SESSION_STARTED, + content::NotificationService::AllSources()); +#endif } ChromeShellDelegate::~ChromeShellDelegate() { @@ -63,6 +73,19 @@ views::Widget* ChromeShellDelegate::CreateStatusArea() { return status_area_widget; } +bool ChromeShellDelegate::CanCreateLauncher() { +#if defined(OS_CHROMEOS) + // When running a Chrome OS build outside of a device (i.e. on a developer's + // workstation), pretend like we're always logged in. + if (!base::chromeos::IsRunningOnChromeOS()) + return true; + + return chromeos::UserManager::Get()->IsUserLoggedIn(); +#else + return true; +#endif +} + #if defined(OS_CHROMEOS) void ChromeShellDelegate::LockScreen() { if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { @@ -109,3 +132,20 @@ ash::SystemTrayDelegate* ChromeShellDelegate::CreateSystemTrayDelegate( return NULL; #endif } + +void ChromeShellDelegate::Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) { +#if defined(OS_CHROMEOS) + switch (type) { + case chrome::NOTIFICATION_SESSION_STARTED: + ash::Shell::GetInstance()->CreateLauncher(); + break; + default: + NOTREACHED() << "Unexpected notification " << type; + } +#else + // MSVC++ warns about switch statements without any cases. + NOTREACHED() << "Unexpected notification " << type; +#endif +} diff --git a/chrome/browser/ui/views/ash/chrome_shell_delegate.h b/chrome/browser/ui/views/ash/chrome_shell_delegate.h index 125b575..5c30d88 100644 --- a/chrome/browser/ui/views/ash/chrome_shell_delegate.h +++ b/chrome/browser/ui/views/ash/chrome_shell_delegate.h @@ -11,6 +11,8 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" +#include "content/public/browser/notification_observer.h" +#include "content/public/browser/notification_registrar.h" class StatusAreaHostAura; class StatusAreaView; @@ -19,7 +21,8 @@ namespace views { class View; } -class ChromeShellDelegate : public ash::ShellDelegate { +class ChromeShellDelegate : public ash::ShellDelegate, + public content::NotificationObserver { public: ChromeShellDelegate(); virtual ~ChromeShellDelegate(); @@ -34,6 +37,7 @@ class ChromeShellDelegate : public ash::ShellDelegate { // ash::ShellDelegate overrides; virtual views::Widget* CreateStatusArea() OVERRIDE; + virtual bool CanCreateLauncher() OVERRIDE; #if defined(OS_CHROMEOS) virtual void LockScreen() OVERRIDE; #endif @@ -48,9 +52,16 @@ class ChromeShellDelegate : public ash::ShellDelegate { virtual ash::SystemTrayDelegate* CreateSystemTrayDelegate( ash::SystemTray* tray) OVERRIDE; + // content::NotificationObserver override: + virtual void Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) OVERRIDE; + private: static ChromeShellDelegate* instance_; + content::NotificationRegistrar registrar_; + scoped_ptr<StatusAreaHostAura> status_area_host_; DISALLOW_COPY_AND_ASSIGN(ChromeShellDelegate); |