Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1151)

Side by Side Diff: chrome/browser/extensions/dev_mode_bubble_controller.cc

Issue 114153003: Add an extension bubble explaining which extensions are in dev mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to head Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
5 #include "chrome/browser/extensions/dev_mode_bubble_controller.h"
6
7 #include "base/bind.h"
8 #include "base/metrics/histogram.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/extensions/extension_action_manager.h"
12 #include "chrome/browser/extensions/extension_message_bubble.h"
13 #include "chrome/browser/extensions/extension_prefs.h"
14 #include "chrome/browser/extensions/extension_service.h"
15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_finder.h"
17 #include "chrome/common/chrome_version_info.h"
18 #include "chrome/common/url_constants.h"
19 #include "content/public/browser/notification_service.h"
20 #include "content/public/browser/user_metrics.h"
21 #include "extensions/common/feature_switch.h"
22 #include "grit/chromium_strings.h"
23 #include "grit/generated_resources.h"
24 #include "ui/base/l10n/l10n_util.h"
25
26 namespace {
27
28 static base::LazyInstance<extensions::ProfileKeyedAPIFactory<
29 extensions::DevModeBubbleController> >
30 g_factory = LAZY_INSTANCE_INITIALIZER;
31
32 } // namespace
33
34 namespace extensions {
35
36 ////////////////////////////////////////////////////////////////////////////////
37 // DevModeBubbleController
38
39 DevModeBubbleController::DevModeBubbleController(
40 Profile* profile)
41 : ExtensionMessageBubbleController(this, profile),
42 service_(extensions::ExtensionSystem::Get(profile)->extension_service()),
tapted 2013/12/15 22:54:04 Not sure if it applies to PrfoileKeyedAPIs.. but I
Finnur 2013/12/16 14:57:02 Great tip. Looking at the tip of tree code I don't
43 profile_(profile) {
44 }
45
46 DevModeBubbleController::~DevModeBubbleController() {
47 }
48
49 // static
50 ProfileKeyedAPIFactory<DevModeBubbleController>*
51 DevModeBubbleController::GetFactoryInstance() {
52 return &g_factory.Get();
53 }
54
55 // static
56 DevModeBubbleController* DevModeBubbleController::Get(
57 Profile* profile) {
58 return ProfileKeyedAPIFactory<
59 DevModeBubbleController>::GetForProfile(profile);
60 }
61
62 bool DevModeBubbleController::IsDevModeExtension(
63 const Extension* extension) const {
64 if (!extensions::FeatureSwitch::force_dev_mode_highlighting()->IsEnabled()) {
65 if (chrome::VersionInfo::GetChannel() <
66 chrome::VersionInfo::CHANNEL_BETA)
67 return false;
68 }
69 return extension->location() == Manifest::UNPACKED ||
70 extension->location() == Manifest::COMMAND_LINE;
71 }
72
73 bool DevModeBubbleController::ShouldIncludeExtension(
74 const std::string& extension_id) {
75 const Extension* extension = service_->GetExtensionById(extension_id, false);
76 if (!extension)
77 return false;
78 return IsDevModeExtension(extension);
79 }
80
81 void DevModeBubbleController::AcknowledgeExtension(
82 const std::string& extension_id,
83 ExtensionMessageBubbleController::BubbleAction user_action) {
84 }
85
86 void DevModeBubbleController::PerformAction(
87 const ExtensionIdList& list) {
88 for (size_t i = 0; i < list.size(); ++i)
89 service_->DisableExtension(list[i], Extension::DISABLE_USER_ACTION);
90 }
91
92 string16 DevModeBubbleController::GetTitle() const {
93 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_DISABLE_DEVELOPER_MODE_TITLE);
94 }
95
96 string16 DevModeBubbleController::GetMessageBody() const {
97 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_DISABLE_DEVELOPER_MODE_BODY);
98 }
99
100 string16 DevModeBubbleController::GetOverflowText(
101 const string16& overflow_count) const {
102 return l10n_util::GetStringFUTF16(
103 IDS_EXTENSIONS_SUSPICIOUS_DISABLED_AND_N_MORE,
104 overflow_count);
105 }
106
107 string16 DevModeBubbleController::GetLearnMoreLabel() const {
108 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
109 }
110
111 GURL DevModeBubbleController::GetLearnMoreUrl() const {
112 return GURL(chrome::kChromeUIExtensionsURL);
113 }
114
115 string16 DevModeBubbleController::GetActionButtonLabel() const {
116 return l10n_util::GetStringUTF16(IDS_DISABLE);
117 }
118
119 string16 DevModeBubbleController::GetDismissButtonLabel() const {
120 return l10n_util::GetStringUTF16(IDS_CANCEL);
121 }
122
123 bool DevModeBubbleController::ShouldShowExtensionList() const {
124 return false;
125 }
126
127 std::vector<string16> DevModeBubbleController::GetExtensions() {
128 return GetExtensionList();
129 }
130
131 void DevModeBubbleController::LogExtensionCount(size_t count) {
132 UMA_HISTOGRAM_COUNTS_100(
133 "DevModeExtensionBubble.ExtensionsInDevModeCount", count);
134 }
135
136 void DevModeBubbleController::LogAction(
137 ExtensionMessageBubbleController::BubbleAction action) {
138 UMA_HISTOGRAM_ENUMERATION(
139 "DevModeExtensionBubble.UserSelection",
140 action, ExtensionMessageBubbleController::ACTION_BOUNDARY);
141 }
142
143 template <>
144 void ProfileKeyedAPIFactory<
145 DevModeBubbleController>::DeclareFactoryDependencies() {
146 DependsOn(extensions::ExtensionSystemFactory::GetInstance());
147 }
148
149 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/dev_mode_bubble_controller.h ('k') | chrome/browser/extensions/extension_message_bubble.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698