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

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

Issue 95133002: Add an extension bubble explaining which extensions are in dev mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test 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/url_constants.h"
18 #include "content/public/browser/notification_service.h"
19 #include "content/public/browser/user_metrics.h"
20 #include "grit/chromium_strings.h"
21 #include "grit/generated_resources.h"
22 #include "ui/base/l10n/l10n_util.h"
23
24 namespace {
25
26 static base::LazyInstance<extensions::ProfileKeyedAPIFactory<
27 extensions::DevModeBubbleController> >
28 g_factory = LAZY_INSTANCE_INITIALIZER;
29
30 } // namespace
31
32 namespace extensions {
33
34 ////////////////////////////////////////////////////////////////////////////////
35 // DevModeBubbleController
36
37 DevModeBubbleController::DevModeBubbleController(
38 Profile* profile)
39 : ExtensionMessageBubbleController(this, profile),
40 service_(extensions::ExtensionSystem::Get(profile)->extension_service()),
41 profile_(profile) {
42 }
43
44 DevModeBubbleController::~DevModeBubbleController() {
45 }
46
47 // static
48 ProfileKeyedAPIFactory<DevModeBubbleController>*
49 DevModeBubbleController::GetFactoryInstance() {
50 return &g_factory.Get();
51 }
52
53 // static
54 DevModeBubbleController* DevModeBubbleController::Get(
55 Profile* profile) {
56 return ProfileKeyedAPIFactory<
57 DevModeBubbleController>::GetForProfile(profile);
58 }
59
60 bool DevModeBubbleController::IsDevModeExtension(
61 const Extension* extension) const {
62 return extension->location() == Manifest::UNPACKED ||
63 extension->location() == Manifest::COMMAND_LINE;
64 }
65
66 bool DevModeBubbleController::ShouldIncludeExtension(
67 const std::string& extension_id) {
not at google - send to devlin 2013/12/12 18:21:38 I think generally methods should take Extensions n
Finnur 2013/12/12 20:25:12 Generally, yes. However, in this case, we want the
not at google - send to devlin 2013/12/12 21:17:19 Ok that makes sense.
68 const Extension* extension = service_->GetExtensionById(extension_id, false);
69 if (!extension)
70 return false;
71 if (!IsDevModeExtension(extension))
72 return false;
73 return true;
74 }
75
76 void DevModeBubbleController::AcknowledgeExtension(
77 const std::string& extension_id,
78 ExtensionMessageBubbleController::BubbleAction user_action) {
79 }
80
81 void DevModeBubbleController::PerformAction(
82 const ExtensionIdList& list) {
83 for (size_t i = 0; i < list.size(); ++i)
84 service_->DisableExtension(list[i], Extension::DISABLE_USER_ACTION);
not at google - send to devlin 2013/12/12 18:21:38 don't you want to disable the extensions on Chrome
Finnur 2013/12/12 20:25:12 Not the DevMode bubble. It is meant to highlight d
85 }
86
87 string16 DevModeBubbleController::GetTitle() const {
88 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_DISABLE_DEVELOPER_MODE_TITLE);
89 }
90
91 string16 DevModeBubbleController::GetMessageBody() const {
92 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_DISABLE_DEVELOPER_MODE_BODY);
93 }
94
95 string16 DevModeBubbleController::GetOverflowText(
96 const string16& overflow_count) const {
97 return l10n_util::GetStringFUTF16(
98 IDS_EXTENSIONS_SUSPICIOUS_DISABLED_AND_N_MORE,
99 overflow_count);
100 }
101
102 string16 DevModeBubbleController::GetLearnMoreLabel() const {
103 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
104 }
105
106 GURL DevModeBubbleController::GetLearnMoreUrl() const {
107 return GURL(chrome::kChromeUIExtensionsURL);
108 }
109
110 string16 DevModeBubbleController::GetActionButtonLabel() const {
111 return l10n_util::GetStringUTF16(IDS_DISABLE);
112 }
113
114 string16 DevModeBubbleController::GetDismissButtonLabel() const {
115 return l10n_util::GetStringUTF16(IDS_CANCEL);
116 }
117
118 bool DevModeBubbleController::ShouldShowExtensionList() const {
119 return false;
120 }
121
122 std::vector<string16> DevModeBubbleController::GetExtensions() {
123 return GetExtensionList();
not at google - send to devlin 2013/12/12 18:21:38 calling from the Delegate back into the Controller
124 }
125
126 void DevModeBubbleController::LogExtensionCount(size_t count) {
127 UMA_HISTOGRAM_COUNTS_100(
128 "DevModeExtensionBubble.ExtensionsInDevModeCount", count);
129 }
130
131 void DevModeBubbleController::LogAction(
132 ExtensionMessageBubbleController::BubbleAction action) {
133 UMA_HISTOGRAM_ENUMERATION(
134 "DevModeExtensionBubble.UserSelection",
135 action, ExtensionMessageBubbleController::ACTION_BOUNDARY);
136 }
137
138 template <>
139 void ProfileKeyedAPIFactory<
140 DevModeBubbleController>::DeclareFactoryDependencies() {
141 DependsOn(extensions::ExtensionSystemFactory::GetInstance());
142 }
143
144 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698