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

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

Issue 11032052: Merge 160403 - Fix crash when a download is requested for an outdated plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1287/src/
Patch Set: Created 8 years, 2 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
« no previous file with comments | « chrome/browser/plugins/plugin_installer.h ('k') | chrome/browser/plugins/plugin_observer.cc » ('j') | 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/file_util.h" 9 #include "base/file_util.h"
10 #include "base/process.h" 10 #include "base/process.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 void PluginInstaller::AddWeakObserver(WeakPluginInstallerObserver* observer) { 123 void PluginInstaller::AddWeakObserver(WeakPluginInstallerObserver* observer) {
124 weak_observers_.AddObserver(observer); 124 weak_observers_.AddObserver(observer);
125 } 125 }
126 126
127 void PluginInstaller::RemoveWeakObserver( 127 void PluginInstaller::RemoveWeakObserver(
128 WeakPluginInstallerObserver* observer) { 128 WeakPluginInstallerObserver* observer) {
129 weak_observers_.RemoveObserver(observer); 129 weak_observers_.RemoveObserver(observer);
130 } 130 }
131 131
132 void PluginInstaller::StartInstalling(bool url_for_display, 132 void PluginInstaller::StartInstalling(const GURL& plugin_url,
133 const GURL& plugin_url,
134 TabContents* tab_contents) { 133 TabContents* tab_contents) {
135 DCHECK_EQ(INSTALLER_STATE_IDLE, state_); 134 DCHECK_EQ(INSTALLER_STATE_IDLE, state_);
136 DCHECK(url_for_display);
137 state_ = INSTALLER_STATE_DOWNLOADING; 135 state_ = INSTALLER_STATE_DOWNLOADING;
138 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadStarted()); 136 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadStarted());
139 content::WebContents* web_contents = tab_contents->web_contents(); 137 content::WebContents* web_contents = tab_contents->web_contents();
140 DownloadManager* download_manager = 138 DownloadManager* download_manager =
141 BrowserContext::GetDownloadManager(tab_contents->profile()); 139 BrowserContext::GetDownloadManager(tab_contents->profile());
142 download_util::RecordDownloadSource( 140 download_util::RecordDownloadSource(
143 download_util::INITIATED_BY_PLUGIN_INSTALLER); 141 download_util::INITIATED_BY_PLUGIN_INSTALLER);
144 BrowserThread::PostTask( 142 BrowserThread::PostTask(
145 BrowserThread::IO, FROM_HERE, 143 BrowserThread::IO, FROM_HERE,
146 base::Bind(&BeginDownload, 144 base::Bind(&BeginDownload,
(...skipping 20 matching lines...) Expand all
167 // TODO(benjhayden): DCHECK(item && item->IsInProgress()) after figuring out 165 // TODO(benjhayden): DCHECK(item && item->IsInProgress()) after figuring out
168 // why DownloadStarted may get net:OK but an invalid id. 166 // why DownloadStarted may get net:OK but an invalid id.
169 if (!download_item) { 167 if (!download_item) {
170 DownloadError("Download not found"); 168 DownloadError("Download not found");
171 return; 169 return;
172 } 170 }
173 download_item->SetOpenWhenComplete(true); 171 download_item->SetOpenWhenComplete(true);
174 download_item->AddObserver(this); 172 download_item->AddObserver(this);
175 } 173 }
176 174
177 void PluginInstaller::OpenDownloadURL(bool url_for_display, 175 void PluginInstaller::OpenDownloadURL(const GURL& plugin_url,
178 const GURL& plugin_url,
179 content::WebContents* web_contents) { 176 content::WebContents* web_contents) {
180 DCHECK_EQ(INSTALLER_STATE_IDLE, state_); 177 DCHECK_EQ(INSTALLER_STATE_IDLE, state_);
181 DCHECK(url_for_display);
182 web_contents->OpenURL(content::OpenURLParams( 178 web_contents->OpenURL(content::OpenURLParams(
183 plugin_url, 179 plugin_url,
184 content::Referrer(web_contents->GetURL(), 180 content::Referrer(web_contents->GetURL(),
185 WebKit::WebReferrerPolicyDefault), 181 WebKit::WebReferrerPolicyDefault),
186 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_TYPED, false)); 182 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_TYPED, false));
187 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadFinished()); 183 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadFinished());
188 } 184 }
189 185
190 void PluginInstaller::DownloadError(const std::string& msg) { 186 void PluginInstaller::DownloadError(const std::string& msg) {
191 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); 187 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_);
192 state_ = INSTALLER_STATE_IDLE; 188 state_ = INSTALLER_STATE_IDLE;
193 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadError(msg)); 189 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadError(msg));
194 } 190 }
195 191
196 void PluginInstaller::DownloadCancelled() { 192 void PluginInstaller::DownloadCancelled() {
197 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); 193 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_);
198 state_ = INSTALLER_STATE_IDLE; 194 state_ = INSTALLER_STATE_IDLE;
199 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled()); 195 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled());
200 } 196 }
OLDNEW
« no previous file with comments | « chrome/browser/plugins/plugin_installer.h ('k') | chrome/browser/plugins/plugin_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698