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

Side by Side Diff: chrome/browser/ui/views/extensions/extension_installed_bubble_view.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: 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_ 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_VIEW_H_
7 7
8 #include "base/memory/weak_ptr.h" 8 #include "base/compiler_specific.h"
9 #include "content/public/browser/notification_observer.h" 9 #include "chrome/browser/ui/extensions/extension_installed_bubble.h"
10 #include "content/public/browser/notification_registrar.h"
11 #include "third_party/skia/include/core/SkBitmap.h"
12 #include "ui/views/bubble/bubble_delegate.h" 10 #include "ui/views/bubble/bubble_delegate.h"
13 11
14 class Browser; 12 class Browser;
15 13
16 namespace extensions { 14 namespace extensions {
17 class Extension; 15 class Extension;
18 } 16 }
19 17
20 // Provides feedback to the user upon successful installation of an 18 // Provides feedback to the user upon successful installation of an
21 // extension. Depending on the type of extension, the Bubble will 19 // extension. Depending on the type of extension, the Bubble will
22 // point to: 20 // point to:
23 // OMNIBOX_KEYWORD-> The omnibox. 21 // OMNIBOX_KEYWORD-> The omnibox.
24 // BROWSER_ACTION -> The browserAction icon in the toolbar. 22 // BROWSER_ACTION -> The browserAction icon in the toolbar.
25 // PAGE_ACTION -> A preview of the pageAction icon in the location 23 // PAGE_ACTION -> A preview of the pageAction icon in the location
26 // bar which is shown while the Bubble is shown. 24 // bar which is shown while the Bubble is shown.
27 // GENERIC -> The wrench menu. This case includes pageActions that 25 // GENERIC -> The wrench menu. This case includes pageActions that
28 // don't specify a default icon. 26 // don't specify a default icon.
29 class ExtensionInstalledBubble 27 class ExtensionInstalledBubbleView
30 : public views::BubbleDelegateView, 28 : public ExtensionInstalledBubble,
31 public content::NotificationObserver { 29 public views::BubbleDelegateView {
32 public: 30 public:
33 // The behavior and content of this Bubble comes in these varieties: 31 // Creates the ExtensionInstalledBubbleView and schedules it to be shown once
34 enum BubbleType {
35 OMNIBOX_KEYWORD = 0,
36 BROWSER_ACTION,
37 PAGE_ACTION,
38 GENERIC,
39 };
40
41 // Creates the ExtensionInstalledBubble and schedules it to be shown once
42 // the extension has loaded. |extension| is the installed extension. |browser| 32 // the extension has loaded. |extension| is the installed extension. |browser|
43 // is the browser window which will host the bubble. |icon| is the install 33 // is the browser window which will host the bubble. |icon| is the install
44 // icon of the extension. 34 // icon of the extension.
45 static void Show(const extensions::Extension* extension, 35 static void Show(const extensions::Extension* extension,
46 Browser *browser, 36 Browser *browser,
47 const SkBitmap& icon); 37 const SkBitmap& icon);
48 38
49 private: 39 private:
50 // Private ctor. Registers a listener for EXTENSION_LOADED. 40 ExtensionInstalledBubbleView(const extensions::Extension* extension,
51 ExtensionInstalledBubble(const extensions::Extension* extension, 41 Browser *browser,
52 Browser *browser, 42 const SkBitmap& icon);
53 const SkBitmap& icon);
54 43
55 virtual ~ExtensionInstalledBubble(); 44 virtual ~ExtensionInstalledBubbleView();
56 45
57 // Shows the bubble. Called internally via PostTask. 46 // Shows the bubble. Called internally via PostTask.
58 void ShowInternal(); 47 virtual void ShowInternal() OVERRIDE;
59
60 // content::NotificationObserver
61 virtual void Observe(int type,
62 const content::NotificationSource& source,
63 const content::NotificationDetails& details) OVERRIDE;
64 48
65 // views::WidgetDelegate 49 // views::WidgetDelegate
66 virtual void WindowClosing() OVERRIDE; 50 virtual void WindowClosing() OVERRIDE;
67 51
68 // views::BubbleDelegate 52 // views::BubbleDelegate
69 virtual gfx::Rect GetAnchorRect() OVERRIDE; 53 virtual gfx::Rect GetAnchorRect() OVERRIDE;
70 54
71 const extensions::Extension* extension_; 55 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubbleView);
72 Browser* browser_;
73 SkBitmap icon_;
74 content::NotificationRegistrar registrar_;
75 BubbleType type_;
76
77 // How many times we've deferred due to animations being in progress.
78 int animation_wait_retries_;
79
80 base::WeakPtrFactory<ExtensionInstalledBubble> weak_factory_;
81
82 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubble);
83 }; 56 };
84 57
85 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_ 58 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698