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

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

Issue 14593012: BrowserContext should simply own DownloadManager (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
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"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 weak_observers_.RemoveObserver(observer); 129 weak_observers_.RemoveObserver(observer);
130 } 130 }
131 131
132 void PluginInstaller::StartInstalling(const GURL& plugin_url, 132 void PluginInstaller::StartInstalling(const GURL& plugin_url,
133 content::WebContents* web_contents) { 133 content::WebContents* web_contents) {
134 DCHECK_EQ(INSTALLER_STATE_IDLE, state_); 134 DCHECK_EQ(INSTALLER_STATE_IDLE, state_);
135 state_ = INSTALLER_STATE_DOWNLOADING; 135 state_ = INSTALLER_STATE_DOWNLOADING;
136 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadStarted()); 136 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadStarted());
137 Profile* profile = 137 Profile* profile =
138 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 138 Profile::FromBrowserContext(web_contents->GetBrowserContext());
139 DownloadManager* download_manager =
140 BrowserContext::GetDownloadManager(profile);
141 download_util::RecordDownloadSource( 139 download_util::RecordDownloadSource(
142 download_util::INITIATED_BY_PLUGIN_INSTALLER); 140 download_util::INITIATED_BY_PLUGIN_INSTALLER);
143 BrowserThread::PostTask( 141 BrowserThread::PostTask(
144 BrowserThread::IO, FROM_HERE, 142 BrowserThread::IO, FROM_HERE,
145 base::Bind(&BeginDownload, 143 base::Bind(&BeginDownload,
146 plugin_url, 144 plugin_url,
147 profile->GetResourceContext(), 145 profile->GetResourceContext(),
148 web_contents->GetRenderProcessHost()->GetID(), 146 web_contents->GetRenderProcessHost()->GetID(),
149 web_contents->GetRenderViewHost()->GetRoutingID(), 147 web_contents->GetRenderViewHost()->GetRoutingID(),
150 base::Bind(&PluginInstaller::DownloadStarted, 148 base::Bind(&PluginInstaller::DownloadStarted,
151 base::Unretained(this), 149 base::Unretained(this))));
152 make_scoped_refptr(download_manager))));
153 } 150 }
154 151
155 void PluginInstaller::DownloadStarted( 152 void PluginInstaller::DownloadStarted(
156 scoped_refptr<content::DownloadManager> dlm,
157 content::DownloadItem* item, 153 content::DownloadItem* item,
158 net::Error error) { 154 net::Error error) {
159 if (!item) { 155 if (!item) {
160 DCHECK_NE(net::OK, error); 156 DCHECK_NE(net::OK, error);
161 std::string msg = 157 std::string msg =
162 base::StringPrintf("Error %d: %s", error, net::ErrorToString(error)); 158 base::StringPrintf("Error %d: %s", error, net::ErrorToString(error));
163 DownloadError(msg); 159 DownloadError(msg);
164 return; 160 return;
165 } 161 }
166 DCHECK_EQ(net::OK, error); 162 DCHECK_EQ(net::OK, error);
(...skipping 16 matching lines...) Expand all
183 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); 179 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_);
184 state_ = INSTALLER_STATE_IDLE; 180 state_ = INSTALLER_STATE_IDLE;
185 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadError(msg)); 181 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadError(msg));
186 } 182 }
187 183
188 void PluginInstaller::DownloadCancelled() { 184 void PluginInstaller::DownloadCancelled() {
189 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); 185 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_);
190 state_ = INSTALLER_STATE_IDLE; 186 state_ = INSTALLER_STATE_IDLE;
191 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled()); 187 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled());
192 } 188 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698