| OLD | NEW |
| 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/download/download_request_limiter.h" | 5 #include "chrome/browser/download/download_request_limiter.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // automatic downloads content settings. Alternatively, they can copy the | 90 // automatic downloads content settings. Alternatively, they can copy the |
| 91 // URL into a new tab, which will make a new DownloadRequestLimiter. | 91 // URL into a new tab, which will make a new DownloadRequestLimiter. |
| 92 // See also the initial_page_host_ logic in Observe() for | 92 // See also the initial_page_host_ logic in Observe() for |
| 93 // NOTIFICATION_NAV_ENTRY_PENDING. | 93 // NOTIFICATION_NAV_ENTRY_PENDING. |
| 94 break; | 94 break; |
| 95 default: | 95 default: |
| 96 NOTREACHED(); | 96 NOTREACHED(); |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 | 99 |
| 100 void DownloadRequestLimiter::TabDownloadState::DidGetUserGesture() { | 100 void DownloadRequestLimiter::TabDownloadState::DidGetUserInteraction( |
| 101 if (is_showing_prompt()) { | 101 const blink::WebInputEvent::Type type) { |
| 102 // Don't change the state if the user clicks on the page somewhere. | 102 if (is_showing_prompt() || type == blink::WebInputEvent::MouseWheel) { |
| 103 // Don't change state if a prompt is showing or if the user has scrolled. |
| 103 return; | 104 return; |
| 104 } | 105 } |
| 105 | 106 |
| 106 #if BUILDFLAG(ANDROID_JAVA_UI) | 107 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 107 bool promptable = InfoBarService::FromWebContents(web_contents()) != nullptr; | 108 bool promptable = InfoBarService::FromWebContents(web_contents()) != nullptr; |
| 108 #else | 109 #else |
| 109 bool promptable = | 110 bool promptable = |
| 110 PermissionBubbleManager::FromWebContents(web_contents()) != nullptr; | 111 PermissionBubbleManager::FromWebContents(web_contents()) != nullptr; |
| 111 #endif | 112 #endif |
| 112 | 113 |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 NOTREACHED(); | 488 NOTREACHED(); |
| 488 } | 489 } |
| 489 } | 490 } |
| 490 | 491 |
| 491 void DownloadRequestLimiter::Remove(TabDownloadState* state, | 492 void DownloadRequestLimiter::Remove(TabDownloadState* state, |
| 492 content::WebContents* contents) { | 493 content::WebContents* contents) { |
| 493 DCHECK(ContainsKey(state_map_, contents)); | 494 DCHECK(ContainsKey(state_map_, contents)); |
| 494 state_map_.erase(contents); | 495 state_map_.erase(contents); |
| 495 delete state; | 496 delete state; |
| 496 } | 497 } |
| OLD | NEW |