From 474a5a3f0a86af709cc79fc9a9eaa457f4fcc0db Mon Sep 17 00:00:00 2001
From: "smaslo@chromium.org"
 <smaslo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Mon, 28 Jul 2014 18:23:24 +0000
Subject: Refactoring isUrlReportable to isDistilledPage

Refactored and renamed isUrlReportable to isDistilledPage.  Also moved
dom distiller url scheme constant from chrome to components.

BUG=

Review URL: https://codereview.chromium.org/413983008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285948 0039d316-1c4b-4281-b951-d872f2087c98
---
 .../components/dom_distiller/core/DomDistillerUrlUtils.java | 13 ++++++++++---
 components/dom_distiller/core/url_constants.cc              |  1 +
 components/dom_distiller/core/url_constants.h               |  1 +
 components/dom_distiller/core/url_utils.cc                  |  4 ++--
 components/dom_distiller/core/url_utils.h                   |  4 ++--
 components/dom_distiller/core/url_utils_android.cc          |  8 ++------
 6 files changed, 18 insertions(+), 13 deletions(-)

(limited to 'components')

diff --git a/components/dom_distiller/android/java/src/org/chromium/components/dom_distiller/core/DomDistillerUrlUtils.java b/components/dom_distiller/android/java/src/org/chromium/components/dom_distiller/core/DomDistillerUrlUtils.java
index 60eda9e..9607f65 100644
--- a/components/dom_distiller/android/java/src/org/chromium/components/dom_distiller/core/DomDistillerUrlUtils.java
+++ b/components/dom_distiller/android/java/src/org/chromium/components/dom_distiller/core/DomDistillerUrlUtils.java
@@ -36,11 +36,18 @@ public final class DomDistillerUrlUtils {
         return nativeGetOriginalUrlFromDistillerUrl(url);
     }
 
-    public static boolean isUrlReportable(String scheme, String url) {
-        return nativeIsUrlReportable(scheme, url);
+    /**
+     * Returns whether the url is for a distilled page.
+     *
+     * @param url The url of the page.
+     * @return whether the url is for a distilled page.
+     */
+    public static boolean isDistilledPage(String url) {
+        return nativeIsDistilledPage(url);
     }
 
     private static native String nativeGetDistillerViewUrlFromUrl(String scheme, String url);
     private static native String nativeGetOriginalUrlFromDistillerUrl(String viewerUrl);
-    private static native boolean nativeIsUrlReportable(String scheme, String url);
+    private static native boolean nativeIsDistilledPage(String url);
+
 }
diff --git a/components/dom_distiller/core/url_constants.cc b/components/dom_distiller/core/url_constants.cc
index 4d94361..3e6809b 100644
--- a/components/dom_distiller/core/url_constants.cc
+++ b/components/dom_distiller/core/url_constants.cc
@@ -6,6 +6,7 @@
 
 namespace dom_distiller {
 
+const char kDomDistillerScheme[] = "chrome-distiller";
 const char kEntryIdKey[] = "entry_id";
 const char kUrlKey[] = "url";
 const char kViewerCssPath[] = "dom_distiller_viewer.css";
diff --git a/components/dom_distiller/core/url_constants.h b/components/dom_distiller/core/url_constants.h
index 71a8a8b..f9f745e 100644
--- a/components/dom_distiller/core/url_constants.h
+++ b/components/dom_distiller/core/url_constants.h
@@ -7,6 +7,7 @@
 
 namespace dom_distiller {
 
+extern const char kDomDistillerScheme[];
 extern const char kEntryIdKey[];
 extern const char kUrlKey[];
 extern const char kViewerCssPath[];
diff --git a/components/dom_distiller/core/url_utils.cc b/components/dom_distiller/core/url_utils.cc
index e1d9b3d..d5ca57d 100644
--- a/components/dom_distiller/core/url_utils.cc
+++ b/components/dom_distiller/core/url_utils.cc
@@ -47,8 +47,8 @@ bool IsUrlDistillable(const GURL& url) {
   return url.is_valid() && url.SchemeIsHTTPOrHTTPS();
 }
 
-bool IsUrlReportable(const std::string& scheme, const GURL& url) {
-  return url.is_valid() && url.scheme() == scheme;
+bool IsDistilledPage(const GURL& url) {
+  return url.is_valid() && url.scheme() == kDomDistillerScheme;
 }
 
 }  // namespace url_utils
diff --git a/components/dom_distiller/core/url_utils.h b/components/dom_distiller/core/url_utils.h
index 8202850..4dc73b3 100644
--- a/components/dom_distiller/core/url_utils.h
+++ b/components/dom_distiller/core/url_utils.h
@@ -28,8 +28,8 @@ std::string GetValueForKeyInUrlPathQuery(const std::string& path,
 // Returns whether it should be possible to distill the given |url|.
 bool IsUrlDistillable(const GURL& url);
 
-// Returns whether it should be possible to report the given |url|.
-bool IsUrlReportable(const std::string& scheme, const GURL& url);
+// Returns whether the given |url| is for a distilled page.
+bool IsDistilledPage(const GURL& url);
 
 }  // namespace url_utils
 
diff --git a/components/dom_distiller/core/url_utils_android.cc b/components/dom_distiller/core/url_utils_android.cc
index fcadd52..b71eee1 100644
--- a/components/dom_distiller/core/url_utils_android.cc
+++ b/components/dom_distiller/core/url_utils_android.cc
@@ -53,13 +53,9 @@ jstring GetOriginalUrlFromDistillerUrl(JNIEnv* env,
       .Release();
 }
 
-jboolean IsUrlReportable(JNIEnv* env,
-                         jclass clazz,
-                         jstring j_scheme,
-                         jstring j_url) {
-  std::string scheme(base::android::ConvertJavaStringToUTF8(env, j_scheme));
+jboolean IsDistilledPage(JNIEnv* env, jclass clazz, jstring j_url) {
   GURL url(base::android::ConvertJavaStringToUTF8(env, j_url));
-  return dom_distiller::url_utils::IsUrlReportable(scheme, url);
+  return dom_distiller::url_utils::IsDistilledPage(url);
 }
 
 bool RegisterUrlUtils(JNIEnv* env) { return RegisterNativesImpl(env); }
-- 
cgit v1.1