OLD | NEW |
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/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/stl_util.h" |
10 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
13 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
15 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" | 16 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" |
16 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 17 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
17 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h" | 18 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h" |
18 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" | 19 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" |
19 #include "chrome/browser/android/tab_android.h" | 20 #include "chrome/browser/android/tab_android.h" |
(...skipping 18 matching lines...) Expand all Loading... |
38 const GURL& url, | 39 const GURL& url, |
39 int tab_id, | 40 int tab_id, |
40 const std::vector<std::string>& namespaces_to_show_in_original_tab, | 41 const std::vector<std::string>& namespaces_to_show_in_original_tab, |
41 const base::Callback<void(const OfflinePageItem*)>& callback, | 42 const base::Callback<void(const OfflinePageItem*)>& callback, |
42 const MultipleOfflinePageItemResult& pages) { | 43 const MultipleOfflinePageItemResult& pages) { |
43 const OfflinePageItem* selected_page_for_final_url = nullptr; | 44 const OfflinePageItem* selected_page_for_final_url = nullptr; |
44 const OfflinePageItem* selected_page_for_original_url = nullptr; | 45 const OfflinePageItem* selected_page_for_original_url = nullptr; |
45 std::string tab_id_str = base::IntToString(tab_id); | 46 std::string tab_id_str = base::IntToString(tab_id); |
46 | 47 |
47 for (const auto& page : pages) { | 48 for (const auto& page : pages) { |
48 auto result = std::find(namespaces_to_show_in_original_tab.begin(), | 49 if (base::ContainsValue(namespaces_to_show_in_original_tab, |
49 namespaces_to_show_in_original_tab.end(), | 50 page.client_id.name_space) && |
50 page.client_id.name_space); | |
51 if (result != namespaces_to_show_in_original_tab.end() && | |
52 page.client_id.id != tab_id_str) { | 51 page.client_id.id != tab_id_str) { |
53 continue; | 52 continue; |
54 } | 53 } |
55 | 54 |
56 if (OfflinePageUtils::EqualsIgnoringFragment(url, page.url)) { | 55 if (OfflinePageUtils::EqualsIgnoringFragment(url, page.url)) { |
57 if (!selected_page_for_final_url || | 56 if (!selected_page_for_final_url || |
58 page.creation_time > selected_page_for_final_url->creation_time) { | 57 page.creation_time > selected_page_for_final_url->creation_time) { |
59 selected_page_for_final_url = &page; | 58 selected_page_for_final_url = &page; |
60 } | 59 } |
61 } else { | 60 } else { |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 OfflinePageModelQueryBuilder builder; | 333 OfflinePageModelQueryBuilder builder; |
335 builder.RequireRemovedOnCacheReset( | 334 builder.RequireRemovedOnCacheReset( |
336 OfflinePageModelQuery::Requirement::INCLUDE_MATCHING); | 335 OfflinePageModelQuery::Requirement::INCLUDE_MATCHING); |
337 offline_page_model->GetPagesMatchingQuery( | 336 offline_page_model->GetPagesMatchingQuery( |
338 builder.Build(offline_page_model->GetPolicyController()), | 337 builder.Build(offline_page_model->GetPolicyController()), |
339 base::Bind(&DoCalculateSizeBetween, callback, begin_time, end_time)); | 338 base::Bind(&DoCalculateSizeBetween, callback, begin_time, end_time)); |
340 return true; | 339 return true; |
341 } | 340 } |
342 | 341 |
343 } // namespace offline_pages | 342 } // namespace offline_pages |
OLD | NEW |