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" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 bool AppBannerManager::IsFetcherActive() { | 63 bool AppBannerManager::IsFetcherActive() { |
64 return data_fetcher_ != nullptr && data_fetcher_->is_active(); | 64 return data_fetcher_ != nullptr && data_fetcher_->is_active(); |
65 } | 65 } |
66 | 66 |
67 void AppBannerManager::DidNavigateMainFrame( | 67 void AppBannerManager::DidNavigateMainFrame( |
68 const content::LoadCommittedDetails& details, | 68 const content::LoadCommittedDetails& details, |
69 const content::FrameNavigateParams& params) { | 69 const content::FrameNavigateParams& params) { |
70 last_transition_type_ = params.transition; | 70 last_transition_type_ = params.transition; |
71 } | 71 } |
72 | 72 |
73 void AppBannerManager::DidFinishLoad( | 73 void AppBannerManager::TriggerAppBannerFetch( |
74 content::RenderFrameHost* render_frame_host, | 74 content::RenderFrameHost* render_frame_host, |
75 const GURL& validated_url) { | 75 const GURL& validated_url, |
| 76 bool is_debug_mode) { |
76 if (render_frame_host->GetParent()) | 77 if (render_frame_host->GetParent()) |
77 return; | 78 return; |
78 | 79 |
79 if (data_fetcher_.get() && data_fetcher_->is_active() && | 80 if (data_fetcher_.get() && data_fetcher_->is_active() && |
80 URLsAreForTheSamePage(data_fetcher_->validated_url(), validated_url)) { | 81 URLsAreForTheSamePage(data_fetcher_->validated_url(), validated_url)) { |
81 return; | 82 return; |
82 } | 83 } |
83 | 84 |
84 // A secure origin is required to show banners, so exit early if we see the | 85 // A secure origin is required to show banners, so exit early if we see the |
85 // URL is invalid. | 86 // URL is invalid. |
86 if (!content::IsOriginSecure(validated_url) && | 87 if (!content::IsOriginSecure(validated_url) && |
87 !gDisableSecureCheckForTesting) { | 88 !gDisableSecureCheckForTesting) { |
88 OutputDeveloperNotShownMessage(web_contents(), kNotServedFromSecureOrigin); | 89 OutputDeveloperNotShownMessage(web_contents(), kNotServedFromSecureOrigin, |
| 90 is_debug_mode); |
89 return; | 91 return; |
90 } | 92 } |
91 | 93 |
92 // Kick off the data retrieval pipeline. | 94 // Kick off the data retrieval pipeline. |
93 data_fetcher_ = CreateAppBannerDataFetcher(weak_factory_.GetWeakPtr()); | 95 data_fetcher_ = |
| 96 CreateAppBannerDataFetcher(weak_factory_.GetWeakPtr(), is_debug_mode); |
94 data_fetcher_->Start(validated_url, last_transition_type_); | 97 data_fetcher_->Start(validated_url, last_transition_type_); |
95 } | 98 } |
96 | 99 |
| 100 void AppBannerManager::DidFinishLoad( |
| 101 content::RenderFrameHost* render_frame_host, |
| 102 const GURL& validated_url) { |
| 103 TriggerAppBannerFetch(render_frame_host, validated_url, false); |
| 104 } |
| 105 |
97 bool AppBannerManager::HandleNonWebApp(const std::string& platform, | 106 bool AppBannerManager::HandleNonWebApp(const std::string& platform, |
98 const GURL& url, | 107 const GURL& url, |
99 const std::string& id) { | 108 const std::string& id) { |
100 return false; | 109 return false; |
101 } | 110 } |
102 | 111 |
103 void AppBannerManager::CancelActiveFetcher() { | 112 void AppBannerManager::CancelActiveFetcher() { |
104 if (data_fetcher_ != nullptr) { | 113 if (data_fetcher_ != nullptr) { |
105 data_fetcher_->Cancel(); | 114 data_fetcher_->Cancel(); |
106 data_fetcher_ = nullptr; | 115 data_fetcher_ = nullptr; |
107 } | 116 } |
108 } | 117 } |
109 | 118 |
110 } // namespace banners | 119 } // namespace banners |
OLD | NEW |