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

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

Issue 331743004: Always enable enhanced bookmarks external component extensions for incognito mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: set incognito pref on install Created 6 years, 6 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
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | no next file » | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/extension_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <set> 9 #include <set>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/sha1.h"
13 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "base/threading/sequenced_worker_pool.h" 17 #include "base/threading/sequenced_worker_pool.h"
17 #include "base/threading/thread_restrictions.h" 18 #include "base/threading/thread_restrictions.h"
18 #include "base/time/time.h" 19 #include "base/time/time.h"
19 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/chrome_notification_types.h" 21 #include "chrome/browser/chrome_notification_types.h"
21 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 22 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
22 #include "chrome/browser/extensions/component_loader.h" 23 #include "chrome/browser/extensions/component_loader.h"
(...skipping 1960 matching lines...) Expand 10 before | Expand all | Expand 10 after
1983 1984
1984 bool unacknowledged_external = IsUnacknowledgedExternalExtension(extension); 1985 bool unacknowledged_external = IsUnacknowledgedExternalExtension(extension);
1985 1986
1986 // Unpacked extensions default to allowing file access, but if that has been 1987 // Unpacked extensions default to allowing file access, but if that has been
1987 // overridden, don't reset the value. 1988 // overridden, don't reset the value.
1988 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) && 1989 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) &&
1989 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) { 1990 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) {
1990 extension_prefs_->SetAllowFileAccess(extension->id(), true); 1991 extension_prefs_->SetAllowFileAccess(extension->id(), true);
1991 } 1992 }
1992 1993
1994 if (ShouldEnableForIncognito(extension))
1995 extension_prefs_->SetIsIncognitoEnabled(extension->id(), true);
1996
1993 AddExtension(extension); 1997 AddExtension(extension);
1994 1998
1995 // If this is a new external extension that was disabled, alert the user 1999 // If this is a new external extension that was disabled, alert the user
1996 // so he can reenable it. We do this last so that it has already been 2000 // so he can reenable it. We do this last so that it has already been
1997 // added to our list of extensions. 2001 // added to our list of extensions.
1998 if (unacknowledged_external && !is_update) { 2002 if (unacknowledged_external && !is_update) {
1999 UpdateExternalExtensionAlert(); 2003 UpdateExternalExtensionAlert();
2000 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent", 2004 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent",
2001 EXTERNAL_EXTENSION_INSTALLED, 2005 EXTERNAL_EXTENSION_INSTALLED,
2002 EXTERNAL_EXTENSION_BUCKET_BOUNDARY); 2006 EXTERNAL_EXTENSION_BUCKET_BOUNDARY);
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
2529 2533
2530 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { 2534 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) {
2531 update_observers_.AddObserver(observer); 2535 update_observers_.AddObserver(observer);
2532 } 2536 }
2533 2537
2534 void ExtensionService::RemoveUpdateObserver( 2538 void ExtensionService::RemoveUpdateObserver(
2535 extensions::UpdateObserver* observer) { 2539 extensions::UpdateObserver* observer) {
2536 update_observers_.RemoveObserver(observer); 2540 update_observers_.RemoveObserver(observer);
2537 } 2541 }
2538 2542
2543 bool ExtensionService::ShouldEnableForIncognito(
2544 const extensions::Extension* extension) {
2545 // NB: Component extensions are already always enabled via logic in
2546 // extensions::util::IsIncognitoEnabled.
2547 if (extension->location() != Manifest::EXTERNAL_COMPONENT)
2548 return false;
2549
2550 // External component extensions with hashes in this array are always enabled
2551 // in incognito mode.
2552 static const char* kIncognitoEnabledExternalComponentExtensionHash[] = {
2553 "D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2", // http://crbug.com/312900
2554 "D57DE394F36DC1C3220E7604C575D29C51A6C495", // http://crbug.com/319444
2555 "3F65507A3B39259B38C8173C6FFA3D12DF64CCE9" // http://crbug.com/371562
not at google - send to devlin 2014/06/18 00:42:02 This code would be better contained in here, is wh
Mike Wittman 2014/06/18 03:17:50 Moved the hashes and logic to extension_utils.{cc,
2556 };
2557
2558 std::string hash = base::SHA1HashString(extension->id());
2559 hash = base::HexEncode(hash.c_str(), hash.length());
2560 for (size_t i = 0;
2561 i < arraysize(kIncognitoEnabledExternalComponentExtensionHash); i++) {
2562 if (hash == kIncognitoEnabledExternalComponentExtensionHash[i])
2563 return true;
2564 }
2565
2566 return true;
2567 }
2568
2539 // Used only by test code. 2569 // Used only by test code.
2540 void ExtensionService::UnloadAllExtensionsInternal() { 2570 void ExtensionService::UnloadAllExtensionsInternal() {
2541 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); 2571 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions();
2542 2572
2543 registry_->ClearAll(); 2573 registry_->ClearAll();
2544 system_->runtime_data()->ClearAll(); 2574 system_->runtime_data()->ClearAll();
2545 2575
2546 // TODO(erikkay) should there be a notification for this? We can't use 2576 // TODO(erikkay) should there be a notification for this? We can't use
2547 // EXTENSION_UNLOADED since that implies that the extension has been disabled 2577 // EXTENSION_UNLOADED since that implies that the extension has been disabled
2548 // or uninstalled. 2578 // or uninstalled.
2549 } 2579 }
2550 2580
2551 void ExtensionService::OnProfileDestructionStarted() { 2581 void ExtensionService::OnProfileDestructionStarted() {
2552 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); 2582 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2553 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); 2583 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2554 it != ids_to_unload.end(); 2584 it != ids_to_unload.end();
2555 ++it) { 2585 ++it) {
2556 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); 2586 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2557 } 2587 }
2558 } 2588 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698