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

Side by Side 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, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/extension_downloads_api.h"
6
7 #include <algorithm>
8 #include <string>
9
10 #include "base/bind.h"
11 #include "base/logging.h"
12 #include "base/stl_util.h"
13 #include "base/values.h"
14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/download/download_file_manager.h"
16 #include "chrome/browser/download/download_item.h"
17 #include "chrome/browser/download/download_manager.h"
18 #include "chrome/browser/download/download_util.h"
19 #include "chrome/browser/extensions/extension_downloads_api_constants.h"
20 #include "chrome/browser/icon_loader.h"
21 #include "chrome/browser/icon_manager.h"
22 #include "chrome/browser/renderer_host/chrome_render_message_filter.h"
23 #include "chrome/browser/ui/browser_list.h"
24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
25 #include "content/browser/renderer_host/render_view_host.h"
26 #include "content/browser/renderer_host/resource_dispatcher_host.h"
27
28 namespace constants = extension_downloads_api_constants;
29
30 bool DownloadsDownloadFunction::RunImpl() {
31 base::DictionaryValue* options = NULL;
32 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &options));
33 EXTENSION_FUNCTION_VALIDATE(options->GetString(constants::kUrlKey, &url_));
34 if (options->HasKey(constants::kFilenameKey))
35 EXTENSION_FUNCTION_VALIDATE(options->GetString(
36 constants::kFilenameKey, &filename_));
37 if (options->HasKey(constants::kSaveAsKey))
38 EXTENSION_FUNCTION_VALIDATE(options->GetBoolean(
39 constants::kSaveAsKey, &save_as_));
40 if (options->HasKey(constants::kMethodKey))
41 EXTENSION_FUNCTION_VALIDATE(options->GetString(
42 constants::kMethodKey, &method_));
43 if (options->HasKey(constants::kHeadersKey))
44 EXTENSION_FUNCTION_VALIDATE(options->GetDictionary(
45 constants::kHeadersKey, &extra_headers_));
46 if (options->HasKey(constants::kBodyKey))
47 EXTENSION_FUNCTION_VALIDATE(options->GetString(
48 constants::kBodyKey, &post_body_));
49 rdh_ = g_browser_process->resource_dispatcher_host();
50 TabContents* tab_contents = BrowserList::GetLastActive()
51 ->GetSelectedTabContentsWrapper()->tab_contents();
52 resource_context_ = &profile()->GetResourceContext();
53 render_process_host_id_ = tab_contents->GetRenderProcessHost()->id();
54 render_view_host_routing_id_ = tab_contents->render_view_host()
55 ->routing_id();
56 VLOG(1) << __FUNCTION__ << " " << url_;
57 error_ = constants::kNotImplemented;
58 return false;
59 }
60
61 bool DownloadsSearchFunction::RunImpl() {
62 DictionaryValue* query_json = NULL;
63 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &query_json));
64 error_ = constants::kNotImplemented;
65 return false;
66 }
67
68 bool DownloadsPauseFunction::RunImpl() {
69 int dl_id = 0;
70 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
71 VLOG(1) << __FUNCTION__ << " " << dl_id;
72 error_ = constants::kNotImplemented;
73 return false;
74 }
75
76 bool DownloadsResumeFunction::RunImpl() {
77 int dl_id = 0;
78 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
79 VLOG(1) << __FUNCTION__ << " " << dl_id;
80 error_ = constants::kNotImplemented;
81 return false;
82 }
83
84 bool DownloadsCancelFunction::RunImpl() {
85 int dl_id = 0;
86 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
87 VLOG(1) << __FUNCTION__ << " " << dl_id;
88 error_ = constants::kNotImplemented;
89 return false;
90 }
91
92 bool DownloadsEraseFunction::RunImpl() {
93 DictionaryValue* query_json = NULL;
94 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &query_json));
95 error_ = constants::kNotImplemented;
96 return false;
97 }
98
99 bool DownloadsSetDestinationFunction::RunImpl() {
100 int dl_id = 0;
101 std::string path;
102 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
103 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &path));
104 VLOG(1) << __FUNCTION__ << " " << dl_id << " " << &path;
105 error_ = constants::kNotImplemented;
106 return false;
107 }
108
109 bool DownloadsAcceptDangerFunction::RunImpl() {
110 int dl_id = 0;
111 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
112 VLOG(1) << __FUNCTION__ << " " << dl_id;
113 error_ = constants::kNotImplemented;
114 return false;
115 }
116
117 bool DownloadsShowFunction::RunImpl() {
118 int dl_id = 0;
119 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
120 VLOG(1) << __FUNCTION__ << " " << dl_id;
121 error_ = constants::kNotImplemented;
122 return false;
123 }
124
125 bool DownloadsDragFunction::RunImpl() {
126 int dl_id = 0;
127 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
128 VLOG(1) << __FUNCTION__ << " " << dl_id;
129 error_ = constants::kNotImplemented;
130 return false;
131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698