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

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

Issue 2630523002: Ensure the entire page is secure for PWAs. (Closed)
Patch Set: Whitelist localhost Created 3 years, 11 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "chrome/browser/banners/app_banner_metrics.h" 14 #include "chrome/browser/banners/app_banner_metrics.h"
15 #include "chrome/browser/banners/app_banner_settings_helper.h" 15 #include "chrome/browser/banners/app_banner_settings_helper.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/engagement/site_engagement_service.h" 17 #include "chrome/browser/engagement/site_engagement_service.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "components/rappor/public/rappor_utils.h" 20 #include "components/rappor/public/rappor_utils.h"
21 #include "components/rappor/rappor_service_impl.h" 21 #include "components/rappor/rappor_service_impl.h"
22 #include "content/public/browser/navigation_handle.h" 22 #include "content/public/browser/navigation_handle.h"
23 #include "content/public/browser/render_frame_host.h" 23 #include "content/public/browser/render_frame_host.h"
24 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
25 #include "content/public/common/origin_util.h"
26 #include "mojo/public/cpp/bindings/interface_request.h" 25 #include "mojo/public/cpp/bindings/interface_request.h"
27 #include "services/service_manager/public/cpp/interface_provider.h" 26 #include "services/service_manager/public/cpp/interface_provider.h"
28 #include "third_party/WebKit/public/platform/modules/installation/installation.m ojom.h" 27 #include "third_party/WebKit/public/platform/modules/installation/installation.m ojom.h"
29 #include "third_party/skia/include/core/SkBitmap.h" 28 #include "third_party/skia/include/core/SkBitmap.h"
30 29
31 namespace { 30 namespace {
32 31
33 int gCurrentRequestID = -1; 32 int gCurrentRequestID = -1;
34 int gTimeDeltaInDaysForTesting = 0; 33 int gTimeDeltaInDaysForTesting = 0;
35 34
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 need_to_log_status_ = !IsDebugMode(); 98 need_to_log_status_ = !IsDebugMode();
100 99
101 if (contents->GetMainFrame()->GetParent()) { 100 if (contents->GetMainFrame()->GetParent()) {
102 ReportStatus(contents, NOT_IN_MAIN_FRAME); 101 ReportStatus(contents, NOT_IN_MAIN_FRAME);
103 Stop(); 102 Stop();
104 return; 103 return;
105 } 104 }
106 105
107 // A secure origin is required to show banners, so exit early if we see the 106 // A secure origin is required to show banners, so exit early if we see the
108 // URL is invalid. 107 // URL is invalid.
109 if (!content::IsOriginSecure(validated_url)) { 108 if (!InstallableManager::IsContentSecure(contents)) {
110 ReportStatus(contents, NOT_FROM_SECURE_ORIGIN); 109 ReportStatus(contents, NOT_FROM_SECURE_ORIGIN);
111 Stop(); 110 Stop();
112 return; 111 return;
113 } 112 }
114 113
115 if (validated_url_.is_empty()) 114 if (validated_url_.is_empty())
116 validated_url_ = validated_url; 115 validated_url_ = validated_url;
117 116
118 // Any existing binding is invalid when we request a new banner. 117 // Any existing binding is invalid when we request a new banner.
119 if (binding_.is_bound()) 118 if (binding_.is_bound())
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. 535 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner.
537 // Don't reset |was_canceled_by_page_| yet for metrics purposes. 536 // Don't reset |was_canceled_by_page_| yet for metrics purposes.
538 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); 537 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_);
539 } else { 538 } else {
540 // Log that the prompt request was made for when we get the prompt reply. 539 // Log that the prompt request was made for when we get the prompt reply.
541 page_requested_prompt_ = true; 540 page_requested_prompt_ = true;
542 } 541 }
543 } 542 }
544 543
545 } // namespace banners 544 } // namespace banners
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698