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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 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 #ifndef CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_
6 #define CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_
7
8 #include "base/memory/weak_ptr.h"
9 #include "content/public/browser/notification_observer.h"
10 #include "content/public/browser/notification_registrar.h"
11 #include "third_party/skia/include/core/SkBitmap.h"
12
13 class Browser;
14
15 namespace extensions {
16 class Extension;
17 }
18
19 // Provides feedback to the user upon successful installation of an
20 // extension. Depending on the type of extension, the Bubble will
21 // point to:
22 // OMNIBOX_KEYWORD-> The omnibox.
23 // BROWSER_ACTION -> The browser action icon in the toolbar.
24 // PAGE_ACTION -> A preview of the page action icon in the location
25 // bar which is shown while the Bubble is shown.
26 // GENERIC -> The wrench menu. This case includes page actions that
27 // don't specify a default icon.
28 //
29 // ExtensionInstallBubble manages its own lifetime.
30 class ExtensionInstalledBubble : public content::NotificationObserver {
31 public:
32 // The behavior and content of this Bubble comes in these varieties:
33 enum BubbleType {
34 OMNIBOX_KEYWORD,
35 BROWSER_ACTION,
36 PAGE_ACTION,
37 GENERIC
38 };
39
40 // Implements the UI for showing the bubble. Owns us.
41 class Delegate {
42 public:
43 virtual ~Delegate() {}
44
45 // Shows the bubble. Called internally via PostTask.
46 virtual void ShowInternal() = 0;
47
48 // Informs the view that our browser is closing, so it should
49 // delete itself.
50 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.
51 };
52
53 ExtensionInstalledBubble(Delegate* delegate,
54 const extensions::Extension* extension,
55 Browser *browser,
56 const SkBitmap& icon);
57
58 virtual ~ExtensionInstalledBubble();
59
60 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.
61 Browser* browser() { return browser_; }
62 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.
63 BubbleType type() { return type_; }
sky 2013/09/04 00:04:06 BubbleType type() const
Yoyo Zhou 2013/09/05 00:12:21 Done.
64 content::NotificationRegistrar* registrar() { return &registrar_; }
65
66 // When showing the bubble for a new browser action, we may have to wait for
67 // the toolbar to finish animating to know where the item's final position
68 // will be.
69 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.
70
71 // Stop listening to NOTIFICATION_BROWSER_CLOSING.
72 void IgnoreBrowserClosing();
73
74 private:
75 // Delegates showing the view to our |view_|.
76 void ShowInternal();
77
78 // content::NotificationObserver:
79 virtual void Observe(int type,
80 const content::NotificationSource& source,
81 const content::NotificationDetails& details) OVERRIDE;
82
83 // The view delegate that shows the bubble. Owns us.
84 Delegate* delegate_;
85
86 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.
87 Browser* browser_;
88 const SkBitmap icon_;
89 BubbleType type_;
90 content::NotificationRegistrar registrar_;
91
92 // The number of times to retry showing the bubble if the browser action
93 // toolbar is animating.
94 int animation_wait_retries_;
95
96 base::WeakPtrFactory<ExtensionInstalledBubble> weak_factory_;
97
98 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubble);
99 };
100
101 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698