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_spec = manifest_url.spec(); | |
590 base::StringPiece share_target( | |
Matt Giuca
2017/01/24 03:26:09
This is a confusing name since it's the manifest U
constantina
2017/01/24 23:39:04
Done.
| |
591 manifest_url_spec.data(), | |
592 manifest_url_spec.size() - manifest_url.ExtractFileName().size()); | |
Matt Giuca
2017/01/24 03:26:09
This is getting the path to the directory the mani
constantina
2017/01/24 23:39:04
My bad, I misinterpretted manifest URL, as this. C
| |
593 | |
594 base::Optional<std::string> url_template = base::nullopt; | |
Matt Giuca
2017/01/24 03:26:09
I don't think you need "= base::nullopt" (default
constantina
2017/01/24 23:39:04
Done.
| |
595 if (manifest.share_target.has_value() && | |
596 !manifest.share_target.value().url_template.is_null()) { | |
597 url_template = base::Optional<std::string>(base::UTF16ToUTF8( | |
598 manifest.share_target.value().url_template.string())); | |
599 } | |
600 | |
601 webshare::AddShareTargetToPrefs(share_target, url_template, | |
Matt Giuca
2017/01/24 03:26:09
std::move(url_template) to avoid copying.
constantina
2017/01/24 23:39:04
Done.
| |
602 profile_->GetPrefs()); | |
603 } | |
604 | |
586 // Add urls from the WebApplicationInfo. | 605 // Add urls from the WebApplicationInfo. |
587 std::vector<GURL> web_app_info_icon_urls; | 606 std::vector<GURL> web_app_info_icon_urls; |
588 for (std::vector<WebApplicationInfo::IconInfo>::const_iterator it = | 607 for (std::vector<WebApplicationInfo::IconInfo>::const_iterator it = |
589 web_app_info_.icons.begin(); | 608 web_app_info_.icons.begin(); |
590 it != web_app_info_.icons.end(); | 609 it != web_app_info_.icons.end(); |
591 ++it) { | 610 ++it) { |
592 if (it->url.is_valid()) | 611 if (it->url.is_valid()) |
593 web_app_info_icon_urls.push_back(it->url); | 612 web_app_info_icon_urls.push_back(it->url); |
594 } | 613 } |
595 | 614 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
808 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); | 827 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); |
809 } | 828 } |
810 | 829 |
811 bool IsValidBookmarkAppUrl(const GURL& url) { | 830 bool IsValidBookmarkAppUrl(const GURL& url) { |
812 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); | 831 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); |
813 origin_only_pattern.SetMatchAllURLs(true); | 832 origin_only_pattern.SetMatchAllURLs(true); |
814 return url.is_valid() && origin_only_pattern.MatchesURL(url); | 833 return url.is_valid() && origin_only_pattern.MatchesURL(url); |
815 } | 834 } |
816 | 835 |
817 } // namespace extensions | 836 } // namespace extensions |
OLD | NEW |