OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_DOM_DISTILLER_CONTENT_DOM_DISTILLER_VIEWER_SOURCE_H_ | 5 #ifndef COMPONENTS_DOM_DISTILLER_CONTENT_DOM_DISTILLER_VIEWER_SOURCE_H_ |
6 #define COMPONENTS_DOM_DISTILLER_CONTENT_DOM_DISTILLER_VIEWER_SOURCE_H_ | 6 #define COMPONENTS_DOM_DISTILLER_CONTENT_DOM_DISTILLER_VIEWER_SOURCE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/gtest_prod_util.h" | |
10 #include "content/public/browser/url_data_source.h" | 11 #include "content/public/browser/url_data_source.h" |
11 | 12 |
12 namespace dom_distiller { | 13 namespace dom_distiller { |
13 | 14 |
14 class DomDistillerService; | 15 class DomDistillerServiceInterface; |
16 class DomDistillerViewerSourceTest; | |
17 class ViewerHandle; | |
18 class ViewRequestDelegate; | |
15 | 19 |
16 // Serves HTML and resources for viewing distilled articles. | 20 // Serves HTML and resources for viewing distilled articles. |
17 class DomDistillerViewerSource : public content::URLDataSource { | 21 class DomDistillerViewerSource : public content::URLDataSource { |
18 public: | 22 public: |
19 DomDistillerViewerSource(DomDistillerService* dom_distiller_service, | 23 DomDistillerViewerSource(DomDistillerServiceInterface* dom_distiller_service, |
20 const std::string& scheme); | 24 const std::string& scheme); |
21 virtual ~DomDistillerViewerSource(); | 25 virtual ~DomDistillerViewerSource(); |
22 | 26 |
23 private: | 27 private: |
28 class RequestViewerHandle; | |
29 | |
24 // Overridden from content::URLDataSource: | 30 // Overridden from content::URLDataSource: |
cjhopman
2014/02/25 22:25:14
Making the URLDataSource overrides private means t
nyquist
2014/02/27 00:07:37
Moved the methods from content::URLDataSource to b
| |
25 virtual std::string GetSource() const OVERRIDE; | 31 virtual std::string GetSource() const OVERRIDE; |
26 virtual void StartDataRequest( | 32 virtual void StartDataRequest( |
27 const std::string& path, | 33 const std::string& path, |
28 int render_process_id, | 34 int render_process_id, |
29 int render_frame_id, | 35 int render_frame_id, |
30 const content::URLDataSource::GotDataCallback& callback) OVERRIDE; | 36 const content::URLDataSource::GotDataCallback& callback) OVERRIDE; |
31 virtual std::string GetMimeType(const std::string& path) const OVERRIDE; | 37 virtual std::string GetMimeType(const std::string& path) const OVERRIDE; |
32 virtual bool ShouldServiceRequest(const net::URLRequest* request) | 38 virtual bool ShouldServiceRequest(const net::URLRequest* request) const |
33 const OVERRIDE; | 39 OVERRIDE; |
34 virtual void WillServiceRequest(const net::URLRequest* request, | 40 virtual void WillServiceRequest(const net::URLRequest* request, |
35 std::string* path) const OVERRIDE; | 41 std::string* path) const OVERRIDE; |
36 virtual std::string GetContentSecurityPolicyObjectSrc() const OVERRIDE; | 42 virtual std::string GetContentSecurityPolicyObjectSrc() const OVERRIDE; |
37 | 43 |
44 scoped_ptr<ViewerHandle> CreateViewRequest( | |
45 const std::string& path, | |
46 ViewRequestDelegate* view_request_delegate); | |
47 | |
48 // The host of the URL is not passed when starting a data request, so wrap | |
49 // net::GetValueForKeyInQuery to support arbitrary path strings. | |
50 std::string GetValueForKeyInURLPathQuery(const std::string& path, | |
cjhopman
2014/02/25 22:25:14
static
nyquist
2014/02/27 00:07:37
Done.
| |
51 const std::string& key); | |
52 | |
53 FRIEND_TEST_ALL_PREFIXES(DomDistillerViewerSourceTest, TestMimeType); | |
54 FRIEND_TEST_ALL_PREFIXES(DomDistillerViewerSourceTest, TestPathUtil); | |
cjhopman
2014/02/25 22:25:14
Only this test should be a friend.
nyquist
2014/02/27 00:07:37
See new implementation with a single friend class.
| |
55 FRIEND_TEST_ALL_PREFIXES(DomDistillerViewerSourceTest, | |
56 TestCreatingViewUrlRequest); | |
57 FRIEND_TEST_ALL_PREFIXES(DomDistillerViewerSourceTest, | |
58 TestCreatingViewEntryRequest); | |
59 FRIEND_TEST_ALL_PREFIXES(DomDistillerViewerSourceTest, | |
60 TestCreatingInvalidViewRequest); | |
61 | |
38 // The scheme this URLDataSource is hosted under. | 62 // The scheme this URLDataSource is hosted under. |
39 std::string scheme_; | 63 std::string scheme_; |
40 | 64 |
41 // The service which contains all the functionality needed to interact with | 65 // The service which contains all the functionality needed to interact with |
42 // the list of articles. | 66 // the list of articles. |
43 DomDistillerService* dom_distiller_service_; | 67 DomDistillerServiceInterface* dom_distiller_service_; |
44 | 68 |
45 DISALLOW_COPY_AND_ASSIGN(DomDistillerViewerSource); | 69 DISALLOW_COPY_AND_ASSIGN(DomDistillerViewerSource); |
46 }; | 70 }; |
47 | 71 |
48 } // namespace dom_distiller | 72 } // namespace dom_distiller |
49 | 73 |
50 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_DOM_DISTILLER_VIEWER_SOURCE_H_ | 74 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_DOM_DISTILLER_VIEWER_SOURCE_H_ |
OLD | NEW |