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

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

Issue 9222013: Prevent unnecessary prompts when unpacked extensions use chrome.permissions.request. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/unpacked_installer.h" 5 #include "chrome/browser/extensions/unpacked_installer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "chrome/browser/extensions/extension_install_ui.h" 10 #include "chrome/browser/extensions/extension_install_ui.h"
11 #include "chrome/browser/extensions/extension_prefs.h" 11 #include "chrome/browser/extensions/extension_prefs.h"
12 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/permissions_updater.h"
13 #include "chrome/common/extensions/extension.h" 14 #include "chrome/common/extensions/extension.h"
14 #include "chrome/common/extensions/extension_file_util.h" 15 #include "chrome/common/extensions/extension_file_util.h"
15 #include "chrome/common/string_ordinal.h" 16 #include "chrome/common/string_ordinal.h"
16 17
17 using content::BrowserThread; 18 using content::BrowserThread;
18 19
19 namespace { 20 namespace {
20 21
21 // Manages an ExtensionInstallUI for a particular extension. 22 // Manages an ExtensionInstallUI for a particular extension.
22 class SimpleExtensionLoadPrompt : public ExtensionInstallUI::Delegate { 23 class SimpleExtensionLoadPrompt : public ExtensionInstallUI::Delegate {
(...skipping 25 matching lines...) Expand all
48 } 49 }
49 50
50 SimpleExtensionLoadPrompt::~SimpleExtensionLoadPrompt() { 51 SimpleExtensionLoadPrompt::~SimpleExtensionLoadPrompt() {
51 } 52 }
52 53
53 void SimpleExtensionLoadPrompt::ShowPrompt() { 54 void SimpleExtensionLoadPrompt::ShowPrompt() {
54 install_ui_->ConfirmInstall(this, extension_); 55 install_ui_->ConfirmInstall(this, extension_);
55 } 56 }
56 57
57 void SimpleExtensionLoadPrompt::InstallUIProceed() { 58 void SimpleExtensionLoadPrompt::InstallUIProceed() {
58 if (service_weak_.get()) 59 if (service_weak_.get()) {
60 extensions::PermissionsUpdater perms_updater(service_weak_->profile());
61 perms_updater.GrantActivePermissions(extension_);
59 service_weak_->OnExtensionInstalled( 62 service_weak_->OnExtensionInstalled(
60 extension_, false, StringOrdinal()); // Not from web store. 63 extension_, false, StringOrdinal()); // Not from web store.
64 }
61 delete this; 65 delete this;
62 } 66 }
63 67
64 void SimpleExtensionLoadPrompt::InstallUIAbort(bool user_initiated) { 68 void SimpleExtensionLoadPrompt::InstallUIAbort(bool user_initiated) {
65 delete this; 69 delete this;
66 } 70 }
67 71
68 } // namespace 72 } // namespace
69 73
70 namespace extensions { 74 namespace extensions {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 196
193 void UnpackedInstaller::OnLoaded( 197 void UnpackedInstaller::OnLoaded(
194 const scoped_refptr<const Extension>& extension) { 198 const scoped_refptr<const Extension>& extension) {
195 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 199 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
196 if (!service_weak_.get()) 200 if (!service_weak_.get())
197 return; 201 return;
198 const ExtensionSet* disabled_extensions = 202 const ExtensionSet* disabled_extensions =
199 service_weak_->disabled_extensions(); 203 service_weak_->disabled_extensions();
200 if (service_weak_->show_extensions_prompts() && 204 if (service_weak_->show_extensions_prompts() &&
201 prompt_for_plugins_ && 205 prompt_for_plugins_ &&
202 !extension->plugins().empty() && 206 !extension->CanSilentlyIncreasePermissionsDuringInstall() &&
203 disabled_extensions->Contains(extension->id())) { 207 disabled_extensions->Contains(extension->id())) {
204 SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt( 208 SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt(
205 service_weak_->profile(), 209 service_weak_->profile(),
206 service_weak_, 210 service_weak_,
207 extension); 211 extension);
208 prompt->ShowPrompt(); 212 prompt->ShowPrompt();
209 return; // continues in SimpleExtensionLoadPrompt::InstallUI* 213 return; // continues in SimpleExtensionLoadPrompt::InstallUI*
210 } 214 }
215
216 PermissionsUpdater perms_updater(service_weak_->profile());
217 perms_updater.GrantActivePermissions(extension);
211 service_weak_->OnExtensionInstalled(extension, 218 service_weak_->OnExtensionInstalled(extension,
212 false, // Not from web store. 219 false, // Not from web store.
213 StringOrdinal()); 220 StringOrdinal());
214 } 221 }
215 222
216 } // namespace extensions 223 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698