| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/cros/update_library.h" | 5 #include "chrome/browser/chromeos/cros/update_library.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/browser/chromeos/cros/cros_library.h" | 9 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 10 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
| 11 #include "content/common/notification_service.h" | |
| 12 #include "content/common/notification_type.h" | |
| 13 | 11 |
| 14 namespace chromeos { | 12 namespace chromeos { |
| 15 | 13 |
| 16 class UpdateLibraryImpl : public UpdateLibrary { | 14 class UpdateLibraryImpl : public UpdateLibrary { |
| 17 public: | 15 public: |
| 18 UpdateLibraryImpl() | 16 UpdateLibraryImpl() |
| 19 : status_connection_(NULL) { | 17 : status_connection_(NULL) { |
| 20 if (CrosLibrary::Get()->EnsureLoaded()) { | 18 if (CrosLibrary::Get()->EnsureLoaded()) { |
| 21 Init(); | 19 Init(); |
| 22 } | 20 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // Make sure we run on UI thread. | 82 // Make sure we run on UI thread. |
| 85 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 83 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 86 BrowserThread::PostTask( | 84 BrowserThread::PostTask( |
| 87 BrowserThread::UI, FROM_HERE, | 85 BrowserThread::UI, FROM_HERE, |
| 88 NewRunnableMethod(this, &UpdateLibraryImpl::UpdateStatus, status)); | 86 NewRunnableMethod(this, &UpdateLibraryImpl::UpdateStatus, status)); |
| 89 return; | 87 return; |
| 90 } | 88 } |
| 91 | 89 |
| 92 status_ = status; | 90 status_ = status; |
| 93 FOR_EACH_OBSERVER(Observer, observers_, UpdateStatusChanged(this)); | 91 FOR_EACH_OBSERVER(Observer, observers_, UpdateStatusChanged(this)); |
| 94 | |
| 95 // If the update is ready to install, send a notification so that Chrome | |
| 96 // can update the UI. | |
| 97 if (status_.status == UPDATE_STATUS_UPDATED_NEED_REBOOT) { | |
| 98 NotificationService::current()->Notify( | |
| 99 NotificationType::UPGRADE_RECOMMENDED, | |
| 100 Source<UpdateLibrary>(this), | |
| 101 NotificationService::NoDetails()); | |
| 102 } | |
| 103 } | 92 } |
| 104 | 93 |
| 105 ObserverList<Observer> observers_; | 94 ObserverList<Observer> observers_; |
| 106 | 95 |
| 107 // A reference to the update api, to allow callbacks when the update | 96 // A reference to the update api, to allow callbacks when the update |
| 108 // status changes. | 97 // status changes. |
| 109 UpdateStatusConnection status_connection_; | 98 UpdateStatusConnection status_connection_; |
| 110 | 99 |
| 111 // The latest power status. | 100 // The latest power status. |
| 112 Status status_; | 101 Status status_; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 return new UpdateLibraryStubImpl(); | 137 return new UpdateLibraryStubImpl(); |
| 149 else | 138 else |
| 150 return new UpdateLibraryImpl(); | 139 return new UpdateLibraryImpl(); |
| 151 } | 140 } |
| 152 | 141 |
| 153 } // namespace chromeos | 142 } // namespace chromeos |
| 154 | 143 |
| 155 // Allows InvokeLater without adding refcounting. This class is a Singleton and | 144 // Allows InvokeLater without adding refcounting. This class is a Singleton and |
| 156 // won't be deleted until it's last InvokeLater is run. | 145 // won't be deleted until it's last InvokeLater is run. |
| 157 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::UpdateLibraryImpl); | 146 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::UpdateLibraryImpl); |
| OLD | NEW |