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

Side by Side Diff: chrome/browser/gtk/extension_view_gtk.cc

Issue 505047: Limit the size of extension views on linux.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: // namespace Created 11 years 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
« no previous file with comments | « chrome/browser/gtk/extension_view_gtk.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/gtk/extension_view_gtk.h" 5 #include "chrome/browser/gtk/extension_view_gtk.h"
6 6
7 #include "chrome/browser/extensions/extension_host.h" 7 #include "chrome/browser/extensions/extension_host.h"
8 #include "chrome/browser/renderer_host/render_view_host.h" 8 #include "chrome/browser/renderer_host/render_view_host.h"
9 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" 9 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
10 10
11 namespace {
12
13 // The minimum/maximum dimensions of the extension view.
14 // The minimum is just a little larger than the size of a browser action button.
15 // The maximum is an arbitrary number that should be smaller than most screens.
16 const int kMinWidth = 25;
17 const int kMinHeight = 25;
18 const int kMaxWidth = 800;
19 const int kMaxHeight = 600;
20
21 } // namespace
22
11 ExtensionViewGtk::ExtensionViewGtk(ExtensionHost* extension_host, 23 ExtensionViewGtk::ExtensionViewGtk(ExtensionHost* extension_host,
12 Browser* browser) 24 Browser* browser)
13 : is_toolstrip_(false), 25 : browser_(browser),
14 browser_(browser),
15 extension_host_(extension_host), 26 extension_host_(extension_host),
16 render_widget_host_view_(NULL) { 27 render_widget_host_view_(NULL) {
17 } 28 }
18 29
19 void ExtensionViewGtk::Init() { 30 void ExtensionViewGtk::Init() {
20 CreateWidgetHostView(); 31 CreateWidgetHostView();
21 } 32 }
22 33
23 gfx::NativeView ExtensionViewGtk::native_view() { 34 gfx::NativeView ExtensionViewGtk::native_view() {
24 return render_widget_host_view_->native_view(); 35 return render_widget_host_view_->native_view();
25 } 36 }
26 37
27 RenderViewHost* ExtensionViewGtk::render_view_host() const { 38 RenderViewHost* ExtensionViewGtk::render_view_host() const {
28 return extension_host_->render_view_host(); 39 return extension_host_->render_view_host();
29 } 40 }
30 41
31 void ExtensionViewGtk::SetBackground(const SkBitmap& background) { 42 void ExtensionViewGtk::SetBackground(const SkBitmap& background) {
32 if (render_view_host()->IsRenderViewLive()) { 43 if (render_view_host()->IsRenderViewLive()) {
33 render_widget_host_view_->SetBackground(background); 44 render_widget_host_view_->SetBackground(background);
34 } else { 45 } else {
35 pending_background_ = background; 46 pending_background_ = background;
36 } 47 }
37 } 48 }
38 49
39 void ExtensionViewGtk::UpdatePreferredSize(const gfx::Size& new_size) { 50 void ExtensionViewGtk::UpdatePreferredSize(const gfx::Size& new_size) {
40 // If we are showing in a shelf, then the shelf sets our height. 51 int width = std::max(kMinWidth, std::min(kMaxWidth, new_size.width()));
41 int height = is_toolstrip() ? -1 : new_size.height(); 52 int height = std::max(kMinHeight, std::min(kMaxHeight, new_size.height()));
42 53
43 render_widget_host_view_->SetSize(gfx::Size(new_size.width(), height)); 54 render_widget_host_view_->SetSize(gfx::Size(width, height));
44 gtk_widget_set_size_request(native_view(), new_size.width(), height); 55 gtk_widget_set_size_request(native_view(), width, height);
45 } 56 }
46 57
47 void ExtensionViewGtk::CreateWidgetHostView() { 58 void ExtensionViewGtk::CreateWidgetHostView() {
48 DCHECK(!render_widget_host_view_); 59 DCHECK(!render_widget_host_view_);
49 render_widget_host_view_ = new RenderWidgetHostViewGtk(render_view_host()); 60 render_widget_host_view_ = new RenderWidgetHostViewGtk(render_view_host());
50 render_widget_host_view_->InitAsChild(); 61 render_widget_host_view_->InitAsChild();
51 62
52 extension_host_->CreateRenderViewSoon(render_widget_host_view_); 63 extension_host_->CreateRenderViewSoon(render_widget_host_view_);
53 } 64 }
54 65
55 void ExtensionViewGtk::RenderViewCreated() { 66 void ExtensionViewGtk::RenderViewCreated() {
56 if (!pending_background_.empty() && render_view_host()->view()) { 67 if (!pending_background_.empty() && render_view_host()->view()) {
57 render_widget_host_view_->SetBackground(pending_background_); 68 render_widget_host_view_->SetBackground(pending_background_);
58 pending_background_.reset(); 69 pending_background_.reset();
59 } 70 }
60 } 71 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/extension_view_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698