1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PERMISSION_REQUEST_H_ 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PERMISSION_REQUEST_H_ 7 8 #include "base/macros.h" 9 #include "base/memory/weak_ptr.h" 10 #include "chrome/browser/download/download_request_limiter.h" 11 #include "components/permissions/permission_request.h" 12 #include "url/origin.h" 13 14 // A permission request that presents the user with a choice to allow or deny 15 // multiple downloads from the same site. This confirmation step protects 16 // against "carpet-bombing", where a malicious site forces multiple downloads on 17 // an unsuspecting user. 18 class DownloadPermissionRequest : public permissions::PermissionRequest { 19 public: 20 DownloadPermissionRequest( 21 base::WeakPtr<DownloadRequestLimiter::TabDownloadState> host, 22 const url::Origin& request_origin); 23 ~DownloadPermissionRequest() override; 24 25 private: 26 // permissions::PermissionRequest: 27 IconId GetIconId() const override; 28 #if defined(OS_ANDROID) 29 base::string16 GetMessageText() const override; 30 #endif 31 base::string16 GetMessageTextFragment() const override; 32 GURL GetOrigin() const override; 33 void PermissionGranted(bool is_one_time) override; 34 void PermissionDenied() override; 35 void Cancelled() override; 36 void RequestFinished() override; 37 permissions::PermissionRequestType GetPermissionRequestType() const override; 38 39 base::WeakPtr<DownloadRequestLimiter::TabDownloadState> host_; 40 url::Origin request_origin_; 41 42 DISALLOW_COPY_AND_ASSIGN(DownloadPermissionRequest); 43 }; 44 45 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PERMISSION_REQUEST_H_ 46