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

Side by Side Diff: chrome/browser/ui/extensions/extension_message_bubble_factory.cc

Issue 1087713002: [Reland] [Extensions] Make extension message bubble factory platform-abstract (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Finnur's Created 5 years, 8 months 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
OLDNEW
(Empty)
1 // Copyright 2015 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/ui/extensions/extension_message_bubble_factory.h"
6
7 #include "base/lazy_instance.h"
8 #include "chrome/browser/extensions/dev_mode_bubble_controller.h"
9 #include "chrome/browser/extensions/extension_message_bubble_controller.h"
10 #include "chrome/browser/extensions/proxy_overridden_bubble_controller.h"
11 #include "chrome/browser/extensions/settings_api_bubble_controller.h"
12 #include "chrome/browser/extensions/settings_api_helpers.h"
13 #include "chrome/browser/extensions/suspicious_extension_bubble_controller.h"
14 #include "chrome/browser/profiles/profile.h"
15
16 namespace {
17
18 // A map of all profiles evaluated, so we can tell if it's the initial check.
19 // TODO(devlin): It would be nice to coalesce all the "profiles evaluated" maps
20 // that are in the different bubble controllers.
21 base::LazyInstance<std::set<Profile*> > g_profiles_evaluated =
22 LAZY_INSTANCE_INITIALIZER;
23
24 // Currently, we only show these bubbles on windows platforms. This can be
25 // overridden for testing purposes.
26 #if defined(OS_WIN)
27 bool g_enabled = true;
28 #else
29 bool g_enabled = false;
30 #endif
31
32 } // namespace
33
34 ExtensionMessageBubbleFactory::ExtensionMessageBubbleFactory(Profile* profile)
35 : profile_(profile) {
36 }
37
38 ExtensionMessageBubbleFactory::~ExtensionMessageBubbleFactory() {
39 }
40
41 scoped_ptr<extensions::ExtensionMessageBubbleController>
42 ExtensionMessageBubbleFactory::GetController() {
43 if (!g_enabled)
44 return scoped_ptr<extensions::ExtensionMessageBubbleController>();
45
46 Profile* original_profile = profile_->GetOriginalProfile();
47 std::set<Profile*>& profiles_evaluated = g_profiles_evaluated.Get();
48 bool is_initial_check = profiles_evaluated.count(original_profile) == 0;
49 profiles_evaluated.insert(original_profile);
50
51 // The list of suspicious extensions takes priority over the dev mode bubble
52 // and the settings API bubble, since that needs to be shown as soon as we
53 // disable something. The settings API bubble is shown on first startup after
54 // an extension has changed the startup pages and it is acceptable if that
55 // waits until the next startup because of the suspicious extension bubble.
56 // The dev mode bubble is not time sensitive like the other two so we'll catch
57 // the dev mode extensions on the next startup/next window that opens. That
58 // way, we're not too spammy with the bubbles.
59 {
60 scoped_ptr<extensions::SuspiciousExtensionBubbleController> controller(
61 new extensions::SuspiciousExtensionBubbleController(profile_));
62 if (controller->ShouldShow())
63 return controller.Pass();
64 }
65
66 {
67 // No use showing this if it's not the startup of the profile.
68 if (is_initial_check) {
69 scoped_ptr<extensions::SettingsApiBubbleController> controller(
70 new extensions::SettingsApiBubbleController(
71 profile_, extensions::BUBBLE_TYPE_STARTUP_PAGES));
72 if (controller->ShouldShow())
73 return controller.Pass();
74 }
75 }
76
77 {
78 // TODO(devlin): Move the "GetExtensionOverridingProxy" part into the
79 // proxy bubble controller.
80 const extensions::Extension* extension =
81 extensions::GetExtensionOverridingProxy(profile_);
82 if (extension) {
83 scoped_ptr<extensions::ProxyOverriddenBubbleController> controller(
84 new extensions::ProxyOverriddenBubbleController(profile_));
85 if (controller->ShouldShow(extension->id()))
86 return controller.Pass();
87 }
88 }
89
90 {
91 scoped_ptr<extensions::DevModeBubbleController> controller(
92 new extensions::DevModeBubbleController(profile_));
93 if (controller->ShouldShow())
94 return controller.Pass();
95 }
96
97 return scoped_ptr<extensions::ExtensionMessageBubbleController>();
98 }
99
100 // static
101 void ExtensionMessageBubbleFactory::set_enabled_for_tests(bool enabled) {
102 g_enabled = enabled;
103 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/extensions/extension_message_bubble_factory.h ('k') | chrome/browser/ui/toolbar/toolbar_actions_bar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698