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

Unified Diff: chrome/browser/ui/extensions/extension_installed_bubble.h

Issue 23461013: Refactor out duplicate code from GTK/Views extension installed bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moar Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/extensions/extension_installed_bubble.h
diff --git a/chrome/browser/ui/extensions/extension_installed_bubble.h b/chrome/browser/ui/extensions/extension_installed_bubble.h
new file mode 100644
index 0000000000000000000000000000000000000000..a176f17c0fc081000bb7b6184d28099dc1643ce4
--- /dev/null
+++ b/chrome/browser/ui/extensions/extension_installed_bubble.h
@@ -0,0 +1,101 @@
+// Copyright 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_UI_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_
+#define CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_
+
+#include "base/memory/weak_ptr.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+
+class Browser;
+
+namespace extensions {
+class Extension;
+}
+
+// Provides feedback to the user upon successful installation of an
+// extension. Depending on the type of extension, the Bubble will
+// point to:
+// OMNIBOX_KEYWORD-> The omnibox.
+// BROWSER_ACTION -> The browser action icon in the toolbar.
+// PAGE_ACTION -> A preview of the page action icon in the location
+// bar which is shown while the Bubble is shown.
+// GENERIC -> The wrench menu. This case includes page actions that
+// don't specify a default icon.
+//
+// ExtensionInstallBubble manages its own lifetime.
+class ExtensionInstalledBubble : public content::NotificationObserver {
+ public:
+ // The behavior and content of this Bubble comes in these varieties:
+ enum BubbleType {
+ OMNIBOX_KEYWORD,
+ BROWSER_ACTION,
+ PAGE_ACTION,
+ GENERIC
+ };
+
+ // Implements the UI for showing the bubble. Owns us.
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+
+ // Shows the bubble. Called internally via PostTask.
+ virtual void ShowInternal() = 0;
+
+ // Informs the view that our browser is closing, so it should
+ // delete itself.
+ virtual void OnBrowserClosing() = 0;
sky 2013/09/04 00:04:06 Do you even need this method? Should it instead be
Yoyo Zhou 2013/09/05 00:12:21 That's better.
+ };
+
+ ExtensionInstalledBubble(Delegate* delegate,
+ const extensions::Extension* extension,
+ Browser *browser,
+ const SkBitmap& icon);
+
+ virtual ~ExtensionInstalledBubble();
+
+ const extensions::Extension* extension() { return extension_; }
sky 2013/09/04 00:04:06 const extensions::Extension* extension() const
Yoyo Zhou 2013/09/05 00:12:21 Done.
+ Browser* browser() { return browser_; }
+ const SkBitmap& icon() { return icon_; }
sky 2013/09/04 00:04:06 const SkBitmap& icon() const
Yoyo Zhou 2013/09/05 00:12:21 Done.
+ BubbleType type() { return type_; }
sky 2013/09/04 00:04:06 BubbleType type() const
Yoyo Zhou 2013/09/05 00:12:21 Done.
+ content::NotificationRegistrar* registrar() { return &registrar_; }
+
+ // When showing the bubble for a new browser action, we may have to wait for
+ // the toolbar to finish animating to know where the item's final position
+ // will be.
+ void MaybeShowLater();
sky 2013/09/04 00:04:06 AFAICT this is an implementation detail and only p
Yoyo Zhou 2013/09/05 00:12:21 Done.
+
+ // Stop listening to NOTIFICATION_BROWSER_CLOSING.
+ void IgnoreBrowserClosing();
+
+ private:
+ // Delegates showing the view to our |view_|.
+ void ShowInternal();
+
+ // content::NotificationObserver:
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ // The view delegate that shows the bubble. Owns us.
+ Delegate* delegate_;
+
+ const extensions::Extension* extension_;
sky 2013/09/04 00:04:06 nit: document this is NULL when deleted.
Yoyo Zhou 2013/09/05 00:12:21 Done.
+ Browser* browser_;
+ const SkBitmap icon_;
+ BubbleType type_;
+ content::NotificationRegistrar registrar_;
+
+ // The number of times to retry showing the bubble if the browser action
+ // toolbar is animating.
+ int animation_wait_retries_;
+
+ base::WeakPtrFactory<ExtensionInstalledBubble> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubble);
+};
+
+#endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_

Powered by Google App Engine
This is Rietveld 408576698