| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |