Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: chrome/browser/banners/app_banner_manager.cc

Issue 1017193002: [App banners] Be less strict about navigations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
23 bool AppBannerManager::URLsAreForTheSamePage(const GURL& first,
24 const GURL& second) {
25 return first.GetWithEmptyPath() == second.GetWithEmptyPath() &&
26 first.path() == second.path() && first.query() == second.query();
27 }
28
22 AppBannerManager::AppBannerManager(int icon_size) 29 AppBannerManager::AppBannerManager(int icon_size)
23 : ideal_icon_size_(icon_size), 30 : ideal_icon_size_(icon_size),
24 data_fetcher_(nullptr), 31 data_fetcher_(nullptr),
25 weak_factory_(this) { 32 weak_factory_(this) {
26 } 33 }
27 34
28 AppBannerManager::~AppBannerManager() { 35 AppBannerManager::~AppBannerManager() {
29 CancelActiveFetcher(); 36 CancelActiveFetcher();
30 } 37 }
31 38
32 void AppBannerManager::DidFinishLoad( 39 void AppBannerManager::DidFinishLoad(
33 content::RenderFrameHost* render_frame_host, 40 content::RenderFrameHost* render_frame_host,
34 const GURL& validated_url) { 41 const GURL& validated_url) {
35 if (render_frame_host->GetParent()) 42 if (render_frame_host->GetParent())
36 return; 43 return;
37 44
45 if (data_fetcher_.get() && data_fetcher_->is_active() &&
46 URLsAreForTheSamePage(data_fetcher_->validated_url(), validated_url)) {
47 return;
48 }
49
38 // A secure scheme is required to show banners, so exit early if we see the 50 // A secure scheme is required to show banners, so exit early if we see the
39 // URL is invalid. 51 // URL is invalid.
40 if (!validated_url.SchemeIsSecure() && !gDisableSecureCheckForTesting) 52 if (!validated_url.SchemeIsSecure() && !gDisableSecureCheckForTesting)
41 return; 53 return;
42 54
43 // Kick off the data retrieval pipeline. 55 // Kick off the data retrieval pipeline.
44 data_fetcher_ = CreateAppBannerDataFetcher(weak_factory_.GetWeakPtr(), 56 data_fetcher_ = CreateAppBannerDataFetcher(weak_factory_.GetWeakPtr(),
45 ideal_icon_size_); 57 ideal_icon_size_);
46 data_fetcher_->Start(validated_url); 58 data_fetcher_->Start(validated_url);
47 } 59 }
(...skipping 29 matching lines...) Expand all
77 89
78 void AppBannerManager::DisableSecureSchemeCheckForTesting() { 90 void AppBannerManager::DisableSecureSchemeCheckForTesting() {
79 gDisableSecureCheckForTesting = true; 91 gDisableSecureCheckForTesting = true;
80 } 92 }
81 93
82 bool AppBannerManager::IsEnabled() { 94 bool AppBannerManager::IsEnabled() {
83 return base::FieldTrialList::FindFullName("AppBanners") == "Enabled"; 95 return base::FieldTrialList::FindFullName("AppBanners") == "Enabled";
84 } 96 }
85 97
86 } // namespace banners 98 } // namespace banners
OLDNEW
« no previous file with comments | « chrome/browser/banners/app_banner_manager.h ('k') | chrome/browser/banners/app_banner_settings_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698