Commit 3e898930 authored by yoshiki's avatar yoshiki Committed by Commit bot

Open the learn more page when user clicks a notification of malicious download

Open the learn more page about downloading malicious file, when user clicks a notification of suspicious download.

BUG=488109
TEST=none

Review URL: https://codereview.chromium.org/1126343006

Cr-Commit-Position: refs/heads/master@{#330688}
parent 6a8a06ca
...@@ -112,22 +112,34 @@ DownloadNotificationItem::~DownloadNotificationItem() { ...@@ -112,22 +112,34 @@ DownloadNotificationItem::~DownloadNotificationItem() {
} }
void DownloadNotificationItem::OnNotificationClick() { void DownloadNotificationItem::OnNotificationClick() {
if (openable_) { if (item_->IsDangerous()) {
if (item_->IsDone()) { #if defined(FULL_SAFE_BROWSING)
DownloadCommands(item_).ExecuteCommand(
DownloadCommands::LEARN_MORE_SCANNING);
#else
CloseNotificationByUser();
#endif
return;
}
switch (item_->GetState()) {
case content::DownloadItem::IN_PROGRESS:
item_->SetOpenWhenComplete(!item_->GetOpenWhenComplete()); // Toggle
break;
case content::DownloadItem::CANCELLED:
case content::DownloadItem::INTERRUPTED:
GetBrowser()->OpenURL(content::OpenURLParams(
GURL(chrome::kChromeUIDownloadsURL), content::Referrer(),
NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK,
false /* is_renderer_initiated */));
CloseNotificationByUser();
break;
case content::DownloadItem::COMPLETE:
item_->OpenDownload(); item_->OpenDownload();
CloseNotificationByUser(); CloseNotificationByUser();
} else { break;
item_->SetOpenWhenComplete(!item_->GetOpenWhenComplete()); // Toggle case content::DownloadItem::MAX_DOWNLOAD_STATE:
} NOTREACHED();
} else if (item_->GetState() == content::DownloadItem::INTERRUPTED ||
item_->GetState() == content::DownloadItem::CANCELLED) {
GetBrowser()->OpenURL(content::OpenURLParams(
GURL(chrome::kChromeUIDownloadsURL), content::Referrer(),
NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK,
false /* is_renderer_initiated */));
CloseNotificationByUser();
} else if (item_->IsDone()) {
CloseNotificationByUser();
} }
} }
...@@ -266,20 +278,15 @@ void DownloadNotificationItem::UpdateNotificationData( ...@@ -266,20 +278,15 @@ void DownloadNotificationItem::UpdateNotificationData(
std::vector<message_center::ButtonInfo> notification_actions; std::vector<message_center::ButtonInfo> notification_actions;
scoped_ptr<std::vector<DownloadCommands::Command>> actions( scoped_ptr<std::vector<DownloadCommands::Command>> actions(
GetPossibleActions().Pass()); GetExtraActions().Pass());
openable_ = false;
button_actions_.reset(new std::vector<DownloadCommands::Command>); button_actions_.reset(new std::vector<DownloadCommands::Command>);
for (auto it = actions->begin(); it != actions->end(); it++) { for (auto it = actions->begin(); it != actions->end(); it++) {
if (*it == DownloadCommands::OPEN_WHEN_COMPLETE) { button_actions_->push_back(*it);
openable_ = true; message_center::ButtonInfo button_info =
} else { message_center::ButtonInfo(GetCommandLabel(*it));
button_actions_->push_back(*it); button_info.icon = command.GetCommandIcon(*it);
message_center::ButtonInfo button_info = notification_actions.push_back(button_info);
message_center::ButtonInfo(GetCommandLabel(*it));
button_info.icon = command.GetCommandIcon(*it);
notification_actions.push_back(button_info);
}
} }
notification_->set_buttons(notification_actions); notification_->set_buttons(notification_actions);
...@@ -348,7 +355,7 @@ NotificationUIManager* DownloadNotificationItem::notification_ui_manager() ...@@ -348,7 +355,7 @@ NotificationUIManager* DownloadNotificationItem::notification_ui_manager()
} }
scoped_ptr<std::vector<DownloadCommands::Command>> scoped_ptr<std::vector<DownloadCommands::Command>>
DownloadNotificationItem::GetPossibleActions() const { DownloadNotificationItem::GetExtraActions() const {
scoped_ptr<std::vector<DownloadCommands::Command>> actions( scoped_ptr<std::vector<DownloadCommands::Command>> actions(
new std::vector<DownloadCommands::Command>()); new std::vector<DownloadCommands::Command>());
...@@ -360,7 +367,6 @@ DownloadNotificationItem::GetPossibleActions() const { ...@@ -360,7 +367,6 @@ DownloadNotificationItem::GetPossibleActions() const {
switch (item_->GetState()) { switch (item_->GetState()) {
case content::DownloadItem::IN_PROGRESS: case content::DownloadItem::IN_PROGRESS:
actions->push_back(DownloadCommands::OPEN_WHEN_COMPLETE);
if (!item_->IsPaused()) if (!item_->IsPaused())
actions->push_back(DownloadCommands::PAUSE); actions->push_back(DownloadCommands::PAUSE);
else else
...@@ -373,7 +379,6 @@ DownloadNotificationItem::GetPossibleActions() const { ...@@ -373,7 +379,6 @@ DownloadNotificationItem::GetPossibleActions() const {
actions->push_back(DownloadCommands::RESUME); actions->push_back(DownloadCommands::RESUME);
break; break;
case content::DownloadItem::COMPLETE: case content::DownloadItem::COMPLETE:
actions->push_back(DownloadCommands::OPEN_WHEN_COMPLETE);
actions->push_back(DownloadCommands::SHOW_IN_FOLDER); actions->push_back(DownloadCommands::SHOW_IN_FOLDER);
break; break;
case content::DownloadItem::MAX_DOWNLOAD_STATE: case content::DownloadItem::MAX_DOWNLOAD_STATE:
......
...@@ -102,9 +102,9 @@ class DownloadNotificationItem : public content::DownloadItem::Observer { ...@@ -102,9 +102,9 @@ class DownloadNotificationItem : public content::DownloadItem::Observer {
Browser* GetBrowser(); Browser* GetBrowser();
scoped_ptr<std::vector<DownloadCommands::Command>> GetPossibleActions() const; // Returns the list of possible extra (all except the default) actions.
scoped_ptr<std::vector<DownloadCommands::Command>> GetExtraActions() const;
bool openable_ = false;
int image_resource_id_ = 0; int image_resource_id_ = 0;
content::DownloadItem::DownloadState previous_download_state_ = content::DownloadItem::DownloadState previous_download_state_ =
content::DownloadItem::MAX_DOWNLOAD_STATE; // As uninitialized state content::DownloadItem::MAX_DOWNLOAD_STATE; // As uninitialized state
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment