OLD | NEW |
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 UI_VIEWS_CONTROLS_WEBVIEW_WEBVIEW_H_ | 5 #ifndef UI_VIEWS_CONTROLS_WEBVIEW_WEBVIEW_H_ |
6 #define UI_VIEWS_CONTROLS_WEBVIEW_WEBVIEW_H_ | 6 #define UI_VIEWS_CONTROLS_WEBVIEW_WEBVIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // WebContents is attached, and not rely on the delegate to | 63 // WebContents is attached, and not rely on the delegate to |
64 // forward this notification. | 64 // forward this notification. |
65 void OnWebContentsFocused(content::WebContents* web_contents); | 65 void OnWebContentsFocused(content::WebContents* web_contents); |
66 | 66 |
67 // When used to host UI, we need to explicitly allow accelerators to be | 67 // When used to host UI, we need to explicitly allow accelerators to be |
68 // processed. Default is false. | 68 // processed. Default is false. |
69 void set_allow_accelerators(bool allow_accelerators) { | 69 void set_allow_accelerators(bool allow_accelerators) { |
70 allow_accelerators_ = allow_accelerators; | 70 allow_accelerators_ = allow_accelerators; |
71 } | 71 } |
72 | 72 |
| 73 // Sets the preferred size. If empty, View's implementation of |
| 74 // GetPreferredSize() is used. |
| 75 void SetPreferredSize(const gfx::Size& preferred_size); |
| 76 |
73 // Overridden from View: | 77 // Overridden from View: |
74 virtual std::string GetClassName() const OVERRIDE; | 78 virtual std::string GetClassName() const OVERRIDE; |
75 | 79 |
76 private: | 80 private: |
77 // Overridden from View: | 81 // Overridden from View: |
78 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; | 82 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; |
79 virtual void ViewHierarchyChanged(bool is_add, | 83 virtual void ViewHierarchyChanged(bool is_add, |
80 View* parent, | 84 View* parent, |
81 View* child) OVERRIDE; | 85 View* child) OVERRIDE; |
82 virtual bool SkipDefaultKeyEventProcessing( | 86 virtual bool SkipDefaultKeyEventProcessing( |
83 const views::KeyEvent& event) OVERRIDE; | 87 const views::KeyEvent& event) OVERRIDE; |
84 virtual bool IsFocusable() const OVERRIDE; | 88 virtual bool IsFocusable() const OVERRIDE; |
85 virtual void OnFocus() OVERRIDE; | 89 virtual void OnFocus() OVERRIDE; |
86 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; | 90 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; |
87 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 91 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
88 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; | 92 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; |
| 93 virtual gfx::Size GetPreferredSize() OVERRIDE; |
89 | 94 |
90 // Overridden from content::NotificationObserver: | 95 // Overridden from content::NotificationObserver: |
91 virtual void Observe(int type, | 96 virtual void Observe(int type, |
92 const content::NotificationSource& source, | 97 const content::NotificationSource& source, |
93 const content::NotificationDetails& details) OVERRIDE; | 98 const content::NotificationDetails& details) OVERRIDE; |
94 | 99 |
95 // Overridden from content::WebContentsDelegate: | 100 // Overridden from content::WebContentsDelegate: |
96 virtual void WebContentsFocused(content::WebContents* web_contents) OVERRIDE; | 101 virtual void WebContentsFocused(content::WebContents* web_contents) OVERRIDE; |
97 | 102 |
98 void AttachWebContents(); | 103 void AttachWebContents(); |
99 void DetachWebContents(); | 104 void DetachWebContents(); |
100 | 105 |
101 void RenderViewHostChanged(content::RenderViewHost* old_host, | 106 void RenderViewHostChanged(content::RenderViewHost* old_host, |
102 content::RenderViewHost* new_host); | 107 content::RenderViewHost* new_host); |
103 void WebContentsDestroyed(content::WebContents* web_contents); | 108 void WebContentsDestroyed(content::WebContents* web_contents); |
104 | 109 |
105 // Create a regular or test web contents (based on whether we're running | 110 // Create a regular or test web contents (based on whether we're running |
106 // in a unit test or not). | 111 // in a unit test or not). |
107 content::WebContents* CreateWebContents( | 112 content::WebContents* CreateWebContents( |
108 content::BrowserContext* browser_context, | 113 content::BrowserContext* browser_context, |
109 content::SiteInstance* site_instance); | 114 content::SiteInstance* site_instance); |
110 | 115 |
111 | 116 |
112 NativeViewHost* wcv_holder_; | 117 NativeViewHost* wcv_holder_; |
113 scoped_ptr<content::WebContents> wc_owner_; | 118 scoped_ptr<content::WebContents> wc_owner_; |
114 content::WebContents* web_contents_; | 119 content::WebContents* web_contents_; |
115 content::BrowserContext* browser_context_; | 120 content::BrowserContext* browser_context_; |
116 content::NotificationRegistrar registrar_; | 121 content::NotificationRegistrar registrar_; |
117 bool allow_accelerators_; | 122 bool allow_accelerators_; |
| 123 gfx::Size preferred_size_; |
118 | 124 |
119 DISALLOW_COPY_AND_ASSIGN(WebView); | 125 DISALLOW_COPY_AND_ASSIGN(WebView); |
120 }; | 126 }; |
121 | 127 |
122 } // namespace views | 128 } // namespace views |
123 | 129 |
124 #endif // UI_VIEWS_CONTROLS_WEBVIEW_WEBVIEW_H_ | 130 #endif // UI_VIEWS_CONTROLS_WEBVIEW_WEBVIEW_H_ |
OLD | NEW |