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

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

Issue 1694863003: Refactor the offline page storage to include client namespace and id. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments. Created 4 years, 10 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 <cstdlib>
8
9 #include "base/strings/string_number_conversions.h"
7 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
8 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
9 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" 12 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h"
10 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 13 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
11 #include "components/offline_pages/offline_page_feature.h" 14 #include "components/offline_pages/offline_page_feature.h"
12 #include "components/offline_pages/offline_page_item.h" 15 #include "components/offline_pages/offline_page_item.h"
13 #include "components/offline_pages/offline_page_model.h" 16 #include "components/offline_pages/offline_page_model.h"
14 #include "content/public/browser/browser_context.h" 17 #include "content/public/browser/browser_context.h"
15 #include "url/gurl.h" 18 #include "url/gurl.h"
16 19
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 99
97 // static 100 // static
98 int64_t OfflinePageUtils::GetBookmarkIdForOfflineURL( 101 int64_t OfflinePageUtils::GetBookmarkIdForOfflineURL(
99 content::BrowserContext* browser_context, 102 content::BrowserContext* browser_context,
100 const GURL& offline_url) { 103 const GURL& offline_url) {
101 const offline_pages::OfflinePageItem* offline_page = 104 const offline_pages::OfflinePageItem* offline_page =
102 GetOfflinePageForOfflineURL(browser_context, offline_url); 105 GetOfflinePageForOfflineURL(browser_context, offline_url);
103 if (!offline_page) 106 if (!offline_page)
104 return -1; 107 return -1;
105 108
106 return offline_page->bookmark_id; 109 if (offline_page->client_id_name_space != "bookmark") {
fgorski 2016/02/23 17:15:30 this should be declared someplace in offline pages
bburns 2016/02/23 19:25:38 Done.
110 return -1;
111 }
112
113 int64_t result;
114 if (base::StringToInt64(offline_page->client_id, &result)) {
115 return result;
116 }
117 return -1;
107 } 118 }
108 119
109 // static 120 // static
110 bool OfflinePageUtils::IsOfflinePage(content::BrowserContext* browser_context, 121 bool OfflinePageUtils::IsOfflinePage(content::BrowserContext* browser_context,
111 const GURL& offline_url) { 122 const GURL& offline_url) {
112 return GetOfflinePageForOfflineURL(browser_context, offline_url) != nullptr; 123 return GetOfflinePageForOfflineURL(browser_context, offline_url) != nullptr;
113 } 124 }
114 125
115 // static 126 // static
116 bool OfflinePageUtils::HasOfflinePageForOnlineURL( 127 bool OfflinePageUtils::HasOfflinePageForOnlineURL(
(...skipping 12 matching lines...) Expand all
129 if (!offline_pages::IsOfflinePagesEnabled()) 140 if (!offline_pages::IsOfflinePagesEnabled())
130 return false; 141 return false;
131 142
132 offline_pages::OfflinePageModel* offline_page_model = 143 offline_pages::OfflinePageModel* offline_page_model =
133 offline_pages::OfflinePageModelFactory::GetForBrowserContext( 144 offline_pages::OfflinePageModelFactory::GetForBrowserContext(
134 browser_context); 145 browser_context);
135 return offline_page_model->HasOfflinePages(); 146 return offline_page_model->HasOfflinePages();
136 } 147 }
137 148
138 } // namespace offline_pages 149 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698