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" |
11 #include "ash/system/tray/system_tray_delegate.h" | 11 #include "ash/system/tray/system_tray_delegate.h" |
12 #include "ash/system/tray/tray_constants.h" | 12 #include "ash/system/tray/tray_constants.h" |
| 13 #include "ash/system/tray/tray_details_view.h" |
13 #include "ash/system/tray/tray_item_more.h" | 14 #include "ash/system/tray/tray_item_more.h" |
14 #include "ash/system/tray/tray_item_view.h" | 15 #include "ash/system/tray/tray_item_view.h" |
15 #include "ash/system/tray/tray_views.h" | 16 #include "ash/system/tray/tray_views.h" |
16 #include "base/logging.h" | 17 #include "base/logging.h" |
17 #include "base/string_number_conversions.h" | 18 #include "base/string_number_conversions.h" |
18 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
19 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
20 #include "grit/ash_strings.h" | 21 #include "grit/ash_strings.h" |
21 #include "grit/ui_resources.h" | 22 #include "grit/ui_resources.h" |
22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 DCHECK(list); | 80 DCHECK(list); |
80 string16 label = GetTrayLabel(*list); | 81 string16 label = GetTrayLabel(*list); |
81 SetLabel(label); | 82 SetLabel(label); |
82 SetAccessibleName(label); | 83 SetAccessibleName(label); |
83 } | 84 } |
84 | 85 |
85 private: | 86 private: |
86 DISALLOW_COPY_AND_ASSIGN(DriveDefaultView); | 87 DISALLOW_COPY_AND_ASSIGN(DriveDefaultView); |
87 }; | 88 }; |
88 | 89 |
89 class DriveDetailedView : public views::View, | 90 class DriveDetailedView : public TrayDetailsView, |
90 public ViewClickListener { | 91 public ViewClickListener { |
91 public: | 92 public: |
92 DriveDetailedView(SystemTrayItem* owner, | 93 DriveDetailedView(SystemTrayItem* owner, |
93 const DriveOperationStatusList* list) | 94 const DriveOperationStatusList* list) |
94 : header_(NULL), | 95 : settings_(NULL), |
95 operations_(NULL), | |
96 settings_(NULL), | |
97 in_progress_img_(NULL), | 96 in_progress_img_(NULL), |
98 done_img_(NULL), | 97 done_img_(NULL), |
99 failed_img_(NULL) { | 98 failed_img_(NULL) { |
100 SetLayoutManager(new views::BoxLayout( | |
101 views::BoxLayout::kVertical, 0, 0, 0)); | |
102 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); | |
103 | |
104 in_progress_img_ = ResourceBundle::GetSharedInstance().GetBitmapNamed( | 99 in_progress_img_ = ResourceBundle::GetSharedInstance().GetBitmapNamed( |
105 IDR_AURA_UBER_TRAY_DRIVE); | 100 IDR_AURA_UBER_TRAY_DRIVE); |
106 done_img_ = ResourceBundle::GetSharedInstance().GetBitmapNamed( | 101 done_img_ = ResourceBundle::GetSharedInstance().GetBitmapNamed( |
107 IDR_AURA_UBER_TRAY_DRIVE_DONE); | 102 IDR_AURA_UBER_TRAY_DRIVE_DONE); |
108 failed_img_ = ResourceBundle::GetSharedInstance().GetBitmapNamed( | 103 failed_img_ = ResourceBundle::GetSharedInstance().GetBitmapNamed( |
109 IDR_AURA_UBER_TRAY_DRIVE_FAILED); | 104 IDR_AURA_UBER_TRAY_DRIVE_FAILED); |
110 | 105 |
111 Update(list); | 106 Update(list); |
112 } | 107 } |
113 | 108 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 views::ImageView* status_img_; | 254 views::ImageView* status_img_; |
260 views::View* label_container_; | 255 views::View* label_container_; |
261 views::ProgressBar* progress_bar_; | 256 views::ProgressBar* progress_bar_; |
262 views::ImageButton* cancel_button_; | 257 views::ImageButton* cancel_button_; |
263 FilePath file_path_; | 258 FilePath file_path_; |
264 | 259 |
265 DISALLOW_COPY_AND_ASSIGN(RowView); | 260 DISALLOW_COPY_AND_ASSIGN(RowView); |
266 }; | 261 }; |
267 | 262 |
268 void AppendHeaderEntry(const DriveOperationStatusList* list) { | 263 void AppendHeaderEntry(const DriveOperationStatusList* list) { |
269 if (header_) | 264 if (footer()) |
270 return; | 265 return; |
271 header_ = new SpecialPopupRow(); | 266 CreateSpecialRow(IDS_ASH_STATUS_TRAY_DRIVE, this); |
272 header_->SetTextLabel(IDS_ASH_STATUS_TRAY_DRIVE, this); | |
273 AddChildView(header_); | |
274 } | 267 } |
275 | 268 |
276 SkBitmap* GetImageForState(ash::DriveOperationStatus::OperationState state) { | 269 SkBitmap* GetImageForState(ash::DriveOperationStatus::OperationState state) { |
277 switch (state) { | 270 switch (state) { |
278 case ash::DriveOperationStatus::OPERATION_NOT_STARTED: | 271 case ash::DriveOperationStatus::OPERATION_NOT_STARTED: |
279 case ash::DriveOperationStatus::OPERATION_STARTED: | 272 case ash::DriveOperationStatus::OPERATION_STARTED: |
280 case ash::DriveOperationStatus::OPERATION_IN_PROGRESS: | 273 case ash::DriveOperationStatus::OPERATION_IN_PROGRESS: |
281 case ash::DriveOperationStatus::OPERATION_SUSPENDED: | 274 case ash::DriveOperationStatus::OPERATION_SUSPENDED: |
282 return in_progress_img_; | 275 return in_progress_img_; |
283 case ash::DriveOperationStatus::OPERATION_COMPLETED: | 276 case ash::DriveOperationStatus::OPERATION_COMPLETED: |
284 return done_img_; | 277 return done_img_; |
285 case ash::DriveOperationStatus::OPERATION_FAILED: | 278 case ash::DriveOperationStatus::OPERATION_FAILED: |
286 return failed_img_; | 279 return failed_img_; |
287 } | 280 } |
288 return failed_img_; | 281 return failed_img_; |
289 } | 282 } |
290 | 283 |
291 virtual void OnCancelOperation(const FilePath& file_path) { | 284 virtual void OnCancelOperation(const FilePath& file_path) { |
292 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 285 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
293 delegate->CancelDriveOperation(file_path); | 286 delegate->CancelDriveOperation(file_path); |
294 } | 287 } |
295 | 288 |
296 void AppendOperationList(const DriveOperationStatusList* list) { | 289 void AppendOperationList(const DriveOperationStatusList* list) { |
297 if (!operations_) { | 290 if (!scroller()) |
298 operations_ = new views::View; | 291 CreateScrollableList(); |
299 operations_->SetLayoutManager(new views::BoxLayout( | |
300 views::BoxLayout::kVertical, 0, 0, 1)); | |
301 AddChildView(operations_); | |
302 } | |
303 | 292 |
304 // Apply the update. | 293 // Apply the update. |
305 std::set<FilePath> new_set; | 294 std::set<FilePath> new_set; |
306 for (DriveOperationStatusList::const_iterator it = list->begin(); | 295 for (DriveOperationStatusList::const_iterator it = list->begin(); |
307 it != list->end(); ++it) { | 296 it != list->end(); ++it) { |
308 const DriveOperationStatus& operation = *it; | 297 const DriveOperationStatus& operation = *it; |
309 | 298 |
310 new_set.insert(operation.file_path); | 299 new_set.insert(operation.file_path); |
311 std::map<FilePath, RowView*>::iterator existing_item = | 300 std::map<FilePath, RowView*>::iterator existing_item = |
312 update_map_.find(operation.file_path); | 301 update_map_.find(operation.file_path); |
313 | 302 |
314 if (existing_item != update_map_.end()) { | 303 if (existing_item != update_map_.end()) { |
315 existing_item->second->UpdateStatus(operation.state, | 304 existing_item->second->UpdateStatus(operation.state, |
316 operation.progress); | 305 operation.progress); |
317 } else { | 306 } else { |
318 RowView* row_view = new RowView(this, | 307 RowView* row_view = new RowView(this, |
319 operation.state, | 308 operation.state, |
320 operation.progress, | 309 operation.progress, |
321 operation.file_path); | 310 operation.file_path); |
322 | 311 |
323 update_map_[operation.file_path] = row_view; | 312 update_map_[operation.file_path] = row_view; |
324 operations_->AddChildView(row_view); | 313 scroll_content()->AddChildView(row_view); |
325 } | 314 } |
326 } | 315 } |
327 | 316 |
328 // Remove items from the list that haven't been added or modified with this | 317 // Remove items from the list that haven't been added or modified with this |
329 // update batch. | 318 // update batch. |
330 std::set<FilePath> remove_set; | 319 std::set<FilePath> remove_set; |
331 for (std::map<FilePath, RowView*>::iterator update_iter = | 320 for (std::map<FilePath, RowView*>::iterator update_iter = |
332 update_map_.begin(); | 321 update_map_.begin(); |
333 update_iter != update_map_.end(); ++update_iter) { | 322 update_iter != update_map_.end(); ++update_iter) { |
334 if (new_set.find(update_iter->first) == new_set.end()) { | 323 if (new_set.find(update_iter->first) == new_set.end()) { |
(...skipping 21 matching lines...) Expand all Loading... |
356 container->AddLabel(ui::ResourceBundle::GetSharedInstance(). | 345 container->AddLabel(ui::ResourceBundle::GetSharedInstance(). |
357 GetLocalizedString(IDS_ASH_STATUS_TRAY_DRIVE_SETTINGS), | 346 GetLocalizedString(IDS_ASH_STATUS_TRAY_DRIVE_SETTINGS), |
358 gfx::Font::NORMAL); | 347 gfx::Font::NORMAL); |
359 AddChildView(container); | 348 AddChildView(container); |
360 settings_ = container; | 349 settings_ = container; |
361 } | 350 } |
362 | 351 |
363 // Overridden from ViewClickListener. | 352 // Overridden from ViewClickListener. |
364 virtual void ClickedOn(views::View* sender) OVERRIDE { | 353 virtual void ClickedOn(views::View* sender) OVERRIDE { |
365 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 354 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
366 if (sender == header_->content()) { | 355 if (sender == footer()->content()) { |
367 Shell::GetInstance()->tray()->ShowDefaultView(); | 356 Shell::GetInstance()->tray()->ShowDefaultView(BUBBLE_USE_EXISTING); |
368 } else if (sender == settings_) { | 357 } else if (sender == settings_) { |
369 delegate->ShowDriveSettings(); | 358 delegate->ShowDriveSettings(); |
370 } | 359 } |
371 } | 360 } |
372 | 361 |
373 // Maps operation entries to their file paths. | 362 // Maps operation entries to their file paths. |
374 std::map<FilePath, RowView*> update_map_; | 363 std::map<FilePath, RowView*> update_map_; |
375 SpecialPopupRow* header_; | |
376 views::View* operations_; | |
377 views::View* settings_; | 364 views::View* settings_; |
378 SkBitmap* in_progress_img_; | 365 SkBitmap* in_progress_img_; |
379 SkBitmap* done_img_; | 366 SkBitmap* done_img_; |
380 SkBitmap* failed_img_; | 367 SkBitmap* failed_img_; |
381 | 368 |
382 DISALLOW_COPY_AND_ASSIGN(DriveDetailedView); | 369 DISALLOW_COPY_AND_ASSIGN(DriveDetailedView); |
383 }; | 370 }; |
384 | 371 |
385 } // namespace tray | 372 } // namespace tray |
386 | 373 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 | 436 |
450 if (default_) | 437 if (default_) |
451 default_->Update(&list); | 438 default_->Update(&list); |
452 | 439 |
453 if (detailed_) | 440 if (detailed_) |
454 detailed_->Update(&list); | 441 detailed_->Update(&list); |
455 } | 442 } |
456 | 443 |
457 } // namespace internal | 444 } // namespace internal |
458 } // namespace ash | 445 } // namespace ash |
OLD | NEW |