Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/installable/installable_manager.h" | 5 #include "chrome/browser/installable/installable_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "chrome/browser/manifest/manifest_icon_downloader.h" | 9 #include "chrome/browser/manifest/manifest_icon_downloader.h" |
| 10 #include "chrome/browser/manifest/manifest_icon_selector.h" | 10 #include "chrome/browser/manifest/manifest_icon_selector.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ssl/security_state_tab_helper.h" | |
| 13 #include "components/security_state/core/security_state.h" | |
| 12 #include "content/public/browser/browser_context.h" | 14 #include "content/public/browser/browser_context.h" |
| 13 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/navigation_handle.h" | 16 #include "content/public/browser/navigation_handle.h" |
| 15 #include "content/public/browser/service_worker_context.h" | 17 #include "content/public/browser/service_worker_context.h" |
| 16 #include "content/public/browser/storage_partition.h" | 18 #include "content/public/browser/storage_partition.h" |
| 19 #include "net/base/url_util.h" | |
| 17 #include "third_party/WebKit/public/platform/WebDisplayMode.h" | 20 #include "third_party/WebKit/public/platform/WebDisplayMode.h" |
| 18 | 21 |
| 19 namespace { | 22 namespace { |
| 20 | 23 |
| 21 const char kPngExtension[] = ".png"; | 24 const char kPngExtension[] = ".png"; |
| 22 | 25 |
| 23 // This constant is the icon size on Android (48dp) multiplied by the scale | 26 // This constant is the icon size on Android (48dp) multiplied by the scale |
| 24 // factor of a Nexus 5 device (3x). For mobile and desktop platforms, a 144px | 27 // factor of a Nexus 5 device (3x). For mobile and desktop platforms, a 144px |
| 25 // icon is an approximate, appropriate lower bound. It is the currently | 28 // icon is an approximate, appropriate lower bound. It is the currently |
| 26 // advertised minimum icon size for triggering banners. | 29 // advertised minimum icon size for triggering banners. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 InstallableManager::InstallableManager(content::WebContents* web_contents) | 91 InstallableManager::InstallableManager(content::WebContents* web_contents) |
| 89 : content::WebContentsObserver(web_contents), | 92 : content::WebContentsObserver(web_contents), |
| 90 manifest_(new ManifestProperty()), | 93 manifest_(new ManifestProperty()), |
| 91 installable_(new InstallableProperty()), | 94 installable_(new InstallableProperty()), |
| 92 is_active_(false), | 95 is_active_(false), |
| 93 weak_factory_(this) { } | 96 weak_factory_(this) { } |
| 94 | 97 |
| 95 InstallableManager::~InstallableManager() = default; | 98 InstallableManager::~InstallableManager() = default; |
| 96 | 99 |
| 97 // static | 100 // static |
| 101 bool InstallableManager::IsContentSecure(content::WebContents* web_contents) { | |
| 102 if (!web_contents) | |
| 103 return false; | |
| 104 | |
| 105 // Whitelist localhost. Check the VisibleURL to match what the | |
| 106 // SecurityStateTabHelper looks at. | |
| 107 if (net::IsLocalhost(web_contents->GetVisibleURL().HostNoBrackets())) | |
|
benwells
2017/01/13 04:34:13
Hmm, it's a bit unfortunate you need to manually c
dominickn
2017/01/13 04:38:54
Yeah, that's what I expected too. Then it failed a
| |
| 108 return true; | |
| 109 | |
| 110 security_state::SecurityInfo security_info; | |
| 111 SecurityStateTabHelper::FromWebContents(web_contents) | |
| 112 ->GetSecurityInfo(&security_info); | |
| 113 return security_info.security_level == security_state::SECURE || | |
| 114 security_info.security_level == security_state::EV_SECURE; | |
| 115 } | |
| 116 | |
| 117 // static | |
| 98 int InstallableManager::GetMinimumIconSizeInPx() { | 118 int InstallableManager::GetMinimumIconSizeInPx() { |
| 99 return kIconMinimumSizeInPx; | 119 return kIconMinimumSizeInPx; |
| 100 } | 120 } |
| 101 | 121 |
| 102 void InstallableManager::GetData(const InstallableParams& params, | 122 void InstallableManager::GetData(const InstallableParams& params, |
| 103 const InstallableCallback& callback) { | 123 const InstallableCallback& callback) { |
| 104 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 124 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 105 | 125 |
| 106 // Return immediately if we're already working on a task. The new task will be | 126 // Return immediately if we're already working on a task. The new task will be |
| 107 // looked at once the current task is finished. | 127 // looked at once the current task is finished. |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 return manifest_->url; | 456 return manifest_->url; |
| 437 } | 457 } |
| 438 | 458 |
| 439 const content::Manifest& InstallableManager::manifest() const { | 459 const content::Manifest& InstallableManager::manifest() const { |
| 440 return manifest_->manifest; | 460 return manifest_->manifest; |
| 441 } | 461 } |
| 442 | 462 |
| 443 bool InstallableManager::is_installable() const { | 463 bool InstallableManager::is_installable() const { |
| 444 return installable_->installable; | 464 return installable_->installable; |
| 445 } | 465 } |
| OLD | NEW |