Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / ash / system / tray_update.cc
index 79a3ad6..d24a6e9 100644 (file)
@@ -37,21 +37,21 @@ const int kUpdateNaggingTimeSeconds = 24 * 60 * 60;
 // How long should the nag reminder be displayed?
 const int kShowUpdateNaggerForSeconds = 15;
 
-int DecideResource(ash::UpdateObserver::UpdateSeverity severity, bool dark) {
+int DecideResource(ash::UpdateInfo::UpdateSeverity severity, bool dark) {
   switch (severity) {
-    case ash::UpdateObserver::UPDATE_NORMAL:
+    case ash::UpdateInfo::UPDATE_NORMAL:
       return dark ? IDR_AURA_UBER_TRAY_UPDATE_DARK:
                     IDR_AURA_UBER_TRAY_UPDATE;
 
-    case ash::UpdateObserver::UPDATE_LOW_GREEN:
+    case ash::UpdateInfo::UPDATE_LOW_GREEN:
       return dark ? IDR_AURA_UBER_TRAY_UPDATE_DARK_GREEN :
                     IDR_AURA_UBER_TRAY_UPDATE_GREEN;
 
-    case ash::UpdateObserver::UPDATE_HIGH_ORANGE:
+    case ash::UpdateInfo::UPDATE_HIGH_ORANGE:
       return dark ? IDR_AURA_UBER_TRAY_UPDATE_DARK_ORANGE :
                     IDR_AURA_UBER_TRAY_UPDATE_ORANGE;
 
-    case ash::UpdateObserver::UPDATE_SEVERE_RED:
+    case ash::UpdateInfo::UPDATE_SEVERE_RED:
       return dark ? IDR_AURA_UBER_TRAY_UPDATE_DARK_RED :
                     IDR_AURA_UBER_TRAY_UPDATE_RED;
   }
@@ -62,7 +62,7 @@ int DecideResource(ash::UpdateObserver::UpdateSeverity severity, bool dark) {
 
 class UpdateView : public ash::ActionableView {
  public:
-  explicit UpdateView(ash::UpdateObserver::UpdateSeverity severity) {
+  explicit UpdateView(const ash::UpdateInfo& info) {
     SetLayoutManager(new
         views::BoxLayout(views::BoxLayout::kHorizontal,
         ash::kTrayPopupPaddingHorizontal, 0,
@@ -71,20 +71,25 @@ class UpdateView : public ash::ActionableView {
     ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
     views::ImageView* image =
         new ash::FixedSizedImageView(0, ash::kTrayPopupItemHeight);
-    image->SetImage(bundle.GetImageNamed(DecideResource(severity, true)).
-        ToImageSkia());
+    image->SetImage(bundle.GetImageNamed(DecideResource(info.severity, true))
+                        .ToImageSkia());
 
     AddChildView(image);
-    AddChildView(new views::Label(
-        bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE)));
-    SetAccessibleName(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE));
+
+    base::string16 label =
+        info.factory_reset_required
+            ? bundle.GetLocalizedString(
+                  IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE)
+            : bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE);
+    AddChildView(new views::Label(label));
+    SetAccessibleName(label);
   }
 
-  virtual ~UpdateView() {}
+  ~UpdateView() override {}
 
  private:
   // Overridden from ActionableView.
-  virtual bool PerformAction(const ui::Event& event) OVERRIDE {
+  bool PerformAction(const ui::Event& event) override {
     ash::Shell::GetInstance()->
         system_tray_delegate()->RequestRestartForUpdate();
     return true;
@@ -107,7 +112,7 @@ class UpdateNagger : public ui::LayerAnimationObserver {
         GetAnimator()->AddObserver(this);
   }
 
-  virtual ~UpdateNagger() {
+  ~UpdateNagger() override {
     StatusAreaWidget* status_area =
         Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget();
     if (status_area) {
@@ -130,8 +135,7 @@ class UpdateNagger : public ui::LayerAnimationObserver {
   }
 
   // Overridden from ui::LayerAnimationObserver.
-  virtual void OnLayerAnimationEnded(
-      ui::LayerAnimationSequence* sequence) OVERRIDE {
+  void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) override {
     // TODO(oshima): Find out if the updator will be shown on non
     // primary display.
     if (Shell::GetPrimaryRootWindowController()->shelf()->IsVisible())
@@ -140,11 +144,10 @@ class UpdateNagger : public ui::LayerAnimationObserver {
       RestartTimer();
   }
 
-  virtual void OnLayerAnimationAborted(
-      ui::LayerAnimationSequence* sequence) OVERRIDE {}
+  void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) override {}
 
-  virtual void OnLayerAnimationScheduled(
-      ui::LayerAnimationSequence* sequence) OVERRIDE {}
+  void OnLayerAnimationScheduled(
+      ui::LayerAnimationSequence* sequence) override {}
 
   SystemTrayItem* owner_;
   base::OneShotTimer<UpdateNagger> timer_;
@@ -155,8 +158,7 @@ class UpdateNagger : public ui::LayerAnimationObserver {
 }  // namespace tray
 
 TrayUpdate::TrayUpdate(SystemTray* system_tray)
-    : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_UPDATE),
-      severity_(UpdateObserver::UPDATE_NORMAL) {
+    : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_UPDATE) {
   Shell::GetInstance()->system_tray_notifier()->AddUpdateObserver(this);
 }
 
@@ -165,13 +167,15 @@ TrayUpdate::~TrayUpdate() {
 }
 
 bool TrayUpdate::GetInitialVisibility() {
-  return Shell::GetInstance()->system_tray_delegate()->SystemShouldUpgrade();
+  UpdateInfo info;
+  Shell::GetInstance()->system_tray_delegate()->GetSystemUpdateInfo(&info);
+  return info.update_required;
 }
 
 views::View* TrayUpdate::CreateDefaultView(user::LoginStatus status) {
-  if (!Shell::GetInstance()->system_tray_delegate()->SystemShouldUpgrade())
-    return NULL;
-  return new UpdateView(severity_);
+  UpdateInfo info;
+  Shell::GetInstance()->system_tray_delegate()->GetSystemUpdateInfo(&info);
+  return info.update_required ? new UpdateView(info) : nullptr;
 }
 
 views::View* TrayUpdate::CreateDetailedView(user::LoginStatus status) {
@@ -188,9 +192,8 @@ void TrayUpdate::DestroyDetailedView() {
   }
 }
 
-void TrayUpdate::OnUpdateRecommended(UpdateObserver::UpdateSeverity severity) {
-  severity_ = severity;
-  SetImageFromResourceId(DecideResource(severity_, false));
+void TrayUpdate::OnUpdateRecommended(const UpdateInfo& info) {
+  SetImageFromResourceId(DecideResource(info.severity, false));
   tray_view()->SetVisible(true);
   if (!Shell::GetPrimaryRootWindowController()->shelf()->IsVisible() &&
       !nagger_.get()) {