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

Side by Side 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 final 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/android/tab_android.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h" 5 #include "chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/task/cancelable_task_tracker.h" 10 #include "base/task/cancelable_task_tracker.h"
11 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 11 #include "chrome/browser/android/offline_pages/offline_page_utils.h"
12 #include "chrome/browser/android/shortcut_helper.h" 12 #include "chrome/browser/android/shortcut_helper.h"
13 #include "chrome/browser/favicon/favicon_service_factory.h" 13 #include "chrome/browser/favicon/favicon_service_factory.h"
14 #include "chrome/browser/manifest/manifest_icon_downloader.h" 14 #include "chrome/browser/manifest/manifest_icon_downloader.h"
15 #include "chrome/browser/manifest/manifest_icon_selector.h" 15 #include "chrome/browser/manifest/manifest_icon_selector.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/chrome_constants.h" 17 #include "chrome/common/chrome_constants.h"
18 #include "chrome/common/render_messages.h" 18 #include "chrome/common/render_messages.h"
19 #include "chrome/common/web_application_info.h" 19 #include "chrome/common/web_application_info.h"
20 #include "components/dom_distiller/core/url_utils.h" 20 #include "components/dom_distiller/core/url_utils.h"
21 #include "components/favicon/core/favicon_service.h" 21 #include "components/favicon/core/favicon_service.h"
22 #include "components/offline_pages/offline_page_feature.h"
23 #include "components/offline_pages/offline_page_item.h"
24 #include "components/offline_pages/offline_page_model.h"
25 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
26 #include "content/public/browser/user_metrics.h" 23 #include "content/public/browser/user_metrics.h"
27 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
28 #include "content/public/browser/web_contents_observer.h" 25 #include "content/public/browser/web_contents_observer.h"
29 #include "content/public/common/frame_navigate_params.h" 26 #include "content/public/common/frame_navigate_params.h"
30 #include "content/public/common/manifest.h" 27 #include "content/public/common/manifest.h"
31 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationLockType.h" 28 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationLockType.h"
32 #include "ui/gfx/codec/png_codec.h" 29 #include "ui/gfx/codec/png_codec.h"
33 #include "ui/gfx/favicon_size.h" 30 #include "ui/gfx/favicon_size.h"
34 #include "ui/gfx/screen.h" 31 #include "ui/gfx/screen.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 return; 266 return;
270 267
271 is_icon_saved_ = true; 268 is_icon_saved_ = true;
272 shortcut_icon_ = bitmap; 269 shortcut_icon_ = bitmap;
273 shortcut_info_.is_icon_generated = is_generated; 270 shortcut_info_.is_icon_generated = is_generated;
274 is_ready_ = true; 271 is_ready_ = true;
275 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_); 272 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_);
276 } 273 }
277 274
278 GURL AddToHomescreenDataFetcher::GetShortcutUrl(const GURL& actual_url) { 275 GURL AddToHomescreenDataFetcher::GetShortcutUrl(const GURL& actual_url) {
279 GURL shortcut_url = 276 GURL original_url =
280 dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl(actual_url); 277 dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl(actual_url);
281 278
282 if (!offline_pages::IsOfflinePagesEnabled()) 279 // If URL points to an offline content, get original URL.
283 return shortcut_url; 280 GURL online_url = offline_pages::OfflinePageUtils::GetOnlineURLForOfflineURL(
281 web_contents()->GetBrowserContext(), original_url);
282 if (online_url.is_valid())
283 return online_url;
284 284
285 Profile* profile = 285 return original_url;
286 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
287
288 offline_pages::OfflinePageModel* offline_page_model =
289 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile);
290 const offline_pages::OfflinePageItem* offline_page =
291 offline_page_model->GetPageByOfflineURL(shortcut_url);
292 if (!offline_page)
293 return shortcut_url;
294
295 return offline_page->url;
296 } 286 }
OLDNEW
« no previous file with comments | « chrome/browser/android/tab_android.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698