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, |
dominickn
2016/01/17 23:20:19
I dislike how render_frame_host is passed in here,
horo
2016/01/18 06:28:56
Done.
| |
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) && |
82 !is_debug_mode) { | |
81 return; | 83 return; |
82 } | 84 } |
83 | 85 |
84 // A secure origin is required to show banners, so exit early if we see the | 86 // A secure origin is required to show banners, so exit early if we see the |
85 // URL is invalid. | 87 // URL is invalid. |
86 if (!content::IsOriginSecure(validated_url) && | 88 if (!content::IsOriginSecure(validated_url) && |
87 !gDisableSecureCheckForTesting) { | 89 !gDisableSecureCheckForTesting) { |
88 OutputDeveloperNotShownMessage(web_contents(), kNotServedFromSecureOrigin); | 90 OutputDeveloperNotShownMessage(web_contents(), kNotServedFromSecureOrigin, |
91 is_debug_mode); | |
89 return; | 92 return; |
90 } | 93 } |
91 | 94 |
92 // Kick off the data retrieval pipeline. | 95 // Kick off the data retrieval pipeline. |
93 data_fetcher_ = CreateAppBannerDataFetcher(weak_factory_.GetWeakPtr()); | 96 data_fetcher_ = |
97 CreateAppBannerDataFetcher(weak_factory_.GetWeakPtr(), is_debug_mode); | |
94 data_fetcher_->Start(validated_url, last_transition_type_); | 98 data_fetcher_->Start(validated_url, last_transition_type_); |
95 } | 99 } |
96 | 100 |
101 void AppBannerManager::DidFinishLoad( | |
102 content::RenderFrameHost* render_frame_host, | |
103 const GURL& validated_url) { | |
104 TriggerAppBannerFetch(render_frame_host, validated_url, false); | |
dominickn
2016/01/17 23:20:18
Nit: add a comment explaining argument 3.
horo
2016/01/18 06:28:56
Done.
| |
105 } | |
106 | |
97 bool AppBannerManager::HandleNonWebApp(const std::string& platform, | 107 bool AppBannerManager::HandleNonWebApp(const std::string& platform, |
98 const GURL& url, | 108 const GURL& url, |
99 const std::string& id) { | 109 const std::string& id, |
110 bool is_debug_mode) { | |
100 return false; | 111 return false; |
101 } | 112 } |
102 | 113 |
103 void AppBannerManager::CancelActiveFetcher() { | 114 void AppBannerManager::CancelActiveFetcher() { |
104 if (data_fetcher_ != nullptr) { | 115 if (data_fetcher_ != nullptr) { |
105 data_fetcher_->Cancel(); | 116 data_fetcher_->Cancel(); |
106 data_fetcher_ = nullptr; | 117 data_fetcher_ = nullptr; |
107 } | 118 } |
108 } | 119 } |
109 | 120 |
110 } // namespace banners | 121 } // namespace banners |
OLD | NEW |