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/system_tray_item.h" |
12 #include "ash/system/tray/tray_constants.h" | 13 #include "ash/system/tray/tray_constants.h" |
13 #include "ash/system/tray/tray_details_view.h" | 14 #include "ash/system/tray/tray_details_view.h" |
14 #include "ash/system/tray/tray_item_more.h" | 15 #include "ash/system/tray/tray_item_more.h" |
15 #include "ash/system/tray/tray_item_view.h" | 16 #include "ash/system/tray/tray_item_view.h" |
16 #include "ash/system/tray/tray_views.h" | 17 #include "ash/system/tray/tray_views.h" |
17 #include "base/logging.h" | 18 #include "base/logging.h" |
18 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
19 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
20 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
21 #include "grit/ash_resources.h" | 22 #include "grit/ash_resources.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 return list; | 59 return list; |
59 } | 60 } |
60 | 61 |
61 } | 62 } |
62 | 63 |
63 namespace tray { | 64 namespace tray { |
64 | 65 |
65 | 66 |
66 class DriveDefaultView : public TrayItemMore { | 67 class DriveDefaultView : public TrayItemMore { |
67 public: | 68 public: |
68 DriveDefaultView(SystemTrayItem* owner, | 69 DriveDefaultView(SystemTrayItem* tray, |
69 const DriveOperationStatusList* list) | 70 const DriveOperationStatusList* list) |
70 : TrayItemMore(owner, true) { | 71 : TrayItemMore(tray, true) { |
71 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 72 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
72 | 73 |
73 SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DRIVE).ToImageSkia()); | 74 SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DRIVE).ToImageSkia()); |
74 Update(list); | 75 Update(list); |
75 } | 76 } |
76 | 77 |
77 virtual ~DriveDefaultView() {} | 78 virtual ~DriveDefaultView() {} |
78 | 79 |
79 void Update(const DriveOperationStatusList* list) { | 80 void Update(const DriveOperationStatusList* list) { |
80 DCHECK(list); | 81 DCHECK(list); |
81 string16 label = GetTrayLabel(*list); | 82 string16 label = GetTrayLabel(*list); |
82 SetLabel(label); | 83 SetLabel(label); |
83 SetAccessibleName(label); | 84 SetAccessibleName(label); |
84 } | 85 } |
85 | 86 |
86 private: | 87 private: |
87 DISALLOW_COPY_AND_ASSIGN(DriveDefaultView); | 88 DISALLOW_COPY_AND_ASSIGN(DriveDefaultView); |
88 }; | 89 }; |
89 | 90 |
90 class DriveDetailedView : public TrayDetailsView, | 91 class DriveDetailedView : public TrayDetailsView, |
91 public ViewClickListener { | 92 public ViewClickListener { |
92 public: | 93 public: |
93 DriveDetailedView(SystemTrayItem* owner, | 94 DriveDetailedView(SystemTrayItem* tray, |
94 const DriveOperationStatusList* list) | 95 const DriveOperationStatusList* list) |
95 : settings_(NULL), | 96 : TrayDetailsView(tray), |
| 97 settings_(NULL), |
96 in_progress_img_(NULL), | 98 in_progress_img_(NULL), |
97 done_img_(NULL), | 99 done_img_(NULL), |
98 failed_img_(NULL) { | 100 failed_img_(NULL) { |
99 in_progress_img_ = ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 101 in_progress_img_ = ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
100 IDR_AURA_UBER_TRAY_DRIVE); | 102 IDR_AURA_UBER_TRAY_DRIVE); |
101 done_img_ = ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 103 done_img_ = ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
102 IDR_AURA_UBER_TRAY_DRIVE_DONE); | 104 IDR_AURA_UBER_TRAY_DRIVE_DONE); |
103 failed_img_ = ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 105 failed_img_ = ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
104 IDR_AURA_UBER_TRAY_DRIVE_FAILED); | 106 IDR_AURA_UBER_TRAY_DRIVE_FAILED); |
105 | 107 |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 GetLocalizedString(IDS_ASH_STATUS_TRAY_DRIVE_SETTINGS), | 351 GetLocalizedString(IDS_ASH_STATUS_TRAY_DRIVE_SETTINGS), |
350 gfx::Font::NORMAL); | 352 gfx::Font::NORMAL); |
351 AddChildView(container); | 353 AddChildView(container); |
352 settings_ = container; | 354 settings_ = container; |
353 } | 355 } |
354 | 356 |
355 // Overridden from ViewClickListener. | 357 // Overridden from ViewClickListener. |
356 virtual void ClickedOn(views::View* sender) OVERRIDE { | 358 virtual void ClickedOn(views::View* sender) OVERRIDE { |
357 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 359 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
358 if (sender == footer()->content()) { | 360 if (sender == footer()->content()) { |
359 Shell::GetInstance()->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); | 361 tray()->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); |
360 } else if (sender == settings_) { | 362 } else if (sender == settings_) { |
361 delegate->ShowDriveSettings(); | 363 delegate->ShowDriveSettings(); |
362 } | 364 } |
363 } | 365 } |
364 | 366 |
365 // Maps operation entries to their file paths. | 367 // Maps operation entries to their file paths. |
366 std::map<FilePath, RowView*> update_map_; | 368 std::map<FilePath, RowView*> update_map_; |
367 views::View* settings_; | 369 views::View* settings_; |
368 gfx::ImageSkia* in_progress_img_; | 370 gfx::ImageSkia* in_progress_img_; |
369 gfx::ImageSkia* done_img_; | 371 gfx::ImageSkia* done_img_; |
370 gfx::ImageSkia* failed_img_; | 372 gfx::ImageSkia* failed_img_; |
371 | 373 |
372 DISALLOW_COPY_AND_ASSIGN(DriveDetailedView); | 374 DISALLOW_COPY_AND_ASSIGN(DriveDetailedView); |
373 }; | 375 }; |
374 | 376 |
375 } // namespace tray | 377 } // namespace tray |
376 | 378 |
377 TrayDrive::TrayDrive() : | 379 TrayDrive::TrayDrive(SystemTray* system_tray) : |
378 TrayImageItem(IDR_AURA_UBER_TRAY_DRIVE_LIGHT), | 380 TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_DRIVE_LIGHT), |
379 default_(NULL), | 381 default_(NULL), |
380 detailed_(NULL) { | 382 detailed_(NULL) { |
381 } | 383 } |
382 | 384 |
383 TrayDrive::~TrayDrive() { | 385 TrayDrive::~TrayDrive() { |
384 } | 386 } |
385 | 387 |
386 bool TrayDrive::GetInitialVisibility() { | 388 bool TrayDrive::GetInitialVisibility() { |
387 scoped_ptr<DriveOperationStatusList> list(GetCurrentOperationList()); | 389 scoped_ptr<DriveOperationStatusList> list(GetCurrentOperationList()); |
388 return list->size() > 0; | 390 return list->size() > 0; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 | 441 |
440 if (default_) | 442 if (default_) |
441 default_->Update(&list); | 443 default_->Update(&list); |
442 | 444 |
443 if (detailed_) | 445 if (detailed_) |
444 detailed_->Update(&list); | 446 detailed_->Update(&list); |
445 } | 447 } |
446 | 448 |
447 } // namespace internal | 449 } // namespace internal |
448 } // namespace ash | 450 } // namespace ash |
OLD | NEW |