Commit d27c00d0 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Remove dead methods from DomDistillerService

After recent cleanups, HasEntry(), GetUrlForEntry(), and ViewEntry()
didn't do anything useful anymore.

Bug: 1007942
Change-Id: I14cfaf0804bed1f280c9710b470e81968090d639
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1855982
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Auto-Submit: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705299}
parent d5ea427f
...@@ -32,22 +32,6 @@ LazyDomDistillerService* LazyDomDistillerService::Create(Profile* profile) { ...@@ -32,22 +32,6 @@ LazyDomDistillerService* LazyDomDistillerService::Create(Profile* profile) {
LazyDomDistillerService::~LazyDomDistillerService() = default; LazyDomDistillerService::~LazyDomDistillerService() = default;
bool LazyDomDistillerService::HasEntry(const std::string& entry_id) {
return GetImpl()->HasEntry(entry_id);
}
std::string LazyDomDistillerService::GetUrlForEntry(
const std::string& entry_id) {
return GetImpl()->GetUrlForEntry(entry_id);
}
std::unique_ptr<ViewerHandle> LazyDomDistillerService::ViewEntry(
ViewRequestDelegate* delegate,
std::unique_ptr<DistillerPage> distiller_page,
const std::string& entry_id) {
return GetImpl()->ViewEntry(delegate, std::move(distiller_page), entry_id);
}
std::unique_ptr<ViewerHandle> LazyDomDistillerService::ViewUrl( std::unique_ptr<ViewerHandle> LazyDomDistillerService::ViewUrl(
ViewRequestDelegate* delegate, ViewRequestDelegate* delegate,
std::unique_ptr<DistillerPage> distiller_page, std::unique_ptr<DistillerPage> distiller_page,
......
...@@ -28,12 +28,6 @@ class LazyDomDistillerService : public DomDistillerServiceInterface, ...@@ -28,12 +28,6 @@ class LazyDomDistillerService : public DomDistillerServiceInterface,
~LazyDomDistillerService() override; ~LazyDomDistillerService() override;
// DomDistillerServiceInterface implementation: // DomDistillerServiceInterface implementation:
bool HasEntry(const std::string& entry_id) override;
std::string GetUrlForEntry(const std::string& entry_id) override;
std::unique_ptr<ViewerHandle> ViewEntry(
ViewRequestDelegate* delegate,
std::unique_ptr<DistillerPage> distiller_page,
const std::string& entry_id) override;
std::unique_ptr<ViewerHandle> ViewUrl( std::unique_ptr<ViewerHandle> ViewUrl(
ViewRequestDelegate* delegate, ViewRequestDelegate* delegate,
std::unique_ptr<DistillerPage> distiller_page, std::unique_ptr<DistillerPage> distiller_page,
......
...@@ -56,21 +56,6 @@ DomDistillerService::CreateDefaultDistillerPageWithHandle( ...@@ -56,21 +56,6 @@ DomDistillerService::CreateDefaultDistillerPageWithHandle(
std::move(handle)); std::move(handle));
} }
bool DomDistillerService::HasEntry(const std::string& entry_id) {
return false;
}
std::string DomDistillerService::GetUrlForEntry(const std::string& entry_id) {
return "";
}
std::unique_ptr<ViewerHandle> DomDistillerService::ViewEntry(
ViewRequestDelegate* delegate,
std::unique_ptr<DistillerPage> distiller_page,
const std::string& entry_id) {
return nullptr;
}
std::unique_ptr<ViewerHandle> DomDistillerService::ViewUrl( std::unique_ptr<ViewerHandle> DomDistillerService::ViewUrl(
ViewRequestDelegate* delegate, ViewRequestDelegate* delegate,
std::unique_ptr<DistillerPage> distiller_page, std::unique_ptr<DistillerPage> distiller_page,
......
...@@ -34,14 +34,6 @@ class DomDistillerServiceInterface { ...@@ -34,14 +34,6 @@ class DomDistillerServiceInterface {
typedef base::Callback<void(bool)> ArticleAvailableCallback; typedef base::Callback<void(bool)> ArticleAvailableCallback;
virtual ~DomDistillerServiceInterface() {} virtual ~DomDistillerServiceInterface() {}
// TODO(crbug.com/1007942): Remove these methods; no entries ever exist.
virtual bool HasEntry(const std::string& entry_id) = 0;
virtual std::string GetUrlForEntry(const std::string& entry_id) = 0;
virtual std::unique_ptr<ViewerHandle> ViewEntry(
ViewRequestDelegate* delegate,
std::unique_ptr<DistillerPage> distiller_page,
const std::string& entry_id) = 0;
// Request to view an article by url. // Request to view an article by url.
// Use CreateDefaultDistillerPage() to create a default |distiller_page|. // Use CreateDefaultDistillerPage() to create a default |distiller_page|.
// The provided |distiller_page| is only used if there is not already a // The provided |distiller_page| is only used if there is not already a
...@@ -78,12 +70,6 @@ class DomDistillerService : public DomDistillerServiceInterface { ...@@ -78,12 +70,6 @@ class DomDistillerService : public DomDistillerServiceInterface {
~DomDistillerService() override; ~DomDistillerService() override;
// DomDistillerServiceInterface implementation. // DomDistillerServiceInterface implementation.
bool HasEntry(const std::string& entry_id) override;
std::string GetUrlForEntry(const std::string& entry_id) override;
std::unique_ptr<ViewerHandle> ViewEntry(
ViewRequestDelegate* delegate,
std::unique_ptr<DistillerPage> distiller_page,
const std::string& entry_id) override;
std::unique_ptr<ViewerHandle> ViewUrl( std::unique_ptr<ViewerHandle> ViewUrl(
ViewRequestDelegate* delegate, ViewRequestDelegate* delegate,
std::unique_ptr<DistillerPage> distiller_page, std::unique_ptr<DistillerPage> distiller_page,
......
...@@ -34,18 +34,14 @@ bool DomDistillerServiceAndroid::HasEntry( ...@@ -34,18 +34,14 @@ bool DomDistillerServiceAndroid::HasEntry(
JNIEnv* env, JNIEnv* env,
const JavaParamRef<jobject>& obj, const JavaParamRef<jobject>& obj,
const JavaParamRef<jstring>& j_entry_id) { const JavaParamRef<jstring>& j_entry_id) {
const std::string entry_id = return false;
base::android::ConvertJavaStringToUTF8(env, j_entry_id);
return service_->HasEntry(entry_id);
} }
ScopedJavaLocalRef<jstring> DomDistillerServiceAndroid::GetUrlForEntry( ScopedJavaLocalRef<jstring> DomDistillerServiceAndroid::GetUrlForEntry(
JNIEnv* env, JNIEnv* env,
const JavaParamRef<jobject>& obj, const JavaParamRef<jobject>& obj,
const JavaParamRef<jstring>& j_entry_id) { const JavaParamRef<jstring>& j_entry_id) {
const std::string entry_id = return ConvertUTF8ToJavaString(env, std::string());
base::android::ConvertJavaStringToUTF8(env, j_entry_id);
return ConvertUTF8ToJavaString(env, service_->GetUrlForEntry(entry_id));
} }
jlong DomDistillerServiceAndroid::GetDistilledPagePrefsPtr(JNIEnv* env) { jlong DomDistillerServiceAndroid::GetDistilledPagePrefsPtr(JNIEnv* env) {
......
...@@ -24,6 +24,8 @@ class DomDistillerServiceAndroid { ...@@ -24,6 +24,8 @@ class DomDistillerServiceAndroid {
// Returns native pointer to native DistilledPagePrefs registered with // Returns native pointer to native DistilledPagePrefs registered with
// DomDistillerService. // DomDistillerService.
jlong GetDistilledPagePrefsPtr(JNIEnv* env); jlong GetDistilledPagePrefsPtr(JNIEnv* env);
// TODO(crbug.com/1007942): Remove HasEntry and GetUrlForEntry, they always
// return false / empty string.
bool HasEntry(JNIEnv* env, bool HasEntry(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj, const base::android::JavaParamRef<jobject>& obj,
const base::android::JavaParamRef<jstring>& entry_id); const base::android::JavaParamRef<jstring>& entry_id);
......
...@@ -270,10 +270,7 @@ std::unique_ptr<ViewerHandle> CreateViewRequest( ...@@ -270,10 +270,7 @@ std::unique_ptr<ViewerHandle> CreateViewRequest(
} }
if (has_valid_entry_id) { if (has_valid_entry_id) {
return dom_distiller_service->ViewEntry( return nullptr;
view_request_delegate,
dom_distiller_service->CreateDefaultDistillerPage(render_view_size),
entry_id);
} }
if (has_valid_url) { if (has_valid_url) {
return dom_distiller_service->ViewUrl( return dom_distiller_service->ViewUrl(
......
...@@ -41,8 +41,6 @@ class TestDomDistillerService : public DomDistillerServiceInterface { ...@@ -41,8 +41,6 @@ class TestDomDistillerService : public DomDistillerServiceInterface {
TestDomDistillerService() {} TestDomDistillerService() {}
~TestDomDistillerService() override {} ~TestDomDistillerService() override {}
MOCK_METHOD1(HasEntry, bool(const std::string&));
MOCK_METHOD1(GetUrlForEntry, std::string(const std::string&));
MOCK_METHOD0(ViewUrlImpl, ViewerHandle*()); MOCK_METHOD0(ViewUrlImpl, ViewerHandle*());
std::unique_ptr<ViewerHandle> ViewUrl( std::unique_ptr<ViewerHandle> ViewUrl(
ViewRequestDelegate*, ViewRequestDelegate*,
...@@ -50,13 +48,6 @@ class TestDomDistillerService : public DomDistillerServiceInterface { ...@@ -50,13 +48,6 @@ class TestDomDistillerService : public DomDistillerServiceInterface {
const GURL&) override { const GURL&) override {
return std::unique_ptr<ViewerHandle>(ViewUrlImpl()); return std::unique_ptr<ViewerHandle>(ViewUrlImpl());
} }
MOCK_METHOD0(ViewEntryImpl, ViewerHandle*());
std::unique_ptr<ViewerHandle> ViewEntry(
ViewRequestDelegate*,
std::unique_ptr<DistillerPage> distiller_page,
const std::string&) override {
return std::unique_ptr<ViewerHandle>(ViewEntryImpl());
}
std::unique_ptr<DistillerPage> CreateDefaultDistillerPage( std::unique_ptr<DistillerPage> CreateDefaultDistillerPage(
const gfx::Size& render_view_size) override { const gfx::Size& render_view_size) override {
return std::unique_ptr<DistillerPage>(); return std::unique_ptr<DistillerPage>();
...@@ -89,26 +80,13 @@ TEST_F(DomDistillerViewerTest, TestCreatingViewUrlRequest) { ...@@ -89,26 +80,13 @@ TEST_F(DomDistillerViewerTest, TestCreatingViewUrlRequest) {
ViewerHandle* viewer_handle(new ViewerHandle(ViewerHandle::CancelCallback())); ViewerHandle* viewer_handle(new ViewerHandle(ViewerHandle::CancelCallback()));
EXPECT_CALL(*service_, ViewUrlImpl()) EXPECT_CALL(*service_, ViewUrlImpl())
.WillOnce(testing::Return(viewer_handle)); .WillOnce(testing::Return(viewer_handle));
EXPECT_CALL(*service_, ViewEntryImpl()).Times(0);
CreateViewRequest(GetDistillerViewUrlFromUrl("http://www.example.com/"), CreateViewRequest(GetDistillerViewUrlFromUrl("http://www.example.com/"),
view_request_delegate.get()); view_request_delegate.get());
} }
TEST_F(DomDistillerViewerTest, TestCreatingViewEntryRequest) {
std::unique_ptr<FakeViewRequestDelegate> view_request_delegate(
new FakeViewRequestDelegate());
ViewerHandle* viewer_handle(new ViewerHandle(ViewerHandle::CancelCallback()));
EXPECT_CALL(*service_, ViewEntryImpl())
.WillOnce(testing::Return(viewer_handle));
EXPECT_CALL(*service_, ViewUrlImpl()).Times(0);
CreateViewRequest(GetDistillerViewUrlFromEntryId("abc-def"),
view_request_delegate.get());
}
TEST_F(DomDistillerViewerTest, TestCreatingInvalidViewRequest) { TEST_F(DomDistillerViewerTest, TestCreatingInvalidViewRequest) {
std::unique_ptr<FakeViewRequestDelegate> view_request_delegate( std::unique_ptr<FakeViewRequestDelegate> view_request_delegate(
new FakeViewRequestDelegate()); new FakeViewRequestDelegate());
EXPECT_CALL(*service_, ViewEntryImpl()).Times(0);
EXPECT_CALL(*service_, ViewUrlImpl()).Times(0); EXPECT_CALL(*service_, ViewUrlImpl()).Times(0);
// Specify none of the required query parameters. // Specify none of the required query parameters.
CreateViewRequest(GURL(std::string(kDomDistillerScheme) + "://host?foo=bar"), CreateViewRequest(GURL(std::string(kDomDistillerScheme) + "://host?foo=bar"),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment