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

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

Powered by Google App Engine
This is Rietveld 408576698