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

Side by Side Diff: chrome/browser/android/offline_pages/downloads/offline_page_download_bridge.cc

Issue 2342443006: [Offline pages] Use the new policy bits (Closed)
Patch Set: code review update Created 4 years, 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/downloads/offline_page_download_b ridge.h" 5 #include "chrome/browser/android/offline_pages/downloads/offline_page_download_b ridge.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/guid.h" 11 #include "base/guid.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "chrome/browser/android/offline_pages/downloads/offline_page_notificati on_bridge.h" 14 #include "chrome/browser/android/offline_pages/downloads/offline_page_notificati on_bridge.h"
15 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" 15 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h"
16 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 16 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
17 #include "chrome/browser/android/offline_pages/recent_tab_helper.h" 17 #include "chrome/browser/android/offline_pages/recent_tab_helper.h"
18 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" 18 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h"
19 #include "chrome/browser/android/tab_android.h" 19 #include "chrome/browser/android/tab_android.h"
20 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/profiles/profile_android.h" 21 #include "chrome/browser/profiles/profile_android.h"
22 #include "components/offline_pages/background/request_coordinator.h" 22 #include "components/offline_pages/background/request_coordinator.h"
23 #include "components/offline_pages/client_namespace_constants.h" 23 #include "components/offline_pages/client_namespace_constants.h"
24 #include "components/offline_pages/client_policy_controller.h"
24 #include "components/offline_pages/downloads/download_ui_item.h" 25 #include "components/offline_pages/downloads/download_ui_item.h"
25 #include "components/offline_pages/offline_page_feature.h" 26 #include "components/offline_pages/offline_page_feature.h"
26 #include "components/offline_pages/offline_page_model.h" 27 #include "components/offline_pages/offline_page_model.h"
27 #include "content/public/browser/browser_context.h" 28 #include "content/public/browser/browser_context.h"
28 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
29 #include "jni/OfflinePageDownloadBridge_jni.h" 30 #include "jni/OfflinePageDownloadBridge_jni.h"
30 #include "net/base/filename_util.h" 31 #include "net/base/filename_util.h"
31 #include "url/gurl.h" 32 #include "url/gurl.h"
32 33
33 using base::android::AttachCurrentThread; 34 using base::android::AttachCurrentThread;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 ConvertUTF8ToJavaString(env, item.url.spec()), 66 ConvertUTF8ToJavaString(env, item.url.spec()),
66 ConvertUTF16ToJavaString(env, item.title), 67 ConvertUTF16ToJavaString(env, item.title),
67 ConvertUTF8ToJavaString(env, item.target_path.value()), 68 ConvertUTF8ToJavaString(env, item.target_path.value()),
68 item.start_time.ToJavaTime(), item.total_bytes); 69 item.start_time.ToJavaTime(), item.total_bytes);
69 } 70 }
70 71
71 std::vector<int64_t> FilterRequestsByGuid( 72 std::vector<int64_t> FilterRequestsByGuid(
72 std::vector<std::unique_ptr<SavePageRequest>> requests, 73 std::vector<std::unique_ptr<SavePageRequest>> requests,
73 const std::string& guid) { 74 const std::string& guid) {
74 std::vector<int64_t> request_ids; 75 std::vector<int64_t> request_ids;
76 ClientPolicyController policy_controller;
75 for (const auto& request : requests) { 77 for (const auto& request : requests) {
76 if (request->client_id().id == guid && 78 if (request->client_id().id == guid &&
77 (request->client_id().name_space == kDownloadNamespace || 79 policy_controller.IsSupportedByDownload(
78 request->client_id().name_space == kAsyncNamespace)) { 80 request->client_id().name_space)) {
79 request_ids.push_back(request->request_id()); 81 request_ids.push_back(request->request_id());
80 } 82 }
81 } 83 }
82 return request_ids; 84 return request_ids;
83 } 85 }
84 86
85 void CancelRequestCallback(const RequestQueue::UpdateMultipleRequestResults&) { 87 void CancelRequestCallback(const RequestQueue::UpdateMultipleRequestResults&) {
86 // Results ignored here, as UI uses observer to update itself. 88 // Results ignored here, as UI uses observer to update itself.
87 } 89 }
88 90
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 356
355 DownloadUIAdapter* adapter = 357 DownloadUIAdapter* adapter =
356 DownloadUIAdapter::FromOfflinePageModel(offline_page_model); 358 DownloadUIAdapter::FromOfflinePageModel(offline_page_model);
357 359
358 return reinterpret_cast<jlong>( 360 return reinterpret_cast<jlong>(
359 new OfflinePageDownloadBridge(env, obj, adapter, browser_context)); 361 new OfflinePageDownloadBridge(env, obj, adapter, browser_context));
360 } 362 }
361 363
362 } // namespace android 364 } // namespace android
363 } // namespace offline_pages 365 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698