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

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

Issue 2241393003: Offline Pages: Add custom tabs namespace to tab helper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Generalize to allow all namespaces. Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | 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/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/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 callback.Run(result_url); 57 callback.Run(result_url);
58 } 58 }
59 59
60 void OnGetPagesByOnlineURLDone( 60 void OnGetPagesByOnlineURLDone(
61 int tab_id, 61 int tab_id,
62 const base::Callback<void(const OfflinePageItem*)>& callback, 62 const base::Callback<void(const OfflinePageItem*)>& callback,
63 const MultipleOfflinePageItemResult& pages) { 63 const MultipleOfflinePageItemResult& pages) {
64 const OfflinePageItem* selected_page = nullptr; 64 const OfflinePageItem* selected_page = nullptr;
65 std::string tab_id_str = base::IntToString(tab_id); 65 std::string tab_id_str = base::IntToString(tab_id);
66 for (const auto& offline_page : pages) { 66 for (const auto& offline_page : pages) {
67 if ((offline_page.client_id.name_space == kBookmarkNamespace) || 67 if (offline_page.client_id.name_space != kLastNNamespace ||
68 (offline_page.client_id.name_space == kAsyncNamespace) || 68 offline_page.client_id.id == tab_id_str) {
69 (offline_page.client_id.name_space == kLastNNamespace &&
70 offline_page.client_id.id == tab_id_str)) {
71 if (!selected_page || 69 if (!selected_page ||
72 offline_page.creation_time > selected_page->creation_time) { 70 offline_page.creation_time > selected_page->creation_time) {
73 selected_page = &offline_page; 71 selected_page = &offline_page;
74 } 72 }
75 } 73 }
76 } 74 }
77 callback.Run(selected_page); 75 callback.Run(selected_page);
78 } 76 }
79 77
80 } // namespace 78 } // namespace
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 bool OfflinePageUtils::GetTabId(content::WebContents* web_contents, 166 bool OfflinePageUtils::GetTabId(content::WebContents* web_contents,
169 int* tab_id) { 167 int* tab_id) {
170 TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents); 168 TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents);
171 if (!tab_android) 169 if (!tab_android)
172 return false; 170 return false;
173 *tab_id = tab_android->GetAndroidId(); 171 *tab_id = tab_android->GetAndroidId();
174 return true; 172 return true;
175 } 173 }
176 174
177 } // namespace offline_pages 175 } // namespace offline_pages
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698