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

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: l upload 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) {
68 const Extension* extension = service_->GetExtensionById(extension_id, false);
69 if (!extension)
70 return false;
71 return IsDevModeExtension(extension);
72 }
73
74 void DevModeBubbleController::AcknowledgeExtension(
75 const std::string& extension_id,
76 ExtensionMessageBubbleController::BubbleAction user_action) {
77 }
78
79 void DevModeBubbleController::PerformAction(
80 const ExtensionIdList& list) {
81 for (size_t i = 0; i < list.size(); ++i)
82 service_->DisableExtension(list[i], Extension::DISABLE_USER_ACTION);
83 }
84
85 string16 DevModeBubbleController::GetTitle() const {
86 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_DISABLE_DEVELOPER_MODE_TITLE);
87 }
88
89 string16 DevModeBubbleController::GetMessageBody() const {
90 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_DISABLE_DEVELOPER_MODE_BODY);
91 }
92
93 string16 DevModeBubbleController::GetOverflowText(
94 const string16& overflow_count) const {
95 return l10n_util::GetStringFUTF16(
96 IDS_EXTENSIONS_SUSPICIOUS_DISABLED_AND_N_MORE,
97 overflow_count);
98 }
99
100 string16 DevModeBubbleController::GetLearnMoreLabel() const {
101 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
102 }
103
104 GURL DevModeBubbleController::GetLearnMoreUrl() const {
105 return GURL(chrome::kChromeUIExtensionsURL);
106 }
107
108 string16 DevModeBubbleController::GetActionButtonLabel() const {
109 return l10n_util::GetStringUTF16(IDS_DISABLE);
110 }
111
112 string16 DevModeBubbleController::GetDismissButtonLabel() const {
113 return l10n_util::GetStringUTF16(IDS_CANCEL);
114 }
115
116 bool DevModeBubbleController::ShouldShowExtensionList() const {
117 return false;
118 }
119
120 std::vector<string16> DevModeBubbleController::GetExtensions() {
121 return GetExtensionList();
122 }
123
124 void DevModeBubbleController::LogExtensionCount(size_t count) {
125 UMA_HISTOGRAM_COUNTS_100(
126 "DevModeExtensionBubble.ExtensionsInDevModeCount", count);
127 }
128
129 void DevModeBubbleController::LogAction(
130 ExtensionMessageBubbleController::BubbleAction action) {
131 UMA_HISTOGRAM_ENUMERATION(
132 "DevModeExtensionBubble.UserSelection",
133 action, ExtensionMessageBubbleController::ACTION_BOUNDARY);
134 }
135
136 template <>
137 void ProfileKeyedAPIFactory<
138 DevModeBubbleController>::DeclareFactoryDependencies() {
139 DependsOn(extensions::ExtensionSystemFactory::GetInstance());
140 }
141
142 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698