Chromium Code Reviews| Index: ui/base/web_contents_sizer.cc |
| diff --git a/ui/base/web_contents_sizer.cc b/ui/base/web_contents_sizer.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6417e537612a6fdc82aaecd7bbf93d2ebbae9e3a |
| --- /dev/null |
| +++ b/ui/base/web_contents_sizer.cc |
| @@ -0,0 +1,35 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ui/base/web_contents_sizer.h" |
| + |
| +#include "content/public/browser/web_contents.h" |
| +#include "content/public/browser/web_contents_view.h" |
| + |
| +#if defined(USE_AURA) |
| +#include "ui/aura/window.h" |
| +#elif defined(TOOLKIT_GTK) |
| +#include <gtk/gtk.h> |
| +#elif defined(OS_ANDROID) |
|
sky
2014/04/03 15:05:51
Why the empty elif?
|
| +#endif |
| + |
| +namespace ui { |
| + |
| +void ResizeWebContents(content::WebContents* web_contents, |
| + const gfx::Size& new_size) { |
| +#if defined(USE_AURA) |
| + gfx::NativeView view = web_contents->GetView()->GetNativeView(); |
|
sky
2014/04/03 15:05:51
gfx::NativeView->aura::Window
|
| + gfx::Rect rect = view->bounds(); |
| + rect.set_size(new_size); |
| + view->SetBounds(rect); |
|
sky
2014/04/03 15:05:51
window->SetBounds(gfx::Rect(window->bounds().size(
|
| +#elif defined(TOOLKIT_GTK) |
| + gfx::NativeView view = web_contents->GetView()->GetNativeView(); |
| + gtk_widget_set_size_request(view, new_size.width(), new_size.height()); |
| +#elif defined(OS_ANDROID) |
| + content::RenderWidgetHostView* view = web_contents->GetRenderWidgetHostView(); |
| + view->SetSize(new_size); |
| +#endif |
| +} |
| + |
| +} // namespace ui |