OLD | NEW |
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/dev_mode_bubble_controller.h" | 5 #include "chrome/browser/extensions/dev_mode_bubble_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/extensions/extension_action_manager.h" | 12 #include "chrome/browser/extensions/extension_action_manager.h" |
13 #include "chrome/browser/extensions/extension_message_bubble.h" | 13 #include "chrome/browser/extensions/extension_message_bubble.h" |
14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
17 #include "chrome/common/chrome_version_info.h" | 17 #include "chrome/common/chrome_version_info.h" |
18 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
19 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
20 #include "content/public/browser/user_metrics.h" | 20 #include "content/public/browser/user_metrics.h" |
21 #include "extensions/browser/extension_prefs.h" | 21 #include "extensions/browser/extension_prefs.h" |
| 22 #include "extensions/browser/extension_system.h" |
22 #include "extensions/common/feature_switch.h" | 23 #include "extensions/common/feature_switch.h" |
23 #include "grit/chromium_strings.h" | 24 #include "grit/chromium_strings.h" |
24 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
25 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 base::LazyInstance<std::set<Profile*> > g_shown_for_profiles = | 30 base::LazyInstance<std::set<Profile*> > g_shown_for_profiles = |
30 LAZY_INSTANCE_INITIALIZER; | 31 LAZY_INSTANCE_INITIALIZER; |
31 | 32 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // DevModeBubbleController | 117 // DevModeBubbleController |
117 | 118 |
118 // static | 119 // static |
119 void DevModeBubbleController::ClearProfileListForTesting() { | 120 void DevModeBubbleController::ClearProfileListForTesting() { |
120 g_shown_for_profiles.Get().clear(); | 121 g_shown_for_profiles.Get().clear(); |
121 } | 122 } |
122 | 123 |
123 // static | 124 // static |
124 bool DevModeBubbleController::IsDevModeExtension( | 125 bool DevModeBubbleController::IsDevModeExtension( |
125 const Extension* extension) { | 126 const Extension* extension) { |
126 if (!extensions::FeatureSwitch::force_dev_mode_highlighting()->IsEnabled()) { | 127 if (!FeatureSwitch::force_dev_mode_highlighting()->IsEnabled()) { |
127 if (chrome::VersionInfo::GetChannel() < | 128 if (chrome::VersionInfo::GetChannel() < |
128 chrome::VersionInfo::CHANNEL_BETA) | 129 chrome::VersionInfo::CHANNEL_BETA) |
129 return false; | 130 return false; |
130 } | 131 } |
131 return extension->location() == Manifest::UNPACKED || | 132 return extension->location() == Manifest::UNPACKED || |
132 extension->location() == Manifest::COMMAND_LINE; | 133 extension->location() == Manifest::COMMAND_LINE; |
133 } | 134 } |
134 | 135 |
135 DevModeBubbleController::DevModeBubbleController(Profile* profile) | 136 DevModeBubbleController::DevModeBubbleController(Profile* profile) |
136 : ExtensionMessageBubbleController( | 137 : ExtensionMessageBubbleController( |
137 new DevModeBubbleDelegate( | 138 new DevModeBubbleDelegate( |
138 extensions::ExtensionSystem::Get(profile)->extension_service()), | 139 ExtensionSystem::Get(profile)->extension_service()), |
139 profile), | 140 profile), |
140 profile_(profile) { | 141 profile_(profile) {} |
141 } | |
142 | 142 |
143 DevModeBubbleController::~DevModeBubbleController() { | 143 DevModeBubbleController::~DevModeBubbleController() { |
144 } | 144 } |
145 | 145 |
146 bool DevModeBubbleController::ShouldShow() { | 146 bool DevModeBubbleController::ShouldShow() { |
147 return !g_shown_for_profiles.Get().count(profile_) && | 147 return !g_shown_for_profiles.Get().count(profile_) && |
148 !GetExtensionList().empty(); | 148 !GetExtensionList().empty(); |
149 } | 149 } |
150 | 150 |
151 void DevModeBubbleController::Show(ExtensionMessageBubble* bubble) { | 151 void DevModeBubbleController::Show(ExtensionMessageBubble* bubble) { |
152 g_shown_for_profiles.Get().insert(profile_); | 152 g_shown_for_profiles.Get().insert(profile_); |
153 ExtensionMessageBubbleController::Show(bubble); | 153 ExtensionMessageBubbleController::Show(bubble); |
154 } | 154 } |
155 | 155 |
156 } // namespace extensions | 156 } // namespace extensions |
OLD | NEW |