| 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 "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 "content/public/common/origin_util.h" |
| 15 #include "net/base/load_flags.h" | 15 #include "net/base/load_flags.h" |
| 16 #include "ui/gfx/screen.h" | 16 #include "ui/gfx/screen.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 bool gDisableSecureCheckForTesting = false; | 19 bool gDisableSecureCheckForTesting = false; |
| 20 } // anonymous namespace | 20 } // anonymous namespace |
| 21 | 21 |
| 22 namespace banners { | 22 namespace banners { |
| 23 | 23 |
| 24 bool AppBannerManager::URLsAreForTheSamePage(const GURL& first, | 24 bool AppBannerManager::URLsAreForTheSamePage(const GURL& first, |
| 25 const GURL& second) { | 25 const GURL& second) { |
| 26 return first.GetWithEmptyPath() == second.GetWithEmptyPath() && | 26 return first.GetWithEmptyPath() == second.GetWithEmptyPath() && |
| 27 first.path() == second.path() && first.query() == second.query(); | 27 first.path() == second.path() && first.query() == second.query(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 AppBannerManager::AppBannerManager(int icon_size) | 30 AppBannerManager::AppBannerManager(int ideal_icon_size_in_dp) |
| 31 : ideal_icon_size_(icon_size), | 31 : ideal_icon_size_in_dp_(ideal_icon_size_in_dp), |
| 32 data_fetcher_(nullptr), | 32 data_fetcher_(nullptr), |
| 33 weak_factory_(this) { | 33 weak_factory_(this) { |
| 34 } | 34 } |
| 35 | 35 |
| 36 AppBannerManager::AppBannerManager(content::WebContents* web_contents, | 36 AppBannerManager::AppBannerManager(content::WebContents* web_contents, |
| 37 int icon_size) | 37 int ideal_icon_size_in_dp) |
| 38 : content::WebContentsObserver(web_contents), | 38 : content::WebContentsObserver(web_contents), |
| 39 ideal_icon_size_(icon_size), | 39 ideal_icon_size_in_dp_(ideal_icon_size_in_dp), |
| 40 data_fetcher_(nullptr), | 40 data_fetcher_(nullptr), |
| 41 weak_factory_(this) { | 41 weak_factory_(this) { |
| 42 } | 42 } |
| 43 | 43 |
| 44 AppBannerManager::~AppBannerManager() { | 44 AppBannerManager::~AppBannerManager() { |
| 45 CancelActiveFetcher(); | 45 CancelActiveFetcher(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void AppBannerManager::DidCommitProvisionalLoadForFrame( | 48 void AppBannerManager::DidCommitProvisionalLoadForFrame( |
| 49 content::RenderFrameHost* render_frame_host, | 49 content::RenderFrameHost* render_frame_host, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 66 // A secure origin is required to show banners, so exit early if we see the | 66 // A secure origin is required to show banners, so exit early if we see the |
| 67 // URL is invalid. | 67 // URL is invalid. |
| 68 if (!content::IsOriginSecure(validated_url) && | 68 if (!content::IsOriginSecure(validated_url) && |
| 69 !gDisableSecureCheckForTesting) { | 69 !gDisableSecureCheckForTesting) { |
| 70 OutputDeveloperNotShownMessage(web_contents(), kNotServedFromSecureOrigin); | 70 OutputDeveloperNotShownMessage(web_contents(), kNotServedFromSecureOrigin); |
| 71 return; | 71 return; |
| 72 } | 72 } |
| 73 | 73 |
| 74 // Kick off the data retrieval pipeline. | 74 // Kick off the data retrieval pipeline. |
| 75 data_fetcher_ = CreateAppBannerDataFetcher(weak_factory_.GetWeakPtr(), | 75 data_fetcher_ = CreateAppBannerDataFetcher(weak_factory_.GetWeakPtr(), |
| 76 ideal_icon_size_); | 76 ideal_icon_size_in_dp_); |
| 77 data_fetcher_->Start(validated_url, last_transition_type_); | 77 data_fetcher_->Start(validated_url, last_transition_type_); |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool AppBannerManager::HandleNonWebApp(const std::string& platform, | 80 bool AppBannerManager::HandleNonWebApp(const std::string& platform, |
| 81 const GURL& url, | 81 const GURL& url, |
| 82 const std::string& id) { | 82 const std::string& id) { |
| 83 return false; | 83 return false; |
| 84 } | 84 } |
| 85 | 85 |
| 86 void AppBannerManager::ReplaceWebContents(content::WebContents* web_contents) { | 86 void AppBannerManager::ReplaceWebContents(content::WebContents* web_contents) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 105 } | 105 } |
| 106 | 106 |
| 107 void AppBannerManager::ForceEngagementWeightsForTesting( | 107 void AppBannerManager::ForceEngagementWeightsForTesting( |
| 108 double direct_engagement, | 108 double direct_engagement, |
| 109 double indirect_engagement) { | 109 double indirect_engagement) { |
| 110 AppBannerSettingsHelper::SetEngagementWeights(direct_engagement, | 110 AppBannerSettingsHelper::SetEngagementWeights(direct_engagement, |
| 111 indirect_engagement); | 111 indirect_engagement); |
| 112 } | 112 } |
| 113 | 113 |
| 114 } // namespace banners | 114 } // namespace banners |
| OLD | NEW |