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 6b12400c3c504f60efbcd012ffb45f0dcde34ba0..9e09506633daeed66bc7fd77458e3b54f5b59446 100644 |
| --- a/chrome/browser/webshare/share_service_impl.cc |
| +++ b/chrome/browser/webshare/share_service_impl.cc |
| @@ -9,8 +9,10 @@ |
| #include <utility> |
| #include "base/strings/string_util.h" |
| +#include "base/strings/utf_string_conversions.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/browser_commands.h" |
| +#include "chrome/browser/ui/browser_dialogs.h" |
| #include "chrome/browser/ui/browser_list.h" |
| #include "chrome/browser/ui/browser_tabstrip.h" |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| @@ -124,6 +126,28 @@ void ShareServiceImpl::Share(const std::string& title, |
| const std::string& text, |
| const GURL& share_url, |
| const ShareCallback& callback) { |
| + // TODO(constantina): Replace hard-coded name with the registered target list. |
| + constexpr wchar_t kTargetName[] = L"Web Share Target Test App"; |
|
sky
2017/01/23 16:38:56
Make this const char and use Ascii to UTF16.
Matt Giuca
2017/01/30 04:07:13
In the past, I've done it this way because at leas
|
| + std::vector<base::string16> targets{base::WideToUTF16(kTargetName)}; |
| + |
| + // TODO(mgiuca): Get the browser window as |parent_window|. |
| + gfx::NativeWindow browser_window = nullptr; |
| + chrome::ShowWebShareTargetPickerDialog( |
| + browser_window, targets, |
| + base::Bind(&ShareServiceImpl::OnPickerClosed, base::Unretained(this), |
| + title, text, share_url, callback)); |
| +} |
| + |
| +void ShareServiceImpl::OnPickerClosed(const std::string& title, |
| + const std::string& text, |
| + const GURL& share_url, |
| + const ShareCallback& callback, |
| + bool picked) { |
| + if (!picked) { |
| + 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[] = |