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

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

Issue 1899433002: Update flags used by offline pages and bookmarks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_piece.h" 8 #include "base/strings/string_piece.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" 10 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h"
11 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 11 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
12 #include "components/offline_pages/offline_page_feature.h" 12 #include "components/offline_pages/offline_page_feature.h"
13 #include "components/offline_pages/offline_page_item.h" 13 #include "components/offline_pages/offline_page_item.h"
14 #include "components/offline_pages/offline_page_model.h" 14 #include "components/offline_pages/offline_page_model.h"
15 #include "content/public/browser/browser_context.h" 15 #include "content/public/browser/browser_context.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 namespace offline_pages { 18 namespace offline_pages {
19 namespace { 19 namespace {
20 20
21 // Returns an offline page originated from the |online_url|. 21 // Returns an offline page originated from the |online_url|.
22 const offline_pages::OfflinePageItem* GetOfflinePageForOnlineURL( 22 const offline_pages::OfflinePageItem* GetOfflinePageForOnlineURL(
23 content::BrowserContext* browser_context, 23 content::BrowserContext* browser_context,
24 const GURL& online_url) { 24 const GURL& online_url) {
25 DCHECK(browser_context); 25 DCHECK(browser_context);
26 26
27 if (!offline_pages::IsOfflinePagesEnabled()) 27 if (!offline_pages::IsOfflineBookmarksEnabled())
fgorski 2016/04/18 17:09:36 This is a bit tricky. I don't think we should be c
jianli 2016/04/18 21:17:00 Done.
28 return nullptr; 28 return nullptr;
29 29
30 offline_pages::OfflinePageModel* offline_page_model = 30 offline_pages::OfflinePageModel* offline_page_model =
31 offline_pages::OfflinePageModelFactory::GetForBrowserContext( 31 offline_pages::OfflinePageModelFactory::GetForBrowserContext(
32 browser_context); 32 browser_context);
33 if (!offline_page_model) 33 if (!offline_page_model)
34 return nullptr; 34 return nullptr;
35 35
36 return offline_page_model->GetPageByOnlineURL(online_url); 36 return offline_page_model->GetPageByOnlineURL(online_url);
37 } 37 }
38 38
39 // Returns an offline page that is stored as the |offline_url|. 39 // Returns an offline page that is stored as the |offline_url|.
40 const offline_pages::OfflinePageItem* GetOfflinePageForOfflineURL( 40 const offline_pages::OfflinePageItem* GetOfflinePageForOfflineURL(
41 content::BrowserContext* browser_context, 41 content::BrowserContext* browser_context,
42 const GURL& offline_url) { 42 const GURL& offline_url) {
43 DCHECK(browser_context); 43 DCHECK(browser_context);
44 44
45 if (!offline_pages::IsOfflinePagesEnabled()) 45 if (!offline_pages::IsOfflineBookmarksEnabled())
46 return nullptr; 46 return nullptr;
47 47
48 // Note that we first check if the url likely points to an offline page 48 // Note that we first check if the url likely points to an offline page
49 // before calling GetPageByOfflineURL in order to avoid unnecessary lookup 49 // before calling GetPageByOfflineURL in order to avoid unnecessary lookup
50 // cost. 50 // cost.
51 if (!OfflinePageUtils::MightBeOfflineURL(offline_url)) 51 if (!OfflinePageUtils::MightBeOfflineURL(offline_url))
52 return nullptr; 52 return nullptr;
53 53
54 offline_pages::OfflinePageModel* offline_page_model = 54 offline_pages::OfflinePageModel* offline_page_model =
55 offline_pages::OfflinePageModelFactory::GetForBrowserContext( 55 offline_pages::OfflinePageModelFactory::GetForBrowserContext(
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 const offline_pages::OfflinePageItem* offline_page = 128 const offline_pages::OfflinePageItem* offline_page =
129 GetOfflinePageForOnlineURL(browser_context, online_url); 129 GetOfflinePageForOnlineURL(browser_context, online_url);
130 return offline_page && !offline_page->file_path.empty(); 130 return offline_page && !offline_page->file_path.empty();
131 } 131 }
132 132
133 // static 133 // static
134 bool OfflinePageUtils::HasOfflinePages( 134 bool OfflinePageUtils::HasOfflinePages(
135 content::BrowserContext* browser_context) { 135 content::BrowserContext* browser_context) {
136 DCHECK(browser_context); 136 DCHECK(browser_context);
137 137
138 if (!offline_pages::IsOfflinePagesEnabled()) 138 if (!offline_pages::IsOfflineBookmarksEnabled())
139 return false; 139 return false;
140 140
141 offline_pages::OfflinePageModel* offline_page_model = 141 offline_pages::OfflinePageModel* offline_page_model =
142 offline_pages::OfflinePageModelFactory::GetForBrowserContext( 142 offline_pages::OfflinePageModelFactory::GetForBrowserContext(
143 browser_context); 143 browser_context);
144 return offline_page_model->HasOfflinePages(); 144 return offline_page_model->HasOfflinePages();
145 } 145 }
146 146
147 } // namespace offline_pages 147 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698