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

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

Issue 2738553002: [Extensions] Log instances of invalid extensions being added (Closed)
Patch Set: . Created 3 years, 9 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) 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <utility> 13 #include <utility>
14 14
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/debug/alias.h"
17 #include "base/debug/dump_without_crashing.h"
16 #include "base/location.h" 18 #include "base/location.h"
17 #include "base/metrics/histogram_macros.h" 19 #include "base/metrics/histogram_macros.h"
18 #include "base/single_thread_task_runner.h" 20 #include "base/single_thread_task_runner.h"
19 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/string_tokenizer.h" 22 #include "base/strings/string_tokenizer.h"
21 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
22 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
23 #include "base/threading/sequenced_worker_pool.h" 25 #include "base/threading/sequenced_worker_pool.h"
24 #include "base/threading/thread_restrictions.h" 26 #include "base/threading/thread_restrictions.h"
25 #include "base/threading/thread_task_runner_handle.h" 27 #include "base/threading/thread_task_runner_handle.h"
(...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 to_enable.push_back(extension); 1476 to_enable.push_back(extension);
1475 } 1477 }
1476 for (const auto& extension : to_enable) { 1478 for (const auto& extension : to_enable) {
1477 EnableExtension(extension->id()); 1479 EnableExtension(extension->id());
1478 } 1480 }
1479 1481
1480 OnBlacklistUpdated(); 1482 OnBlacklistUpdated();
1481 } 1483 }
1482 1484
1483 void ExtensionService::AddExtension(const Extension* extension) { 1485 void ExtensionService::AddExtension(const Extension* extension) {
1486 if (!Manifest::IsValidLocation(extension->location())) {
1487 // TODO(devlin): We should *never* add an extension with an invalid
1488 // location, but some bugs (e.g. crbug.com/692069) seem to indicate we do.
1489 // Track down the cases when this can happen, and remove this
1490 // DumpWithoutCrashing() (possibly replacing it with a CHECK).
1491 NOTREACHED();
1492 char extension_id_copy[32];
lazyboy 2017/03/08 19:01:01 I think you need 33 here, b/c of strlcpy.
Devlin 2017/03/09 01:23:38 done.
1493 base::strlcpy(extension_id_copy, extension->id().c_str(),
1494 arraysize(extension_id_copy));
1495 Manifest::Location location = extension->location();
1496 int creation_flags = extension->creation_flags();
1497 Manifest::Type type = extension->manifest()->type();
1498 base::debug::Alias(extension_id_copy);
1499 base::debug::Alias(&location);
1500 base::debug::Alias(&creation_flags);
1501 base::debug::Alias(&type);
1502 base::debug::DumpWithoutCrashing();
1503 return;
1504 }
1505
1484 // TODO(jstritar): We may be able to get rid of this branch by overriding the 1506 // TODO(jstritar): We may be able to get rid of this branch by overriding the
1485 // default extension state to DISABLED when the --disable-extensions flag 1507 // default extension state to DISABLED when the --disable-extensions flag
1486 // is set (http://crbug.com/29067). 1508 // is set (http://crbug.com/29067).
1487 if (!extensions_enabled() && !extension->is_theme() && 1509 if (!extensions_enabled() && !extension->is_theme() &&
1488 extension->location() != Manifest::COMPONENT && 1510 extension->location() != Manifest::COMPONENT &&
1489 !Manifest::IsExternalLocation(extension->location()) && 1511 !Manifest::IsExternalLocation(extension->location()) &&
1490 disable_flag_exempted_extensions_.count(extension->id()) == 0) { 1512 disable_flag_exempted_extensions_.count(extension->id()) == 0) {
1491 return; 1513 return;
1492 } 1514 }
1493 1515
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
2520 } 2542 }
2521 2543
2522 void ExtensionService::OnProfileDestructionStarted() { 2544 void ExtensionService::OnProfileDestructionStarted() {
2523 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); 2545 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2524 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); 2546 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2525 it != ids_to_unload.end(); 2547 it != ids_to_unload.end();
2526 ++it) { 2548 ++it) {
2527 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); 2549 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2528 } 2550 }
2529 } 2551 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698