| 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 "content/public/browser/navigation_details.h" | 10 #include "content/public/browser/navigation_details.h" | 
| 10 #include "content/public/browser/render_frame_host.h" | 11 #include "content/public/browser/render_frame_host.h" | 
| 11 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" | 
| 12 #include "content/public/common/frame_navigate_params.h" | 13 #include "content/public/common/frame_navigate_params.h" | 
| 13 #include "net/base/load_flags.h" | 14 #include "net/base/load_flags.h" | 
| 14 #include "ui/gfx/screen.h" | 15 #include "ui/gfx/screen.h" | 
| 15 | 16 | 
| 16 namespace { | 17 namespace { | 
| 17 bool gDisableSecureCheckForTesting = false; | 18 bool gDisableSecureCheckForTesting = false; | 
| 18 }  // anonymous namespace | 19 }  // anonymous namespace | 
| 19 | 20 | 
| 20 namespace banners { | 21 namespace banners { | 
| 21 | 22 | 
| 22 AppBannerManager::AppBannerManager(int icon_size) | 23 AppBannerManager::AppBannerManager(int icon_size) | 
| 23     : ideal_icon_size_(icon_size), | 24     : ideal_icon_size_(icon_size), | 
| 24       data_fetcher_(nullptr), | 25       data_fetcher_(nullptr), | 
| 25       weak_factory_(this) { | 26       weak_factory_(this) { | 
| 26 } | 27 } | 
| 27 | 28 | 
| 28 AppBannerManager::~AppBannerManager() { | 29 AppBannerManager::~AppBannerManager() { | 
| 29   CancelActiveFetcher(); | 30   CancelActiveFetcher(); | 
| 30 } | 31 } | 
| 31 | 32 | 
| 32 void AppBannerManager::DidFinishLoad( | 33 void AppBannerManager::DidFinishLoad( | 
| 33     content::RenderFrameHost* render_frame_host, | 34     content::RenderFrameHost* render_frame_host, | 
| 34     const GURL& validated_url) { | 35     const GURL& validated_url) { | 
| 35   if (render_frame_host->GetParent()) | 36   if (render_frame_host->GetParent()) | 
| 36     return; | 37     return; | 
| 37 | 38 | 
|  | 39   if (data_fetcher_.get() && data_fetcher_->is_active() | 
|  | 40         && AppBannerSettingsHelper::URLsAreForTheSamePage( | 
|  | 41               data_fetcher_->validated_url(), | 
|  | 42               validated_url)) { | 
|  | 43     return; | 
|  | 44   } | 
|  | 45 | 
| 38   // A secure scheme is required to show banners, so exit early if we see the | 46   // A secure scheme is required to show banners, so exit early if we see the | 
| 39   // URL is invalid. | 47   // URL is invalid. | 
| 40   if (!validated_url.SchemeIsSecure() && !gDisableSecureCheckForTesting) | 48   if (!validated_url.SchemeIsSecure() && !gDisableSecureCheckForTesting) | 
| 41     return; | 49     return; | 
| 42 | 50 | 
| 43   // Kick off the data retrieval pipeline. | 51   // Kick off the data retrieval pipeline. | 
| 44   data_fetcher_ = CreateAppBannerDataFetcher(weak_factory_.GetWeakPtr(), | 52   data_fetcher_ = CreateAppBannerDataFetcher(weak_factory_.GetWeakPtr(), | 
| 45                                              ideal_icon_size_); | 53                                              ideal_icon_size_); | 
| 46   data_fetcher_->Start(validated_url); | 54   data_fetcher_->Start(validated_url); | 
| 47 } | 55 } | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
| 77 | 85 | 
| 78 void AppBannerManager::DisableSecureSchemeCheckForTesting() { | 86 void AppBannerManager::DisableSecureSchemeCheckForTesting() { | 
| 79   gDisableSecureCheckForTesting = true; | 87   gDisableSecureCheckForTesting = true; | 
| 80 } | 88 } | 
| 81 | 89 | 
| 82 bool AppBannerManager::IsEnabled() { | 90 bool AppBannerManager::IsEnabled() { | 
| 83   return base::FieldTrialList::FindFullName("AppBanners") == "Enabled"; | 91   return base::FieldTrialList::FindFullName("AppBanners") == "Enabled"; | 
| 84 } | 92 } | 
| 85 | 93 | 
| 86 }  // namespace banners | 94 }  // namespace banners | 
| OLD | NEW | 
|---|