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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 DISALLOW_COPY_AND_ASSIGN(OperationProgressBar); | 135 DISALLOW_COPY_AND_ASSIGN(OperationProgressBar); |
136 }; | 136 }; |
137 | 137 |
138 class RowView : public HoverHighlightView, | 138 class RowView : public HoverHighlightView, |
139 public views::ButtonListener { | 139 public views::ButtonListener { |
140 public: | 140 public: |
141 RowView(DriveDetailedView* parent, | 141 RowView(DriveDetailedView* parent, |
142 ash::DriveOperationStatus::OperationState state, | 142 ash::DriveOperationStatus::OperationState state, |
143 double progress, | 143 double progress, |
144 const FilePath& file_path) | 144 const base::FilePath& file_path) |
145 : HoverHighlightView(parent), | 145 : HoverHighlightView(parent), |
146 container_(parent), | 146 container_(parent), |
147 status_img_(NULL), | 147 status_img_(NULL), |
148 label_container_(NULL), | 148 label_container_(NULL), |
149 progress_bar_(NULL), | 149 progress_bar_(NULL), |
150 cancel_button_(NULL), | 150 cancel_button_(NULL), |
151 file_path_(file_path) { | 151 file_path_(file_path) { |
152 // Status image. | 152 // Status image. |
153 status_img_ = new views::ImageView(); | 153 status_img_ = new views::ImageView(); |
154 AddChildView(status_img_); | 154 AddChildView(status_img_); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 const ui::Event& event) OVERRIDE { | 252 const ui::Event& event) OVERRIDE { |
253 DCHECK(sender == cancel_button_); | 253 DCHECK(sender == cancel_button_); |
254 container_->OnCancelOperation(file_path_); | 254 container_->OnCancelOperation(file_path_); |
255 } | 255 } |
256 | 256 |
257 DriveDetailedView* container_; | 257 DriveDetailedView* container_; |
258 views::ImageView* status_img_; | 258 views::ImageView* status_img_; |
259 views::View* label_container_; | 259 views::View* label_container_; |
260 views::ProgressBar* progress_bar_; | 260 views::ProgressBar* progress_bar_; |
261 views::ImageButton* cancel_button_; | 261 views::ImageButton* cancel_button_; |
262 FilePath file_path_; | 262 base::FilePath file_path_; |
263 | 263 |
264 DISALLOW_COPY_AND_ASSIGN(RowView); | 264 DISALLOW_COPY_AND_ASSIGN(RowView); |
265 }; | 265 }; |
266 | 266 |
267 void AppendHeaderEntry(const DriveOperationStatusList* list) { | 267 void AppendHeaderEntry(const DriveOperationStatusList* list) { |
268 if (footer()) | 268 if (footer()) |
269 return; | 269 return; |
270 CreateSpecialRow(IDS_ASH_STATUS_TRAY_DRIVE, this); | 270 CreateSpecialRow(IDS_ASH_STATUS_TRAY_DRIVE, this); |
271 } | 271 } |
272 | 272 |
273 gfx::ImageSkia* GetImageForState( | 273 gfx::ImageSkia* GetImageForState( |
274 ash::DriveOperationStatus::OperationState state) { | 274 ash::DriveOperationStatus::OperationState state) { |
275 switch (state) { | 275 switch (state) { |
276 case ash::DriveOperationStatus::OPERATION_NOT_STARTED: | 276 case ash::DriveOperationStatus::OPERATION_NOT_STARTED: |
277 case ash::DriveOperationStatus::OPERATION_STARTED: | 277 case ash::DriveOperationStatus::OPERATION_STARTED: |
278 case ash::DriveOperationStatus::OPERATION_IN_PROGRESS: | 278 case ash::DriveOperationStatus::OPERATION_IN_PROGRESS: |
279 case ash::DriveOperationStatus::OPERATION_SUSPENDED: | 279 case ash::DriveOperationStatus::OPERATION_SUSPENDED: |
280 return in_progress_img_; | 280 return in_progress_img_; |
281 case ash::DriveOperationStatus::OPERATION_COMPLETED: | 281 case ash::DriveOperationStatus::OPERATION_COMPLETED: |
282 return done_img_; | 282 return done_img_; |
283 case ash::DriveOperationStatus::OPERATION_FAILED: | 283 case ash::DriveOperationStatus::OPERATION_FAILED: |
284 return failed_img_; | 284 return failed_img_; |
285 } | 285 } |
286 return failed_img_; | 286 return failed_img_; |
287 } | 287 } |
288 | 288 |
289 virtual void OnCancelOperation(const FilePath& file_path) { | 289 virtual void OnCancelOperation(const base::FilePath& file_path) { |
290 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); | 290 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); |
291 delegate->CancelDriveOperation(file_path); | 291 delegate->CancelDriveOperation(file_path); |
292 } | 292 } |
293 | 293 |
294 void AppendOperationList(const DriveOperationStatusList* list) { | 294 void AppendOperationList(const DriveOperationStatusList* list) { |
295 if (!scroller()) | 295 if (!scroller()) |
296 CreateScrollableList(); | 296 CreateScrollableList(); |
297 | 297 |
298 // Apply the update. | 298 // Apply the update. |
299 std::set<FilePath> new_set; | 299 std::set<base::FilePath> new_set; |
300 bool item_list_changed = false; | 300 bool item_list_changed = false; |
301 for (DriveOperationStatusList::const_iterator it = list->begin(); | 301 for (DriveOperationStatusList::const_iterator it = list->begin(); |
302 it != list->end(); ++it) { | 302 it != list->end(); ++it) { |
303 const DriveOperationStatus& operation = *it; | 303 const DriveOperationStatus& operation = *it; |
304 | 304 |
305 new_set.insert(operation.file_path); | 305 new_set.insert(operation.file_path); |
306 std::map<FilePath, RowView*>::iterator existing_item = | 306 std::map<base::FilePath, RowView*>::iterator existing_item = |
307 update_map_.find(operation.file_path); | 307 update_map_.find(operation.file_path); |
308 | 308 |
309 if (existing_item != update_map_.end()) { | 309 if (existing_item != update_map_.end()) { |
310 existing_item->second->UpdateStatus(operation.state, | 310 existing_item->second->UpdateStatus(operation.state, |
311 operation.progress); | 311 operation.progress); |
312 } else { | 312 } else { |
313 RowView* row_view = new RowView(this, | 313 RowView* row_view = new RowView(this, |
314 operation.state, | 314 operation.state, |
315 operation.progress, | 315 operation.progress, |
316 operation.file_path); | 316 operation.file_path); |
317 | 317 |
318 update_map_[operation.file_path] = row_view; | 318 update_map_[operation.file_path] = row_view; |
319 scroll_content()->AddChildView(row_view); | 319 scroll_content()->AddChildView(row_view); |
320 item_list_changed = true; | 320 item_list_changed = true; |
321 } | 321 } |
322 } | 322 } |
323 | 323 |
324 // Remove items from the list that haven't been added or modified with this | 324 // Remove items from the list that haven't been added or modified with this |
325 // update batch. | 325 // update batch. |
326 std::set<FilePath> remove_set; | 326 std::set<base::FilePath> remove_set; |
327 for (std::map<FilePath, RowView*>::iterator update_iter = | 327 for (std::map<base::FilePath, RowView*>::iterator update_iter = |
328 update_map_.begin(); | 328 update_map_.begin(); |
329 update_iter != update_map_.end(); ++update_iter) { | 329 update_iter != update_map_.end(); ++update_iter) { |
330 if (new_set.find(update_iter->first) == new_set.end()) { | 330 if (new_set.find(update_iter->first) == new_set.end()) { |
331 remove_set.insert(update_iter->first); | 331 remove_set.insert(update_iter->first); |
332 } | 332 } |
333 } | 333 } |
334 | 334 |
335 for (std::set<FilePath>::iterator removed_iter = remove_set.begin(); | 335 for (std::set<base::FilePath>::iterator removed_iter = remove_set.begin(); |
336 removed_iter != remove_set.end(); ++removed_iter) { | 336 removed_iter != remove_set.end(); ++removed_iter) { |
337 delete update_map_[*removed_iter]; | 337 delete update_map_[*removed_iter]; |
338 update_map_.erase(*removed_iter); | 338 update_map_.erase(*removed_iter); |
339 item_list_changed = true; | 339 item_list_changed = true; |
340 } | 340 } |
341 | 341 |
342 if (item_list_changed) | 342 if (item_list_changed) |
343 scroller()->Layout(); | 343 scroller()->Layout(); |
344 | 344 |
345 // Close the details if there is really nothing to show there anymore. | 345 // Close the details if there is really nothing to show there anymore. |
(...skipping 17 matching lines...) Expand all Loading... |
363 virtual void ClickedOn(views::View* sender) OVERRIDE { | 363 virtual void ClickedOn(views::View* sender) OVERRIDE { |
364 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); | 364 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); |
365 if (sender == footer()->content()) { | 365 if (sender == footer()->content()) { |
366 owner()->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); | 366 owner()->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); |
367 } else if (sender == settings_) { | 367 } else if (sender == settings_) { |
368 delegate->ShowDriveSettings(); | 368 delegate->ShowDriveSettings(); |
369 } | 369 } |
370 } | 370 } |
371 | 371 |
372 // Maps operation entries to their file paths. | 372 // Maps operation entries to their file paths. |
373 std::map<FilePath, RowView*> update_map_; | 373 std::map<base::FilePath, RowView*> update_map_; |
374 views::View* settings_; | 374 views::View* settings_; |
375 gfx::ImageSkia* in_progress_img_; | 375 gfx::ImageSkia* in_progress_img_; |
376 gfx::ImageSkia* done_img_; | 376 gfx::ImageSkia* done_img_; |
377 gfx::ImageSkia* failed_img_; | 377 gfx::ImageSkia* failed_img_; |
378 | 378 |
379 DISALLOW_COPY_AND_ASSIGN(DriveDetailedView); | 379 DISALLOW_COPY_AND_ASSIGN(DriveDetailedView); |
380 }; | 380 }; |
381 | 381 |
382 } // namespace tray | 382 } // namespace tray |
383 | 383 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 473 |
474 tray_view()->SetVisible(false); | 474 tray_view()->SetVisible(false); |
475 if (default_) | 475 if (default_) |
476 default_->Update(&empty_list); | 476 default_->Update(&empty_list); |
477 if (detailed_) | 477 if (detailed_) |
478 detailed_->Update(&empty_list); | 478 detailed_->Update(&empty_list); |
479 } | 479 } |
480 | 480 |
481 } // namespace internal | 481 } // namespace internal |
482 } // namespace ash | 482 } // namespace ash |
OLD | NEW |