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

Side by Side Diff: chrome/browser/android/offline_pages/offline_page_utils.cc

Issue 2059513002: Remove obsoleted function and add test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove empty lines Created 4 years, 6 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 unified diff | Download patch
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/offline_pages/offline_page_utils.h" 5 #include "chrome/browser/android/offline_pages/offline_page_utils.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/optional.h" 9 #include "base/optional.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // static 85 // static
86 bool OfflinePageUtils::MightBeOfflineURL(const GURL& url) { 86 bool OfflinePageUtils::MightBeOfflineURL(const GURL& url) {
87 // It has to be a file URL ending with .mhtml extension. 87 // It has to be a file URL ending with .mhtml extension.
88 return url.is_valid() && url.SchemeIsFile() && 88 return url.is_valid() && url.SchemeIsFile() &&
89 base::EndsWith(url.spec(), 89 base::EndsWith(url.spec(),
90 OfflinePageMHTMLArchiver::GetFileNameExtension(), 90 OfflinePageMHTMLArchiver::GetFileNameExtension(),
91 base::CompareCase::INSENSITIVE_ASCII); 91 base::CompareCase::INSENSITIVE_ASCII);
92 } 92 }
93 93
94 // static 94 // static
95 GURL OfflinePageUtils::MaybeGetOfflineURLForOnlineURL(
96 content::BrowserContext* browser_context,
97 const GURL& online_url) {
98 const OfflinePageItem* offline_page =
99 MaybeGetBestOfflinePageForOnlineURL(browser_context, online_url);
100 if (!offline_page)
101 return GURL();
102
103 return offline_page->GetOfflineURL();
104 }
105
106 // static
107 void OfflinePageUtils::GetOfflineURLForOnlineURL( 95 void OfflinePageUtils::GetOfflineURLForOnlineURL(
108 content::BrowserContext* browser_context, 96 content::BrowserContext* browser_context,
109 const GURL& online_url, 97 const GURL& online_url,
110 const base::Callback<void(const GURL&)>& callback) { 98 const base::Callback<void(const GURL&)>& callback) {
111 OfflinePageModel* offline_page_model = 99 OfflinePageModel* offline_page_model =
112 OfflinePageModelFactory::GetForBrowserContext(browser_context); 100 OfflinePageModelFactory::GetForBrowserContext(browser_context);
113 if (!offline_page_model) { 101 if (!offline_page_model) {
114 base::ThreadTaskRunnerHandle::Get()->PostTask( 102 base::ThreadTaskRunnerHandle::Get()->PostTask(
115 FROM_HERE, 103 FROM_HERE,
116 base::Bind(&OnGetPageByOfflineURLDone, callback, base::nullopt)); 104 base::Bind(&OnGetPageByOfflineURLDone, callback, base::nullopt));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 if (!offline_page) 164 if (!offline_page)
177 return; 165 return;
178 166
179 OfflinePageModel* offline_page_model = 167 OfflinePageModel* offline_page_model =
180 OfflinePageModelFactory::GetForBrowserContext(browser_context); 168 OfflinePageModelFactory::GetForBrowserContext(browser_context);
181 DCHECK(offline_page_model); 169 DCHECK(offline_page_model);
182 offline_page_model->MarkPageAccessed(offline_page->offline_id); 170 offline_page_model->MarkPageAccessed(offline_page->offline_id);
183 } 171 }
184 172
185 } // namespace offline_pages 173 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698