diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-21 00:05:41 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-21 00:05:41 +0000 |
commit | 1410fb00866fd282414a32e04b300230a51bbe1c (patch) | |
tree | 8a737a4414af262de364b3e56af898e990d9dc23 /chrome | |
parent | 9fe2d0edd3d21c60886ebeb449fc057ace9ebe76 (diff) | |
download | chromium_src-1410fb00866fd282414a32e04b300230a51bbe1c.zip chromium_src-1410fb00866fd282414a32e04b300230a51bbe1c.tar.gz chromium_src-1410fb00866fd282414a32e04b300230a51bbe1c.tar.bz2 |
ash/chromeos: Defer creating launcher until after login.
This fixes several issues (blank titles in context menu,
missing icons, pinned apps not getting restored) caused by
launcher-related code that was initialized at startup and
cached the pre-login profile. This change makes us defer
initialization of the launcher until after the user has
logged in when running on Chrome OS devices.
To test:
- Logged in on a Chrome OS device and checked that
previously-pinned apps appear in the launcher and that
non-component extensions have icons and titles in their
context menus.
- Killed the Chrome process and checked that the launcher is
visible when it restarts.
- Ran Chrome and ash_shell on a Linux workstation and
checked that the launcher is present.
BUG=118129,118945
TEST=manual: see above
Review URL: https://chromiumcodereview.appspot.com/9733024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127841 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-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); |