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

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

Issue 10452009: Improve the UI for disabling off-store extension install. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments, fixed tests Created 8 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 | 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/extensions/crx_installer.h" 5 #include "chrome/browser/extensions/crx_installer.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 18 matching lines...) Expand all
29 #include "chrome/browser/extensions/permissions_updater.h" 29 #include "chrome/browser/extensions/permissions_updater.h"
30 #include "chrome/browser/extensions/webstore_installer.h" 30 #include "chrome/browser/extensions/webstore_installer.h"
31 #include "chrome/browser/profiles/profile.h" 31 #include "chrome/browser/profiles/profile.h"
32 #include "chrome/browser/shell_integration.h" 32 #include "chrome/browser/shell_integration.h"
33 #include "chrome/browser/web_applications/web_app.h" 33 #include "chrome/browser/web_applications/web_app.h"
34 #include "chrome/common/chrome_notification_types.h" 34 #include "chrome/common/chrome_notification_types.h"
35 #include "chrome/common/chrome_paths.h" 35 #include "chrome/common/chrome_paths.h"
36 #include "chrome/common/extensions/extension_constants.h" 36 #include "chrome/common/extensions/extension_constants.h"
37 #include "chrome/common/extensions/extension_file_util.h" 37 #include "chrome/common/extensions/extension_file_util.h"
38 #include "chrome/common/extensions/extension_icon_set.h" 38 #include "chrome/common/extensions/extension_icon_set.h"
39 #include "chrome/common/extensions/extension_switch_utils.h"
39 #include "content/public/browser/browser_thread.h" 40 #include "content/public/browser/browser_thread.h"
40 #include "content/public/browser/notification_service.h" 41 #include "content/public/browser/notification_service.h"
41 #include "content/public/browser/resource_dispatcher_host.h" 42 #include "content/public/browser/resource_dispatcher_host.h"
42 #include "content/public/browser/user_metrics.h" 43 #include "content/public/browser/user_metrics.h"
43 #include "grit/chromium_strings.h" 44 #include "grit/chromium_strings.h"
44 #include "grit/generated_resources.h" 45 #include "grit/generated_resources.h"
45 #include "grit/theme_resources.h" 46 #include "grit/theme_resources.h"
46 #include "third_party/skia/include/core/SkBitmap.h" 47 #include "third_party/skia/include/core/SkBitmap.h"
47 #include "ui/base/l10n/l10n_util.h" 48 #include "ui/base/l10n/l10n_util.h"
48 #include "ui/base/resource/resource_bundle.h" 49 #include "ui/base/resource/resource_bundle.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // TODO(aa): conversion data gets lost here :( 183 // TODO(aa): conversion data gets lost here :(
183 184
184 OnUnpackSuccess(extension->path(), extension->path(), NULL, extension); 185 OnUnpackSuccess(extension->path(), extension->path(), NULL, extension);
185 } 186 }
186 187
187 bool CrxInstaller::AllowInstall(const Extension* extension, 188 bool CrxInstaller::AllowInstall(const Extension* extension,
188 string16* error) { 189 string16* error) {
189 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 190 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
190 DCHECK(error); 191 DCHECK(error);
191 192
193 if (!extension->is_theme() &&
194 !extensions::switch_utils::IsOffStoreInstallEnabled() &&
195 !is_gallery_install()) {
196 *error = l10n_util::GetStringUTF16(
197 IDS_EXTENSION_INSTALL_DISALLOWED_ON_SITE);
198 return false;
199 }
200
192 // Make sure the expected ID matches if one was supplied or if we want to 201 // Make sure the expected ID matches if one was supplied or if we want to
193 // bypass the prompt. 202 // bypass the prompt.
194 if ((approved_ || !expected_id_.empty()) && 203 if ((approved_ || !expected_id_.empty()) &&
195 expected_id_ != extension->id()) { 204 expected_id_ != extension->id()) {
196 *error = l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALL_UNEXPECTED_ID, 205 *error = l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALL_UNEXPECTED_ID,
197 ASCIIToUTF16(expected_id_), 206 ASCIIToUTF16(expected_id_),
198 ASCIIToUTF16(extension->id())); 207 ASCIIToUTF16(extension->id()));
199 return false; 208 return false;
200 } 209 }
201 210
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 // Some users (such as the download shelf) need to know when a 560 // Some users (such as the download shelf) need to know when a
552 // CRXInstaller is done. Listening for the EXTENSION_* events 561 // CRXInstaller is done. Listening for the EXTENSION_* events
553 // is problematic because they don't know anything about the 562 // is problematic because they don't know anything about the
554 // extension before it is unpacked, so they cannot filter based 563 // extension before it is unpacked, so they cannot filter based
555 // on the extension. 564 // on the extension.
556 content::NotificationService::current()->Notify( 565 content::NotificationService::current()->Notify(
557 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 566 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
558 content::Source<CrxInstaller>(this), 567 content::Source<CrxInstaller>(this),
559 content::Details<const Extension>(extension)); 568 content::Details<const Extension>(extension));
560 } 569 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698