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::RequestAppBanner( |
74 content::RenderFrameHost* render_frame_host, | 74 content::RenderFrameHost* render_frame_host, |
75 const GURL& validated_url) { | 75 const GURL& validated_url, |
76 if (render_frame_host->GetParent()) | 76 bool is_debug_mode) { |
77 return; | 77 if (render_frame_host->GetParent()) { |
78 | 78 OutputDeveloperNotShownMessage(web_contents(), kNotLoadedInMainFrame, |
79 if (data_fetcher_.get() && data_fetcher_->is_active() && | 79 is_debug_mode); |
80 URLsAreForTheSamePage(data_fetcher_->validated_url(), validated_url)) { | |
81 return; | 80 return; |
82 } | 81 } |
83 | 82 |
| 83 if (data_fetcher_.get() && data_fetcher_->is_active() && |
| 84 URLsAreForTheSamePage(data_fetcher_->validated_url(), validated_url) && |
| 85 !is_debug_mode) { |
| 86 return; |
| 87 } |
| 88 |
84 // A secure origin is required to show banners, so exit early if we see the | 89 // A secure origin is required to show banners, so exit early if we see the |
85 // URL is invalid. | 90 // URL is invalid. |
86 if (!content::IsOriginSecure(validated_url) && | 91 if (!content::IsOriginSecure(validated_url) && |
87 !gDisableSecureCheckForTesting) { | 92 !gDisableSecureCheckForTesting) { |
88 OutputDeveloperNotShownMessage(web_contents(), kNotServedFromSecureOrigin); | 93 OutputDeveloperNotShownMessage(web_contents(), kNotServedFromSecureOrigin, |
| 94 is_debug_mode); |
89 return; | 95 return; |
90 } | 96 } |
91 | 97 |
92 // Kick off the data retrieval pipeline. | 98 // Kick off the data retrieval pipeline. |
93 data_fetcher_ = CreateAppBannerDataFetcher(weak_factory_.GetWeakPtr()); | 99 data_fetcher_ = |
| 100 CreateAppBannerDataFetcher(weak_factory_.GetWeakPtr(), is_debug_mode); |
94 data_fetcher_->Start(validated_url, last_transition_type_); | 101 data_fetcher_->Start(validated_url, last_transition_type_); |
95 } | 102 } |
96 | 103 |
| 104 void AppBannerManager::DidFinishLoad( |
| 105 content::RenderFrameHost* render_frame_host, |
| 106 const GURL& validated_url) { |
| 107 // The third argument is the is_debug_mode boolean value, which is true only |
| 108 // when it is triggered by the developer's action in DevTools. |
| 109 RequestAppBanner(render_frame_host, validated_url, false /* is_debug_mode */); |
| 110 } |
| 111 |
97 bool AppBannerManager::HandleNonWebApp(const std::string& platform, | 112 bool AppBannerManager::HandleNonWebApp(const std::string& platform, |
98 const GURL& url, | 113 const GURL& url, |
99 const std::string& id) { | 114 const std::string& id, |
| 115 bool is_debug_mode) { |
100 return false; | 116 return false; |
101 } | 117 } |
102 | 118 |
103 void AppBannerManager::CancelActiveFetcher() { | 119 void AppBannerManager::CancelActiveFetcher() { |
104 if (data_fetcher_ != nullptr) { | 120 if (data_fetcher_ != nullptr) { |
105 data_fetcher_->Cancel(); | 121 data_fetcher_->Cancel(); |
106 data_fetcher_ = nullptr; | 122 data_fetcher_ = nullptr; |
107 } | 123 } |
108 } | 124 } |
109 | 125 |
110 } // namespace banners | 126 } // namespace banners |
OLD | NEW |