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

Side by Side Diff: chrome/browser/plugins/plugin_installer.cc

Issue 15467002: Remove unused reference to DownloadManager in PluginInstaller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 7 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
« no previous file with comments | « chrome/browser/plugins/plugin_installer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/plugins/plugin_installer.h" 5 #include "chrome/browser/plugins/plugin_installer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/process.h" 9 #include "base/process.h"
10 #include "chrome/browser/download/download_service.h" 10 #include "chrome/browser/download/download_service.h"
11 #include "chrome/browser/download/download_service_factory.h" 11 #include "chrome/browser/download/download_service_factory.h"
12 #include "chrome/browser/download/download_util.h" 12 #include "chrome/browser/download/download_util.h"
13 #include "chrome/browser/platform_util.h" 13 #include "chrome/browser/platform_util.h"
14 #include "chrome/browser/plugins/plugin_installer_observer.h" 14 #include "chrome/browser/plugins/plugin_installer_observer.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "content/public/browser/browser_context.h" 16 #include "content/public/browser/browser_context.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/download_id.h" 18 #include "content/public/browser/download_id.h"
19 #include "content/public/browser/download_item.h" 19 #include "content/public/browser/download_item.h"
20 #include "content/public/browser/download_manager.h"
21 #include "content/public/browser/download_save_info.h" 20 #include "content/public/browser/download_save_info.h"
22 #include "content/public/browser/render_process_host.h" 21 #include "content/public/browser/render_process_host.h"
23 #include "content/public/browser/render_view_host.h" 22 #include "content/public/browser/render_view_host.h"
24 #include "content/public/browser/resource_context.h" 23 #include "content/public/browser/resource_context.h"
25 #include "content/public/browser/resource_dispatcher_host.h" 24 #include "content/public/browser/resource_dispatcher_host.h"
26 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
27 #include "net/url_request/url_request.h" 26 #include "net/url_request/url_request.h"
28 #include "net/url_request/url_request_context.h" 27 #include "net/url_request/url_request_context.h"
29 28
30 using content::BrowserContext; 29 using content::BrowserContext;
31 using content::BrowserThread; 30 using content::BrowserThread;
32 using content::DownloadItem; 31 using content::DownloadItem;
33 using content::DownloadManager;
34 using content::ResourceDispatcherHost; 32 using content::ResourceDispatcherHost;
35 33
36 namespace { 34 namespace {
37 35
38 void BeginDownload( 36 void BeginDownload(
39 const GURL& url, 37 const GURL& url,
40 content::ResourceContext* resource_context, 38 content::ResourceContext* resource_context,
41 int render_process_host_id, 39 int render_process_host_id,
42 int render_view_host_routing_id, 40 int render_view_host_routing_id,
43 const ResourceDispatcherHost::DownloadStartedCallback& callback) { 41 const ResourceDispatcherHost::DownloadStartedCallback& callback) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 weak_observers_.RemoveObserver(observer); 127 weak_observers_.RemoveObserver(observer);
130 } 128 }
131 129
132 void PluginInstaller::StartInstalling(const GURL& plugin_url, 130 void PluginInstaller::StartInstalling(const GURL& plugin_url,
133 content::WebContents* web_contents) { 131 content::WebContents* web_contents) {
134 DCHECK_EQ(INSTALLER_STATE_IDLE, state_); 132 DCHECK_EQ(INSTALLER_STATE_IDLE, state_);
135 state_ = INSTALLER_STATE_DOWNLOADING; 133 state_ = INSTALLER_STATE_DOWNLOADING;
136 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadStarted()); 134 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadStarted());
137 Profile* profile = 135 Profile* profile =
138 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 136 Profile::FromBrowserContext(web_contents->GetBrowserContext());
139 DownloadManager* download_manager =
140 BrowserContext::GetDownloadManager(profile);
141 download_util::RecordDownloadSource( 137 download_util::RecordDownloadSource(
142 download_util::INITIATED_BY_PLUGIN_INSTALLER); 138 download_util::INITIATED_BY_PLUGIN_INSTALLER);
143 BrowserThread::PostTask( 139 BrowserThread::PostTask(
144 BrowserThread::IO, FROM_HERE, 140 BrowserThread::IO, FROM_HERE,
145 base::Bind(&BeginDownload, 141 base::Bind(&BeginDownload,
146 plugin_url, 142 plugin_url,
147 profile->GetResourceContext(), 143 profile->GetResourceContext(),
148 web_contents->GetRenderProcessHost()->GetID(), 144 web_contents->GetRenderProcessHost()->GetID(),
149 web_contents->GetRenderViewHost()->GetRoutingID(), 145 web_contents->GetRenderViewHost()->GetRoutingID(),
150 base::Bind(&PluginInstaller::DownloadStarted, 146 base::Bind(&PluginInstaller::DownloadStarted,
151 base::Unretained(this), 147 base::Unretained(this))));
152 make_scoped_refptr(download_manager))));
153 } 148 }
154 149
155 void PluginInstaller::DownloadStarted( 150 void PluginInstaller::DownloadStarted(content::DownloadItem* item,
156 scoped_refptr<content::DownloadManager> dlm, 151 net::Error error) {
157 content::DownloadItem* item,
158 net::Error error) {
159 if (!item) { 152 if (!item) {
160 DCHECK_NE(net::OK, error); 153 DCHECK_NE(net::OK, error);
161 std::string msg = 154 std::string msg =
162 base::StringPrintf("Error %d: %s", error, net::ErrorToString(error)); 155 base::StringPrintf("Error %d: %s", error, net::ErrorToString(error));
163 DownloadError(msg); 156 DownloadError(msg);
164 return; 157 return;
165 } 158 }
166 DCHECK_EQ(net::OK, error); 159 DCHECK_EQ(net::OK, error);
167 item->SetOpenWhenComplete(true); 160 item->SetOpenWhenComplete(true);
168 item->AddObserver(this); 161 item->AddObserver(this);
(...skipping 14 matching lines...) Expand all
183 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); 176 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_);
184 state_ = INSTALLER_STATE_IDLE; 177 state_ = INSTALLER_STATE_IDLE;
185 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadError(msg)); 178 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadError(msg));
186 } 179 }
187 180
188 void PluginInstaller::DownloadCancelled() { 181 void PluginInstaller::DownloadCancelled() {
189 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); 182 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_);
190 state_ = INSTALLER_STATE_IDLE; 183 state_ = INSTALLER_STATE_IDLE;
191 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled()); 184 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled());
192 } 185 }
OLDNEW
« no previous file with comments | « chrome/browser/plugins/plugin_installer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698