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

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: merge 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 DownloadsDownloadFunction::DownloadsDownloadFunction()
31 : save_as_(false),
32 extra_headers_(NULL),
33 rdh_(NULL),
34 resource_context_(NULL),
35 render_process_host_id_(0),
36 render_view_host_routing_id_(0) {
37 }
38 DownloadsDownloadFunction::~DownloadsDownloadFunction() {}
39
40 bool DownloadsDownloadFunction::RunImpl() {
41 base::DictionaryValue* options = NULL;
42 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &options));
43 EXTENSION_FUNCTION_VALIDATE(options->GetString(constants::kUrlKey, &url_));
44 if (options->HasKey(constants::kFilenameKey))
45 EXTENSION_FUNCTION_VALIDATE(options->GetString(
46 constants::kFilenameKey, &filename_));
47 if (options->HasKey(constants::kSaveAsKey))
48 EXTENSION_FUNCTION_VALIDATE(options->GetBoolean(
49 constants::kSaveAsKey, &save_as_));
50 if (options->HasKey(constants::kMethodKey))
51 EXTENSION_FUNCTION_VALIDATE(options->GetString(
52 constants::kMethodKey, &method_));
53 if (options->HasKey(constants::kHeadersKey))
54 EXTENSION_FUNCTION_VALIDATE(options->GetDictionary(
55 constants::kHeadersKey, &extra_headers_));
56 if (options->HasKey(constants::kBodyKey))
57 EXTENSION_FUNCTION_VALIDATE(options->GetString(
58 constants::kBodyKey, &post_body_));
59 rdh_ = g_browser_process->resource_dispatcher_host();
60 TabContents* tab_contents = BrowserList::GetLastActive()
61 ->GetSelectedTabContentsWrapper()->tab_contents();
62 resource_context_ = &profile()->GetResourceContext();
63 render_process_host_id_ = tab_contents->GetRenderProcessHost()->id();
64 render_view_host_routing_id_ = tab_contents->render_view_host()
65 ->routing_id();
66 VLOG(1) << __FUNCTION__ << " " << url_;
67 error_ = constants::kNotImplemented;
68 return false;
69 }
70
71 DownloadsSearchFunction::DownloadsSearchFunction() {}
72 DownloadsSearchFunction::~DownloadsSearchFunction() {}
73
74 bool DownloadsSearchFunction::RunImpl() {
75 DictionaryValue* query_json = NULL;
76 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &query_json));
77 error_ = constants::kNotImplemented;
78 return false;
79 }
80
81 DownloadsPauseFunction::DownloadsPauseFunction() {}
82 DownloadsPauseFunction::~DownloadsPauseFunction() {}
83
84 bool DownloadsPauseFunction::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 DownloadsResumeFunction::DownloadsResumeFunction() {}
93 DownloadsResumeFunction::~DownloadsResumeFunction() {}
94
95 bool DownloadsResumeFunction::RunImpl() {
96 int dl_id = 0;
97 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
98 VLOG(1) << __FUNCTION__ << " " << dl_id;
99 error_ = constants::kNotImplemented;
100 return false;
101 }
102
103 DownloadsCancelFunction::DownloadsCancelFunction() {}
104 DownloadsCancelFunction::~DownloadsCancelFunction() {}
105
106 bool DownloadsCancelFunction::RunImpl() {
107 int dl_id = 0;
108 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
109 VLOG(1) << __FUNCTION__ << " " << dl_id;
110 error_ = constants::kNotImplemented;
111 return false;
112 }
113
114 DownloadsEraseFunction::DownloadsEraseFunction() {}
115 DownloadsEraseFunction::~DownloadsEraseFunction() {}
116
117 bool DownloadsEraseFunction::RunImpl() {
118 DictionaryValue* query_json = NULL;
119 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &query_json));
120 error_ = constants::kNotImplemented;
121 return false;
122 }
123
124 DownloadsSetDestinationFunction::DownloadsSetDestinationFunction() {}
125 DownloadsSetDestinationFunction::~DownloadsSetDestinationFunction() {}
126
127 bool DownloadsSetDestinationFunction::RunImpl() {
128 int dl_id = 0;
129 std::string path;
130 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
131 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &path));
132 VLOG(1) << __FUNCTION__ << " " << dl_id << " " << &path;
133 error_ = constants::kNotImplemented;
134 return false;
135 }
136
137 DownloadsAcceptDangerFunction::DownloadsAcceptDangerFunction() {}
138 DownloadsAcceptDangerFunction::~DownloadsAcceptDangerFunction() {}
139
140 bool DownloadsAcceptDangerFunction::RunImpl() {
141 int dl_id = 0;
142 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
143 VLOG(1) << __FUNCTION__ << " " << dl_id;
144 error_ = constants::kNotImplemented;
145 return false;
146 }
147
148 DownloadsShowFunction::DownloadsShowFunction() {}
149 DownloadsShowFunction::~DownloadsShowFunction() {}
150
151 bool DownloadsShowFunction::RunImpl() {
152 int dl_id = 0;
153 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
154 VLOG(1) << __FUNCTION__ << " " << dl_id;
155 error_ = constants::kNotImplemented;
156 return false;
157 }
158
159 DownloadsDragFunction::DownloadsDragFunction() {}
160 DownloadsDragFunction::~DownloadsDragFunction() {}
161
162 bool DownloadsDragFunction::RunImpl() {
163 int dl_id = 0;
164 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &dl_id));
165 VLOG(1) << __FUNCTION__ << " " << dl_id;
166 error_ = constants::kNotImplemented;
167 return false;
168 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_downloads_api.h ('k') | chrome/browser/extensions/extension_downloads_api_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698