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

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

Issue 10912183: Remove DownloadManager::GetDownloadItem in favor of GetDownload() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 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
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/file_util.h" 9 #include "base/file_util.h"
10 #include "base/process.h" 10 #include "base/process.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 void PluginInstaller::DownloadStarted( 223 void PluginInstaller::DownloadStarted(
224 scoped_refptr<content::DownloadManager> dlm, 224 scoped_refptr<content::DownloadManager> dlm,
225 content::DownloadId download_id, 225 content::DownloadId download_id,
226 net::Error error) { 226 net::Error error) {
227 if (error != net::OK) { 227 if (error != net::OK) {
228 std::string msg = 228 std::string msg =
229 base::StringPrintf("Error %d: %s", error, net::ErrorToString(error)); 229 base::StringPrintf("Error %d: %s", error, net::ErrorToString(error));
230 DownloadError(msg); 230 DownloadError(msg);
231 return; 231 return;
232 } 232 }
233 DownloadItem* download_item = 233 DownloadItem* download_item = dlm->GetDownload(download_id.local());
234 dlm->GetActiveDownloadItem(download_id.local()); 234 // TODO(benjhayden): DCHECK(item && item->IsInProgress()) after figuring out
235 // why DownloadStarted may get net:OK but an invalid id.
236 if (!download_item) {
237 DownloadError("Download not found");
238 return;
239 }
235 download_item->SetOpenWhenComplete(true); 240 download_item->SetOpenWhenComplete(true);
236 download_item->AddObserver(this); 241 download_item->AddObserver(this);
237 } 242 }
238 243
239 void PluginInstaller::OpenDownloadURL(content::WebContents* web_contents) { 244 void PluginInstaller::OpenDownloadURL(content::WebContents* web_contents) {
240 DCHECK_EQ(INSTALLER_STATE_IDLE, state_); 245 DCHECK_EQ(INSTALLER_STATE_IDLE, state_);
241 DCHECK(url_for_display_); 246 DCHECK(url_for_display_);
242 web_contents->OpenURL(content::OpenURLParams( 247 web_contents->OpenURL(content::OpenURLParams(
243 plugin_url_, 248 plugin_url_,
244 content::Referrer(web_contents->GetURL(), 249 content::Referrer(web_contents->GetURL(),
(...skipping 10 matching lines...) Expand all
255 260
256 void PluginInstaller::DownloadCancelled() { 261 void PluginInstaller::DownloadCancelled() {
257 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); 262 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_);
258 state_ = INSTALLER_STATE_IDLE; 263 state_ = INSTALLER_STATE_IDLE;
259 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled()); 264 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled());
260 } 265 }
261 266
262 bool PluginInstaller::MatchesPlugin(const webkit::WebPluginInfo& plugin) { 267 bool PluginInstaller::MatchesPlugin(const webkit::WebPluginInfo& plugin) {
263 return plugin.name.find(group_name_matcher_) != string16::npos; 268 return plugin.name.find(group_name_matcher_) != string16::npos;
264 } 269 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/webstore_installer.cc ('k') | chrome/browser/ui/webui/downloads_dom_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698