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

Side by Side Diff: chrome/browser/extensions/extension_view.h

Issue 125164: Fix a bug where ExtensionHost and ExtensionView weren't getting closed proper... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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/extensions/extension_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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_EXTENSIONS_EXTENSION_VIEW_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
11 #include "chrome/common/notification_registrar.h"
11 #include "googleurl/src/gurl.h" 12 #include "googleurl/src/gurl.h"
12 #include "third_party/skia/include/core/SkBitmap.h" 13 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "views/controls/native/native_view_host.h" 14 #include "views/controls/native/native_view_host.h"
14 15
15 class Browser; 16 class Browser;
16 class Extension; 17 class Extension;
17 class ExtensionHost; 18 class ExtensionHost;
18 class ExtensionView; 19 class ExtensionView;
19 class RenderViewHost; 20 class RenderViewHost;
20 21
21 // A class that represents the container that this view is in. 22 // A class that represents the container that this view is in.
22 // (bottom shelf, side bar, etc.) 23 // (bottom shelf, side bar, etc.)
23 class ExtensionContainer { 24 class ExtensionContainer {
24 public: 25 public:
25 // Mouse event notifications from the view. (useful for hover UI). 26 // Mouse event notifications from the view. (useful for hover UI).
26 virtual void OnExtensionMouseEvent(ExtensionView* view) = 0; 27 virtual void OnExtensionMouseEvent(ExtensionView* view) = 0;
27 virtual void OnExtensionMouseLeave(ExtensionView* view) = 0; 28 virtual void OnExtensionMouseLeave(ExtensionView* view) = 0;
28 }; 29 };
29 30
30 // This handles the display portion of an ExtensionHost. 31 // This handles the display portion of an ExtensionHost.
31 class ExtensionView : public views::NativeViewHost { 32 class ExtensionView : public views::NativeViewHost,
33 public NotificationObserver {
32 public: 34 public:
33 ExtensionView(ExtensionHost* host, Browser* browser); 35 ExtensionView(ExtensionHost* host, Browser* browser);
34 ~ExtensionView(); 36 ~ExtensionView();
35 37
36 ExtensionHost* host() const { return host_; } 38 ExtensionHost* host() const { return host_; }
37 Browser* browser() const { return browser_; } 39 Browser* browser() const { return browser_; }
38 Extension* extension() const; 40 Extension* extension() const;
39 RenderViewHost* render_view_host() const; 41 RenderViewHost* render_view_host() const;
40 42
41 // Notification from ExtensionHost. 43 // Notification from ExtensionHost.
42 void DidContentsPreferredWidthChange(const int pref_width); 44 void DidContentsPreferredWidthChange(const int pref_width);
43 void HandleMouseEvent(); 45 void HandleMouseEvent();
44 void HandleMouseLeave(); 46 void HandleMouseLeave();
45 47
46 // Set a custom background for the view. The background will be tiled. 48 // Set a custom background for the view. The background will be tiled.
47 void SetBackground(const SkBitmap& background); 49 void SetBackground(const SkBitmap& background);
48 50
49 // Sets the container for this view. 51 // Sets the container for this view.
50 void SetContainer(ExtensionContainer* container) { container_ = container; } 52 void SetContainer(ExtensionContainer* container) { container_ = container; }
51 53
52 // Overridden from views::NativeViewHost: 54 // Overridden from views::NativeViewHost:
53 virtual void SetVisible(bool is_visible); 55 virtual void SetVisible(bool is_visible);
54 virtual void DidChangeBounds(const gfx::Rect& previous, 56 virtual void DidChangeBounds(const gfx::Rect& previous,
55 const gfx::Rect& current); 57 const gfx::Rect& current);
56 virtual void ViewHierarchyChanged(bool is_add, 58 virtual void ViewHierarchyChanged(bool is_add,
57 views::View *parent, views::View *child); 59 views::View *parent, views::View *child);
58 60
61 // NotificationObserver:
62 virtual void Observe(NotificationType type,
63 const NotificationSource& source,
64 const NotificationDetails& details);
65
59 private: 66 private:
60 friend class ExtensionHost; 67 friend class ExtensionHost;
61 68
62 // We wait to show the ExtensionView until several things have loaded. 69 // We wait to show the ExtensionView until several things have loaded.
63 void ShowIfCompletelyLoaded(); 70 void ShowIfCompletelyLoaded();
64 71
65 // The running extension instance that we're displaying. 72 // The running extension instance that we're displaying.
66 // Note that host_ owns view 73 // Note that host_ owns view
67 ExtensionHost* host_; 74 ExtensionHost* host_;
68 75
69 // The browser window that this view is in. 76 // The browser window that this view is in.
70 Browser* browser_; 77 Browser* browser_;
71 78
72 // True if we've been initialized. 79 // True if we've been initialized.
73 bool initialized_; 80 bool initialized_;
74 81
75 // The background the view should have once it is initialized. This is set 82 // The background the view should have once it is initialized. This is set
76 // when the view has a custom background, but hasn't been initialized yet. 83 // when the view has a custom background, but hasn't been initialized yet.
77 SkBitmap pending_background_; 84 SkBitmap pending_background_;
78 85
79 // What we should set the preferred width to once the ExtensionView has 86 // What we should set the preferred width to once the ExtensionView has
80 // loaded. 87 // loaded.
81 int pending_preferred_width_; 88 int pending_preferred_width_;
82 89
83 // The container this view is in (not necessarily its direct superview). 90 // The container this view is in (not necessarily its direct superview).
84 // Note: the view does not own its container. 91 // Note: the view does not own its container.
85 ExtensionContainer* container_; 92 ExtensionContainer* container_;
86 93
94 // So that we can track browser window closing.
95 NotificationRegistrar registrar_;
96
87 DISALLOW_COPY_AND_ASSIGN(ExtensionView); 97 DISALLOW_COPY_AND_ASSIGN(ExtensionView);
88 }; 98 };
89 99
90 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_ 100 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698