| 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 "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
| 8 #include "chrome/browser/banners/app_banner_data_fetcher.h" | 8 #include "chrome/browser/banners/app_banner_data_fetcher.h" |
| 9 #include "chrome/browser/banners/app_banner_settings_helper.h" | 9 #include "chrome/browser/banners/app_banner_settings_helper.h" |
| 10 #include "content/public/browser/navigation_details.h" | 10 #include "content/public/browser/navigation_details.h" |
| 11 #include "content/public/browser/render_frame_host.h" | 11 #include "content/public/browser/render_frame_host.h" |
| 12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
| 13 #include "content/public/common/frame_navigate_params.h" | 13 #include "content/public/common/frame_navigate_params.h" |
| 14 #include "content/public/common/origin_util.h" |
| 14 #include "net/base/load_flags.h" | 15 #include "net/base/load_flags.h" |
| 15 #include "ui/gfx/screen.h" | 16 #include "ui/gfx/screen.h" |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 bool gDisableSecureCheckForTesting = false; | 19 bool gDisableSecureCheckForTesting = false; |
| 19 } // anonymous namespace | 20 } // anonymous namespace |
| 20 | 21 |
| 21 namespace banners { | 22 namespace banners { |
| 22 | 23 |
| 23 bool AppBannerManager::URLsAreForTheSamePage(const GURL& first, | 24 bool AppBannerManager::URLsAreForTheSamePage(const GURL& first, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 40 content::RenderFrameHost* render_frame_host, | 41 content::RenderFrameHost* render_frame_host, |
| 41 const GURL& validated_url) { | 42 const GURL& validated_url) { |
| 42 if (render_frame_host->GetParent()) | 43 if (render_frame_host->GetParent()) |
| 43 return; | 44 return; |
| 44 | 45 |
| 45 if (data_fetcher_.get() && data_fetcher_->is_active() && | 46 if (data_fetcher_.get() && data_fetcher_->is_active() && |
| 46 URLsAreForTheSamePage(data_fetcher_->validated_url(), validated_url)) { | 47 URLsAreForTheSamePage(data_fetcher_->validated_url(), validated_url)) { |
| 47 return; | 48 return; |
| 48 } | 49 } |
| 49 | 50 |
| 50 // A secure scheme is required to show banners, so exit early if we see the | 51 // A secure origin is required to show banners, so exit early if we see the |
| 51 // URL is invalid. | 52 // URL is invalid. |
| 52 if (!validated_url.SchemeIsSecure() && !gDisableSecureCheckForTesting) | 53 if (!IsOriginSecure(validated_url) && !gDisableSecureCheckForTesting) |
| 53 return; | 54 return; |
| 54 | 55 |
| 55 // Kick off the data retrieval pipeline. | 56 // Kick off the data retrieval pipeline. |
| 56 data_fetcher_ = CreateAppBannerDataFetcher(weak_factory_.GetWeakPtr(), | 57 data_fetcher_ = CreateAppBannerDataFetcher(weak_factory_.GetWeakPtr(), |
| 57 ideal_icon_size_); | 58 ideal_icon_size_); |
| 58 data_fetcher_->Start(validated_url); | 59 data_fetcher_->Start(validated_url); |
| 59 } | 60 } |
| 60 | 61 |
| 61 | 62 |
| 62 bool AppBannerManager::HandleNonWebApp(const std::string& platform, | 63 bool AppBannerManager::HandleNonWebApp(const std::string& platform, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 91 | 92 |
| 92 void AppBannerManager::DisableSecureSchemeCheckForTesting() { | 93 void AppBannerManager::DisableSecureSchemeCheckForTesting() { |
| 93 gDisableSecureCheckForTesting = true; | 94 gDisableSecureCheckForTesting = true; |
| 94 } | 95 } |
| 95 | 96 |
| 96 bool AppBannerManager::IsEnabled() { | 97 bool AppBannerManager::IsEnabled() { |
| 97 return base::FieldTrialList::FindFullName("AppBanners") == "Enabled"; | 98 return base::FieldTrialList::FindFullName("AppBanners") == "Enabled"; |
| 98 } | 99 } |
| 99 | 100 |
| 100 } // namespace banners | 101 } // namespace banners |
| OLD | NEW |