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

Unified Diff: chrome/browser/android/download/download_controller.h

Issue 2014803002: Move DownloadControllerAndroid from content/ to chrome/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/download/download_controller.h
diff --git a/chrome/browser/android/download/download_controller.h b/chrome/browser/android/download/download_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..6df0657ed25c650a8f76d8a96c4acc841a39e044
--- /dev/null
+++ b/chrome/browser/android/download/download_controller.h
@@ -0,0 +1,105 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
Ted C 2016/06/15 23:56:38 we no longer put (c) in these :-P
Jinsuk Kim 2016/06/16 05:34:13 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This class pairs with DownloadController on Java side to forward requests
+// for GET downloads to the current DownloadListener. POST downloads are
+// handled on the native side.
+//
+// Both classes are Singleton classes. C++ object owns Java object.
+//
+// Call sequence
+// GET downloads:
+// DownloadController::CreateGETDownload() =>
+// DownloadController.newHttpGetDownload() =>
+// DownloadListener.onDownloadStart() /
+// DownloadListener2.requestHttpGetDownload()
+//
+
+#ifndef CHROME_BROWSER_ANDROID_DOWNLOAD_DOWNLOAD_CONTROLLER_H_
+#define CHROME_BROWSER_ANDROID_DOWNLOAD_DOWNLOAD_CONTROLLER_H_
+
+#include "base/android/scoped_java_ref.h"
+#include "base/memory/singleton.h"
+#include "chrome/browser/android/download/download_controller_base.h"
+
+namespace net {
+class URLRequest;
+}
+
+namespace ui {
+class WindowAndroid;
+}
+
+namespace content {
+class WebContents;
+}
+
+class DownloadController : public DownloadControllerBase {
+ public:
+ static DownloadController* GetInstance();
+
+ static bool RegisterDownloadController(JNIEnv* env);
+
+ // Called when DownloadController Java object is instantiated.
+ void Init(JNIEnv* env, jobject obj);
+
+ // DownloadControllerBase implementation.
+ void AcquireFileAccessPermission(
+ content::WebContents* web_contents,
+ const AcquireFileAccessPermissionCallback& callback) override;
+ void SetDefaultDownloadFileName(const std::string& file_name) override;
+
+ private:
+ struct JavaObject;
+ friend struct base::DefaultSingletonTraits<DownloadController>;
+ DownloadController();
+ ~DownloadController() override;
+
+ // Helper method for implementing AcquireFileAccessPermission().
+ bool HasFileAccessPermission(ui::WindowAndroid* window_android);
+
+ // DownloadControllerBase implementation.
+ void CreateGETDownload(int render_process_id,
+ int render_view_id,
+ bool must_download,
+ const DownloadInfo& info) override;
+ void OnDownloadStarted(content::DownloadItem* download_item) override;
+ void StartContextMenuDownload(const content::ContextMenuParams& params,
+ content::WebContents* web_contents,
+ bool is_link,
+ const std::string& extra_headers) override;
+ void DangerousDownloadValidated(content::WebContents* web_contents,
+ const std::string& download_guid,
+ bool accept) override;
+
+ // DownloadItem::Observer interface.
+ void OnDownloadUpdated(content::DownloadItem* item) override;
+
+ void StartAndroidDownload(int render_process_id,
+ int render_view_id,
+ bool must_download,
+ const DownloadInfo& info);
+ void StartAndroidDownloadInternal(int render_process_id,
+ int render_view_id,
+ bool must_download,
+ const DownloadInfo& info,
+ bool allowed);
+
+ // The download item contains dangerous file types.
+ void OnDangerousDownload(content::DownloadItem *item);
+
+ base::android::ScopedJavaLocalRef<jobject> GetContentViewCoreFromWebContents(
+ content::WebContents* web_contents);
+
+ // Creates Java object if it is not created already and returns it.
+ JavaObject* GetJavaObject();
+
+ JavaObject* java_object_;
+
+ std::string default_file_name_;
+
+ DISALLOW_COPY_AND_ASSIGN(DownloadController);
+};
+
+#endif // CHROME_BROWSER_ANDROID_DOWNLOAD_DOWNLOAD_CONTROLLER_H_
« no previous file with comments | « chrome/browser/android/download/chrome_download_delegate.cc ('k') | chrome/browser/android/download/download_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698