Chromium Code Reviews| Index: chrome/browser/webshare/share_service_impl.cc |
| diff --git a/chrome/browser/webshare/share_service_impl.cc b/chrome/browser/webshare/share_service_impl.cc |
| index 051bb65c364dad989fdb1038e1723e73991d76d0..94f7b90bbac82a5778364337fa43c69e64bff108 100644 |
| --- a/chrome/browser/webshare/share_service_impl.cc |
| +++ b/chrome/browser/webshare/share_service_impl.cc |
| @@ -115,13 +115,13 @@ bool ShareServiceImpl::ReplacePlaceholders(base::StringPiece url_template, |
| void ShareServiceImpl::ShowPickerDialog( |
| const std::vector<base::string16>& targets, |
| - const base::Callback<void(SharePickerResult)>& callback) { |
| + const base::Callback<void(base::Optional<base::string16>)>& callback) { |
| // TODO(mgiuca): Get the browser window as |parent_window|. |
| #if defined(OS_LINUX) || defined(OS_WIN) |
| chrome::ShowWebShareTargetPickerDialog(nullptr /* parent_window */, targets, |
| callback); |
| #else |
| - callback.Run(SharePickerResult::CANCEL); |
| + callback.Run(base::nullopt); |
| #endif |
| } |
| @@ -139,8 +139,8 @@ void ShareServiceImpl::Share(const std::string& title, |
| const GURL& share_url, |
| const ShareCallback& callback) { |
| // TODO(constantina): Replace hard-coded name with the registered target list. |
| - constexpr char kTargetName[] = "Web Share Target Test App"; |
| - std::vector<base::string16> targets{base::ASCIIToUTF16(kTargetName)}; |
| + constexpr char kUrlBase[] = "https://wicg.github.io/web-share-target/demos/"; |
|
Matt Giuca
2017/02/01 07:04:33
This makes it ugly: you are no longer displaying t
constantina
2017/02/01 23:24:21
Done.
|
| + std::vector<base::string16> targets{base::ASCIIToUTF16(kUrlBase)}; |
|
Matt Giuca
2017/02/01 07:04:33
Also I'm confused what the actual URL is that you'
Matt Giuca
2017/02/01 07:25:23
Had an offline chat: the summary is that this will
constantina
2017/02/01 23:24:21
Done.
|
| ShowPickerDialog(targets, base::Bind(&ShareServiceImpl::OnPickerClosed, |
| base::Unretained(this), title, text, |
| @@ -151,16 +151,14 @@ void ShareServiceImpl::OnPickerClosed(const std::string& title, |
| const std::string& text, |
| const GURL& share_url, |
| const ShareCallback& callback, |
| - SharePickerResult result) { |
| - if (result == SharePickerResult::CANCEL) { |
| + base::Optional<base::string16> result) { |
| + if (!result.has_value()) { |
| callback.Run(base::Optional<std::string>("Share was cancelled")); |
| return; |
| } |
| - // TODO(constantina): replace hard-coded URL with one from user-chosen site. |
| - constexpr char kUrlBase[] = "https://wicg.github.io/web-share-target/"; |
| constexpr char kUrlTemplate[] = |
| - "demos/sharetarget.html?title={title}&text={text}&url={url}"; |
| + "sharetarget.html?title={title}&text={text}&url={url}"; |
|
Matt Giuca
2017/02/01 07:04:33
This template part of the URL is still hard-coded
constantina
2017/02/01 23:24:21
Done as per your last comment.
|
| std::string url_template_filled; |
| if (!ReplacePlaceholders(kUrlTemplate, title, text, share_url, |
| @@ -170,7 +168,8 @@ void ShareServiceImpl::OnPickerClosed(const std::string& title, |
| return; |
| } |
| - GURL target_url(kUrlBase + url_template_filled); |
| + std::string url_base = base::UTF16ToASCII(result.value()); |
|
Matt Giuca
2017/02/01 07:17:23
UTF16ToUTF8
Otherwise this will fail if it contai
constantina
2017/02/01 23:24:21
Done.
|
| + GURL target_url(url_base + url_template_filled); |
| if (!target_url.is_valid()) { |
| callback.Run(base::Optional<std::string>( |
| "Error: url of share target is not a valid url.")); |