OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/download/notification/download_notification_item.h" | 5 #include "chrome/browser/download/notification/download_notification_item.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/download/download_crx_util.h" | 9 #include "chrome/browser/download/download_crx_util.h" |
10 #include "chrome/browser/download/download_item_model.h" | 10 #include "chrome/browser/download/download_item_model.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 if (previous_download_state_ != content::DownloadItem::IN_PROGRESS) { | 194 if (previous_download_state_ != content::DownloadItem::IN_PROGRESS) { |
195 if (item_->GetState() == content::DownloadItem::IN_PROGRESS) | 195 if (item_->GetState() == content::DownloadItem::IN_PROGRESS) |
196 delegate_->OnDownloadStarted(this); | 196 delegate_->OnDownloadStarted(this); |
197 } else { | 197 } else { |
198 if (item_->GetState() != content::DownloadItem::IN_PROGRESS) | 198 if (item_->GetState() != content::DownloadItem::IN_PROGRESS) |
199 delegate_->OnDownloadStopped(this); | 199 delegate_->OnDownloadStopped(this); |
200 } | 200 } |
201 | 201 |
202 if (item_->IsDangerous()) { | 202 if (item_->IsDangerous()) { |
203 notification_->set_type(message_center::NOTIFICATION_TYPE_SIMPLE); | 203 notification_->set_type(message_center::NOTIFICATION_TYPE_BASE_FORMAT); |
204 notification_->set_title(GetTitle()); | 204 notification_->set_title(GetTitle()); |
205 notification_->set_message(GetWarningText()); | 205 notification_->set_message(GetWarningText()); |
206 | 206 |
207 // Show icon. | 207 // Show icon. |
208 SetNotificationImage(IDR_DOWNLOAD_NOTIFICATION_MALICIOUS); | 208 SetNotificationImage(IDR_DOWNLOAD_NOTIFICATION_MALICIOUS); |
209 } else { | 209 } else { |
210 notification_->set_title(GetTitle()); | 210 notification_->set_title(GetTitle()); |
211 notification_->set_message(model.GetStatusText()); | 211 notification_->set_message(model.GetStatusText()); |
212 | 212 |
213 bool is_off_the_record = item_->GetBrowserContext() && | 213 bool is_off_the_record = item_->GetBrowserContext() && |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 } else if (type == UPDATE_EXISTING) { | 292 } else if (type == UPDATE_EXISTING) { |
293 notification_ui_manager()->Update(*notification_, profile_); | 293 notification_ui_manager()->Update(*notification_, profile_); |
294 | 294 |
295 // When the download is just completed (or interrupted), close the | 295 // When the download is just completed (or interrupted), close the |
296 // notification once and re-show it immediately so it'll pop up. | 296 // notification once and re-show it immediately so it'll pop up. |
297 if ((item_->GetState() == content::DownloadItem::COMPLETE && | 297 if ((item_->GetState() == content::DownloadItem::COMPLETE && |
298 previous_download_state_ != content::DownloadItem::COMPLETE) || | 298 previous_download_state_ != content::DownloadItem::COMPLETE) || |
299 (item_->GetState() == content::DownloadItem::INTERRUPTED && | 299 (item_->GetState() == content::DownloadItem::INTERRUPTED && |
300 previous_download_state_ != content::DownloadItem::INTERRUPTED)) { | 300 previous_download_state_ != content::DownloadItem::INTERRUPTED)) { |
301 CloseNotificationByNonUser(); | 301 CloseNotificationByNonUser(); |
302 // Changes the type from PROGRESS to SIMPLE. | 302 // Changes the type from PROGRESS to BASE_FORMAT. |
303 notification_->set_type(message_center::NOTIFICATION_TYPE_SIMPLE); | 303 notification_->set_type(message_center::NOTIFICATION_TYPE_BASE_FORMAT); |
304 notification_ui_manager()->Add(*notification_, profile_); | 304 notification_ui_manager()->Add(*notification_, profile_); |
305 } | 305 } |
306 } else { | 306 } else { |
307 NOTREACHED(); | 307 NOTREACHED(); |
308 } | 308 } |
309 | 309 |
310 previous_download_state_ = item_->GetState(); | 310 previous_download_state_ = item_->GetState(); |
311 } | 311 } |
312 | 312 |
313 void DownloadNotificationItem::OnDownloadOpened(content::DownloadItem* item) { | 313 void DownloadNotificationItem::OnDownloadOpened(content::DownloadItem* item) { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 NOTREACHED(); | 492 NOTREACHED(); |
493 return base::string16(); | 493 return base::string16(); |
494 } | 494 } |
495 | 495 |
496 Browser* DownloadNotificationItem::GetBrowser() { | 496 Browser* DownloadNotificationItem::GetBrowser() { |
497 chrome::ScopedTabbedBrowserDisplayer browser_displayer( | 497 chrome::ScopedTabbedBrowserDisplayer browser_displayer( |
498 profile_, chrome::GetActiveDesktop()); | 498 profile_, chrome::GetActiveDesktop()); |
499 DCHECK(browser_displayer.browser()); | 499 DCHECK(browser_displayer.browser()); |
500 return browser_displayer.browser(); | 500 return browser_displayer.browser(); |
501 } | 501 } |
OLD | NEW |