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

Unified Diff: components/dom_distiller/content/dom_distiller_viewer_source.h

Issue 151003006: Add support for distilling arbitrary URLs in DOM Distiller Viewer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. added unit tests Created 6 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 side-by-side diff with in-line comments
Download patch
Index: components/dom_distiller/content/dom_distiller_viewer_source.h
diff --git a/components/dom_distiller/content/dom_distiller_viewer_source.h b/components/dom_distiller/content/dom_distiller_viewer_source.h
index eb7559bc20ae18527d94e21e3001ce05809e8cf6..ade4cab902d3303530b29896d08a67b3a9fbd78d 100644
--- a/components/dom_distiller/content/dom_distiller_viewer_source.h
+++ b/components/dom_distiller/content/dom_distiller_viewer_source.h
@@ -7,20 +7,26 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/gtest_prod_util.h"
#include "content/public/browser/url_data_source.h"
namespace dom_distiller {
-class DomDistillerService;
+class DomDistillerServiceInterface;
+class DomDistillerViewerSourceTest;
+class ViewerHandle;
+class ViewRequestDelegate;
// Serves HTML and resources for viewing distilled articles.
class DomDistillerViewerSource : public content::URLDataSource {
public:
- DomDistillerViewerSource(DomDistillerService* dom_distiller_service,
+ DomDistillerViewerSource(DomDistillerServiceInterface* dom_distiller_service,
const std::string& scheme);
virtual ~DomDistillerViewerSource();
private:
+ class RequestViewerHandle;
+
// 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
virtual std::string GetSource() const OVERRIDE;
virtual void StartDataRequest(
@@ -29,18 +35,36 @@ class DomDistillerViewerSource : public content::URLDataSource {
int render_frame_id,
const content::URLDataSource::GotDataCallback& callback) OVERRIDE;
virtual std::string GetMimeType(const std::string& path) const OVERRIDE;
- virtual bool ShouldServiceRequest(const net::URLRequest* request)
- const OVERRIDE;
+ virtual bool ShouldServiceRequest(const net::URLRequest* request) const
+ OVERRIDE;
virtual void WillServiceRequest(const net::URLRequest* request,
std::string* path) const OVERRIDE;
virtual std::string GetContentSecurityPolicyObjectSrc() const OVERRIDE;
+ scoped_ptr<ViewerHandle> CreateViewRequest(
+ const std::string& path,
+ ViewRequestDelegate* view_request_delegate);
+
+ // The host of the URL is not passed when starting a data request, so wrap
+ // net::GetValueForKeyInQuery to support arbitrary path strings.
+ std::string GetValueForKeyInURLPathQuery(const std::string& path,
cjhopman 2014/02/25 22:25:14 static
nyquist 2014/02/27 00:07:37 Done.
+ const std::string& key);
+
+ FRIEND_TEST_ALL_PREFIXES(DomDistillerViewerSourceTest, TestMimeType);
+ 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.
+ FRIEND_TEST_ALL_PREFIXES(DomDistillerViewerSourceTest,
+ TestCreatingViewUrlRequest);
+ FRIEND_TEST_ALL_PREFIXES(DomDistillerViewerSourceTest,
+ TestCreatingViewEntryRequest);
+ FRIEND_TEST_ALL_PREFIXES(DomDistillerViewerSourceTest,
+ TestCreatingInvalidViewRequest);
+
// The scheme this URLDataSource is hosted under.
std::string scheme_;
// The service which contains all the functionality needed to interact with
// the list of articles.
- DomDistillerService* dom_distiller_service_;
+ DomDistillerServiceInterface* dom_distiller_service_;
DISALLOW_COPY_AND_ASSIGN(DomDistillerViewerSource);
};

Powered by Google App Engine
This is Rietveld 408576698