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

Side by Side Diff: chrome/browser/extensions/bundle_installer.cc

Issue 138803012: Fix use-after-free in WebstoreInstaller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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/extensions/bundle_installer.h" 5 #include "chrome/browser/extensions/bundle_installer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/i18n/rtl.h" 12 #include "base/i18n/rtl.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/extensions/crx_installer.h" 15 #include "chrome/browser/extensions/crx_installer.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_finder.h" 18 #include "chrome/browser/ui/browser_finder.h"
19 #include "chrome/browser/ui/browser_list.h" 19 #include "chrome/browser/ui/browser_list.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" 20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
21 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
22 #include "content/public/browser/navigation_controller.h"
23 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
24 #include "extensions/common/extension.h" 23 #include "extensions/common/extension.h"
25 #include "extensions/common/permissions/permission_set.h" 24 #include "extensions/common/permissions/permission_set.h"
26 #include "extensions/common/permissions/permissions_data.h" 25 #include "extensions/common/permissions/permissions_data.h"
27 #include "grit/generated_resources.h" 26 #include "grit/generated_resources.h"
28 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
29 28
30 using content::NavigationController;
31
32 namespace extensions { 29 namespace extensions {
33 30
34 namespace { 31 namespace {
35 32
36 enum AutoApproveForTest { 33 enum AutoApproveForTest {
37 DO_NOT_SKIP = 0, 34 DO_NOT_SKIP = 0,
38 PROCEED, 35 PROCEED,
39 ABORT 36 ABORT
40 }; 37 };
41 38
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 126 }
130 127
131 void BundleInstaller::PromptForApproval(Delegate* delegate) { 128 void BundleInstaller::PromptForApproval(Delegate* delegate) {
132 delegate_ = delegate; 129 delegate_ = delegate;
133 130
134 AddRef(); // Balanced in ReportApproved() and ReportCanceled(). 131 AddRef(); // Balanced in ReportApproved() and ReportCanceled().
135 132
136 ParseManifests(); 133 ParseManifests();
137 } 134 }
138 135
139 void BundleInstaller::CompleteInstall(NavigationController* controller, 136 void BundleInstaller::CompleteInstall(content::WebContents* web_contents,
140 Delegate* delegate) { 137 Delegate* delegate) {
141 CHECK(approved_); 138 CHECK(approved_);
142 139
143 delegate_ = delegate; 140 delegate_ = delegate;
144 141
145 AddRef(); // Balanced in ReportComplete(); 142 AddRef(); // Balanced in ReportComplete();
146 143
147 if (GetItemsWithState(Item::STATE_PENDING).empty()) { 144 if (GetItemsWithState(Item::STATE_PENDING).empty()) {
148 ReportComplete(); 145 ReportComplete();
149 return; 146 return;
(...skipping 11 matching lines...) Expand all
161 profile_, 158 profile_,
162 i->first, 159 i->first,
163 scoped_ptr<base::DictionaryValue>( 160 scoped_ptr<base::DictionaryValue>(
164 parsed_manifests_[i->first]->DeepCopy()), true)); 161 parsed_manifests_[i->first]->DeepCopy()), true));
165 approval->use_app_installed_bubble = false; 162 approval->use_app_installed_bubble = false;
166 approval->skip_post_install_ui = true; 163 approval->skip_post_install_ui = true;
167 164
168 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( 165 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller(
169 profile_, 166 profile_,
170 this, 167 this,
171 controller, 168 web_contents,
172 i->first, 169 i->first,
173 approval.Pass(), 170 approval.Pass(),
174 WebstoreInstaller::INSTALL_SOURCE_OTHER); 171 WebstoreInstaller::INSTALL_SOURCE_OTHER);
175 installer->Start(); 172 installer->Start();
176 } 173 }
177 } 174 }
178 175
179 base::string16 BundleInstaller::GetHeadingTextFor(Item::State state) const { 176 base::string16 BundleInstaller::GetHeadingTextFor(Item::State state) const {
180 // For STATE_FAILED, we can't tell if the items were apps or extensions 177 // For STATE_FAILED, we can't tell if the items were apps or extensions
181 // so we always show the same message. 178 // so we always show the same message.
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 void BundleInstaller::OnBrowserAdded(Browser* browser) {} 345 void BundleInstaller::OnBrowserAdded(Browser* browser) {}
349 346
350 void BundleInstaller::OnBrowserRemoved(Browser* browser) { 347 void BundleInstaller::OnBrowserRemoved(Browser* browser) {
351 if (browser_ == browser) 348 if (browser_ == browser)
352 browser_ = NULL; 349 browser_ = NULL;
353 } 350 }
354 351
355 void BundleInstaller::OnBrowserSetLastActive(Browser* browser) {} 352 void BundleInstaller::OnBrowserSetLastActive(Browser* browser) {}
356 353
357 } // namespace extensions 354 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/bundle_installer.h ('k') | chrome/browser/extensions/webstore_installer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698