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

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: fix gtk 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
« no previous file with comments | « no previous file | chrome/browser/ui/extensions/extension_installed_bubble.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Attempts to show the bubble. Called from ShowInternal. Returns false
46 // if, because of animating (such as from adding a new browser action
47 // to the toolbar), the bubble could not be shown immediately.
48 virtual bool MaybeShowNow() = 0;
49 };
50
51 ExtensionInstalledBubble(Delegate* delegate,
52 const extensions::Extension* extension,
53 Browser *browser,
54 const SkBitmap& icon);
55
56 virtual ~ExtensionInstalledBubble();
57
58 const extensions::Extension* extension() const { return extension_; }
59 Browser* browser() { return browser_; }
60 const SkBitmap& icon() const { return icon_; }
61 BubbleType type() const { return type_; }
62
63 // Stop listening to NOTIFICATION_BROWSER_CLOSING.
64 void IgnoreBrowserClosing();
65
66 private:
67 // Delegates showing the view to our |view_|. Called internally via PostTask.
68 void ShowInternal();
69
70 // content::NotificationObserver:
71 virtual void Observe(int type,
72 const content::NotificationSource& source,
73 const content::NotificationDetails& details) OVERRIDE;
74
75 // The view delegate that shows the bubble. Owns us.
76 Delegate* delegate_;
77
78 // |extension_| is NULL when we are deleted.
79 const extensions::Extension* extension_;
80 Browser* browser_;
81 const SkBitmap icon_;
82 BubbleType type_;
83 content::NotificationRegistrar registrar_;
84
85 // The number of times to retry showing the bubble if the browser action
86 // toolbar is animating.
87 int animation_wait_retries_;
88
89 base::WeakPtrFactory<ExtensionInstalledBubble> weak_factory_;
90
91 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubble);
92 };
93
94 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/extensions/extension_installed_bubble.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698