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

Side by Side Diff: ui/views/controls/webview/webview.cc

Issue 10388203: [Views, WebIntents] Enable auto-resizing for WebContents (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Actually made resize work Created 8 years, 7 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
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 #include "ui/views/controls/webview/webview.h" 5 #include "ui/views/controls/webview/webview.h"
6 6
7 #include "content/public/browser/browser_context.h" 7 #include "content/public/browser/browser_context.h"
8 #include "content/public/browser/navigation_controller.h" 8 #include "content/public/browser/navigation_controller.h"
9 #include "content/public/browser/notification_details.h" 9 #include "content/public/browser/notification_details.h"
10 #include "content/public/browser/notification_registrar.h" 10 #include "content/public/browser/notification_registrar.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 void WebView::SetFastResize(bool fast_resize) { 72 void WebView::SetFastResize(bool fast_resize) {
73 wcv_holder_->set_fast_resize(fast_resize); 73 wcv_holder_->set_fast_resize(fast_resize);
74 } 74 }
75 75
76 void WebView::OnWebContentsFocused(content::WebContents* web_contents) { 76 void WebView::OnWebContentsFocused(content::WebContents* web_contents) {
77 FocusManager* focus_manager = GetFocusManager(); 77 FocusManager* focus_manager = GetFocusManager();
78 if (focus_manager) 78 if (focus_manager)
79 focus_manager->SetFocusedView(this); 79 focus_manager->SetFocusedView(this);
80 } 80 }
81 81
82 void WebView::SetPreferredSize(const gfx::Size& preferred_size) {
83 preferred_size_ = preferred_size;
84 }
85
82 //////////////////////////////////////////////////////////////////////////////// 86 ////////////////////////////////////////////////////////////////////////////////
83 // WebView, View overrides: 87 // WebView, View overrides:
84 88
85 std::string WebView::GetClassName() const { 89 std::string WebView::GetClassName() const {
86 return kViewClassName; 90 return kViewClassName;
87 } 91 }
88 92
89 void WebView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 93 void WebView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
90 wcv_holder_->SetSize(bounds().size()); 94 wcv_holder_->SetSize(bounds().size());
91 } 95 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 gfx::NativeViewAccessible WebView::GetNativeViewAccessible() { 134 gfx::NativeViewAccessible WebView::GetNativeViewAccessible() {
131 if (web_contents_) { 135 if (web_contents_) {
132 content::RenderWidgetHostView* host_view = 136 content::RenderWidgetHostView* host_view =
133 web_contents_->GetRenderWidgetHostView(); 137 web_contents_->GetRenderWidgetHostView();
134 if (host_view) 138 if (host_view)
135 return host_view->GetNativeViewAccessible(); 139 return host_view->GetNativeViewAccessible();
136 } 140 }
137 return View::GetNativeViewAccessible(); 141 return View::GetNativeViewAccessible();
138 } 142 }
139 143
144 gfx::Size WebView::GetPreferredSize() {
145 if (preferred_size_ == gfx::Size())
146 return View::GetPreferredSize();
147 else
148 return preferred_size_;
149 }
150
140 //////////////////////////////////////////////////////////////////////////////// 151 ////////////////////////////////////////////////////////////////////////////////
141 // WebView, content::NotificationObserver implementation: 152 // WebView, content::NotificationObserver implementation:
142 153
143 void WebView::Observe(int type, 154 void WebView::Observe(int type,
144 const content::NotificationSource& source, 155 const content::NotificationSource& source,
145 const content::NotificationDetails& details) { 156 const content::NotificationDetails& details) {
146 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) { 157 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) {
147 std::pair<content::RenderViewHost*, content::RenderViewHost*>* 158 std::pair<content::RenderViewHost*, content::RenderViewHost*>*
148 switched_details = 159 switched_details =
149 content::Details<std::pair<content::RenderViewHost*, 160 content::Details<std::pair<content::RenderViewHost*,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 site_instance, 250 site_instance,
240 MSG_ROUTING_NONE, 251 MSG_ROUTING_NONE,
241 NULL, 252 NULL,
242 NULL); 253 NULL);
243 } 254 }
244 255
245 return contents; 256 return contents;
246 } 257 }
247 258
248 } // namespace views 259 } // namespace views
OLDNEW
« ui/views/controls/webview/webview.h ('K') | « ui/views/controls/webview/webview.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698