OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
Matt Giuca
2017/02/06 00:40:11
CL description:
This is a bit confusing because i
constantina
2017/02/07 05:16:25
Done.
| |
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/extensions/bookmark_app_helper.h" | 5 #include "chrome/browser/extensions/bookmark_app_helper.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cctype> | 9 #include <cctype> |
10 #include <string> | 10 #include <string> |
11 | 11 |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
578 OnDidGetManifest(GURL(), manifest); | 578 OnDidGetManifest(GURL(), manifest); |
579 } | 579 } |
580 | 580 |
581 void BookmarkAppHelper::OnDidGetManifest(const GURL& manifest_url, | 581 void BookmarkAppHelper::OnDidGetManifest(const GURL& manifest_url, |
582 const content::Manifest& manifest) { | 582 const content::Manifest& manifest) { |
583 if (contents_->IsBeingDestroyed()) | 583 if (contents_->IsBeingDestroyed()) |
584 return; | 584 return; |
585 | 585 |
586 UpdateWebAppInfoFromManifest(manifest, &web_app_info_); | 586 UpdateWebAppInfoFromManifest(manifest, &web_app_info_); |
587 | 587 |
588 if (!ChromeOriginTrialPolicy().IsFeatureDisabled("WebShare")) { | 588 if (!ChromeOriginTrialPolicy().IsFeatureDisabled("WebShare")) { |
Matt Giuca
2017/02/06 00:40:11
Drop the braces (for consistency with surrounding
constantina
2017/02/07 05:16:25
Done.
| |
589 const std::string& manifest_url_string = manifest_url.spec(); | 589 UpdateShareTargetInPrefs(manifest_url, manifest, profile_->GetPrefs()); |
Matt Giuca
2017/02/06 00:40:11
Nice refactor.
constantina
2017/02/07 05:16:25
Ty!
| |
590 | |
591 base::Optional<std::string> url_template; | |
592 if (manifest.share_target.has_value() && | |
593 !manifest.share_target.value().url_template.is_null()) { | |
594 url_template = base::Optional<std::string>(base::UTF16ToUTF8( | |
595 manifest.share_target.value().url_template.string())); | |
596 } | |
597 | |
598 // Add this site as a share target, if it declares a url_template in its | |
599 // manifest, or remove if it doesn't. | |
600 UpdateShareTargetInPrefs(manifest_url_string, std::move(url_template), | |
601 profile_->GetPrefs()); | |
602 } | 590 } |
603 | 591 |
604 // Add urls from the WebApplicationInfo. | 592 // Add urls from the WebApplicationInfo. |
605 std::vector<GURL> web_app_info_icon_urls; | 593 std::vector<GURL> web_app_info_icon_urls; |
606 for (std::vector<WebApplicationInfo::IconInfo>::const_iterator it = | 594 for (std::vector<WebApplicationInfo::IconInfo>::const_iterator it = |
607 web_app_info_.icons.begin(); | 595 web_app_info_.icons.begin(); |
608 it != web_app_info_.icons.end(); | 596 it != web_app_info_.icons.end(); |
609 ++it) { | 597 ++it) { |
610 if (it->url.is_valid()) | 598 if (it->url.is_valid()) |
611 web_app_info_icon_urls.push_back(it->url); | 599 web_app_info_icon_urls.push_back(it->url); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
826 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); | 814 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); |
827 } | 815 } |
828 | 816 |
829 bool IsValidBookmarkAppUrl(const GURL& url) { | 817 bool IsValidBookmarkAppUrl(const GURL& url) { |
830 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); | 818 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); |
831 origin_only_pattern.SetMatchAllURLs(true); | 819 origin_only_pattern.SetMatchAllURLs(true); |
832 return url.is_valid() && origin_only_pattern.MatchesURL(url); | 820 return url.is_valid() && origin_only_pattern.MatchesURL(url); |
833 } | 821 } |
834 | 822 |
835 } // namespace extensions | 823 } // namespace extensions |
OLD | NEW |