| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/system/drive/tray_drive.h" | 5 #include "ash/system/drive/tray_drive.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/system/tray/system_tray.h" | 10 #include "ash/system/tray/system_tray.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 namespace tray { | 63 namespace tray { |
| 64 | 64 |
| 65 | 65 |
| 66 class DriveDefaultView : public TrayItemMore { | 66 class DriveDefaultView : public TrayItemMore { |
| 67 public: | 67 public: |
| 68 DriveDefaultView(SystemTrayItem* owner, | 68 DriveDefaultView(SystemTrayItem* owner, |
| 69 const DriveOperationStatusList* list) | 69 const DriveOperationStatusList* list) |
| 70 : TrayItemMore(owner) { | 70 : TrayItemMore(owner) { |
| 71 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 71 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 72 | 72 |
| 73 SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DRIVE).ToSkBitmap()); | 73 SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DRIVE).ToImageSkia()); |
| 74 Update(list); | 74 Update(list); |
| 75 } | 75 } |
| 76 | 76 |
| 77 virtual ~DriveDefaultView() {} | 77 virtual ~DriveDefaultView() {} |
| 78 | 78 |
| 79 void Update(const DriveOperationStatusList* list) { | 79 void Update(const DriveOperationStatusList* list) { |
| 80 DCHECK(list); | 80 DCHECK(list); |
| 81 string16 label = GetTrayLabel(*list); | 81 string16 label = GetTrayLabel(*list); |
| 82 SetLabel(label); | 82 SetLabel(label); |
| 83 SetAccessibleName(label); | 83 SetAccessibleName(label); |
| 84 } | 84 } |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 DISALLOW_COPY_AND_ASSIGN(DriveDefaultView); | 87 DISALLOW_COPY_AND_ASSIGN(DriveDefaultView); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 class DriveDetailedView : public TrayDetailsView, | 90 class DriveDetailedView : public TrayDetailsView, |
| 91 public ViewClickListener { | 91 public ViewClickListener { |
| 92 public: | 92 public: |
| 93 DriveDetailedView(SystemTrayItem* owner, | 93 DriveDetailedView(SystemTrayItem* owner, |
| 94 const DriveOperationStatusList* list) | 94 const DriveOperationStatusList* list) |
| 95 : settings_(NULL), | 95 : settings_(NULL), |
| 96 in_progress_img_(NULL), | 96 in_progress_img_(NULL), |
| 97 done_img_(NULL), | 97 done_img_(NULL), |
| 98 failed_img_(NULL) { | 98 failed_img_(NULL) { |
| 99 in_progress_img_ = ResourceBundle::GetSharedInstance().GetBitmapNamed( | 99 in_progress_img_ = ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 100 IDR_AURA_UBER_TRAY_DRIVE); | 100 IDR_AURA_UBER_TRAY_DRIVE); |
| 101 done_img_ = ResourceBundle::GetSharedInstance().GetBitmapNamed( | 101 done_img_ = ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 102 IDR_AURA_UBER_TRAY_DRIVE_DONE); | 102 IDR_AURA_UBER_TRAY_DRIVE_DONE); |
| 103 failed_img_ = ResourceBundle::GetSharedInstance().GetBitmapNamed( | 103 failed_img_ = ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 104 IDR_AURA_UBER_TRAY_DRIVE_FAILED); | 104 IDR_AURA_UBER_TRAY_DRIVE_FAILED); |
| 105 | 105 |
| 106 Update(list); | 106 Update(list); |
| 107 } | 107 } |
| 108 | 108 |
| 109 virtual ~DriveDetailedView() { | 109 virtual ~DriveDetailedView() { |
| 110 STLDeleteValues(&update_map_); | 110 STLDeleteValues(&update_map_); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void Update(const DriveOperationStatusList* list) { | 113 void Update(const DriveOperationStatusList* list) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 166 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 167 label_container_->AddChildView(label); | 167 label_container_->AddChildView(label); |
| 168 // Add progress bar. | 168 // Add progress bar. |
| 169 progress_bar_ = new OperationProgressBar(); | 169 progress_bar_ = new OperationProgressBar(); |
| 170 label_container_->AddChildView(progress_bar_); | 170 label_container_->AddChildView(progress_bar_); |
| 171 | 171 |
| 172 AddChildView(label_container_); | 172 AddChildView(label_container_); |
| 173 | 173 |
| 174 cancel_button_ = new views::ImageButton(this); | 174 cancel_button_ = new views::ImageButton(this); |
| 175 cancel_button_->SetImage(views::ImageButton::BS_NORMAL, | 175 cancel_button_->SetImage(views::ImageButton::BS_NORMAL, |
| 176 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 176 ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 177 IDR_AURA_UBER_TRAY_DRIVE_CANCEL)); | 177 IDR_AURA_UBER_TRAY_DRIVE_CANCEL)); |
| 178 cancel_button_->SetImage(views::ImageButton::BS_HOT, | 178 cancel_button_->SetImage(views::ImageButton::BS_HOT, |
| 179 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 179 ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 180 IDR_AURA_UBER_TRAY_DRIVE_CANCEL_HOVER)); | 180 IDR_AURA_UBER_TRAY_DRIVE_CANCEL_HOVER)); |
| 181 | 181 |
| 182 UpdateStatus(state, progress); | 182 UpdateStatus(state, progress); |
| 183 AddChildView(cancel_button_); | 183 AddChildView(cancel_button_); |
| 184 } | 184 } |
| 185 | 185 |
| 186 void UpdateStatus(ash::DriveOperationStatus::OperationState state, | 186 void UpdateStatus(ash::DriveOperationStatus::OperationState state, |
| 187 double progress) { | 187 double progress) { |
| 188 status_img_->SetImage(container_->GetImageForState(state)); | 188 status_img_->SetImage(container_->GetImageForState(state)); |
| 189 progress_bar_->SetValue(progress); | 189 progress_bar_->SetValue(progress); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 259 |
| 260 DISALLOW_COPY_AND_ASSIGN(RowView); | 260 DISALLOW_COPY_AND_ASSIGN(RowView); |
| 261 }; | 261 }; |
| 262 | 262 |
| 263 void AppendHeaderEntry(const DriveOperationStatusList* list) { | 263 void AppendHeaderEntry(const DriveOperationStatusList* list) { |
| 264 if (footer()) | 264 if (footer()) |
| 265 return; | 265 return; |
| 266 CreateSpecialRow(IDS_ASH_STATUS_TRAY_DRIVE, this); | 266 CreateSpecialRow(IDS_ASH_STATUS_TRAY_DRIVE, this); |
| 267 } | 267 } |
| 268 | 268 |
| 269 SkBitmap* GetImageForState(ash::DriveOperationStatus::OperationState state) { | 269 gfx::ImageSkia* GetImageForState( |
| 270 ash::DriveOperationStatus::OperationState state) { |
| 270 switch (state) { | 271 switch (state) { |
| 271 case ash::DriveOperationStatus::OPERATION_NOT_STARTED: | 272 case ash::DriveOperationStatus::OPERATION_NOT_STARTED: |
| 272 case ash::DriveOperationStatus::OPERATION_STARTED: | 273 case ash::DriveOperationStatus::OPERATION_STARTED: |
| 273 case ash::DriveOperationStatus::OPERATION_IN_PROGRESS: | 274 case ash::DriveOperationStatus::OPERATION_IN_PROGRESS: |
| 274 case ash::DriveOperationStatus::OPERATION_SUSPENDED: | 275 case ash::DriveOperationStatus::OPERATION_SUSPENDED: |
| 275 return in_progress_img_; | 276 return in_progress_img_; |
| 276 case ash::DriveOperationStatus::OPERATION_COMPLETED: | 277 case ash::DriveOperationStatus::OPERATION_COMPLETED: |
| 277 return done_img_; | 278 return done_img_; |
| 278 case ash::DriveOperationStatus::OPERATION_FAILED: | 279 case ash::DriveOperationStatus::OPERATION_FAILED: |
| 279 return failed_img_; | 280 return failed_img_; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 if (sender == footer()->content()) { | 356 if (sender == footer()->content()) { |
| 356 Shell::GetInstance()->tray()->ShowDefaultView(BUBBLE_USE_EXISTING); | 357 Shell::GetInstance()->tray()->ShowDefaultView(BUBBLE_USE_EXISTING); |
| 357 } else if (sender == settings_) { | 358 } else if (sender == settings_) { |
| 358 delegate->ShowDriveSettings(); | 359 delegate->ShowDriveSettings(); |
| 359 } | 360 } |
| 360 } | 361 } |
| 361 | 362 |
| 362 // Maps operation entries to their file paths. | 363 // Maps operation entries to their file paths. |
| 363 std::map<FilePath, RowView*> update_map_; | 364 std::map<FilePath, RowView*> update_map_; |
| 364 views::View* settings_; | 365 views::View* settings_; |
| 365 SkBitmap* in_progress_img_; | 366 gfx::ImageSkia* in_progress_img_; |
| 366 SkBitmap* done_img_; | 367 gfx::ImageSkia* done_img_; |
| 367 SkBitmap* failed_img_; | 368 gfx::ImageSkia* failed_img_; |
| 368 | 369 |
| 369 DISALLOW_COPY_AND_ASSIGN(DriveDetailedView); | 370 DISALLOW_COPY_AND_ASSIGN(DriveDetailedView); |
| 370 }; | 371 }; |
| 371 | 372 |
| 372 } // namespace tray | 373 } // namespace tray |
| 373 | 374 |
| 374 TrayDrive::TrayDrive() : | 375 TrayDrive::TrayDrive() : |
| 375 TrayImageItem(IDR_AURA_UBER_TRAY_DRIVE_LIGHT), | 376 TrayImageItem(IDR_AURA_UBER_TRAY_DRIVE_LIGHT), |
| 376 default_(NULL), | 377 default_(NULL), |
| 377 detailed_(NULL) { | 378 detailed_(NULL) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 | 437 |
| 437 if (default_) | 438 if (default_) |
| 438 default_->Update(&list); | 439 default_->Update(&list); |
| 439 | 440 |
| 440 if (detailed_) | 441 if (detailed_) |
| 441 detailed_->Update(&list); | 442 detailed_->Update(&list); |
| 442 } | 443 } |
| 443 | 444 |
| 444 } // namespace internal | 445 } // namespace internal |
| 445 } // namespace ash | 446 } // namespace ash |
| OLD | NEW |