security_state_tab_helper.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright 2015 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. #ifndef CHROME_BROWSER_SSL_SECURITY_STATE_TAB_HELPER_H_
  5. #define CHROME_BROWSER_SSL_SECURITY_STATE_TAB_HELPER_H_
  6. #include <memory>
  7. #include "base/macros.h"
  8. #include "components/security_state/core/security_state.h"
  9. #include "content/public/browser/web_contents_observer.h"
  10. #include "content/public/browser/web_contents_user_data.h"
  11. #include "third_party/WebKit/public/platform/WebSecurityStyle.h"
  12. namespace content {
  13. class NavigationHandle;
  14. class WebContents;
  15. } // namespace content
  16. // Tab helper provides the page's security status. Also logs console warnings
  17. // for private data on insecure pages.
  18. class SecurityStateTabHelper
  19. : public content::WebContentsObserver,
  20. public content::WebContentsUserData<SecurityStateTabHelper> {
  21. public:
  22. ~SecurityStateTabHelper() override;
  23. // See security_state::GetSecurityInfo.
  24. void GetSecurityInfo(security_state::SecurityInfo* result) const;
  25. // Called when the NavigationEntry's SSLStatus or other security
  26. // information changes.
  27. void VisibleSecurityStateChanged();
  28. // content::WebContentsObserver:
  29. void DidStartNavigation(
  30. content::NavigationHandle* navigation_handle) override;
  31. void DidFinishNavigation(
  32. content::NavigationHandle* navigation_handle) override;
  33. void WebContentsDestroyed() override;
  34. private:
  35. explicit SecurityStateTabHelper(content::WebContents* web_contents);
  36. friend class content::WebContentsUserData<SecurityStateTabHelper>;
  37. bool UsedPolicyInstalledCertificate() const;
  38. #if 0
  39. security_state::MaliciousContentStatus GetMaliciousContentStatus() const;
  40. #endif
  41. std::unique_ptr<security_state::VisibleSecurityState>
  42. GetVisibleSecurityState() const;
  43. // True if a console message has been logged about an omnibox warning that
  44. // will be shown in future versions of Chrome for insecure HTTP pages. This
  45. // message should only be logged once per main-frame navigation.
  46. bool logged_http_warning_on_current_navigation_;
  47. // The time that a console or omnibox warning was shown for insecure
  48. // HTTP pages that contain password or credit card fields. This is set
  49. // at most once per main-frame navigation (the first time that an HTTP
  50. // warning triggers on that navigation) and is used for UMA
  51. // histogramming.
  52. base::Time time_of_http_warning_on_current_navigation_;
  53. DISALLOW_COPY_AND_ASSIGN(SecurityStateTabHelper);
  54. };
  55. #endif // CHROME_BROWSER_SSL_SECURITY_STATE_TAB_HELPER_H_