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

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

Issue 2706343007: Only show Last N Pages in the UI when the corresponding tab is visible. (cont'd) (Closed)
Patch Set: Rebase. Created 3 years, 9 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 | « chrome/browser/BUILD.gn ('k') | chrome/browser/android/offline_pages/offline_page_bridge.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 namespace { 48 namespace {
49 49
50 class DownloadUIAdapterDelegate : public DownloadUIAdapter::Delegate { 50 class DownloadUIAdapterDelegate : public DownloadUIAdapter::Delegate {
51 public: 51 public:
52 explicit DownloadUIAdapterDelegate(OfflinePageModel* model); 52 explicit DownloadUIAdapterDelegate(OfflinePageModel* model);
53 53
54 // DownloadUIAdapter::Delegate 54 // DownloadUIAdapter::Delegate
55 bool IsVisibleInUI(const ClientId& client_id) override; 55 bool IsVisibleInUI(const ClientId& client_id) override;
56 bool IsTemporarilyHiddenInUI(const ClientId& client_id) override; 56 bool IsTemporarilyHiddenInUI(const ClientId& client_id) override;
57 void SetUIAdapter(DownloadUIAdapter* ui_adapter) override;
57 58
58 private: 59 private:
59 // Not owned, cached service pointer. 60 // Not owned, cached service pointer.
60 OfflinePageModel* model_; 61 OfflinePageModel* model_;
61 }; 62 };
62 63
63 DownloadUIAdapterDelegate::DownloadUIAdapterDelegate(OfflinePageModel* model) 64 DownloadUIAdapterDelegate::DownloadUIAdapterDelegate(OfflinePageModel* model)
64 : model_(model) {} 65 : model_(model) {}
65 66
66 bool DownloadUIAdapterDelegate::IsVisibleInUI(const ClientId& client_id) { 67 bool DownloadUIAdapterDelegate::IsVisibleInUI(const ClientId& client_id) {
67 const std::string& name_space = client_id.name_space; 68 const std::string& name_space = client_id.name_space;
68 return model_->GetPolicyController()->IsSupportedByDownload(name_space) && 69 return model_->GetPolicyController()->IsSupportedByDownload(name_space) &&
69 base::IsValidGUID(client_id.id); 70 base::IsValidGUID(client_id.id);
70 } 71 }
71 72
72 bool DownloadUIAdapterDelegate::IsTemporarilyHiddenInUI( 73 bool DownloadUIAdapterDelegate::IsTemporarilyHiddenInUI(
73 const ClientId& client_id) { 74 const ClientId& client_id) {
74 return false; 75 return false;
75 } 76 }
76 77
78 void DownloadUIAdapterDelegate::SetUIAdapter(DownloadUIAdapter* ui_adapter) {}
79
77 // TODO(dewittj): Move to Download UI Adapter. 80 // TODO(dewittj): Move to Download UI Adapter.
78 content::WebContents* GetWebContentsFromJavaTab( 81 content::WebContents* GetWebContentsFromJavaTab(
79 const ScopedJavaGlobalRef<jobject>& j_tab_ref) { 82 const ScopedJavaGlobalRef<jobject>& j_tab_ref) {
80 JNIEnv* env = AttachCurrentThread(); 83 JNIEnv* env = AttachCurrentThread();
81 TabAndroid* tab = TabAndroid::GetNativeTab(env, j_tab_ref); 84 TabAndroid* tab = TabAndroid::GetNativeTab(env, j_tab_ref);
82 if (!tab) 85 if (!tab)
83 return nullptr; 86 return nullptr;
84 87
85 return tab->web_contents(); 88 return tab->web_contents();
86 } 89 }
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 base::MakeUnique<DownloadUIAdapterDelegate>(offline_page_model)); 497 base::MakeUnique<DownloadUIAdapterDelegate>(offline_page_model));
495 DownloadUIAdapter::AttachToOfflinePageModel(adapter, offline_page_model); 498 DownloadUIAdapter::AttachToOfflinePageModel(adapter, offline_page_model);
496 } 499 }
497 500
498 return reinterpret_cast<jlong>( 501 return reinterpret_cast<jlong>(
499 new OfflinePageDownloadBridge(env, obj, adapter, browser_context)); 502 new OfflinePageDownloadBridge(env, obj, adapter, browser_context));
500 } 503 }
501 504
502 } // namespace android 505 } // namespace android
503 } // namespace offline_pages 506 } // namespace offline_pages
OLDNEW
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/android/offline_pages/offline_page_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698