| 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/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "chrome/browser/extensions/extension_action_manager.h" | 9 #include "chrome/browser/extensions/extension_action_manager.h" |
| 10 #include "chrome/browser/extensions/extension_message_bubble.h" | 10 #include "chrome/browser/extensions/extension_message_bubble.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } | 70 } |
| 71 | 71 |
| 72 DevModeBubbleDelegate::~DevModeBubbleDelegate() { | 72 DevModeBubbleDelegate::~DevModeBubbleDelegate() { |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool DevModeBubbleDelegate::ShouldIncludeExtension( | 75 bool DevModeBubbleDelegate::ShouldIncludeExtension( |
| 76 const std::string& extension_id) { | 76 const std::string& extension_id) { |
| 77 const Extension* extension = service_->GetExtensionById(extension_id, false); | 77 const Extension* extension = service_->GetExtensionById(extension_id, false); |
| 78 if (!extension) | 78 if (!extension) |
| 79 return false; | 79 return false; |
| 80 return DevModeBubbleController::IsDevModeExtension(extension); | 80 return (extension->location() == Manifest::UNPACKED || |
| 81 extension->location() == Manifest::COMMAND_LINE); |
| 81 } | 82 } |
| 82 | 83 |
| 83 void DevModeBubbleDelegate::AcknowledgeExtension( | 84 void DevModeBubbleDelegate::AcknowledgeExtension( |
| 84 const std::string& extension_id, | 85 const std::string& extension_id, |
| 85 ExtensionMessageBubbleController::BubbleAction user_action) { | 86 ExtensionMessageBubbleController::BubbleAction user_action) { |
| 86 } | 87 } |
| 87 | 88 |
| 88 void DevModeBubbleDelegate::PerformAction(const ExtensionIdList& list) { | 89 void DevModeBubbleDelegate::PerformAction(const ExtensionIdList& list) { |
| 89 for (size_t i = 0; i < list.size(); ++i) | 90 for (size_t i = 0; i < list.size(); ++i) |
| 90 service_->DisableExtension(list[i], Extension::DISABLE_USER_ACTION); | 91 service_->DisableExtension(list[i], Extension::DISABLE_USER_ACTION); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 } // namespace | 148 } // namespace |
| 148 | 149 |
| 149 //////////////////////////////////////////////////////////////////////////////// | 150 //////////////////////////////////////////////////////////////////////////////// |
| 150 // DevModeBubbleController | 151 // DevModeBubbleController |
| 151 | 152 |
| 152 // static | 153 // static |
| 153 void DevModeBubbleController::ClearProfileListForTesting() { | 154 void DevModeBubbleController::ClearProfileListForTesting() { |
| 154 g_shown_for_profiles.Get().clear(); | 155 g_shown_for_profiles.Get().clear(); |
| 155 } | 156 } |
| 156 | 157 |
| 157 // static | |
| 158 bool DevModeBubbleController::IsDevModeExtension( | |
| 159 const Extension* extension) { | |
| 160 if (!FeatureSwitch::force_dev_mode_highlighting()->IsEnabled()) { | |
| 161 if (chrome::VersionInfo::GetChannel() < chrome::VersionInfo::CHANNEL_BETA) | |
| 162 return false; | |
| 163 } | |
| 164 return extension->location() == Manifest::UNPACKED || | |
| 165 extension->location() == Manifest::COMMAND_LINE; | |
| 166 } | |
| 167 | |
| 168 DevModeBubbleController::DevModeBubbleController(Profile* profile) | 158 DevModeBubbleController::DevModeBubbleController(Profile* profile) |
| 169 : ExtensionMessageBubbleController(new DevModeBubbleDelegate(profile), | 159 : ExtensionMessageBubbleController(new DevModeBubbleDelegate(profile), |
| 170 profile), | 160 profile), |
| 171 profile_(profile) {} | 161 profile_(profile) {} |
| 172 | 162 |
| 173 DevModeBubbleController::~DevModeBubbleController() { | 163 DevModeBubbleController::~DevModeBubbleController() { |
| 174 } | 164 } |
| 175 | 165 |
| 176 bool DevModeBubbleController::ShouldShow() { | 166 bool DevModeBubbleController::ShouldShow() { |
| 177 return !g_shown_for_profiles.Get().count(profile_->GetOriginalProfile()) && | 167 return !g_shown_for_profiles.Get().count(profile_->GetOriginalProfile()) && |
| 178 !GetExtensionList().empty(); | 168 !GetExtensionList().empty(); |
| 179 } | 169 } |
| 180 | 170 |
| 181 void DevModeBubbleController::Show(ExtensionMessageBubble* bubble) { | 171 void DevModeBubbleController::Show(ExtensionMessageBubble* bubble) { |
| 182 g_shown_for_profiles.Get().insert(profile_->GetOriginalProfile()); | 172 g_shown_for_profiles.Get().insert(profile_->GetOriginalProfile()); |
| 183 ExtensionMessageBubbleController::Show(bubble); | 173 ExtensionMessageBubbleController::Show(bubble); |
| 184 } | 174 } |
| 185 | 175 |
| 186 } // namespace extensions | 176 } // namespace extensions |
| OLD | NEW |