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

Unified Diff: chrome/browser/extensions/extension_downloads_api.cc

Issue 7480046: chrome.experimental.downloads stubs (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: DownloadDelta Created 9 years, 5 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/extensions/extension_downloads_api.cc
diff --git a/chrome/browser/extensions/extension_downloads_api.cc b/chrome/browser/extensions/extension_downloads_api.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f003b80fce5d46913a2f3a2fb60b884f19abd714
--- /dev/null
+++ b/chrome/browser/extensions/extension_downloads_api.cc
@@ -0,0 +1,131 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/extension_downloads_api.h"
+
+#include <algorithm>
+#include <string>
+
+#include "base/bind.h"
+#include "base/logging.h"
+#include "base/stl_util.h"
+#include "base/values.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/download/download_file_manager.h"
+#include "chrome/browser/download/download_item.h"
+#include "chrome/browser/download/download_manager.h"
+#include "chrome/browser/download/download_util.h"
+#include "chrome/browser/extensions/extension_downloads_api_constants.h"
+#include "chrome/browser/icon_loader.h"
+#include "chrome/browser/icon_manager.h"
+#include "chrome/browser/renderer_host/chrome_render_message_filter.h"
+#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
+#include "content/browser/renderer_host/render_view_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host.h"
+
+namespace constants = extension_downloads_api_constants;
+
+bool DownloadsDownloadFunction::RunImpl() {
+ base::DictionaryValue* options = NULL;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &options));
+ EXTENSION_FUNCTION_VALIDATE(options->GetString(constants::kUrlKey, &url_));
+ if (options->HasKey(constants::kFilenameKey))
+ EXTENSION_FUNCTION_VALIDATE(options->GetString(
+ constants::kFilenameKey, &filename_));
+ if (options->HasKey(constants::kSaveAsKey))
+ EXTENSION_FUNCTION_VALIDATE(options->GetBoolean(
+ constants::kSaveAsKey, &save_as_));
+ if (options->HasKey(constants::kMethodKey))
+ EXTENSION_FUNCTION_VALIDATE(options->GetString(
+ constants::kMethodKey, &method_));
+ if (options->HasKey(constants::kHeadersKey))
+ EXTENSION_FUNCTION_VALIDATE(options->GetDictionary(
+ constants::kHeadersKey, &extra_headers_));
+ if (options->HasKey(constants::kBodyKey))
+ EXTENSION_FUNCTION_VALIDATE(options->GetString(
+ constants::kBodyKey, &post_body_));
+ rdh_ = g_browser_process->resource_dispatcher_host();
+ TabContents* tab_contents = BrowserList::GetLastActive()
+ ->GetSelectedTabContentsWrapper()->tab_contents();
+ resource_context_ = &profile()->GetResourceContext();
+ render_process_host_id_ = tab_contents->GetRenderProcessHost()->id();
+ render_view_host_routing_id_ = tab_contents->render_view_host()
+ ->routing_id();
+ VLOG(1) << __FUNCTION__ << " " << url_;
+ error_ = constants::kNotImplemented;
+ return false;
+}
+
+bool DownloadsSearchFunction::RunImpl() {
+ DictionaryValue* query_json = NULL;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &query_json));
+ error_ = constants::kNotImplemented;
+ return false;
+}
+
+bool DownloadsPauseFunction::RunImpl() {
+ int dl_id = 0;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
+ VLOG(1) << __FUNCTION__ << " " << dl_id;
+ error_ = constants::kNotImplemented;
+ return false;
+}
+
+bool DownloadsResumeFunction::RunImpl() {
+ int dl_id = 0;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
+ VLOG(1) << __FUNCTION__ << " " << dl_id;
+ error_ = constants::kNotImplemented;
+ return false;
+}
+
+bool DownloadsCancelFunction::RunImpl() {
+ int dl_id = 0;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
+ VLOG(1) << __FUNCTION__ << " " << dl_id;
+ error_ = constants::kNotImplemented;
+ return false;
+}
+
+bool DownloadsEraseFunction::RunImpl() {
+ DictionaryValue* query_json = NULL;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &query_json));
+ error_ = constants::kNotImplemented;
+ return false;
+}
+
+bool DownloadsSetDestinationFunction::RunImpl() {
+ int dl_id = 0;
+ std::string path;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
+ EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &path));
+ VLOG(1) << __FUNCTION__ << " " << dl_id << " " << &path;
+ error_ = constants::kNotImplemented;
+ return false;
+}
+
+bool DownloadsAcceptDangerFunction::RunImpl() {
+ int dl_id = 0;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
+ VLOG(1) << __FUNCTION__ << " " << dl_id;
+ error_ = constants::kNotImplemented;
+ return false;
+}
+
+bool DownloadsShowFunction::RunImpl() {
+ int dl_id = 0;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
+ VLOG(1) << __FUNCTION__ << " " << dl_id;
+ error_ = constants::kNotImplemented;
+ return false;
+}
+
+bool DownloadsDragFunction::RunImpl() {
+ int dl_id = 0;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
+ VLOG(1) << __FUNCTION__ << " " << dl_id;
+ error_ = constants::kNotImplemented;
+ return false;
+}

Powered by Google App Engine
This is Rietveld 408576698