| OLD | NEW |
| (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 } | |
| 25 | |
| 26 ExtensionMessageBubbleFactory::ExtensionMessageBubbleFactory(Profile* profile) | |
| 27 : profile_(profile) { | |
| 28 } | |
| 29 | |
| 30 ExtensionMessageBubbleFactory::~ExtensionMessageBubbleFactory() { | |
| 31 } | |
| 32 | |
| 33 scoped_ptr<extensions::ExtensionMessageBubbleController> | |
| 34 ExtensionMessageBubbleFactory::GetController() { | |
| 35 // Currently only on windows. | |
| 36 #if !defined(OS_WIN) | |
| 37 return scoped_ptr<extensions::ExtensionMessageBubbleController>(); | |
| 38 #endif | |
| 39 | |
| 40 Profile* original_profile = profile_->GetOriginalProfile(); | |
| 41 std::set<Profile*>& profiles_evaluated = g_profiles_evaluated.Get(); | |
| 42 bool is_initial_check = profiles_evaluated.count(original_profile) == 0; | |
| 43 profiles_evaluated.insert(original_profile); | |
| 44 | |
| 45 // The list of suspicious extensions takes priority over the dev mode bubble | |
| 46 // and the settings API bubble, since that needs to be shown as soon as we | |
| 47 // disable something. The settings API bubble is shown on first startup after | |
| 48 // an extension has changed the startup pages and it is acceptable if that | |
| 49 // waits until the next startup because of the suspicious extension bubble. | |
| 50 // The dev mode bubble is not time sensitive like the other two so we'll catch | |
| 51 // the dev mode extensions on the next startup/next window that opens. That | |
| 52 // way, we're not too spammy with the bubbles. | |
| 53 { | |
| 54 scoped_ptr<extensions::SuspiciousExtensionBubbleController> controller( | |
| 55 new extensions::SuspiciousExtensionBubbleController(profile_)); | |
| 56 if (controller->ShouldShow()) | |
| 57 return controller.Pass(); | |
| 58 } | |
| 59 | |
| 60 { | |
| 61 // No use showing this if it's not the startup of the profile. | |
| 62 if (is_initial_check) { | |
| 63 scoped_ptr<extensions::SettingsApiBubbleController> controller( | |
| 64 new extensions::SettingsApiBubbleController( | |
| 65 profile_, extensions::BUBBLE_TYPE_STARTUP_PAGES)); | |
| 66 if (controller->ShouldShow()) | |
| 67 return controller.Pass(); | |
| 68 } | |
| 69 } | |
| 70 | |
| 71 { | |
| 72 // TODO(devlin): Move the "GetExtensionOverridingProxy" part into the | |
| 73 // proxy bubble controller. | |
| 74 const extensions::Extension* extension = | |
| 75 extensions::GetExtensionOverridingProxy(profile_); | |
| 76 if (extension) { | |
| 77 scoped_ptr<extensions::ProxyOverriddenBubbleController> controller( | |
| 78 new extensions::ProxyOverriddenBubbleController(profile_)); | |
| 79 if (controller->ShouldShow(extension->id())) | |
| 80 return controller.Pass(); | |
| 81 } | |
| 82 } | |
| 83 | |
| 84 { | |
| 85 scoped_ptr<extensions::DevModeBubbleController> controller( | |
| 86 new extensions::DevModeBubbleController(profile_)); | |
| 87 if (controller->ShouldShow()) | |
| 88 return controller.Pass(); | |
| 89 } | |
| 90 | |
| 91 return scoped_ptr<extensions::ExtensionMessageBubbleController>(); | |
| 92 } | |
| OLD | NEW |