Extensions: Show NTP override prompt per ntp extension per profile
Currently, the NTP override prompt only shows once per profile for any
NTP overriding extension installed. The NTP override prompt should be
displayed each time an NTP overriding extension is installed for a
profile. This CL implements such a change.
Bug: 748803
Change-Id: I896d9360a2a6e84f8586da481eb49be2428e9df0
Reviewed-on: https://chromium-review.googlesource.com/722454
Commit-Queue: catmullings <[email protected]>
Reviewed-by: Devlin <[email protected]>
Reviewed-by: catmullings <[email protected]>
Cr-Commit-Position: refs/heads/master@{#518557}
diff --git a/chrome/browser/extensions/dev_mode_bubble_delegate.cc b/chrome/browser/extensions/dev_mode_bubble_delegate.cc
index dcbc0ed..608d200b 100644
--- a/chrome/browser/extensions/dev_mode_bubble_delegate.cc
+++ b/chrome/browser/extensions/dev_mode_bubble_delegate.cc
@@ -19,9 +19,15 @@
namespace extensions {
+namespace {
+
+base::LazyInstance<std::set<Profile*>>::Leaky g_shown =
+ LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
+
DevModeBubbleDelegate::DevModeBubbleDelegate(Profile* profile)
- : ExtensionMessageBubbleController::Delegate(profile) {
-}
+ : ExtensionMessageBubbleController::Delegate(profile), profile_(profile) {}
DevModeBubbleDelegate::~DevModeBubbleDelegate() {
}
@@ -78,6 +84,24 @@
return false;
}
+bool DevModeBubbleDelegate::ShouldShow(
+ const ExtensionIdList& extensions) const {
+ DCHECK_LE(1u, extensions.size());
+ return !g_shown.Get().count(profile_);
+}
+
+void DevModeBubbleDelegate::OnShown(const ExtensionIdList& extensions) {
+ DCHECK_LE(1u, extensions.size());
+ DCHECK(!g_shown.Get().count(profile_));
+ g_shown.Get().insert(profile_);
+}
+
+void DevModeBubbleDelegate::OnAction() {}
+
+void DevModeBubbleDelegate::ClearProfileSetForTesting() {
+ g_shown.Get().clear();
+}
+
bool DevModeBubbleDelegate::ShouldShowExtensionList() const {
return false;
}
@@ -102,14 +126,6 @@
action, ExtensionMessageBubbleController::ACTION_BOUNDARY);
}
-const char* DevModeBubbleDelegate::GetKey() {
- return "DevModeBubbleDelegate";
-}
-
-bool DevModeBubbleDelegate::ClearProfileSetAfterAction() {
- return false;
-}
-
bool DevModeBubbleDelegate::SupportsPolicyIndicator() {
return false;
}