Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 10 matching lines...) Expand all Loading... | |
| 21 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
| 22 #include "chrome/browser/extensions/favicon_downloader.h" | 22 #include "chrome/browser/extensions/favicon_downloader.h" |
| 23 #include "chrome/browser/extensions/launch_util.h" | 23 #include "chrome/browser/extensions/launch_util.h" |
| 24 #include "chrome/browser/extensions/tab_helper.h" | 24 #include "chrome/browser/extensions/tab_helper.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/ui/app_list/app_list_service.h" | 26 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 27 #include "chrome/browser/ui/app_list/app_list_util.h" | 27 #include "chrome/browser/ui/app_list/app_list_util.h" |
| 28 #include "chrome/browser/ui/browser_finder.h" | 28 #include "chrome/browser/ui/browser_finder.h" |
| 29 #include "chrome/browser/ui/browser_window.h" | 29 #include "chrome/browser/ui/browser_window.h" |
| 30 #include "chrome/browser/web_applications/web_app.h" | 30 #include "chrome/browser/web_applications/web_app.h" |
| 31 #include "chrome/browser/webshare/share_target_pref_helper.h" | |
| 31 #include "chrome/common/extensions/extension_constants.h" | 32 #include "chrome/common/extensions/extension_constants.h" |
| 32 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 33 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
| 34 #include "chrome/common/origin_trials/chrome_origin_trial_policy.h" | |
| 33 #include "chrome/common/url_constants.h" | 35 #include "chrome/common/url_constants.h" |
| 34 #include "chrome/grit/platform_locale_settings.h" | 36 #include "chrome/grit/platform_locale_settings.h" |
| 35 #include "components/prefs/pref_service.h" | 37 #include "components/prefs/pref_service.h" |
| 36 #include "content/public/browser/navigation_controller.h" | 38 #include "content/public/browser/navigation_controller.h" |
| 37 #include "content/public/browser/notification_service.h" | 39 #include "content/public/browser/notification_service.h" |
| 38 #include "content/public/browser/notification_source.h" | 40 #include "content/public/browser/notification_source.h" |
| 39 #include "content/public/browser/web_contents.h" | 41 #include "content/public/browser/web_contents.h" |
| 40 #include "extensions/browser/extension_registry.h" | 42 #include "extensions/browser/extension_registry.h" |
| 41 #include "extensions/browser/extension_system.h" | 43 #include "extensions/browser/extension_system.h" |
| 42 #include "extensions/browser/image_loader.h" | 44 #include "extensions/browser/image_loader.h" |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 576 OnDidGetManifest(GURL(), manifest); | 578 OnDidGetManifest(GURL(), manifest); |
| 577 } | 579 } |
| 578 | 580 |
| 579 void BookmarkAppHelper::OnDidGetManifest(const GURL& manifest_url, | 581 void BookmarkAppHelper::OnDidGetManifest(const GURL& manifest_url, |
| 580 const content::Manifest& manifest) { | 582 const content::Manifest& manifest) { |
| 581 if (contents_->IsBeingDestroyed()) | 583 if (contents_->IsBeingDestroyed()) |
| 582 return; | 584 return; |
| 583 | 585 |
| 584 UpdateWebAppInfoFromManifest(manifest, &web_app_info_); | 586 UpdateWebAppInfoFromManifest(manifest, &web_app_info_); |
| 585 | 587 |
| 588 if (!ChromeOriginTrialPolicy().IsFeatureDisabled("WebShare")) { | |
| 589 std::string manifest_url_string = manifest_url.spec(); | |
|
Matt Giuca
2017/01/25 00:25:53
This can be a const std::string& (since GURL::spec
constantina
2017/01/25 03:18:27
Done.
| |
| 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 AddShareTargetToPrefs(manifest_url_string, std::move(url_template), | |
| 599 profile_->GetPrefs()); | |
| 600 } | |
| 601 | |
| 586 // Add urls from the WebApplicationInfo. | 602 // Add urls from the WebApplicationInfo. |
| 587 std::vector<GURL> web_app_info_icon_urls; | 603 std::vector<GURL> web_app_info_icon_urls; |
| 588 for (std::vector<WebApplicationInfo::IconInfo>::const_iterator it = | 604 for (std::vector<WebApplicationInfo::IconInfo>::const_iterator it = |
| 589 web_app_info_.icons.begin(); | 605 web_app_info_.icons.begin(); |
| 590 it != web_app_info_.icons.end(); | 606 it != web_app_info_.icons.end(); |
| 591 ++it) { | 607 ++it) { |
| 592 if (it->url.is_valid()) | 608 if (it->url.is_valid()) |
| 593 web_app_info_icon_urls.push_back(it->url); | 609 web_app_info_icon_urls.push_back(it->url); |
| 594 } | 610 } |
| 595 | 611 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 808 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); | 824 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); |
| 809 } | 825 } |
| 810 | 826 |
| 811 bool IsValidBookmarkAppUrl(const GURL& url) { | 827 bool IsValidBookmarkAppUrl(const GURL& url) { |
| 812 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); | 828 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); |
| 813 origin_only_pattern.SetMatchAllURLs(true); | 829 origin_only_pattern.SetMatchAllURLs(true); |
| 814 return url.is_valid() && origin_only_pattern.MatchesURL(url); | 830 return url.is_valid() && origin_only_pattern.MatchesURL(url); |
| 815 } | 831 } |
| 816 | 832 |
| 817 } // namespace extensions | 833 } // namespace extensions |
| OLD | NEW |