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 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "content/public/browser/web_contents_delegate.h" | 10 #include "content/public/browser/web_contents_delegate.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 // being screen-captured, the view will be centered within WebView, sized to | 31 // being screen-captured, the view will be centered within WebView, sized to |
32 // the aspect ratio of the capture video resolution, and scaling will be avoided | 32 // the aspect ratio of the capture video resolution, and scaling will be avoided |
33 // whenever possible. | 33 // whenever possible. |
34 class WEBVIEW_EXPORT WebView : public View, | 34 class WEBVIEW_EXPORT WebView : public View, |
35 public content::WebContentsDelegate, | 35 public content::WebContentsDelegate, |
36 public content::WebContentsObserver { | 36 public content::WebContentsObserver { |
37 public: | 37 public: |
38 static const char kViewClassName[]; | 38 static const char kViewClassName[]; |
39 | 39 |
40 explicit WebView(content::BrowserContext* browser_context); | 40 explicit WebView(content::BrowserContext* browser_context); |
41 virtual ~WebView(); | 41 ~WebView() override; |
42 | 42 |
43 // This creates a WebContents if none is yet associated with this WebView. The | 43 // This creates a WebContents if none is yet associated with this WebView. The |
44 // WebView owns this implicitly created WebContents. | 44 // WebView owns this implicitly created WebContents. |
45 content::WebContents* GetWebContents(); | 45 content::WebContents* GetWebContents(); |
46 | 46 |
47 // WebView does not assume ownership of WebContents set via this method, only | 47 // WebView does not assume ownership of WebContents set via this method, only |
48 // those it implicitly creates via GetWebContents() above. | 48 // those it implicitly creates via GetWebContents() above. |
49 void SetWebContents(content::WebContents* web_contents); | 49 void SetWebContents(content::WebContents* web_contents); |
50 | 50 |
51 // If |mode| is true, WebView will register itself with WebContents as a | 51 // If |mode| is true, WebView will register itself with WebContents as a |
(...skipping 30 matching lines...) Expand all Loading... |
82 // processed. Default is false. | 82 // processed. Default is false. |
83 void set_allow_accelerators(bool allow_accelerators) { | 83 void set_allow_accelerators(bool allow_accelerators) { |
84 allow_accelerators_ = allow_accelerators; | 84 allow_accelerators_ = allow_accelerators; |
85 } | 85 } |
86 | 86 |
87 // Sets the preferred size. If empty, View's implementation of | 87 // Sets the preferred size. If empty, View's implementation of |
88 // GetPreferredSize() is used. | 88 // GetPreferredSize() is used. |
89 void SetPreferredSize(const gfx::Size& preferred_size); | 89 void SetPreferredSize(const gfx::Size& preferred_size); |
90 | 90 |
91 // Overridden from View: | 91 // Overridden from View: |
92 virtual const char* GetClassName() const override; | 92 const char* GetClassName() const override; |
93 virtual ui::TextInputClient* GetTextInputClient() override; | 93 ui::TextInputClient* GetTextInputClient() override; |
94 | 94 |
95 protected: | 95 protected: |
96 // Swaps the owned WebContents |wc_owner_| with |new_web_contents|. Returns | 96 // Swaps the owned WebContents |wc_owner_| with |new_web_contents|. Returns |
97 // the previously owned WebContents. | 97 // the previously owned WebContents. |
98 scoped_ptr<content::WebContents> SwapWebContents( | 98 scoped_ptr<content::WebContents> SwapWebContents( |
99 scoped_ptr<content::WebContents> new_web_contents); | 99 scoped_ptr<content::WebContents> new_web_contents); |
100 | 100 |
101 // Overridden from View: | 101 // Overridden from View: |
102 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) override; | 102 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
103 virtual void ViewHierarchyChanged( | 103 void ViewHierarchyChanged( |
104 const ViewHierarchyChangedDetails& details) override; | 104 const ViewHierarchyChangedDetails& details) override; |
105 virtual bool SkipDefaultKeyEventProcessing( | 105 bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) override; |
106 const ui::KeyEvent& event) override; | 106 void OnFocus() override; |
107 virtual void OnFocus() override; | 107 void AboutToRequestFocusFromTabTraversal(bool reverse) override; |
108 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) override; | 108 void GetAccessibleState(ui::AXViewState* state) override; |
109 virtual void GetAccessibleState(ui::AXViewState* state) override; | 109 gfx::NativeViewAccessible GetNativeViewAccessible() override; |
110 virtual gfx::NativeViewAccessible GetNativeViewAccessible() override; | 110 gfx::Size GetPreferredSize() const override; |
111 virtual gfx::Size GetPreferredSize() const override; | |
112 | 111 |
113 // Overridden from content::WebContentsDelegate: | 112 // Overridden from content::WebContentsDelegate: |
114 virtual void WebContentsFocused(content::WebContents* web_contents) override; | 113 void WebContentsFocused(content::WebContents* web_contents) override; |
115 virtual bool EmbedsFullscreenWidget() const override; | 114 bool EmbedsFullscreenWidget() const override; |
116 | 115 |
117 // Overridden from content::WebContentsObserver: | 116 // Overridden from content::WebContentsObserver: |
118 virtual void RenderViewDeleted( | 117 void RenderViewDeleted(content::RenderViewHost* render_view_host) override; |
119 content::RenderViewHost* render_view_host) override; | 118 void RenderProcessGone(base::TerminationStatus status) override; |
120 virtual void RenderProcessGone(base::TerminationStatus status) override; | 119 void RenderViewHostChanged(content::RenderViewHost* old_host, |
121 virtual void RenderViewHostChanged( | 120 content::RenderViewHost* new_host) override; |
122 content::RenderViewHost* old_host, | 121 void DidShowFullscreenWidget(int routing_id) override; |
123 content::RenderViewHost* new_host) override; | 122 void DidDestroyFullscreenWidget(int routing_id) override; |
124 virtual void DidShowFullscreenWidget(int routing_id) override; | 123 void DidToggleFullscreenModeForTab(bool entered_fullscreen) override; |
125 virtual void DidDestroyFullscreenWidget(int routing_id) override; | 124 void DidAttachInterstitialPage() override; |
126 virtual void DidToggleFullscreenModeForTab(bool entered_fullscreen) override; | 125 void DidDetachInterstitialPage() override; |
127 virtual void DidAttachInterstitialPage() override; | |
128 virtual void DidDetachInterstitialPage() override; | |
129 // Workaround for MSVC++ linker bug/feature that requires | 126 // Workaround for MSVC++ linker bug/feature that requires |
130 // instantiation of the inline IPC::Listener methods in all translation units. | 127 // instantiation of the inline IPC::Listener methods in all translation units. |
131 virtual void OnChannelConnected(int32 peer_id) override {} | 128 void OnChannelConnected(int32 peer_id) override {} |
132 virtual void OnChannelError() override {} | 129 void OnChannelError() override {} |
133 virtual void OnBadMessageReceived(const IPC::Message& message) override {} | 130 void OnBadMessageReceived(const IPC::Message& message) override {} |
134 | 131 |
135 private: | 132 private: |
136 void AttachWebContents(); | 133 void AttachWebContents(); |
137 void DetachWebContents(); | 134 void DetachWebContents(); |
138 void ReattachForFullscreenChange(bool enter_fullscreen); | 135 void ReattachForFullscreenChange(bool enter_fullscreen); |
139 void NotifyMaybeTextInputClientChanged(); | 136 void NotifyMaybeTextInputClientChanged(); |
140 | 137 |
141 // Create a regular or test web contents (based on whether we're running | 138 // Create a regular or test web contents (based on whether we're running |
142 // in a unit test or not). | 139 // in a unit test or not). |
143 content::WebContents* CreateWebContents( | 140 content::WebContents* CreateWebContents( |
(...skipping 11 matching lines...) Expand all Loading... |
155 content::BrowserContext* browser_context_; | 152 content::BrowserContext* browser_context_; |
156 bool allow_accelerators_; | 153 bool allow_accelerators_; |
157 gfx::Size preferred_size_; | 154 gfx::Size preferred_size_; |
158 | 155 |
159 DISALLOW_COPY_AND_ASSIGN(WebView); | 156 DISALLOW_COPY_AND_ASSIGN(WebView); |
160 }; | 157 }; |
161 | 158 |
162 } // namespace views | 159 } // namespace views |
163 | 160 |
164 #endif // UI_VIEWS_CONTROLS_WEBVIEW_WEBVIEW_H_ | 161 #endif // UI_VIEWS_CONTROLS_WEBVIEW_WEBVIEW_H_ |
OLD | NEW |