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

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

Issue 2684973014: Only show Last N Pages in the UI when the corresponding tab is visible. (Closed)
Patch Set: Move impl out Created 3 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 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 namespace { 52 namespace {
53 53
54 class DownloadUIAdapterDelegate : public DownloadUIAdapter::Delegate { 54 class DownloadUIAdapterDelegate : public DownloadUIAdapter::Delegate {
55 public: 55 public:
56 explicit DownloadUIAdapterDelegate(OfflinePageModel* model); 56 explicit DownloadUIAdapterDelegate(OfflinePageModel* model);
57 57
58 // DownloadUIAdapter::Delegate 58 // DownloadUIAdapter::Delegate
59 bool IsVisibleInUI(const ClientId& client_id) override; 59 bool IsVisibleInUI(const ClientId& client_id) override;
60 bool IsTemporarilyHiddenInUI(const ClientId& client_id) override; 60 bool IsTemporarilyHiddenInUI(const ClientId& client_id) override;
61 void SetUIAdapter(DownloadUIAdapter* ui_adapter) override;
61 62
62 private: 63 private:
63 // Not owned, cached service pointer. 64 // Not owned, cached service pointer.
64 OfflinePageModel* model_; 65 OfflinePageModel* model_;
65 }; 66 };
66 67
67 DownloadUIAdapterDelegate::DownloadUIAdapterDelegate(OfflinePageModel* model) 68 DownloadUIAdapterDelegate::DownloadUIAdapterDelegate(OfflinePageModel* model)
68 : model_(model) {} 69 : model_(model) {}
69 70
70 bool DownloadUIAdapterDelegate::IsVisibleInUI(const ClientId& client_id) { 71 bool DownloadUIAdapterDelegate::IsVisibleInUI(const ClientId& client_id) {
71 const std::string& name_space = client_id.name_space; 72 const std::string& name_space = client_id.name_space;
72 return model_->GetPolicyController()->IsSupportedByDownload(name_space) && 73 return model_->GetPolicyController()->IsSupportedByDownload(name_space) &&
73 base::IsValidGUID(client_id.id); 74 base::IsValidGUID(client_id.id);
74 } 75 }
75 76
76 bool DownloadUIAdapterDelegate::IsTemporarilyHiddenInUI( 77 bool DownloadUIAdapterDelegate::IsTemporarilyHiddenInUI(
77 const ClientId& client_id) { 78 const ClientId& client_id) {
78 return false; 79 return false;
79 } 80 }
80 81
82 void DownloadUIAdapterDelegate::SetUIAdapter(DownloadUIAdapter* ui_adapter) {}
83
81 // TODO(dewittj): Move to Download UI Adapter. 84 // TODO(dewittj): Move to Download UI Adapter.
82 content::WebContents* GetWebContentsFromJavaTab( 85 content::WebContents* GetWebContentsFromJavaTab(
83 const ScopedJavaGlobalRef<jobject>& j_tab_ref) { 86 const ScopedJavaGlobalRef<jobject>& j_tab_ref) {
84 JNIEnv* env = AttachCurrentThread(); 87 JNIEnv* env = AttachCurrentThread();
85 TabAndroid* tab = TabAndroid::GetNativeTab(env, j_tab_ref); 88 TabAndroid* tab = TabAndroid::GetNativeTab(env, j_tab_ref);
86 if (!tab) 89 if (!tab)
87 return nullptr; 90 return nullptr;
88 91
89 return tab->web_contents(); 92 return tab->web_contents();
90 } 93 }
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 base::MakeUnique<DownloadUIAdapterDelegate>(offline_page_model)); 491 base::MakeUnique<DownloadUIAdapterDelegate>(offline_page_model));
489 offline_page_model->SetUserData(kDownloadUIAdapterKey, adapter); 492 offline_page_model->SetUserData(kDownloadUIAdapterKey, adapter);
490 } 493 }
491 494
492 return reinterpret_cast<jlong>( 495 return reinterpret_cast<jlong>(
493 new OfflinePageDownloadBridge(env, obj, adapter, browser_context)); 496 new OfflinePageDownloadBridge(env, obj, adapter, browser_context));
494 } 497 }
495 498
496 } // namespace android 499 } // namespace android
497 } // namespace offline_pages 500 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698