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

Unified Diff: chrome/browser/extensions/bookmark_app_helper.cc

Issue 2639463002: Add a pref name for share targets, and store their manifest data. (Closed)
Patch Set: Separate tests, add .h, as per feedback Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/bookmark_app_helper.cc
diff --git a/chrome/browser/extensions/bookmark_app_helper.cc b/chrome/browser/extensions/bookmark_app_helper.cc
index a70c1b294760af858479e5a0fa4d389438adb6c1..f328909f84c13cfe02b63cc3d12ed113feba912e 100644
--- a/chrome/browser/extensions/bookmark_app_helper.cc
+++ b/chrome/browser/extensions/bookmark_app_helper.cc
@@ -28,8 +28,10 @@
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/web_applications/web_app.h"
+#include "chrome/browser/webshare/share_target_pref_helper.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
+#include "chrome/common/origin_trials/chrome_origin_trial_policy.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/platform_locale_settings.h"
#include "components/prefs/pref_service.h"
@@ -583,6 +585,23 @@ void BookmarkAppHelper::OnDidGetManifest(const GURL& manifest_url,
UpdateWebAppInfoFromManifest(manifest, &web_app_info_);
+ if (!ChromeOriginTrialPolicy().IsFeatureDisabled("WebShare")) {
+ std::string manifest_url_spec = manifest_url.spec();
+ 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.
+ manifest_url_spec.data(),
+ 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
+
+ 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.
+ if (manifest.share_target.has_value() &&
+ !manifest.share_target.value().url_template.is_null()) {
+ url_template = base::Optional<std::string>(base::UTF16ToUTF8(
+ manifest.share_target.value().url_template.string()));
+ }
+
+ 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.
+ profile_->GetPrefs());
+ }
+
// Add urls from the WebApplicationInfo.
std::vector<GURL> web_app_info_icon_urls;
for (std::vector<WebApplicationInfo::IconInfo>::const_iterator it =

Powered by Google App Engine
This is Rietveld 408576698