blob: 5f723de49a978ba6752768282ac02624d452ec09 [file] [log] [blame]
[email protected]c72ebfe2013-12-13 21:57:531// 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
3// found in the LICENSE file.
4
rdevlin.cronin690e44f2015-11-06 00:27:145#include "chrome/browser/extensions/dev_mode_bubble_delegate.h"
[email protected]c72ebfe2013-12-13 21:57:536
[email protected]4f2f353d2014-01-14 11:21:097#include "base/lazy_instance.h"
[email protected]c72ebfe2013-12-13 21:57:538#include "base/metrics/histogram.h"
[email protected]c72ebfe2013-12-13 21:57:539#include "chrome/browser/extensions/extension_action_manager.h"
[email protected]c72ebfe2013-12-13 21:57:5310#include "chrome/browser/extensions/extension_service.h"
[email protected]f8454484652014-02-27 04:20:4211#include "chrome/browser/profiles/profile.h"
[email protected]c72ebfe2013-12-13 21:57:5312#include "chrome/browser/ui/browser.h"
[email protected]c72ebfe2013-12-13 21:57:5313#include "chrome/common/url_constants.h"
[email protected]af39f002014-08-22 10:18:1814#include "chrome/grit/generated_resources.h"
[email protected]489db0842014-01-22 18:20:0315#include "extensions/browser/extension_prefs.h"
[email protected]d46c0502014-02-14 13:33:3616#include "extensions/browser/extension_system.h"
hashimotoa804d982014-09-02 10:35:5717#include "grit/components_strings.h"
[email protected]c72ebfe2013-12-13 21:57:5318#include "ui/base/l10n/l10n_util.h"
19
[email protected]a74569b2014-03-25 02:56:3020namespace extensions {
21
[email protected]c72ebfe2013-12-13 21:57:5322namespace {
23
[email protected]4f2f353d2014-01-14 11:21:0924base::LazyInstance<std::set<Profile*> > g_shown_for_profiles =
25 LAZY_INSTANCE_INITIALIZER;
26
rdevlin.cronin690e44f2015-11-06 00:27:1427} // namespace
[email protected]3d4d93372014-05-20 06:25:3128
[email protected]a74569b2014-03-25 02:56:3029DevModeBubbleDelegate::DevModeBubbleDelegate(Profile* profile)
rdevlin.cronin0ba2a4c2015-08-06 18:40:1930 : ExtensionMessageBubbleController::Delegate(profile) {
merkulova9be182e2014-10-07 14:57:5031}
[email protected]4f2f353d2014-01-14 11:21:0932
33DevModeBubbleDelegate::~DevModeBubbleDelegate() {
34}
35
rdevlin.cronincce78d02015-09-24 19:50:5536bool DevModeBubbleDelegate::ShouldIncludeExtension(const Extension* extension) {
asargenta772c582015-05-08 18:59:0137 return (extension->location() == Manifest::UNPACKED ||
38 extension->location() == Manifest::COMMAND_LINE);
[email protected]4f2f353d2014-01-14 11:21:0939}
40
41void DevModeBubbleDelegate::AcknowledgeExtension(
42 const std::string& extension_id,
43 ExtensionMessageBubbleController::BubbleAction user_action) {
44}
45
[email protected]a74569b2014-03-25 02:56:3046void DevModeBubbleDelegate::PerformAction(const ExtensionIdList& list) {
47 for (size_t i = 0; i < list.size(); ++i)
rdevlin.cronin0ba2a4c2015-08-06 18:40:1948 service()->DisableExtension(list[i], Extension::DISABLE_USER_ACTION);
[email protected]a74569b2014-03-25 02:56:3049}
50
[email protected]4f2f353d2014-01-14 11:21:0951base::string16 DevModeBubbleDelegate::GetTitle() const {
52 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_DISABLE_DEVELOPER_MODE_TITLE);
53}
54
[email protected]8dc56d02014-06-07 00:44:2355base::string16 DevModeBubbleDelegate::GetMessageBody(
rdevlin.cronin9cb84982015-05-15 16:57:4956 bool anchored_to_browser_action,
57 int extension_count) const {
[email protected]4f2f353d2014-01-14 11:21:0958 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_DISABLE_DEVELOPER_MODE_BODY);
59}
60
61base::string16 DevModeBubbleDelegate::GetOverflowText(
62 const base::string16& overflow_count) const {
63 return l10n_util::GetStringFUTF16(
[email protected]d2469242014-05-09 11:56:5864 IDS_EXTENSIONS_DISABLED_AND_N_MORE,
[email protected]4f2f353d2014-01-14 11:21:0965 overflow_count);
66}
67
[email protected]4f2f353d2014-01-14 11:21:0968GURL DevModeBubbleDelegate::GetLearnMoreUrl() const {
69 return GURL(chrome::kChromeUIExtensionsURL);
70}
71
72base::string16 DevModeBubbleDelegate::GetActionButtonLabel() const {
73 return l10n_util::GetStringUTF16(IDS_DISABLE);
74}
75
76base::string16 DevModeBubbleDelegate::GetDismissButtonLabel() const {
77 return l10n_util::GetStringUTF16(IDS_CANCEL);
78}
79
rdevlin.cronin690e44f2015-11-06 00:27:1480bool DevModeBubbleDelegate::ShouldCloseOnDeactivate() const {
81 return false;
82}
83
[email protected]4f2f353d2014-01-14 11:21:0984bool DevModeBubbleDelegate::ShouldShowExtensionList() const {
85 return false;
86}
87
rdevlin.cronin70fc6052015-04-15 17:49:0688bool DevModeBubbleDelegate::ShouldHighlightExtensions() const {
89 return true;
90}
91
rdevlin.cronincce78d02015-09-24 19:50:5592bool DevModeBubbleDelegate::ShouldLimitToEnabledExtensions() const {
93 return true;
94}
95
[email protected]4f2f353d2014-01-14 11:21:0996void DevModeBubbleDelegate::LogExtensionCount(size_t count) {
97 UMA_HISTOGRAM_COUNTS_100(
[email protected]b61b05ce8d2014-05-14 15:33:0198 "ExtensionBubble.ExtensionsInDevModeCount", count);
[email protected]4f2f353d2014-01-14 11:21:0999}
100
101void DevModeBubbleDelegate::LogAction(
102 ExtensionMessageBubbleController::BubbleAction action) {
103 UMA_HISTOGRAM_ENUMERATION(
[email protected]b61b05ce8d2014-05-14 15:33:01104 "ExtensionBubble.DevModeUserSelection",
[email protected]4f2f353d2014-01-14 11:21:09105 action, ExtensionMessageBubbleController::ACTION_BOUNDARY);
106}
[email protected]c72ebfe2013-12-13 21:57:53107
rdevlin.cronincce78d02015-09-24 19:50:55108std::set<Profile*>* DevModeBubbleDelegate::GetProfileSet() {
109 return g_shown_for_profiles.Pointer();
110}
111
[email protected]4f2f353d2014-01-14 11:21:09112// static
rdevlin.cronin690e44f2015-11-06 00:27:14113void DevModeBubbleDelegate::ClearProfileListForTesting() {
[email protected]4f2f353d2014-01-14 11:21:09114 g_shown_for_profiles.Get().clear();
[email protected]c72ebfe2013-12-13 21:57:53115}
116
[email protected]c72ebfe2013-12-13 21:57:53117} // namespace extensions