[email protected] | c72ebfe | 2013-12-13 21:57:53 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
rdevlin.cronin | 690e44f | 2015-11-06 00:27:14 | [diff] [blame^] | 5 | #include "chrome/browser/extensions/dev_mode_bubble_delegate.h" |
[email protected] | c72ebfe | 2013-12-13 21:57:53 | [diff] [blame] | 6 | |
[email protected] | 4f2f353d | 2014-01-14 11:21:09 | [diff] [blame] | 7 | #include "base/lazy_instance.h" |
[email protected] | c72ebfe | 2013-12-13 21:57:53 | [diff] [blame] | 8 | #include "base/metrics/histogram.h" |
[email protected] | c72ebfe | 2013-12-13 21:57:53 | [diff] [blame] | 9 | #include "chrome/browser/extensions/extension_action_manager.h" |
[email protected] | c72ebfe | 2013-12-13 21:57:53 | [diff] [blame] | 10 | #include "chrome/browser/extensions/extension_service.h" |
[email protected] | f845448465 | 2014-02-27 04:20:42 | [diff] [blame] | 11 | #include "chrome/browser/profiles/profile.h" |
[email protected] | c72ebfe | 2013-12-13 21:57:53 | [diff] [blame] | 12 | #include "chrome/browser/ui/browser.h" |
[email protected] | c72ebfe | 2013-12-13 21:57:53 | [diff] [blame] | 13 | #include "chrome/common/url_constants.h" |
[email protected] | af39f00 | 2014-08-22 10:18:18 | [diff] [blame] | 14 | #include "chrome/grit/generated_resources.h" |
[email protected] | 489db084 | 2014-01-22 18:20:03 | [diff] [blame] | 15 | #include "extensions/browser/extension_prefs.h" |
[email protected] | d46c050 | 2014-02-14 13:33:36 | [diff] [blame] | 16 | #include "extensions/browser/extension_system.h" |
hashimoto | a804d98 | 2014-09-02 10:35:57 | [diff] [blame] | 17 | #include "grit/components_strings.h" |
[email protected] | c72ebfe | 2013-12-13 21:57:53 | [diff] [blame] | 18 | #include "ui/base/l10n/l10n_util.h" |
19 | |||||
[email protected] | a74569b | 2014-03-25 02:56:30 | [diff] [blame] | 20 | namespace extensions { |
21 | |||||
[email protected] | c72ebfe | 2013-12-13 21:57:53 | [diff] [blame] | 22 | namespace { |
23 | |||||
[email protected] | 4f2f353d | 2014-01-14 11:21:09 | [diff] [blame] | 24 | base::LazyInstance<std::set<Profile*> > g_shown_for_profiles = |
25 | LAZY_INSTANCE_INITIALIZER; | ||||
26 | |||||
rdevlin.cronin | 690e44f | 2015-11-06 00:27:14 | [diff] [blame^] | 27 | } // namespace |
[email protected] | 3d4d9337 | 2014-05-20 06:25:31 | [diff] [blame] | 28 | |
[email protected] | a74569b | 2014-03-25 02:56:30 | [diff] [blame] | 29 | DevModeBubbleDelegate::DevModeBubbleDelegate(Profile* profile) |
rdevlin.cronin | 0ba2a4c | 2015-08-06 18:40:19 | [diff] [blame] | 30 | : ExtensionMessageBubbleController::Delegate(profile) { |
merkulova | 9be182e | 2014-10-07 14:57:50 | [diff] [blame] | 31 | } |
[email protected] | 4f2f353d | 2014-01-14 11:21:09 | [diff] [blame] | 32 | |
33 | DevModeBubbleDelegate::~DevModeBubbleDelegate() { | ||||
34 | } | ||||
35 | |||||
rdevlin.cronin | cce78d0 | 2015-09-24 19:50:55 | [diff] [blame] | 36 | bool DevModeBubbleDelegate::ShouldIncludeExtension(const Extension* extension) { |
asargent | a772c58 | 2015-05-08 18:59:01 | [diff] [blame] | 37 | return (extension->location() == Manifest::UNPACKED || |
38 | extension->location() == Manifest::COMMAND_LINE); | ||||
[email protected] | 4f2f353d | 2014-01-14 11:21:09 | [diff] [blame] | 39 | } |
40 | |||||
41 | void DevModeBubbleDelegate::AcknowledgeExtension( | ||||
42 | const std::string& extension_id, | ||||
43 | ExtensionMessageBubbleController::BubbleAction user_action) { | ||||
44 | } | ||||
45 | |||||
[email protected] | a74569b | 2014-03-25 02:56:30 | [diff] [blame] | 46 | void DevModeBubbleDelegate::PerformAction(const ExtensionIdList& list) { |
47 | for (size_t i = 0; i < list.size(); ++i) | ||||
rdevlin.cronin | 0ba2a4c | 2015-08-06 18:40:19 | [diff] [blame] | 48 | service()->DisableExtension(list[i], Extension::DISABLE_USER_ACTION); |
[email protected] | a74569b | 2014-03-25 02:56:30 | [diff] [blame] | 49 | } |
50 | |||||
[email protected] | 4f2f353d | 2014-01-14 11:21:09 | [diff] [blame] | 51 | base::string16 DevModeBubbleDelegate::GetTitle() const { |
52 | return l10n_util::GetStringUTF16(IDS_EXTENSIONS_DISABLE_DEVELOPER_MODE_TITLE); | ||||
53 | } | ||||
54 | |||||
[email protected] | 8dc56d0 | 2014-06-07 00:44:23 | [diff] [blame] | 55 | base::string16 DevModeBubbleDelegate::GetMessageBody( |
rdevlin.cronin | 9cb8498 | 2015-05-15 16:57:49 | [diff] [blame] | 56 | bool anchored_to_browser_action, |
57 | int extension_count) const { | ||||
[email protected] | 4f2f353d | 2014-01-14 11:21:09 | [diff] [blame] | 58 | return l10n_util::GetStringUTF16(IDS_EXTENSIONS_DISABLE_DEVELOPER_MODE_BODY); |
59 | } | ||||
60 | |||||
61 | base::string16 DevModeBubbleDelegate::GetOverflowText( | ||||
62 | const base::string16& overflow_count) const { | ||||
63 | return l10n_util::GetStringFUTF16( | ||||
[email protected] | d246924 | 2014-05-09 11:56:58 | [diff] [blame] | 64 | IDS_EXTENSIONS_DISABLED_AND_N_MORE, |
[email protected] | 4f2f353d | 2014-01-14 11:21:09 | [diff] [blame] | 65 | overflow_count); |
66 | } | ||||
67 | |||||
[email protected] | 4f2f353d | 2014-01-14 11:21:09 | [diff] [blame] | 68 | GURL DevModeBubbleDelegate::GetLearnMoreUrl() const { |
69 | return GURL(chrome::kChromeUIExtensionsURL); | ||||
70 | } | ||||
71 | |||||
72 | base::string16 DevModeBubbleDelegate::GetActionButtonLabel() const { | ||||
73 | return l10n_util::GetStringUTF16(IDS_DISABLE); | ||||
74 | } | ||||
75 | |||||
76 | base::string16 DevModeBubbleDelegate::GetDismissButtonLabel() const { | ||||
77 | return l10n_util::GetStringUTF16(IDS_CANCEL); | ||||
78 | } | ||||
79 | |||||
rdevlin.cronin | 690e44f | 2015-11-06 00:27:14 | [diff] [blame^] | 80 | bool DevModeBubbleDelegate::ShouldCloseOnDeactivate() const { |
81 | return false; | ||||
82 | } | ||||
83 | |||||
[email protected] | 4f2f353d | 2014-01-14 11:21:09 | [diff] [blame] | 84 | bool DevModeBubbleDelegate::ShouldShowExtensionList() const { |
85 | return false; | ||||
86 | } | ||||
87 | |||||
rdevlin.cronin | 70fc605 | 2015-04-15 17:49:06 | [diff] [blame] | 88 | bool DevModeBubbleDelegate::ShouldHighlightExtensions() const { |
89 | return true; | ||||
90 | } | ||||
91 | |||||
rdevlin.cronin | cce78d0 | 2015-09-24 19:50:55 | [diff] [blame] | 92 | bool DevModeBubbleDelegate::ShouldLimitToEnabledExtensions() const { |
93 | return true; | ||||
94 | } | ||||
95 | |||||
[email protected] | 4f2f353d | 2014-01-14 11:21:09 | [diff] [blame] | 96 | void DevModeBubbleDelegate::LogExtensionCount(size_t count) { |
97 | UMA_HISTOGRAM_COUNTS_100( | ||||
[email protected] | b61b05ce8d | 2014-05-14 15:33:01 | [diff] [blame] | 98 | "ExtensionBubble.ExtensionsInDevModeCount", count); |
[email protected] | 4f2f353d | 2014-01-14 11:21:09 | [diff] [blame] | 99 | } |
100 | |||||
101 | void DevModeBubbleDelegate::LogAction( | ||||
102 | ExtensionMessageBubbleController::BubbleAction action) { | ||||
103 | UMA_HISTOGRAM_ENUMERATION( | ||||
[email protected] | b61b05ce8d | 2014-05-14 15:33:01 | [diff] [blame] | 104 | "ExtensionBubble.DevModeUserSelection", |
[email protected] | 4f2f353d | 2014-01-14 11:21:09 | [diff] [blame] | 105 | action, ExtensionMessageBubbleController::ACTION_BOUNDARY); |
106 | } | ||||
[email protected] | c72ebfe | 2013-12-13 21:57:53 | [diff] [blame] | 107 | |
rdevlin.cronin | cce78d0 | 2015-09-24 19:50:55 | [diff] [blame] | 108 | std::set<Profile*>* DevModeBubbleDelegate::GetProfileSet() { |
109 | return g_shown_for_profiles.Pointer(); | ||||
110 | } | ||||
111 | |||||
[email protected] | 4f2f353d | 2014-01-14 11:21:09 | [diff] [blame] | 112 | // static |
rdevlin.cronin | 690e44f | 2015-11-06 00:27:14 | [diff] [blame^] | 113 | void DevModeBubbleDelegate::ClearProfileListForTesting() { |
[email protected] | 4f2f353d | 2014-01-14 11:21:09 | [diff] [blame] | 114 | g_shown_for_profiles.Get().clear(); |
[email protected] | c72ebfe | 2013-12-13 21:57:53 | [diff] [blame] | 115 | } |
116 | |||||
[email protected] | c72ebfe | 2013-12-13 21:57:53 | [diff] [blame] | 117 | } // namespace extensions |