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

Side by Side Diff: chrome/browser/ui/bookmarks/enhanced_bookmark_key_service.cc

Issue 850853002: Extensions: Consolidate extension id hashing / searching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ui/bookmarks/enhanced_bookmark_key_service.h" 5 #include "chrome/browser/ui/bookmarks/enhanced_bookmark_key_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/sha1.h"
10 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
11 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
12 #include "chrome/browser/extensions/api/commands/command_service.h" 11 #include "chrome/browser/extensions/api/commands/command_service.h"
13 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/accelerator_utils.h" 13 #include "chrome/browser/ui/accelerator_utils.h"
15 #include "chrome/common/extensions/command.h" 14 #include "chrome/common/extensions/command.h"
15 #include "components/crx_file/id_util.h"
16 #include "extensions/browser/extension_registry.h" 16 #include "extensions/browser/extension_registry.h"
17 #include "extensions/browser/notification_types.h" 17 #include "extensions/browser/notification_types.h"
18 #include "extensions/common/manifest_constants.h" 18 #include "extensions/common/manifest_constants.h"
19 19
20 EnhancedBookmarkKeyService::EnhancedBookmarkKeyService( 20 EnhancedBookmarkKeyService::EnhancedBookmarkKeyService(
21 content::BrowserContext* context) : browser_context_(context) { 21 content::BrowserContext* context) : browser_context_(context) {
22 Profile* profile = Profile::FromBrowserContext(browser_context_); 22 Profile* profile = Profile::FromBrowserContext(browser_context_);
23 registrar_.Add(this, 23 registrar_.Add(this,
24 extensions::NOTIFICATION_EXTENSION_COMMAND_REMOVED, 24 extensions::NOTIFICATION_EXTENSION_COMMAND_REMOVED,
25 content::Source<Profile>(profile->GetOriginalProfile())); 25 content::Source<Profile>(profile->GetOriginalProfile()));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 68
69 const extensions::Extension* 69 const extensions::Extension*
70 EnhancedBookmarkKeyService::GetEnhancedBookmarkExtension() const { 70 EnhancedBookmarkKeyService::GetEnhancedBookmarkExtension() const {
71 const extensions::ExtensionSet& extensions = 71 const extensions::ExtensionSet& extensions =
72 extensions::ExtensionRegistry::Get(browser_context_) 72 extensions::ExtensionRegistry::Get(browser_context_)
73 ->enabled_extensions(); 73 ->enabled_extensions();
74 extensions::ExtensionSet::const_iterator loc = 74 extensions::ExtensionSet::const_iterator loc =
75 std::find_if(extensions.begin(), extensions.end(), 75 std::find_if(extensions.begin(), extensions.end(),
76 [](scoped_refptr<const extensions::Extension> extension) { 76 [](scoped_refptr<const extensions::Extension> extension) {
77 static const char enhanced_extension_hash[] = 77 static const char enhanced_ext_hash[] =
78 // http://crbug.com/312900 78 // http://crbug.com/312900
79 "D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2"; 79 "D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2";
80 std::string hash = base::SHA1HashString(extension->id()); 80 std::string hashed_id =
81 return base::HexEncode(hash.c_str(), hash.length()) == 81 crx_file::id_util::HashedIdInHex(extension->id());
82 enhanced_extension_hash; 82 return hashed_id == enhanced_ext_hash;
83 }); 83 });
84 return loc != extensions.end() ? loc->get() : nullptr; 84 return loc != extensions.end() ? loc->get() : nullptr;
85 } 85 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/extension_backed_data_type_controller.cc ('k') | components/crx_file/id_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698