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 const std::string& manifest_url_string = manifest_url.spec(); |
| 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 |
586 // Add urls from the WebApplicationInfo. | 604 // Add urls from the WebApplicationInfo. |
587 std::vector<GURL> web_app_info_icon_urls; | 605 std::vector<GURL> web_app_info_icon_urls; |
588 for (std::vector<WebApplicationInfo::IconInfo>::const_iterator it = | 606 for (std::vector<WebApplicationInfo::IconInfo>::const_iterator it = |
589 web_app_info_.icons.begin(); | 607 web_app_info_.icons.begin(); |
590 it != web_app_info_.icons.end(); | 608 it != web_app_info_.icons.end(); |
591 ++it) { | 609 ++it) { |
592 if (it->url.is_valid()) | 610 if (it->url.is_valid()) |
593 web_app_info_icon_urls.push_back(it->url); | 611 web_app_info_icon_urls.push_back(it->url); |
594 } | 612 } |
595 | 613 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); | 826 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); |
809 } | 827 } |
810 | 828 |
811 bool IsValidBookmarkAppUrl(const GURL& url) { | 829 bool IsValidBookmarkAppUrl(const GURL& url) { |
812 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); | 830 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); |
813 origin_only_pattern.SetMatchAllURLs(true); | 831 origin_only_pattern.SetMatchAllURLs(true); |
814 return url.is_valid() && origin_only_pattern.MatchesURL(url); | 832 return url.is_valid() && origin_only_pattern.MatchesURL(url); |
815 } | 833 } |
816 | 834 |
817 } // namespace extensions | 835 } // namespace extensions |
OLD | NEW |