summaryrefslogtreecommitdiff
path: root/chromium/components/safe_browsing/password_protection/password_protection_navigation_throttle.h
blob: dcc1723850d36a05aad7fe732158b426e059e7b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_NAVIGATION_THROTTLE_H_
#define COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_NAVIGATION_THROTTLE_H_

#include "content/public/browser/navigation_throttle.h"

namespace content {
class NavigationHandle;
}  // namespace content

namespace safe_browsing {
// PasswordProtectionNavigationThrottle defers or cancel navigation under the
// following condition:
// (1) if a navigation starts when there is a on-going sync password reuse ping,
//     this throttle defers this navigation. When the verdict comes back, if the
//     verdict results in showing a modal warning dialog, the deferred
//     navigation will be canceled; otherwise, the deferred navigation will be
//     resumed.
// (2) if a navigation starts when there is a modal warning showing, this
//     throttle simply cancels this navigation.
class PasswordProtectionNavigationThrottle
    : public content::NavigationThrottle {
 public:
  PasswordProtectionNavigationThrottle(
      content::NavigationHandle* navigation_handle,
      bool is_warning_showing);
  ~PasswordProtectionNavigationThrottle() override;

  // content::NavigationThrottle:
  content::NavigationThrottle::ThrottleCheckResult WillStartRequest() override;
  content::NavigationThrottle::ThrottleCheckResult WillRedirectRequest()
      override;
  const char* GetNameForLogging() override;

  void ResumeNavigation();
  void CancelNavigation(
      content::NavigationThrottle::ThrottleCheckResult result);

 private:
  bool is_warning_showing_;
  DISALLOW_COPY_AND_ASSIGN(PasswordProtectionNavigationThrottle);
};

}  // namespace safe_browsing

#endif  // COMPONENTS_SAFE_BROWSING_PASSWORD_PROTECTION_PASSWORD_PROTECTION_NAVIGATION_THROTTLE_H_