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 "chrome/common/origin_util.h" | |
10 #include "content/public/browser/navigation_details.h" | 11 #include "content/public/browser/navigation_details.h" |
11 #include "content/public/browser/render_frame_host.h" | 12 #include "content/public/browser/render_frame_host.h" |
12 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
13 #include "content/public/common/frame_navigate_params.h" | 14 #include "content/public/common/frame_navigate_params.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 |
(...skipping 20 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 scheme is required to show banners, so exit early if we see the |
jww
2015/04/23 18:24:02
Please update this comment to reflect the new orig
lgarron
2015/04/23 23:05:51
Done.
| |
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::OnInvalidManifest(AppBannerDataFetcher* fetcher) { | 63 bool AppBannerManager::OnInvalidManifest(AppBannerDataFetcher* fetcher) { |
(...skipping 26 matching lines...) Expand all Loading... | |
89 | 90 |
90 void AppBannerManager::DisableSecureSchemeCheckForTesting() { | 91 void AppBannerManager::DisableSecureSchemeCheckForTesting() { |
91 gDisableSecureCheckForTesting = true; | 92 gDisableSecureCheckForTesting = true; |
92 } | 93 } |
93 | 94 |
94 bool AppBannerManager::IsEnabled() { | 95 bool AppBannerManager::IsEnabled() { |
95 return base::FieldTrialList::FindFullName("AppBanners") == "Enabled"; | 96 return base::FieldTrialList::FindFullName("AppBanners") == "Enabled"; |
96 } | 97 } |
97 | 98 |
98 } // namespace banners | 99 } // namespace banners |
OLD | NEW |