trusted_cdn_observer.cc 1.1 KB

123456789101112131415161718192021222324252627282930
  1. // Copyright 2020 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. #include "weblayer/browser/url_bar/trusted_cdn_observer.h"
  5. #include "components/embedder_support/android/util/cdn_utils.h"
  6. #include "content/public/browser/navigation_handle.h"
  7. #include "content/public/browser/web_contents.h"
  8. namespace weblayer {
  9. TrustedCDNObserver::TrustedCDNObserver(content::WebContents* web_contents)
  10. : WebContentsObserver(web_contents),
  11. content::WebContentsUserData<TrustedCDNObserver>(*web_contents) {}
  12. TrustedCDNObserver::~TrustedCDNObserver() = default;
  13. // TrustedCdn should only track primary pages and should skip subframe,
  14. // same-document, or non-committed navigations (downloads or 204/205 responses).
  15. void TrustedCDNObserver::PrimaryPageChanged(content::Page& page) {
  16. publisher_url_ = embedder_support::GetPublisherURL(page);
  17. // Trigger url bar update.
  18. web_contents()->DidChangeVisibleSecurityState();
  19. }
  20. WEB_CONTENTS_USER_DATA_KEY_IMPL(TrustedCDNObserver);
  21. } // namespace weblayer