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

Side by Side Diff: chrome/browser/webshare/share_service_impl.h

Issue 2644793006: Add picker view for Web Share Target. (Closed)
Patch Set: Fix unit tests and add cancellation test (adds virtual method to Impl class). Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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 "base/gtest_prod_util.h"
11 #include "base/strings/string16.h"
12 #include "chrome/browser/ui/browser_dialogs.h"
11 #include "mojo/public/cpp/bindings/interface_request.h" 13 #include "mojo/public/cpp/bindings/interface_request.h"
12 #include "third_party/WebKit/public/platform/modules/webshare/webshare.mojom.h" 14 #include "third_party/WebKit/public/platform/modules/webshare/webshare.mojom.h"
13 15
14 class GURL; 16 class GURL;
15 17
16 // Desktop implementation of the ShareService Mojo service. 18 // Desktop implementation of the ShareService Mojo service.
17 class ShareServiceImpl : public blink::mojom::ShareService { 19 class ShareServiceImpl : public blink::mojom::ShareService {
18 public: 20 public:
19 ShareServiceImpl() = default; 21 ShareServiceImpl() = default;
20 ~ShareServiceImpl() override = default; 22 ~ShareServiceImpl() override = default;
21 23
22 static void Create(mojo::InterfaceRequest<ShareService> request); 24 static void Create(mojo::InterfaceRequest<ShareService> request);
23 25
24 // blink::mojom::ShareService overrides: 26 // blink::mojom::ShareService overrides:
25 void Share(const std::string& title, 27 void Share(const std::string& title,
26 const std::string& text, 28 const std::string& text,
27 const GURL& share_url, 29 const GURL& share_url,
28 const ShareCallback& callback) override; 30 const ShareCallback& callback) override;
29 31
30 private: 32 private:
31 FRIEND_TEST_ALL_PREFIXES(ShareServiceImplUnittest, ReplacePlaceholders); 33 FRIEND_TEST_ALL_PREFIXES(ShareServiceImplUnittest, ReplacePlaceholders);
32 34
35 // Shows the share picker dialog with |targets| as the list of applications
36 // presented to the user. Passes the result to |callback|. Virtual for
37 // testing.
38 virtual void ShowPickerDialog(
39 const std::vector<base::string16>& targets,
40 const base::Callback<void(chrome::SharePickerResult)>& callback);
41
33 // Opens a new tab and navigates to |target_url|. 42 // Opens a new tab and navigates to |target_url|.
34 // Virtual for testing purposes. 43 // Virtual for testing purposes.
35 virtual void OpenTargetURL(const GURL& target_url); 44 virtual void OpenTargetURL(const GURL& target_url);
36 45
37 // Writes to |url_template_filled|, a copy of |url_template| with all 46 // Writes to |url_template_filled|, a copy of |url_template| with all
38 // instances of "{title}", "{text}", and "{url}" replaced with 47 // instances of "{title}", "{text}", and "{url}" replaced with
39 // |title|, |text|, and |url| respectively. 48 // |title|, |text|, and |url| respectively.
40 // Replaces instances of "{X}" where "X" is any string besides "title", 49 // Replaces instances of "{X}" where "X" is any string besides "title",
41 // "text", and "url", with an empty string, for forwards compatibility. 50 // "text", and "url", with an empty string, for forwards compatibility.
42 // Returns false, if there are badly nested placeholders. 51 // Returns false, if there are badly nested placeholders.
43 // This includes any case in which two "{" occur before a "}", or a "}" 52 // This includes any case in which two "{" occur before a "}", or a "}"
44 // occurs with no preceding "{". 53 // occurs with no preceding "{".
45 static bool ReplacePlaceholders(base::StringPiece url_template, 54 static bool ReplacePlaceholders(base::StringPiece url_template,
46 base::StringPiece title, 55 base::StringPiece title,
47 base::StringPiece text, 56 base::StringPiece text,
48 const GURL& share_url, 57 const GURL& share_url,
49 std::string* url_template_filled); 58 std::string* url_template_filled);
50 59
60 void OnPickerClosed(const std::string& title,
61 const std::string& text,
62 const GURL& share_url,
63 const ShareCallback& callback,
64 chrome::SharePickerResult result);
65
51 DISALLOW_COPY_AND_ASSIGN(ShareServiceImpl); 66 DISALLOW_COPY_AND_ASSIGN(ShareServiceImpl);
52 }; 67 };
53 68
54 #endif // CHROME_BROWSER_WEBSHARE_SHARE_SERVICE_IMPL_H_ 69 #endif // CHROME_BROWSER_WEBSHARE_SHARE_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698