| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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/banners/app_banner_manager.h" | 5 #include "chrome/browser/banners/app_banner_manager.h" |
| 6 | 6 |
| 7 #include "chrome/browser/banners/app_banner_data_fetcher.h" | 7 #include "chrome/browser/banners/app_banner_data_fetcher.h" |
| 8 #include "chrome/browser/banners/app_banner_debug_log.h" | 8 #include "chrome/browser/banners/app_banner_debug_log.h" |
| 9 #include "chrome/browser/banners/app_banner_settings_helper.h" | 9 #include "chrome/browser/banners/app_banner_settings_helper.h" |
| 10 #include "chrome/browser/engagement/site_engagement_service.h" | 10 #include "chrome/browser/engagement/site_engagement_service.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool AppBannerManager::IsFetcherActive() { | 60 bool AppBannerManager::IsFetcherActive() { |
| 61 return data_fetcher_ && data_fetcher_->is_active(); | 61 return data_fetcher_ && data_fetcher_->is_active(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void AppBannerManager::RequestAppBanner(const GURL& validated_url, | 64 void AppBannerManager::RequestAppBanner(const GURL& validated_url, |
| 65 bool is_debug_mode) { | 65 bool is_debug_mode) { |
| 66 content::WebContents* contents = web_contents(); | 66 content::WebContents* contents = web_contents(); |
| 67 if (contents->GetMainFrame()->GetParent()) { | 67 if (contents->GetMainFrame()->GetParent()) { |
| 68 OutputDeveloperNotShownMessage(contents, kNotLoadedInMainFrame, | 68 OutputDeveloperNotShownMessage(contents, |
| 69 is_debug_mode); | 69 OutputDeveloperMessageCode::kNotLoadedInMainFrame, is_debug_mode); |
| 70 return; | 70 return; |
| 71 } | 71 } |
| 72 | 72 |
| 73 if (data_fetcher_.get() && data_fetcher_->is_active() && | 73 if (data_fetcher_.get() && data_fetcher_->is_active() && |
| 74 URLsAreForTheSamePage(data_fetcher_->validated_url(), validated_url) && | 74 URLsAreForTheSamePage(data_fetcher_->validated_url(), validated_url) && |
| 75 !is_debug_mode) { | 75 !is_debug_mode) { |
| 76 return; | 76 return; |
| 77 } | 77 } |
| 78 | 78 |
| 79 // A secure origin is required to show banners, so exit early if we see the | 79 // A secure origin is required to show banners, so exit early if we see the |
| 80 // URL is invalid. | 80 // URL is invalid. |
| 81 if (!content::IsOriginSecure(validated_url) && | 81 if (!content::IsOriginSecure(validated_url) && |
| 82 !gDisableSecureCheckForTesting) { | 82 !gDisableSecureCheckForTesting) { |
| 83 OutputDeveloperNotShownMessage(contents, kNotServedFromSecureOrigin, | 83 OutputDeveloperNotShownMessage(contents, |
| 84 is_debug_mode); | 84 OutputDeveloperMessageCode::kNotServedFromSecureOrigin, is_debug_mode); |
| 85 return; | 85 return; |
| 86 } | 86 } |
| 87 | 87 |
| 88 // Kick off the data retrieval pipeline. | 88 // Kick off the data retrieval pipeline. |
| 89 data_fetcher_ = | 89 data_fetcher_ = |
| 90 CreateAppBannerDataFetcher(weak_factory_.GetWeakPtr(), is_debug_mode); | 90 CreateAppBannerDataFetcher(weak_factory_.GetWeakPtr(), is_debug_mode); |
| 91 data_fetcher_->Start(validated_url, last_transition_type_); | 91 data_fetcher_->Start(validated_url, last_transition_type_); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void AppBannerManager::DidStartNavigation( | 94 void AppBannerManager::DidStartNavigation( |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 } | 173 } |
| 174 | 174 |
| 175 void AppBannerManager::CancelActiveFetcher() { | 175 void AppBannerManager::CancelActiveFetcher() { |
| 176 if (data_fetcher_) { | 176 if (data_fetcher_) { |
| 177 data_fetcher_->Cancel(); | 177 data_fetcher_->Cancel(); |
| 178 data_fetcher_ = nullptr; | 178 data_fetcher_ = nullptr; |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 | 181 |
| 182 } // namespace banners | 182 } // namespace banners |
| OLD | NEW |