1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
// Copyright (c) 2012 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 "content/public/browser/download_url_parameters.h"
#include "base/callback.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/download_save_info.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/web_contents.h"
#include "googleurl/src/gurl.h"
namespace content {
DownloadUrlParameters::DownloadUrlParameters(
const GURL& url,
int render_process_host_id,
int render_view_host_routing_id,
ResourceContext* resource_context,
scoped_ptr<DownloadSaveInfo> save_info)
: content_initiated_(false),
load_flags_(0),
method_("GET"),
post_id_(-1),
prefer_cache_(false),
render_process_host_id_(render_process_host_id),
render_view_host_routing_id_(render_view_host_routing_id),
resource_context_(resource_context),
resource_dispatcher_host_(ResourceDispatcherHost::Get()),
save_info_(save_info.Pass()),
url_(url) {
DCHECK(resource_dispatcher_host_);
}
DownloadUrlParameters::~DownloadUrlParameters() {
}
// static
DownloadUrlParameters* DownloadUrlParameters::FromWebContents(
WebContents* web_contents,
const GURL& url,
scoped_ptr<DownloadSaveInfo> save_info) {
return new DownloadUrlParameters(
url,
web_contents->GetRenderProcessHost()->GetID(),
web_contents->GetRenderViewHost()->GetRoutingID(),
web_contents->GetBrowserContext()->GetResourceContext(),
save_info.Pass());
}
scoped_ptr<DownloadSaveInfo> DownloadUrlParameters::GetSaveInfo() {
return save_info_.Pass();
}
} // namespace content
|