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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 if (item_) | 110 if (item_) |
111 item_->RemoveObserver(this); | 111 item_->RemoveObserver(this); |
112 } | 112 } |
113 | 113 |
114 void DownloadNotificationItem::OnNotificationClick() { | 114 void DownloadNotificationItem::OnNotificationClick() { |
115 if (openable_) { | 115 if (openable_) { |
116 if (item_->IsDone()) { | 116 if (item_->IsDone()) { |
117 item_->OpenDownload(); | 117 item_->OpenDownload(); |
118 CloseNotificationByUser(); | 118 CloseNotificationByUser(); |
119 } else { | 119 } else { |
120 item_->SetOpenWhenComplete(!item_->GetOpenWhenComplete()); // Toggle | 120 item_->SetOpenWhenComplete(!item_->GetOpenWhenComplete()); // Toggle |
asanka
2015/05/14 22:07:42
Does this also cause the notification to close aut
yoshiki
2015/05/18 16:51:59
No, the notification doesn't close. When the downl
| |
121 } | 121 } |
122 #if defined(FULL_SAFE_BROWSING) | |
123 } else if (item_->IsDangerous()) { | |
asanka
2015/05/14 22:07:42
At this point, I think it would be readable to bre
yoshiki
2015/05/18 16:51:59
Thanks, I refined the code of OnNotificationClick
| |
124 DownloadCommands(item_).ExecuteCommand( | |
125 DownloadCommands::LEARN_MORE_SCANNING); | |
126 #endif | |
122 } else if (item_->GetState() == content::DownloadItem::INTERRUPTED || | 127 } else if (item_->GetState() == content::DownloadItem::INTERRUPTED || |
123 item_->GetState() == content::DownloadItem::CANCELLED) { | 128 item_->GetState() == content::DownloadItem::CANCELLED) { |
124 GetBrowser()->OpenURL(content::OpenURLParams( | 129 GetBrowser()->OpenURL(content::OpenURLParams( |
125 GURL(chrome::kChromeUIDownloadsURL), content::Referrer(), | 130 GURL(chrome::kChromeUIDownloadsURL), content::Referrer(), |
126 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, | 131 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, |
127 false /* is_renderer_initiated */)); | 132 false /* is_renderer_initiated */)); |
128 CloseNotificationByUser(); | 133 CloseNotificationByUser(); |
129 } else if (item_->IsDone()) { | 134 } else if (item_->IsDone()) { |
130 CloseNotificationByUser(); | 135 CloseNotificationByUser(); |
131 } | 136 } |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
464 NOTREACHED(); | 469 NOTREACHED(); |
465 return base::string16(); | 470 return base::string16(); |
466 } | 471 } |
467 | 472 |
468 Browser* DownloadNotificationItem::GetBrowser() { | 473 Browser* DownloadNotificationItem::GetBrowser() { |
469 chrome::ScopedTabbedBrowserDisplayer browser_displayer( | 474 chrome::ScopedTabbedBrowserDisplayer browser_displayer( |
470 profile_, chrome::GetActiveDesktop()); | 475 profile_, chrome::GetActiveDesktop()); |
471 DCHECK(browser_displayer.browser()); | 476 DCHECK(browser_displayer.browser()); |
472 return browser_displayer.browser(); | 477 return browser_displayer.browser(); |
473 } | 478 } |
OLD | NEW |