Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_WEBSHARE_SHARE_SERVICE_IMPL_H_ | 5 #ifndef CHROME_BROWSER_WEBSHARE_SHARE_SERVICE_IMPL_H_ |
| 6 #define CHROME_BROWSER_WEBSHARE_SHARE_SERVICE_IMPL_H_ | 6 #define CHROME_BROWSER_WEBSHARE_SHARE_SERVICE_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | |
| 10 #include "mojo/public/cpp/bindings/interface_request.h" | 11 #include "mojo/public/cpp/bindings/interface_request.h" |
| 11 #include "third_party/WebKit/public/platform/modules/webshare/webshare.mojom.h" | 12 #include "third_party/WebKit/public/platform/modules/webshare/webshare.mojom.h" |
| 12 | 13 |
| 13 class GURL; | 14 class GURL; |
| 14 | 15 |
| 15 // Desktop implementation of the ShareService Mojo service. | 16 // Desktop implementation of the ShareService Mojo service. |
| 16 class ShareServiceImpl : public blink::mojom::ShareService { | 17 class ShareServiceImpl : public blink::mojom::ShareService { |
| 17 public: | 18 public: |
| 18 ShareServiceImpl() = default; | 19 ShareServiceImpl() = default; |
| 19 ~ShareServiceImpl() override = default; | 20 ~ShareServiceImpl() override = default; |
| 20 | 21 |
| 21 static void Create(mojo::InterfaceRequest<ShareService> request); | 22 static void Create(mojo::InterfaceRequest<ShareService> request); |
| 22 | 23 |
| 24 // blink::mojom::ShareService overrides: | |
| 23 void Share(const std::string& title, | 25 void Share(const std::string& title, |
| 24 const std::string& text, | 26 const std::string& text, |
| 25 const GURL& url, | 27 const GURL& share_url, |
| 26 const ShareCallback& callback) override; | 28 const ShareCallback& callback) override; |
| 27 | 29 |
| 30 protected: | |
| 31 // Opens a new tab and navigates to |target_url|. | |
| 32 // Virtual for testing purposes. | |
| 33 virtual void OpenTargetURL(const GURL& target_url); | |
|
Sam McNally
2017/01/04 09:15:46
This doesn't need to be protected to override it.
constantina
2017/01/05 00:34:38
Matt said to make it protected, but private makes
Matt Giuca
2017/01/05 03:09:25
Acknowledged.
| |
| 34 | |
| 28 private: | 35 private: |
| 36 FRIEND_TEST_ALL_PREFIXES(ShareServiceImplUnittest, ReplacePlaceholders); | |
| 37 FRIEND_TEST_ALL_PREFIXES(ShareServiceImplUnittest, | |
|
Sam McNally
2017/01/04 09:15:46
Remove.
constantina
2017/01/05 00:34:38
Done.
| |
| 38 ReplacePlaceholdersInQuery); | |
| 39 | |
| 40 // Replaces all instances of "%{title}", "%{text}", and "%{url}" (quotes for | |
| 41 // clarity) in |url_template| with |title|, |text|, and |url| respectively. | |
| 42 // Replaces instances of "%{other}" where other is any string besides title, | |
| 43 // text, and url, with and empty string, for backwards compatibility. | |
| 44 // Sets *error to 1, and returns the untouched "url_template|, if there are | |
| 45 // badly nested placeholders. This includes any case in which two "%{" occur | |
| 46 // before a "}", or a "}" occurs with no preceding "%{", | |
| 47 static std::string ReplacePlaceholders(const std::string url_template, | |
|
Sam McNally
2017/01/04 09:15:46
Take base::StringPiece unless you need pass it to
constantina
2017/01/05 00:34:38
Done.
| |
| 48 const std::string title, | |
| 49 const std::string text, | |
| 50 const GURL& share_url, | |
| 51 int* error); | |
|
Sam McNally
2017/01/04 09:15:46
It's more common for the error code/bool to be ret
constantina
2017/01/05 00:34:38
Done.
| |
| 52 | |
| 29 DISALLOW_COPY_AND_ASSIGN(ShareServiceImpl); | 53 DISALLOW_COPY_AND_ASSIGN(ShareServiceImpl); |
| 30 }; | 54 }; |
| 31 | 55 |
| 32 #endif // CHROME_BROWSER_WEBSHARE_SHARE_SERVICE_IMPL_H_ | 56 #endif // CHROME_BROWSER_WEBSHARE_SHARE_SERVICE_IMPL_H_ |
| OLD | NEW |