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

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

Issue 2299203004: Attempt to repair corrupt enterprise policy force-installed extensions (Closed)
Patch Set: switched to using installsource, addressed review comments Created 4 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/pending_extension_manager.h" 5 #include "chrome/browser/extensions/pending_extension_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h"
11 #include "base/stl_util.h"
10 #include "base/version.h" 12 #include "base/version.h"
11 #include "chrome/common/extensions/extension_constants.h" 13 #include "chrome/common/extensions/extension_constants.h"
12 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
13 #include "extensions/browser/extension_prefs.h" 15 #include "extensions/browser/extension_prefs.h"
14 #include "extensions/browser/extension_registry.h" 16 #include "extensions/browser/extension_registry.h"
15 #include "extensions/common/constants.h" 17 #include "extensions/common/constants.h"
16 #include "extensions/common/extension.h" 18 #include "extensions/common/extension.h"
17 #include "url/gurl.h" 19 #include "url/gurl.h"
18 20
19 using content::BrowserThread; 21 using content::BrowserThread;
(...skipping 26 matching lines...) Expand all
46 iter != pending_extension_list_.end(); 48 iter != pending_extension_list_.end();
47 ++iter) { 49 ++iter) {
48 if (id == iter->id()) 50 if (id == iter->id())
49 return &(*iter); 51 return &(*iter);
50 } 52 }
51 53
52 return NULL; 54 return NULL;
53 } 55 }
54 56
55 bool PendingExtensionManager::Remove(const std::string& id) { 57 bool PendingExtensionManager::Remove(const std::string& id) {
58 if (base::ContainsKey(expected_policy_reinstalls_, id)) {
59 base::TimeDelta latency =
60 base::TimeTicks::Now() - expected_policy_reinstalls_[id];
61 UMA_HISTOGRAM_LONG_TIMES("Extensions.CorruptPolicyExtensionResolved",
62 latency);
63 expected_policy_reinstalls_.erase(id);
64 }
56 PendingExtensionList::iterator iter; 65 PendingExtensionList::iterator iter;
57 for (iter = pending_extension_list_.begin(); 66 for (iter = pending_extension_list_.begin();
58 iter != pending_extension_list_.end(); 67 iter != pending_extension_list_.end();
59 ++iter) { 68 ++iter) {
60 if (id == iter->id()) { 69 if (id == iter->id()) {
61 pending_extension_list_.erase(iter); 70 pending_extension_list_.erase(iter);
62 return true; 71 return true;
63 } 72 }
64 } 73 }
65 74
(...skipping 13 matching lines...) Expand all
79 for (iter = pending_extension_list_.begin(); 88 for (iter = pending_extension_list_.begin();
80 iter != pending_extension_list_.end(); 89 iter != pending_extension_list_.end();
81 ++iter) { 90 ++iter) {
82 if (iter->is_from_sync()) 91 if (iter->is_from_sync())
83 return true; 92 return true;
84 } 93 }
85 94
86 return false; 95 return false;
87 } 96 }
88 97
98 void PendingExtensionManager::ExpectPolicyReinstallForCorruption(
99 const ExtensionId& id) {
100 expected_policy_reinstalls_[id] = base::TimeTicks::Now();
101 UMA_HISTOGRAM_BOOLEAN("Extensions.CorruptPolicyExtensionDetected", true);
102 }
103
104 bool PendingExtensionManager::IsPolicyReinstallForCorruptionExpected(
105 const ExtensionId& id) const {
106 return base::ContainsKey(expected_policy_reinstalls_, id);
107 }
108
89 bool PendingExtensionManager::AddFromSync( 109 bool PendingExtensionManager::AddFromSync(
90 const std::string& id, 110 const std::string& id,
91 const GURL& update_url, 111 const GURL& update_url,
92 const base::Version& version, 112 const base::Version& version,
93 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, 113 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install,
94 bool remote_install) { 114 bool remote_install) {
95 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 115 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
96 116
97 if (ExtensionRegistry::Get(context_)->GetExtensionById( 117 if (ExtensionRegistry::Get(context_)->GetExtensionById(
98 id, ExtensionRegistry::EVERYTHING)) { 118 id, ExtensionRegistry::EVERYTHING)) {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 322
303 return true; 323 return true;
304 } 324 }
305 325
306 void PendingExtensionManager::AddForTesting( 326 void PendingExtensionManager::AddForTesting(
307 const PendingExtensionInfo& pending_extension_info) { 327 const PendingExtensionInfo& pending_extension_info) {
308 pending_extension_list_.push_back(pending_extension_info); 328 pending_extension_list_.push_back(pending_extension_info);
309 } 329 }
310 330
311 } // namespace extensions 331 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/pending_extension_manager.h ('k') | chrome/browser/extensions/updater/extension_updater.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698