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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/extension_view_mac.h

Issue 10913243: extensions: Add ExtensionView interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: weak Created 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_ 5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_
6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_ 6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "chrome/browser/extensions/extension_view.h"
9 #include "third_party/skia/include/core/SkBitmap.h" 11 #include "third_party/skia/include/core/SkBitmap.h"
10 #include "ui/gfx/native_widget_types.h"
11 #include "ui/gfx/size.h" 12 #include "ui/gfx/size.h"
12 13
13 class Browser;
14 class SkBitmap;
15
16 namespace content {
17 class RenderViewHost;
18 }
19
20 namespace extensions {
21 class ExtensionHost;
22 }
23
24 // This class represents extension views. An extension view internally contains 14 // This class represents extension views. An extension view internally contains
25 // a bridge to an extension process, which draws to the extension view's 15 // a bridge to an extension process, which draws to the extension view's
26 // native view object through IPC. 16 // native view object through IPC.
27 class ExtensionViewMac { 17 class ExtensionViewMac : public ExtensionView {
28 public: 18 public:
29 class Container {
30 public:
31 virtual ~Container() {}
32 virtual void OnExtensionSizeChanged(ExtensionViewMac* view,
33 const gfx::Size& new_size) {}
34 virtual void OnExtensionViewDidShow(ExtensionViewMac* view) {};
35 };
36
37 ExtensionViewMac(extensions::ExtensionHost* extension_host, Browser* browser); 19 ExtensionViewMac(extensions::ExtensionHost* extension_host, Browser* browser);
38 ~ExtensionViewMac(); 20 virtual ~ExtensionViewMac();
39 21
40 // Starts the extension process and creates the native view. You must call 22 // Starts the extension process and creates the native view. You must call
41 // this method before calling any of this class's other methods. 23 // this method before calling any of this class's other methods.
42 void Init(); 24 void Init();
43 25
44 // Returns the extension's native view.
45 gfx::NativeView native_view();
46
47 // Returns the browser the extension belongs to.
48 Browser* browser() const { return browser_; }
49
50 // Method for the ExtensionHost to notify us that the extension page is
51 // loaded.
52 void DidStopLoading();
53
54 // Sets the extensions's background image. 26 // Sets the extensions's background image.
55 void SetBackground(const SkBitmap& background); 27 void SetBackground(const SkBitmap& background);
56 28
57 // Sets the container for this view.
58 void set_container(Container* container) { container_ = container; }
59
60 // Method for the ExtensionHost to notify us about the correct size for
61 // extension contents.
62 void ResizeDueToAutoResize(const gfx::Size& new_size);
63
64 // Method for the ExtensionHost to notify us when the RenderViewHost has a
65 // connection.
66 void RenderViewCreated();
67
68 // Informs the view that its containing window's frame changed.
69 void WindowFrameChanged();
70
71 // The minimum/maximum dimensions of the popup. 29 // The minimum/maximum dimensions of the popup.
72 // The minimum is just a little larger than the size of the button itself. 30 // The minimum is just a little larger than the size of the button itself.
73 // The maximum is an arbitrary number that should be smaller than most 31 // The maximum is an arbitrary number that should be smaller than most
74 // screens. 32 // screens.
75 static const CGFloat kMinWidth; 33 static const CGFloat kMinWidth;
76 static const CGFloat kMinHeight; 34 static const CGFloat kMinHeight;
77 static const CGFloat kMaxWidth; 35 static const CGFloat kMaxWidth;
78 static const CGFloat kMaxHeight; 36 static const CGFloat kMaxHeight;
79 37
80 private: 38 private:
81 content::RenderViewHost* render_view_host() const; 39 // Overridden from ExtensionView:
40 virtual Browser* GetBrowser() OVERRIDE;
41 virtual const Browser* GetBrowser() const OVERRIDE;
42 virtual gfx::NativeView GetNativeView() OVERRIDE;
43 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE;
44 virtual void SetContainer(ExtensionViewContainer* container) OVERRIDE;
45 virtual void ResizeDueToAutoResize(const gfx::Size& new_size) OVERRIDE;
46 virtual void RenderViewCreated() OVERRIDE;
47 virtual void DidStopLoading() OVERRIDE;
48 virtual void WindowFrameChanged() OVERRIDE;
82 49
83 void CreateWidgetHostView(); 50 void CreateWidgetHostView();
84 51
85 // We wait to show the ExtensionView until several things have loaded. 52 // We wait to show the ExtensionView until several things have loaded.
86 void ShowIfCompletelyLoaded(); 53 void ShowIfCompletelyLoaded();
87 54
88 Browser* browser_; // weak 55 Browser* browser_; // weak
89 56
90 extensions::ExtensionHost* extension_host_; // weak 57 extensions::ExtensionHost* extension_host_; // weak
91 58
92 // The background the view should have once it is initialized. This is set 59 // The background the view should have once it is initialized. This is set
93 // when the view has a custom background, but hasn't been initialized yet. 60 // when the view has a custom background, but hasn't been initialized yet.
94 SkBitmap pending_background_; 61 SkBitmap pending_background_;
95 62
96 // What we should set the preferred width to once the ExtensionView has 63 // What we should set the preferred width to once the ExtensionView has
97 // loaded. 64 // loaded.
98 gfx::Size pending_preferred_size_; 65 gfx::Size pending_preferred_size_;
99 66
100 Container* container_; 67 ExtensionViewContainer* container_; // weak
101 68
102 DISALLOW_COPY_AND_ASSIGN(ExtensionViewMac); 69 DISALLOW_COPY_AND_ASSIGN(ExtensionViewMac);
103 }; 70 };
104 71
105 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_ 72 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698