diff options
| -rw-r--r-- | chrome/browser/chromeos/cros/update_library.cc | 12 | ||||
| -rw-r--r-- | chrome/browser/views/toolbar_view.cc | 19 | ||||
| -rw-r--r-- | chrome/browser/views/toolbar_view.h | 3 |
3 files changed, 30 insertions, 4 deletions
diff --git a/chrome/browser/chromeos/cros/update_library.cc b/chrome/browser/chromeos/cros/update_library.cc index 26a11ef..79b1bba 100644 --- a/chrome/browser/chromeos/cros/update_library.cc +++ b/chrome/browser/chromeos/cros/update_library.cc @@ -8,6 +8,8 @@ #include "base/string_util.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/chromeos/cros/cros_library.h" +#include "chrome/common/notification_service.h" +#include "chrome/common/notification_type.h" namespace chromeos { @@ -74,6 +76,15 @@ class UpdateLibraryImpl : public UpdateLibrary { status_ = status; FOR_EACH_OBSERVER(Observer, observers_, UpdateStatusChanged(this)); + + // If the update is ready to install, send a notification so that Chrome + // can update the UI. + if (status_.status == UPDATE_STATUS_UPDATED_NEED_REBOOT) { + NotificationService::current()->Notify( + NotificationType::UPGRADE_RECOMMENDED, + Source<UpdateLibrary>(this), + NotificationService::NoDetails()); + } } ObserverList<Observer> observers_; @@ -119,4 +130,3 @@ UpdateLibrary* UpdateLibrary::GetImpl(bool stub) { // Allows InvokeLater without adding refcounting. This class is a Singleton and // won't be deleted until it's last InvokeLater is run. DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::UpdateLibraryImpl); - diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc index d1ad65b..277a7ef 100644 --- a/chrome/browser/views/toolbar_view.cc +++ b/chrome/browser/views/toolbar_view.cc @@ -9,6 +9,10 @@ #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_window.h" +#if defined(OS_CHROMEOS) +#include "chrome/browser/chromeos/cros/cros_library.h" +#include "chrome/browser/chromeos/cros/update_library.h" +#endif #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/themes/browser_theme_provider.h" @@ -90,7 +94,7 @@ ToolbarView::ToolbarView(Browser* browser) IDR_LOCATIONBG_POPUPMODE_EDGE); } - if (!Singleton<UpgradeDetector>::get()->notify_upgrade()) { + if (!IsUpgradeRecommended()) { registrar_.Add(this, NotificationType::UPGRADE_RECOMMENDED, NotificationService::AllSources()); } @@ -162,7 +166,7 @@ void ToolbarView::Init(Profile* profile) { app_menu_->SetID(VIEW_ID_APP_MENU); // Catch the case where the window is created after we detect a new version. - if (Singleton<UpgradeDetector>::get()->notify_upgrade()) + if (IsUpgradeRecommended()) ShowUpgradeReminder(); LoadImages(); @@ -513,6 +517,15 @@ void ToolbarView::RemoveToolbarFocus() { //////////////////////////////////////////////////////////////////////////////// // ToolbarView, private: +bool ToolbarView::IsUpgradeRecommended() { +#if defined(OS_CHROMEOS) + return (chromeos::CrosLibrary::Get()->GetUpdateLibrary()->status().status == + chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT); +#else + return (Singleton<UpgradeDetector>::get()->notify_upgrade()); +#endif +} + int ToolbarView::PopupTopSpacing() const { return GetWindow()->GetNonClientView()->UseNativeFrame() ? 0 : kPopupTopSpacingNonGlass; @@ -590,7 +603,7 @@ SkBitmap ToolbarView::GetAppMenuIcon(views::CustomButton::ButtonState state) { } SkBitmap icon = *tp->GetBitmapNamed(id); - if (!Singleton<UpgradeDetector>::get()->notify_upgrade()) + if (!IsUpgradeRecommended()) return icon; // Draw the chrome app menu icon onto the canvas. diff --git a/chrome/browser/views/toolbar_view.h b/chrome/browser/views/toolbar_view.h index d95111b..4031b4a 100644 --- a/chrome/browser/views/toolbar_view.h +++ b/chrome/browser/views/toolbar_view.h @@ -129,6 +129,9 @@ class ToolbarView : public AccessibleToolbarView, virtual void RemoveToolbarFocus(); private: + // Returns true if we should show the upgrade recommended dot. + bool IsUpgradeRecommended(); + // Returns the number of pixels above the location bar in non-normal display. int PopupTopSpacing() const; |
