| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/gtk/download/download_shelf_gtk.h" | 5 #include "chrome/browser/ui/gtk/download/download_shelf_gtk.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "chrome/browser/download/download_item_model.h" | 10 #include "chrome/browser/download/download_item_model.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 212 |
| 213 void DownloadShelfGtk::Closed() { | 213 void DownloadShelfGtk::Closed() { |
| 214 // When the close animation is complete, remove all completed downloads. | 214 // When the close animation is complete, remove all completed downloads. |
| 215 size_t i = 0; | 215 size_t i = 0; |
| 216 while (i < download_items_.size()) { | 216 while (i < download_items_.size()) { |
| 217 DownloadItem* download = download_items_[i]->get_download(); | 217 DownloadItem* download = download_items_[i]->get_download(); |
| 218 bool is_transfer_done = download->IsComplete() || | 218 bool is_transfer_done = download->IsComplete() || |
| 219 download->IsCancelled() || | 219 download->IsCancelled() || |
| 220 download->IsInterrupted(); | 220 download->IsInterrupted(); |
| 221 if (is_transfer_done && | 221 if (is_transfer_done && |
| 222 download->safety_state() != DownloadItem::DANGEROUS) { | 222 download->GetSafetyState() != DownloadItem::DANGEROUS) { |
| 223 RemoveDownloadItem(download_items_[i]); | 223 RemoveDownloadItem(download_items_[i]); |
| 224 } else { | 224 } else { |
| 225 // We set all remaining items as "opened", so that the shelf will auto- | 225 // We set all remaining items as "opened", so that the shelf will auto- |
| 226 // close in the future without the user clicking on them. | 226 // close in the future without the user clicking on them. |
| 227 download->set_opened(true); | 227 download->SetOpened(true); |
| 228 ++i; | 228 ++i; |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 | 232 |
| 233 void DownloadShelfGtk::Observe(int type, | 233 void DownloadShelfGtk::Observe(int type, |
| 234 const content::NotificationSource& source, | 234 const content::NotificationSource& source, |
| 235 const content::NotificationDetails& details) { | 235 const content::NotificationDetails& details) { |
| 236 if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { | 236 if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { |
| 237 GdkColor color = theme_service_->GetGdkColor( | 237 GdkColor color = theme_service_->GetGdkColor( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 Close(); | 296 Close(); |
| 297 } else { | 297 } else { |
| 298 // The link button was clicked. | 298 // The link button was clicked. |
| 299 browser_->ShowDownloadsTab(); | 299 browser_->ShowDownloadsTab(); |
| 300 } | 300 } |
| 301 } | 301 } |
| 302 | 302 |
| 303 void DownloadShelfGtk::AutoCloseIfPossible() { | 303 void DownloadShelfGtk::AutoCloseIfPossible() { |
| 304 for (std::vector<DownloadItemGtk*>::iterator iter = download_items_.begin(); | 304 for (std::vector<DownloadItemGtk*>::iterator iter = download_items_.begin(); |
| 305 iter != download_items_.end(); ++iter) { | 305 iter != download_items_.end(); ++iter) { |
| 306 if (!(*iter)->get_download()->opened()) | 306 if (!(*iter)->get_download()->GetOpened()) |
| 307 return; | 307 return; |
| 308 } | 308 } |
| 309 | 309 |
| 310 SetCloseOnMouseOut(true); | 310 SetCloseOnMouseOut(true); |
| 311 } | 311 } |
| 312 | 312 |
| 313 void DownloadShelfGtk::CancelAutoClose() { | 313 void DownloadShelfGtk::CancelAutoClose() { |
| 314 SetCloseOnMouseOut(false); | 314 SetCloseOnMouseOut(false); |
| 315 weak_factory_.InvalidateWeakPtrs(); | 315 weak_factory_.InvalidateWeakPtrs(); |
| 316 } | 316 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 | 378 |
| 379 MessageLoop::current()->PostDelayedTask( | 379 MessageLoop::current()->PostDelayedTask( |
| 380 FROM_HERE, | 380 FROM_HERE, |
| 381 base::Bind(&DownloadShelfGtk::Close, weak_factory_.GetWeakPtr()), | 381 base::Bind(&DownloadShelfGtk::Close, weak_factory_.GetWeakPtr()), |
| 382 kAutoCloseDelayMs); | 382 kAutoCloseDelayMs); |
| 383 } | 383 } |
| 384 | 384 |
| 385 void DownloadShelfGtk::MouseEnteredShelf() { | 385 void DownloadShelfGtk::MouseEnteredShelf() { |
| 386 weak_factory_.InvalidateWeakPtrs(); | 386 weak_factory_.InvalidateWeakPtrs(); |
| 387 } | 387 } |
| OLD | NEW |