Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: chrome/browser/ui/views/download/download_item_view.cc

Issue 153353006: Opt out of download feedback from settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/ui/views/download/download_item_view.h" 5 #include "chrome/browser/ui/views/download/download_item_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 // WARNING: all end states after this point delete |this|. 550 // WARNING: all end states after this point delete |this|.
551 DCHECK_EQ(discard_button_, sender); 551 DCHECK_EQ(discard_button_, sender);
552 if (model_.IsMalicious()) { 552 if (model_.IsMalicious()) {
553 UMA_HISTOGRAM_LONG_TIMES("clickjacking.dismiss_download", warning_duration); 553 UMA_HISTOGRAM_LONG_TIMES("clickjacking.dismiss_download", warning_duration);
554 shelf_->RemoveDownloadView(this); 554 shelf_->RemoveDownloadView(this);
555 return; 555 return;
556 } 556 }
557 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", warning_duration); 557 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", warning_duration);
558 if (model_.ShouldAllowDownloadFeedback() && 558 if (model_.ShouldAllowDownloadFeedback() &&
559 !shelf_->browser()->profile()->IsOffTheRecord()) { 559 !shelf_->browser()->profile()->IsOffTheRecord()) {
560 DownloadFeedbackDialogView::DownloadReportingStatus pref_value = 560 if (!shelf_->browser()->profile()->GetPrefs()->HasPrefPath(
561 static_cast<DownloadFeedbackDialogView::DownloadReportingStatus>( 561 prefs::kSafeBrowsingDownloadFeedbackEnabled)) {
562 shelf_->browser()->profile()->GetPrefs()->GetInteger( 562 // Show dialog, because the dialog hasn't been shown before.
563 prefs::kSafeBrowsingDownloadReportingEnabled)); 563 DownloadFeedbackDialogView::Show(
564 switch (pref_value) { 564 shelf_->get_parent()->GetNativeWindow(),
565 case DownloadFeedbackDialogView::kDialogNotYetShown: 565 shelf_->browser()->profile(),
566 DownloadFeedbackDialogView::Show( 566 base::Bind(
567 shelf_->get_parent()->GetNativeWindow(), 567 &DownloadItemView::PossiblySubmitDownloadToFeedbackService,
568 shelf_->browser()->profile(), 568 weak_ptr_factory_.GetWeakPtr()));
569 base::Bind( 569 } else {
570 &DownloadItemView::PossiblySubmitDownloadToFeedbackService, 570 PossiblySubmitDownloadToFeedbackService(
571 weak_ptr_factory_.GetWeakPtr())); 571 shelf_->browser()->profile()->GetPrefs()->GetBoolean(
572 break; 572 prefs::kSafeBrowsingDownloadFeedbackEnabled));
573
574 case DownloadFeedbackDialogView::kDownloadReportingEnabled:
575 case DownloadFeedbackDialogView::kDownloadReportingDisabled:
576 PossiblySubmitDownloadToFeedbackService(pref_value);
577 break;
578
579 case DownloadFeedbackDialogView::kMaxValue:
580 NOTREACHED();
581 } 573 }
582 return; 574 return;
583 } 575 }
584 download()->Remove(); 576 download()->Remove();
585 } 577 }
586 578
587 void DownloadItemView::AnimationProgressed(const gfx::Animation* animation) { 579 void DownloadItemView::AnimationProgressed(const gfx::Animation* animation) {
588 // We don't care if what animation (body button/drop button/complete), 580 // We don't care if what animation (body button/drop button/complete),
589 // is calling back, as they all have to go through the same paint call. 581 // is calling back, as they all have to go through the same paint call.
590 SchedulePaint(); 582 SchedulePaint();
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 download_protection_service->feedback_service()->BeginFeedbackForDownload( 922 download_protection_service->feedback_service()->BeginFeedbackForDownload(
931 download()); 923 download());
932 // WARNING: we are deleted at this point. Don't access 'this'. 924 // WARNING: we are deleted at this point. Don't access 'this'.
933 return true; 925 return true;
934 #else 926 #else
935 NOTREACHED(); 927 NOTREACHED();
936 return false; 928 return false;
937 #endif 929 #endif
938 } 930 }
939 931
940 void DownloadItemView::PossiblySubmitDownloadToFeedbackService( 932 void DownloadItemView::PossiblySubmitDownloadToFeedbackService(bool enabled) {
941 DownloadFeedbackDialogView::DownloadReportingStatus status) { 933 if (!enabled || !SubmitDownloadToFeedbackService())
942 if (status != DownloadFeedbackDialogView::kDownloadReportingEnabled ||
943 !SubmitDownloadToFeedbackService()) {
944 download()->Remove(); 934 download()->Remove();
945 }
946 // WARNING: 'this' is deleted at this point. Don't access 'this'. 935 // WARNING: 'this' is deleted at this point. Don't access 'this'.
947 } 936 }
948 937
949 void DownloadItemView::LoadIcon() { 938 void DownloadItemView::LoadIcon() {
950 IconManager* im = g_browser_process->icon_manager(); 939 IconManager* im = g_browser_process->icon_manager();
951 last_download_item_path_ = download()->GetTargetFilePath(); 940 last_download_item_path_ = download()->GetTargetFilePath();
952 im->LoadIcon(last_download_item_path_, 941 im->LoadIcon(last_download_item_path_,
953 IconLoader::SMALL, 942 IconLoader::SMALL,
954 base::Bind(&DownloadItemView::OnExtractIconComplete, 943 base::Bind(&DownloadItemView::OnExtractIconComplete,
955 base::Unretained(this)), 944 base::Unretained(this)),
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 void DownloadItemView::AnimateStateTransition(State from, State to, 1338 void DownloadItemView::AnimateStateTransition(State from, State to,
1350 gfx::SlideAnimation* animation) { 1339 gfx::SlideAnimation* animation) {
1351 if (from == NORMAL && to == HOT) { 1340 if (from == NORMAL && to == HOT) {
1352 animation->Show(); 1341 animation->Show();
1353 } else if (from == HOT && to == NORMAL) { 1342 } else if (from == HOT && to == NORMAL) {
1354 animation->Hide(); 1343 animation->Hide();
1355 } else if (from != to) { 1344 } else if (from != to) {
1356 animation->Reset((to == HOT) ? 1.0 : 0.0); 1345 animation->Reset((to == HOT) ? 1.0 : 0.0);
1357 } 1346 }
1358 } 1347 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/download/download_item_view.h ('k') | chrome/browser/ui/webui/options/browser_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698