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

Unified Diff: chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc

Issue 1521193002: [Offline pages] Refactor URL conversions from TabAndroid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing CR feedback Created 5 years 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: chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc
diff --git a/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc b/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc
index fae9849fdc34ba05c385ef58dbd9beed600911a0..4a3e1a77293cc6a236f8d88002aab3b1b0f69ab4 100644
--- a/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc
+++ b/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc
@@ -8,7 +8,7 @@
#include "base/location.h"
#include "base/strings/string16.h"
#include "base/task/cancelable_task_tracker.h"
-#include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
+#include "chrome/browser/android/offline_pages/offline_page_utils.h"
#include "chrome/browser/android/shortcut_helper.h"
#include "chrome/browser/favicon/favicon_service_factory.h"
#include "chrome/browser/manifest/manifest_icon_downloader.h"
@@ -19,9 +19,6 @@
#include "chrome/common/web_application_info.h"
#include "components/dom_distiller/core/url_utils.h"
#include "components/favicon/core/favicon_service.h"
-#include "components/offline_pages/offline_page_feature.h"
-#include "components/offline_pages/offline_page_item.h"
-#include "components/offline_pages/offline_page_model.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
@@ -276,21 +273,14 @@ void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& bitmap,
}
GURL AddToHomescreenDataFetcher::GetShortcutUrl(const GURL& actual_url) {
- GURL shortcut_url =
+ GURL original_url =
dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl(actual_url);
- if (!offline_pages::IsOfflinePagesEnabled())
- return shortcut_url;
+ // If URL points to an offline content, get original URL.
+ GURL online_url = offline_pages::android::GetOnlineURLByOfflineURL(
+ web_contents()->GetBrowserContext(), original_url);
+ if (online_url.is_valid())
+ return online_url;
- Profile* profile =
- Profile::FromBrowserContext(web_contents()->GetBrowserContext());
-
- offline_pages::OfflinePageModel* offline_page_model =
- offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile);
- const offline_pages::OfflinePageItem* offline_page =
- offline_page_model->GetPageByOfflineURL(shortcut_url);
- if (!offline_page)
- return shortcut_url;
-
- return offline_page->url;
+ return original_url;
}

Powered by Google App Engine
This is Rietveld 408576698