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

Side by Side Diff: chrome/browser/extensions/bookmark_app_helper.cc

Issue 2679523002: Store target app name in Web Share prefs, and add extra logic. (Closed)
Patch Set: My nits Created 3 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/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>
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
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"))
589 const std::string& manifest_url_string = manifest_url.spec(); 589 UpdateShareTargetInPrefs(manifest_url, manifest, profile_->GetPrefs());
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 }
603 590
604 // Add urls from the WebApplicationInfo. 591 // Add urls from the WebApplicationInfo.
605 std::vector<GURL> web_app_info_icon_urls; 592 std::vector<GURL> web_app_info_icon_urls;
606 for (std::vector<WebApplicationInfo::IconInfo>::const_iterator it = 593 for (std::vector<WebApplicationInfo::IconInfo>::const_iterator it =
607 web_app_info_.icons.begin(); 594 web_app_info_.icons.begin();
608 it != web_app_info_.icons.end(); 595 it != web_app_info_.icons.end();
609 ++it) { 596 ++it) {
610 if (it->url.is_valid()) 597 if (it->url.is_valid())
611 web_app_info_icon_urls.push_back(it->url); 598 web_app_info_icon_urls.push_back(it->url);
612 } 599 }
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); 813 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback));
827 } 814 }
828 815
829 bool IsValidBookmarkAppUrl(const GURL& url) { 816 bool IsValidBookmarkAppUrl(const GURL& url) {
830 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); 817 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes);
831 origin_only_pattern.SetMatchAllURLs(true); 818 origin_only_pattern.SetMatchAllURLs(true);
832 return url.is_valid() && origin_only_pattern.MatchesURL(url); 819 return url.is_valid() && origin_only_pattern.MatchesURL(url);
833 } 820 }
834 821
835 } // namespace extensions 822 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698