blob: e838351e3fc92ab0b56050962928c83fe0ebc7ef [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"
asvitkineaa060312016-09-01 22:44:138#include "base/metrics/histogram_macros.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"
thestig4a2e88e2016-08-27 23:23:5115#include "components/strings/grit/components_strings.h"
[email protected]489db0842014-01-22 18:20:0316#include "extensions/browser/extension_prefs.h"
[email protected]d46c0502014-02-14 13:33:3617#include "extensions/browser/extension_system.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]a74569b2014-03-25 02:56:3022DevModeBubbleDelegate::DevModeBubbleDelegate(Profile* profile)
rdevlin.cronin0ba2a4c2015-08-06 18:40:1923 : ExtensionMessageBubbleController::Delegate(profile) {
merkulova9be182e2014-10-07 14:57:5024}
[email protected]4f2f353d2014-01-14 11:21:0925
26DevModeBubbleDelegate::~DevModeBubbleDelegate() {
27}
28
rdevlin.cronincce78d02015-09-24 19:50:5529bool DevModeBubbleDelegate::ShouldIncludeExtension(const Extension* extension) {
asargenta772c582015-05-08 18:59:0130 return (extension->location() == Manifest::UNPACKED ||
31 extension->location() == Manifest::COMMAND_LINE);
[email protected]4f2f353d2014-01-14 11:21:0932}
33
34void DevModeBubbleDelegate::AcknowledgeExtension(
35 const std::string& extension_id,
36 ExtensionMessageBubbleController::BubbleAction user_action) {
37}
38
[email protected]a74569b2014-03-25 02:56:3039void DevModeBubbleDelegate::PerformAction(const ExtensionIdList& list) {
40 for (size_t i = 0; i < list.size(); ++i)
rdevlin.cronin0ba2a4c2015-08-06 18:40:1941 service()->DisableExtension(list[i], Extension::DISABLE_USER_ACTION);
[email protected]a74569b2014-03-25 02:56:3042}
43
[email protected]4f2f353d2014-01-14 11:21:0944base::string16 DevModeBubbleDelegate::GetTitle() const {
45 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_DISABLE_DEVELOPER_MODE_TITLE);
46}
47
[email protected]8dc56d02014-06-07 00:44:2348base::string16 DevModeBubbleDelegate::GetMessageBody(
rdevlin.cronin9cb84982015-05-15 16:57:4949 bool anchored_to_browser_action,
50 int extension_count) const {
[email protected]4f2f353d2014-01-14 11:21:0951 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_DISABLE_DEVELOPER_MODE_BODY);
52}
53
54base::string16 DevModeBubbleDelegate::GetOverflowText(
55 const base::string16& overflow_count) const {
56 return l10n_util::GetStringFUTF16(
[email protected]d2469242014-05-09 11:56:5857 IDS_EXTENSIONS_DISABLED_AND_N_MORE,
[email protected]4f2f353d2014-01-14 11:21:0958 overflow_count);
59}
60
[email protected]4f2f353d2014-01-14 11:21:0961GURL DevModeBubbleDelegate::GetLearnMoreUrl() const {
62 return GURL(chrome::kChromeUIExtensionsURL);
63}
64
65base::string16 DevModeBubbleDelegate::GetActionButtonLabel() const {
66 return l10n_util::GetStringUTF16(IDS_DISABLE);
67}
68
69base::string16 DevModeBubbleDelegate::GetDismissButtonLabel() const {
70 return l10n_util::GetStringUTF16(IDS_CANCEL);
71}
72
rdevlin.cronin690e44f2015-11-06 00:27:1473bool DevModeBubbleDelegate::ShouldCloseOnDeactivate() const {
74 return false;
75}
76
[email protected]4f2f353d2014-01-14 11:21:0977bool DevModeBubbleDelegate::ShouldShowExtensionList() const {
78 return false;
79}
80
rdevlin.cronin70fc6052015-04-15 17:49:0681bool DevModeBubbleDelegate::ShouldHighlightExtensions() const {
82 return true;
83}
84
rdevlin.cronincce78d02015-09-24 19:50:5585bool DevModeBubbleDelegate::ShouldLimitToEnabledExtensions() const {
86 return true;
87}
88
[email protected]4f2f353d2014-01-14 11:21:0989void DevModeBubbleDelegate::LogExtensionCount(size_t count) {
90 UMA_HISTOGRAM_COUNTS_100(
[email protected]b61b05ce8d2014-05-14 15:33:0191 "ExtensionBubble.ExtensionsInDevModeCount", count);
[email protected]4f2f353d2014-01-14 11:21:0992}
93
94void DevModeBubbleDelegate::LogAction(
95 ExtensionMessageBubbleController::BubbleAction action) {
96 UMA_HISTOGRAM_ENUMERATION(
[email protected]b61b05ce8d2014-05-14 15:33:0197 "ExtensionBubble.DevModeUserSelection",
[email protected]4f2f353d2014-01-14 11:21:0998 action, ExtensionMessageBubbleController::ACTION_BOUNDARY);
99}
[email protected]c72ebfe2013-12-13 21:57:53100
rdevlin.cronin486b20e2015-11-20 17:20:35101const char* DevModeBubbleDelegate::GetKey() {
102 return "DevModeBubbleDelegate";
rdevlin.cronincce78d02015-09-24 19:50:55103}
104
rdevlin.cronin486b20e2015-11-20 17:20:35105bool DevModeBubbleDelegate::ClearProfileSetAfterAction() {
106 return false;
[email protected]c72ebfe2013-12-13 21:57:53107}
108
catmullings22bc2372016-11-02 19:59:35109bool DevModeBubbleDelegate::SupportsPolicyIndicator() {
110 return false;
111}
112
[email protected]c72ebfe2013-12-13 21:57:53113} // namespace extensions