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

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

Issue 2564483003: Default share to Share Target: Partial impl. of Web Share for Desktop. (Closed)
Patch Set: Updated documentation 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 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 "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
28 private: 30 private:
31 FRIEND_TEST_ALL_PREFIXES(ShareServiceImplUnittest, ReplacePlaceholders);
32
33 // Opens a new tab and navigates to |target_url|.
34 // Virtual for testing purposes.
35 virtual void OpenTargetURL(const GURL& target_url);
36
37 // Writes to |url_template_filled|, a copy of |url_template with all instances
Matt Giuca 2017/01/05 03:09:25 nit: "|url_template" needs a close '|'.
constantina 2017/01/09 02:12:43 Done.
38 // of "%{title}", "%{text}", and "%{url}" (quotes for clarity) replaced with
Matt Giuca 2017/01/05 03:09:25 Drop "(quotes for clarity)".
constantina 2017/01/09 02:12:43 Done.
39 // |title|, |text|, and |url| respectively.
40 // Replaces instances of "%{other}" where other is any string besides title,
Matt Giuca 2017/01/05 03:09:25 Quote "other", "title", "text" and "url". Also ma
constantina 2017/01/09 02:12:43 Done.
41 // text, and url, with and empty string, for backwards compatibility.
Matt Giuca 2017/01/05 03:09:26 with *an* empty string. For *forwards* compatibil
constantina 2017/01/09 02:12:43 Done.
42 // Returns 1, and writes the untouched |url_template| to
43 // |url_template_filled|, if there are badly nested placeholders.
44 // This includes any case in which two "%{" occur before a "}", or a "}"
45 // occurs with no preceding "%{".
46 static int ReplacePlaceholders(const std::string& url_template,
Matt Giuca 2017/01/05 03:09:25 Can this return a bool, not an int?
constantina 2017/01/09 02:12:43 Done.
47 const std::string& title,
Matt Giuca 2017/01/05 03:09:26 What happened to StringPiece?
constantina 2017/01/09 02:12:43 Sam said to use std::string& if it gets passed dir
Sam McNally 2017/01/09 03:15:21 It doesn't anymore.
Matt Giuca 2017/01/09 03:56:54 None of these do though. url_template gets inspec
constantina 2017/01/09 23:51:03 Done.
48 const std::string& text,
49 const GURL& share_url,
50 std::string* url_template_filled);
51
29 DISALLOW_COPY_AND_ASSIGN(ShareServiceImpl); 52 DISALLOW_COPY_AND_ASSIGN(ShareServiceImpl);
30 }; 53 };
31 54
32 #endif // CHROME_BROWSER_WEBSHARE_SHARE_SERVICE_IMPL_H_ 55 #endif // CHROME_BROWSER_WEBSHARE_SHARE_SERVICE_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/webshare/share_service_impl.cc » ('j') | chrome/browser/webshare/share_service_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698