summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/generated_resources.grd22
-rw-r--r--chrome/app/theme/notification_update.pngbin0 -> 1878 bytes
-rw-r--r--chrome/app/theme/theme_resources.grd1
-rw-r--r--chrome/browser/browser_init.cc6
-rw-r--r--chrome/browser/chromeos/cros/cros_library.cc19
-rw-r--r--chrome/browser/chromeos/cros/cros_library.h8
-rw-r--r--chrome/browser/chromeos/cros/mock_update_library.h30
-rw-r--r--chrome/browser/chromeos/cros/update_library.cc68
-rw-r--r--chrome/browser/chromeos/cros/update_library.h104
-rw-r--r--chrome/browser/chromeos/update_browsertest.cc121
-rw-r--r--chrome/browser/chromeos/update_observer.cc66
-rw-r--r--chrome/browser/chromeos/update_observer.h37
-rw-r--r--chrome/chrome_browser.gypi4
-rw-r--r--chrome/chrome_tests.gypi1
14 files changed, 487 insertions, 0 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 19a5e2a..4825c04 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -7596,6 +7596,28 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_LOW_BATTERY_MESSAGE" desc="Message for low battery notification">
Less than <ph name="MINUTES">$1<ex>15 mins left</ex></ph>.
</message>
+ <message name="IDS_UPDATE_TITLE" desc="Title for update notification">
+ System Update
+ </message>
+ <message name="IDS_UPDATE_ERROR" desc="Notification for failed update">
+ System update failed.
+ </message>
+ <message name="IDS_UPDATE_AVAILABLE" desc="Notification for available update">
+ System update available&#x2026;
+ </message>
+ <message name="IDS_UPDATE_DOWNLOADING" desc="Notification for update download progress">
+ System update downloading: <ph name="PERCENT">$1<ex>10</ex></ph>&#37; complete.
+ </message>
+ <message name="IDS_UPDATE_VERIFYING" desc="Notification for update verifying">
+ Verifying system update&#x2026;
+ </message>
+ <message name="IDS_UPDATE_FINALIZING" desc="Notification for update finalizing">
+ Finalizing system update&#x2026;
+ </message>
+ <message name="IDS_UPDATE_COMPLETED" desc="Notification for update completed">
+ System update complete. Please restart the system by pressing the power
+ button, wait for the system to power down, then press the power button again.
+ </message>
<message name="IDS_INSTALLING_UPDATE" desc="Label shown on the updates installation screen">
Please wait while <ph name="PRODUCT_NAME">$1<ex>Chrome OS</ex></ph> installs an important update.\nYour computer will restart after this is complete.
</message>
diff --git a/chrome/app/theme/notification_update.png b/chrome/app/theme/notification_update.png
new file mode 100644
index 0000000..2b9601f
--- /dev/null
+++ b/chrome/app/theme/notification_update.png
Binary files differ
diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd
index f8ee778..e1e690c 100644
--- a/chrome/app/theme/theme_resources.grd
+++ b/chrome/app/theme/theme_resources.grd
@@ -462,6 +462,7 @@
<include name="IDR_NOTIFICATION_NETWORK_FAILED" file="notification_network_failed.png" type="BINDATA" />
<include name="IDR_NOTIFICATION_NETWORK_OPEN" file="notification_network_open.png" type="BINDATA" />
<include name="IDR_NOTIFICATION_NETWORK_WARNING" file="notification_network_warning.png" type="BINDATA" />
+ <include name="IDR_NOTIFICATION_UPDATE" file="notification_update.png" type="BINDATA" />
<include name="IDR_SPINNER" file="spinner.png" type="BINDATA" />
<include name="IDR_STATUSBAR_BATTERY_CHARGED" file="statusbar_battery_charged.png" type="BINDATA" />
<include name="IDR_STATUSBAR_BATTERY_CHARGING_1" file="statusbar_battery1c.png" type="BINDATA" />
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 7a651e5..495ce1c 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -78,6 +78,7 @@
#include "chrome/browser/chromeos/network_message_observer.h"
#include "chrome/browser/chromeos/network_state_notifier.h"
#include "chrome/browser/chromeos/system_key_event_listener.h"
+#include "chrome/browser/chromeos/update_observer.h"
#include "chrome/browser/chromeos/usb_mount_observer.h"
#include "chrome/browser/chromeos/wm_message_listener.h"
#include "chrome/browser/chromeos/wm_overview_controller.h"
@@ -432,6 +433,11 @@ bool BrowserInit::LaunchBrowser(
chromeos::CrosLibrary::Get()->GetPowerLibrary()->AddObserver(
low_battery_observer);
+ static chromeos::UpdateObserver* update_observer =
+ new chromeos::UpdateObserver(profile);
+ chromeos::CrosLibrary::Get()->GetUpdateLibrary()->AddObserver(
+ update_observer);
+
static chromeos::NetworkMessageObserver* network_message_observer =
new chromeos::NetworkMessageObserver(profile);
chromeos::CrosLibrary::Get()->GetNetworkLibrary()->AddObserver(
diff --git a/chrome/browser/chromeos/cros/cros_library.cc b/chrome/browser/chromeos/cros/cros_library.cc
index e9b834d..a9e469d 100644
--- a/chrome/browser/chromeos/cros/cros_library.cc
+++ b/chrome/browser/chromeos/cros/cros_library.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/chromeos/cros/synaptics_library.h"
#include "chrome/browser/chromeos/cros/syslogs_library.h"
#include "chrome/browser/chromeos/cros/system_library.h"
+#include "chrome/browser/chromeos/cros/update_library.h"
namespace chromeos {
@@ -33,6 +34,7 @@ CrosLibrary::CrosLibrary() : library_loader_(NULL),
synaptics_lib_(NULL),
syslogs_lib_(NULL),
system_lib_(NULL),
+ update_lib_(NULL),
own_library_loader_(true),
own_cryptohome_lib_(true),
own_keyboard_lib_(true),
@@ -46,6 +48,7 @@ CrosLibrary::CrosLibrary() : library_loader_(NULL),
own_synaptics_lib_(true),
own_syslogs_lib_(true),
own_system_lib_(true),
+ own_update_lib_(true),
loaded_(false),
load_error_(false),
test_api_(NULL) {
@@ -79,6 +82,8 @@ CrosLibrary::~CrosLibrary() {
delete syslogs_lib_;
if (own_system_lib_)
delete system_lib_;
+ if (own_update_lib_)
+ delete update_lib_;
delete test_api_;
}
@@ -159,6 +164,12 @@ SystemLibrary* CrosLibrary::GetSystemLibrary() {
return system_lib_;
}
+UpdateLibrary* CrosLibrary::GetUpdateLibrary() {
+ if (!update_lib_)
+ update_lib_ = new UpdateLibraryImpl();
+ return update_lib_;
+}
+
bool CrosLibrary::EnsureLoaded() {
if (!loaded_ && !load_error_) {
if (!library_loader_)
@@ -281,4 +292,12 @@ void CrosLibrary::TestApi::SetSystemLibrary(SystemLibrary* library,
library_->system_lib_ = library;
}
+void CrosLibrary::TestApi::SetUpdateLibrary(UpdateLibrary* library,
+ bool own) {
+ if (library_->update_lib_)
+ delete library_->update_lib_;
+ library_->own_update_lib_ = own;
+ library_->update_lib_ = library;
+}
+
} // namespace chromeos
diff --git a/chrome/browser/chromeos/cros/cros_library.h b/chrome/browser/chromeos/cros/cros_library.h
index 286e532..b08254a 100644
--- a/chrome/browser/chromeos/cros/cros_library.h
+++ b/chrome/browser/chromeos/cros/cros_library.h
@@ -24,6 +24,7 @@ class SpeechSynthesisLibrary;
class SynapticsLibrary;
class SyslogsLibrary;
class SystemLibrary;
+class UpdateLibrary;
// This class handles access to sub-parts of ChromeOS library. it provides
// a level of indirection so individual libraries that it exposes can
@@ -64,6 +65,8 @@ class CrosLibrary {
void SetSyslogsLibrary(SyslogsLibrary* library, bool own);
// Setter for SystemLibrary.
void SetSystemLibrary(SystemLibrary* library, bool own);
+ // Setter for UpdateLibrary.
+ void SetUpdateLibrary(UpdateLibrary* library, bool own);
private:
friend class CrosLibrary;
@@ -110,6 +113,9 @@ class CrosLibrary {
// This gets the singleton SystemLibrary.
SystemLibrary* GetSystemLibrary();
+ // This gets the singleton UpdateLibrary.
+ UpdateLibrary* GetUpdateLibrary();
+
// Getter for Test API that gives access to internal members of this class.
TestApi* GetTestApi();
@@ -142,6 +148,7 @@ class CrosLibrary {
SynapticsLibrary* synaptics_lib_;
SyslogsLibrary* syslogs_lib_;
SystemLibrary* system_lib_;
+ UpdateLibrary* update_lib_;
bool own_library_loader_;
bool own_cryptohome_lib_;
@@ -156,6 +163,7 @@ class CrosLibrary {
bool own_synaptics_lib_;
bool own_syslogs_lib_;
bool own_system_lib_;
+ bool own_update_lib_;
// True if libcros was successfully loaded.
bool loaded_;
diff --git a/chrome/browser/chromeos/cros/mock_update_library.h b/chrome/browser/chromeos/cros/mock_update_library.h
new file mode 100644
index 0000000..4e1e7f6
--- /dev/null
+++ b/chrome/browser/chromeos/cros/mock_update_library.h
@@ -0,0 +1,30 @@
+// Copyright (c) 2010 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_CHROMEOS_CROS_MOCK_UPDATE_LIBRARY_H_
+#define CHROME_BROWSER_CHROMEOS_CROS_MOCK_UPDATE_LIBRARY_H_
+
+#include "base/observer_list.h"
+#include "chrome/browser/chromeos/cros/update_library.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+namespace chromeos {
+
+class MockUpdateLibrary : public UpdateLibrary {
+ public:
+ MockUpdateLibrary() {}
+ virtual ~MockUpdateLibrary() {}
+ MOCK_METHOD1(AddObserver, void(Observer*)); // NOLINT
+ MOCK_METHOD1(RemoveObserver, void(Observer*)); // NOLINT
+
+ MOCK_CONST_METHOD0(status, const Status&(void));
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MockUpdateLibrary);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_CROS_MOCK_UPDATE_LIBRARY_H_
+
diff --git a/chrome/browser/chromeos/cros/update_library.cc b/chrome/browser/chromeos/cros/update_library.cc
new file mode 100644
index 0000000..0ea5f2c
--- /dev/null
+++ b/chrome/browser/chromeos/cros/update_library.cc
@@ -0,0 +1,68 @@
+// Copyright (c) 2009 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/chromeos/cros/update_library.h"
+
+#include "base/message_loop.h"
+#include "base/string_util.h"
+#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/chromeos/cros/cros_library.h"
+
+// 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);
+
+namespace chromeos {
+
+UpdateLibraryImpl::UpdateLibraryImpl()
+ : status_connection_(NULL) {
+ if (CrosLibrary::Get()->EnsureLoaded()) {
+ Init();
+ }
+}
+
+UpdateLibraryImpl::~UpdateLibraryImpl() {
+ if (status_connection_) {
+ DisconnectUpdateProgress(status_connection_);
+ }
+}
+
+void UpdateLibraryImpl::AddObserver(Observer* observer) {
+ observers_.AddObserver(observer);
+}
+
+void UpdateLibraryImpl::RemoveObserver(Observer* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+const UpdateLibrary::Status& UpdateLibraryImpl::status() const {
+ return status_;
+}
+
+// static
+void UpdateLibraryImpl::ChangedHandler(void* object,
+ const UpdateProgress& status) {
+ UpdateLibraryImpl* power = static_cast<UpdateLibraryImpl*>(object);
+ power->UpdateStatus(Status(status));
+}
+
+void UpdateLibraryImpl::Init() {
+ status_connection_ = MonitorUpdateStatus(&ChangedHandler, this);
+}
+
+void UpdateLibraryImpl::UpdateStatus(const Status& status) {
+ // Make sure we run on UI thread.
+ if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) {
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &UpdateLibraryImpl::UpdateStatus, status));
+ return;
+ }
+
+ status_ = status;
+ FOR_EACH_OBSERVER(Observer, observers_, Changed(this));
+}
+
+} // namespace chromeos
+
diff --git a/chrome/browser/chromeos/cros/update_library.h b/chrome/browser/chromeos/cros/update_library.h
new file mode 100644
index 0000000..fe4710b
--- /dev/null
+++ b/chrome/browser/chromeos/cros/update_library.h
@@ -0,0 +1,104 @@
+// Copyright (c) 2009 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_CHROMEOS_CROS_UPDATE_LIBRARY_H_
+#define CHROME_BROWSER_CHROMEOS_CROS_UPDATE_LIBRARY_H_
+
+#include <string>
+
+#include "base/observer_list.h"
+#include "base/singleton.h"
+#include "base/time.h"
+#include "third_party/cros/chromeos_update_engine.h"
+
+namespace chromeos {
+
+// This interface defines interaction with the ChromeOS update library APIs.
+// Classes can add themselves as observers. Users can get an instance of this
+// library class like this: chromeos::CrosLibrary::Get()->GetUpdateLibrary()
+
+class UpdateLibrary {
+ public:
+ // TODO(seanparent): Should make the UpdateProgress type copyable.
+ // We need to copy it to bind it for a deferred notification.
+ // Modifying the cros library just for that, for a single use case,
+ // isn't worth it. Instead we define this a local Status struct that
+ // is copyable.
+
+ struct Status {
+ Status()
+ : status(UPDATE_STATUS_IDLE),
+ download_progress(0.0),
+ last_checked_time(0),
+ new_size(0) {
+ }
+
+ explicit Status(const UpdateProgress& x) :
+ status(x.status_),
+ download_progress(x.download_progress_),
+ last_checked_time(x.last_checked_time_),
+ new_version(x.new_version_),
+ new_size(x.new_size_) {
+ }
+
+ UpdateStatusOperation status;
+ double download_progress; // 0.0 - 1.0
+ int64_t last_checked_time; // As reported by std::time().
+ std::string new_version;
+ int64_t new_size; // Valid during DOWNLOADING, in bytes.
+ };
+
+ class Observer {
+ public:
+ virtual ~Observer() { }
+ virtual void Changed(UpdateLibrary* obj) = 0;
+ };
+
+ virtual ~UpdateLibrary() {}
+ virtual void AddObserver(Observer* observer) = 0;
+ virtual void RemoveObserver(Observer* observer) = 0;
+
+ virtual const Status& status() const = 0;
+};
+
+class UpdateLibraryImpl : public UpdateLibrary {
+ public:
+ UpdateLibraryImpl();
+ virtual ~UpdateLibraryImpl();
+
+ // UpdateLibrary overrides.
+ virtual void AddObserver(Observer* observer);
+ virtual void RemoveObserver(Observer* observer);
+
+ virtual const Status& status() const;
+
+ private:
+
+ // This method is called when there's a change in status.
+ // This method is called on a background thread.
+ static void ChangedHandler(void* object, const UpdateProgress& status);
+
+ // This methods starts the monitoring of power changes.
+ void Init();
+
+ // Called by the handler to update the power status.
+ // This will notify all the Observers.
+ void UpdateStatus(const Status& status);
+
+ ObserverList<Observer> observers_;
+
+ // A reference to the update api, to allow callbacks when the update
+ // status changes.
+ UpdateStatusConnection status_connection_;
+
+ // The latest power status.
+ Status status_;
+
+ DISALLOW_COPY_AND_ASSIGN(UpdateLibraryImpl);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_CROS_UPDATE_LIBRARY_H_
+
diff --git a/chrome/browser/chromeos/update_browsertest.cc b/chrome/browser/chromeos/update_browsertest.cc
new file mode 100644
index 0000000..9dca0bb
--- /dev/null
+++ b/chrome/browser/chromeos/update_browsertest.cc
@@ -0,0 +1,121 @@
+// Copyright (c) 2010 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 "base/ref_counted.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/test/automation/dom_element_proxy.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_list.h"
+#include "chrome/browser/chromeos/update_observer.h"
+#include "chrome/browser/chromeos/cros/mock_update_library.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/url_constants.h"
+#include "chrome/test/in_process_browser_test.h"
+#include "chrome/test/ui_test_utils.h"
+
+using ::testing::AnyNumber;
+using ::testing::InvokeWithoutArgs;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using ::testing::_;
+using ::testing::Invoke;
+using ::testing::Exactly;
+
+namespace {
+
+typedef ObserverList<chromeos::UpdateLibrary::Observer> Observers;
+
+void CallObservers(chromeos::MockUpdateLibrary* lib,
+ Observers* observers,
+ const chromeos::UpdateLibrary::Status& x) {
+ EXPECT_CALL(*lib, status())
+ .Times(AnyNumber())
+ .WillRepeatedly((ReturnRef(x)))
+ .RetiresOnSaturation();
+ FOR_EACH_OBSERVER(chromeos::UpdateLibrary::Observer, *observers,
+ Changed(lib));
+}
+
+void FireSuccessSequence(chromeos::MockUpdateLibrary* lib,
+ Observers* observer) {
+ chromeos::UpdateLibrary::Status status;
+
+ status.status = chromeos::UPDATE_STATUS_IDLE;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_CHECKING_FOR_UPDATE;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_UPDATE_AVAILABLE;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_DOWNLOADING;
+ status.download_progress = 10;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_DOWNLOADING;
+ status.download_progress = 50;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_DOWNLOADING;
+ status.download_progress = 90;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_VERIFYING;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_FINALIZING;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT;
+ CallObservers(lib, observer, status);
+}
+
+void FireFailureSequence(chromeos::MockUpdateLibrary* lib,
+ Observers* observer) {
+ chromeos::UpdateLibrary::Status status;
+
+ status.status = chromeos::UPDATE_STATUS_IDLE;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_CHECKING_FOR_UPDATE;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_UPDATE_AVAILABLE;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_DOWNLOADING;
+ status.download_progress = 10;
+ CallObservers(lib, observer, status);
+
+ status.status = chromeos::UPDATE_STATUS_ERROR;
+ status.download_progress = 10;
+ CallObservers(lib, observer, status);
+}
+
+class UpdateBrowserTest : public InProcessBrowserTest {
+ public:
+ UpdateBrowserTest() {}
+};
+
+IN_PROC_BROWSER_TEST_F(UpdateBrowserTest, Notifications) {
+ scoped_ptr<chromeos::MockUpdateLibrary> lib(
+ new chromeos::MockUpdateLibrary());
+
+ Observers observers;
+
+ EXPECT_CALL(*lib, AddObserver(_))
+ .WillRepeatedly(Invoke(&observers,
+ &Observers::AddObserver));
+
+ chromeos::UpdateObserver* observe =
+ new chromeos::UpdateObserver(browser()->profile());
+ lib->AddObserver(observe);
+
+ FireSuccessSequence(lib.get(), &observers);
+ FireFailureSequence(lib.get(), &observers);
+}
+
+} // namespace
+
diff --git a/chrome/browser/chromeos/update_observer.cc b/chrome/browser/chromeos/update_observer.cc
new file mode 100644
index 0000000..ac1af56
--- /dev/null
+++ b/chrome/browser/chromeos/update_observer.cc
@@ -0,0 +1,66 @@
+// Copyright (c) 2010 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/chromeos/update_observer.h"
+
+#include "app/l10n_util.h"
+#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/common/time_format.h"
+#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
+
+namespace chromeos {
+
+UpdateObserver::UpdateObserver(Profile* profile)
+ : notification_(profile, "update.chromeos", IDR_NOTIFICATION_UPDATE,
+ l10n_util::GetStringUTF16(IDS_UPDATE_TITLE)),
+ progress_(-1) {}
+
+UpdateObserver::~UpdateObserver() {
+ notification_.Hide();
+}
+
+void UpdateObserver::Changed(UpdateLibrary* object) {
+ switch (object->status().status) {
+ case UPDATE_STATUS_ERROR:
+ notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_ERROR), true);
+ break;
+ case UPDATE_STATUS_IDLE:
+ case UPDATE_STATUS_CHECKING_FOR_UPDATE:
+ // Do nothing in these cases, we don't want to notify the user of the
+ // check unless there is an update. We don't hide here because
+ // we want the final state to be sticky.
+ break;
+ case UPDATE_STATUS_UPDATE_AVAILABLE:
+ notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_AVAILABLE),
+ false);
+ break;
+ case UPDATE_STATUS_DOWNLOADING:
+ {
+ int progress = static_cast<int>(object->status().download_progress *
+ 100.0);
+ if (progress != progress_) {
+ progress_ = progress;
+ notification_.Show(l10n_util::GetStringFUTF16(IDS_UPDATE_DOWNLOADING,
+ IntToString16(progress_)), false);
+ }
+ }
+ break;
+ case UPDATE_STATUS_VERIFYING:
+ notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_VERIFYING),
+ false);
+ break;
+ case UPDATE_STATUS_FINALIZING:
+ notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_FINALIZING),
+ false);
+ break;
+ case UPDATE_STATUS_UPDATED_NEED_REBOOT:
+ notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED), true);
+ break;
+ }
+}
+
+} // namespace chromeos
+
diff --git a/chrome/browser/chromeos/update_observer.h b/chrome/browser/chromeos/update_observer.h
new file mode 100644
index 0000000..e199958
--- /dev/null
+++ b/chrome/browser/chromeos/update_observer.h
@@ -0,0 +1,37 @@
+// Copyright (c) 2010 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_CHROMEOS_UPDATE_OBSERVER_H_
+#define CHROME_BROWSER_CHROMEOS_UPDATE_OBSERVER_H_
+
+#include "base/basictypes.h"
+#include "base/time.h"
+#include "chrome/browser/chromeos/cros/update_library.h"
+#include "chrome/browser/chromeos/notifications/system_notification.h"
+
+class Profile;
+
+namespace chromeos {
+
+// The update observer displays a system notification when the an update is
+// available.
+
+class UpdateObserver : public UpdateLibrary::Observer {
+ public:
+ explicit UpdateObserver(Profile* profile);
+ virtual ~UpdateObserver();
+
+ private:
+ virtual void Changed(UpdateLibrary* object);
+
+ SystemNotification notification_;
+ int progress_; // Last displayed remaining time in minutes
+
+ DISALLOW_COPY_AND_ASSIGN(UpdateObserver);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_UPDATE_OBSERVER_H_
+
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 6dc3682..b65d9b3 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -385,6 +385,8 @@
'browser/chromeos/cros/syslogs_library.h',
'browser/chromeos/cros/system_library.cc',
'browser/chromeos/cros/system_library.h',
+ 'browser/chromeos/cros/update_library.cc',
+ 'broswer/chromeos/cors/update_library.h',
'browser/chromeos/customization_document.cc',
'browser/chromeos/customization_document.h',
'browser/chromeos/dom_ui/sync_options_handler.cc',
@@ -566,6 +568,8 @@
'browser/chromeos/status/status_area_view.h',
'browser/chromeos/system_key_event_listener.cc',
'browser/chromeos/system_key_event_listener.h',
+ 'browser/chromeos/update_observer.cc',
+ 'browser/chromeos/update_observer.h',
'browser/chromeos/usb_mount_observer.cc',
'browser/chromeos/usb_mount_observer.h',
'browser/chromeos/version_loader.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 1897371..acc69d4 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1374,6 +1374,7 @@
'browser/chromeos/status/clock_menu_button_browsertest.cc',
'browser/chromeos/status/language_menu_button_browsertest.cc',
'browser/chromeos/status/power_menu_button_browsertest.cc',
+ 'browser/chromeos/update_browsertest.cc',
'browser/crash_recovery_browsertest.cc',
'browser/dom_ui/file_browse_browsertest.cc',
'browser/dom_ui/mediaplayer_browsertest.cc',