diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-20 13:16:25 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-20 13:16:25 +0000 |
commit | c66df4b4861cb83d70771fd0eacc6399d299f5bc (patch) | |
tree | 1313dcb81ac8867c1ee141c9583144c65a4424a8 /chrome/browser/extensions/suspicious_extension_bubble_controller.h | |
parent | 6da2cdb5ab78f2098e48a198221786fbaa35c63e (diff) | |
download | chromium_src-c66df4b4861cb83d70771fd0eacc6399d299f5bc.zip chromium_src-c66df4b4861cb83d70771fd0eacc6399d299f5bc.tar.gz chromium_src-c66df4b4861cb83d70771fd0eacc6399d299f5bc.tar.bz2 |
Add a bubble that lets the user know that one or more extensions have been
disabled because it/they didn't come from the webstore.
Also removing a few stray remnants of the Sideload Wipeout initiative, which are
no longer needed.
This is a retry of landing
https://codereview.chromium.org/70253002
... with only an if-check in the controller different (service_ can be null during testing).
BUG=318120
TBR=kalman
Review URL: https://codereview.chromium.org/77913005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236238 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/suspicious_extension_bubble_controller.h')
-rw-r--r-- | chrome/browser/extensions/suspicious_extension_bubble_controller.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/chrome/browser/extensions/suspicious_extension_bubble_controller.h b/chrome/browser/extensions/suspicious_extension_bubble_controller.h new file mode 100644 index 0000000..0618135 --- /dev/null +++ b/chrome/browser/extensions/suspicious_extension_bubble_controller.h @@ -0,0 +1,88 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ +#define CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ + +#include <string> +#include "chrome/browser/extensions/api/profile_keyed_api_factory.h" +#include "extensions/common/extension.h" + +class Browser; +class ExtensionService; + +namespace extensions { + +class SuspiciousExtensionBubble; + +class SuspiciousExtensionBubbleController : public ProfileKeyedAPI { + public: + explicit SuspiciousExtensionBubbleController(Profile* profile); + virtual ~SuspiciousExtensionBubbleController(); + + // ProfileKeyedAPI implementation. + static ProfileKeyedAPIFactory< + SuspiciousExtensionBubbleController>* GetFactoryInstance(); + + // Convenience method to get the SuspiciousExtensionBubbleController for a + // profile. + static SuspiciousExtensionBubbleController* Get(Profile* profile); + + // Check for suspicious extensions, returns true if found. + bool HasSuspiciousExtensions(); + + // Sets up the callbacks and shows the bubble. + void Show(SuspiciousExtensionBubble* bubble); + + // Text for various UI labels shown in the bubble. + string16 GetTitle(); + string16 GetMessageBody(); + string16 GetOverflowText(const string16& overflow_count); + string16 GetLearnMoreLabel(); + string16 GetDismissButtonLabel(); + + // Returns a vector of names of suspicious extensions found. + std::vector<string16> GetSuspiciousExtensionNames(); + + // Callbacks from bubble. Declared virtual for testing purposes. + virtual void OnBubbleDismiss(); + virtual void OnLinkClicked(); + + private: + friend class ProfileKeyedAPIFactory<SuspiciousExtensionBubbleController>; + + // ProfileKeyedAPI implementation. + static const char* service_name() { + return "SuspiciousExtensionBubbleController"; + } + static const bool kServiceRedirectedInIncognito = true; + + // Mark all extensions found as acknowledged (don't need to warn about them + // again). + void AcknowledgeWipeout(); + + // The list of suspicious extensions found. Reset at the beginning of each + // call to FoundSuspiciousExtensions. + ExtensionIdList suspicious_extensions_; + + // Our extension service. Weak, not owned by us. + ExtensionService* service_; + + // A weak pointer to the profile we are associated with. Not owned by us. + Profile* profile_; + + // This object only checks once for suspicious extensions because the dataset + // doesn't change after startup. + bool has_notified_; + + DISALLOW_COPY_AND_ASSIGN(SuspiciousExtensionBubbleController); +}; + +template <> +void ProfileKeyedAPIFactory< + SuspiciousExtensionBubbleController>::DeclareFactoryDependencies(); + +} // namespace extensions + +#endif // CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ |