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

Side by Side Diff: chrome/browser/ui/views/extensions/extension_view.cc

Issue 7057014: Variety of tweaks to View API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/views/extensions/extension_view.h" 5 #include "chrome/browser/ui/views/extensions/extension_view.h"
6 6
7 #include "chrome/browser/extensions/extension_host.h" 7 #include "chrome/browser/extensions/extension_host.h"
8 #include "chrome/browser/ui/views/extensions/extension_popup.h" 8 #include "chrome/browser/ui/views/extensions/extension_popup.h"
9 #include "content/browser/renderer_host/render_view_host.h" 9 #include "content/browser/renderer_host/render_view_host.h"
10 #include "content/browser/renderer_host/render_widget_host_view.h" 10 #include "content/browser/renderer_host/render_widget_host_view.h"
(...skipping 11 matching lines...) Expand all
22 : host_(host), 22 : host_(host),
23 browser_(browser), 23 browser_(browser),
24 initialized_(false), 24 initialized_(false),
25 container_(NULL), 25 container_(NULL),
26 is_clipped_(false) { 26 is_clipped_(false) {
27 host_->set_view(this); 27 host_->set_view(this);
28 28
29 // This view needs to be focusable so it can act as the focused view for the 29 // This view needs to be focusable so it can act as the focused view for the
30 // focus manager. This is required to have SkipDefaultKeyEventProcessing 30 // focus manager. This is required to have SkipDefaultKeyEventProcessing
31 // called so the tab key events are forwarded to the renderer. 31 // called so the tab key events are forwarded to the renderer.
32 SetFocusable(true); 32 set_focusable(true);
33 } 33 }
34 34
35 ExtensionView::~ExtensionView() { 35 ExtensionView::~ExtensionView() {
36 if (parent()) 36 if (parent())
37 parent()->RemoveChildView(this); 37 parent()->RemoveChildView(this);
38 CleanUp(); 38 CleanUp();
39 } 39 }
40 40
41 const Extension* ExtensionView::extension() const { 41 const Extension* ExtensionView::extension() const {
42 return host_->extension(); 42 return host_->extension();
43 } 43 }
44 44
45 RenderViewHost* ExtensionView::render_view_host() const { 45 RenderViewHost* ExtensionView::render_view_host() const {
46 return host_->render_view_host(); 46 return host_->render_view_host();
47 } 47 }
48 48
49 void ExtensionView::DidStopLoading() { 49 void ExtensionView::DidStopLoading() {
50 ShowIfCompletelyLoaded(); 50 ShowIfCompletelyLoaded();
51 } 51 }
52 52
53 void ExtensionView::SetIsClipped(bool is_clipped) { 53 void ExtensionView::SetIsClipped(bool is_clipped) {
54 if (is_clipped_ != is_clipped) { 54 if (is_clipped_ != is_clipped) {
55 is_clipped_ = is_clipped; 55 is_clipped_ = is_clipped;
56 if (IsVisible()) 56 if (visible())
57 ShowIfCompletelyLoaded(); 57 ShowIfCompletelyLoaded();
58 } 58 }
59 } 59 }
60 60
61 gfx::NativeCursor ExtensionView::GetCursor(const views::MouseEvent& event) { 61 gfx::NativeCursor ExtensionView::GetCursor(const views::MouseEvent& event) {
62 return NULL; 62 return NULL;
63 } 63 }
64 64
65 void ExtensionView::SetVisible(bool is_visible) { 65 void ExtensionView::SetVisible(bool is_visible) {
66 if (is_visible != IsVisible()) { 66 if (is_visible != visible()) {
67 NativeViewHost::SetVisible(is_visible); 67 NativeViewHost::SetVisible(is_visible);
68 68
69 // Also tell RenderWidgetHostView the new visibility. Despite its name, it 69 // Also tell RenderWidgetHostView the new visibility. Despite its name, it
70 // is not part of the View hierarchy and does not know about the change 70 // is not part of the View hierarchy and does not know about the change
71 // unless we tell it. 71 // unless we tell it.
72 if (render_view_host()->view()) { 72 if (render_view_host()->view()) {
73 if (is_visible) 73 if (is_visible)
74 render_view_host()->view()->Show(); 74 render_view_host()->view()->Show();
75 else 75 else
76 render_view_host()->view()->Hide(); 76 render_view_host()->view()->Hide();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 Attach(view_gtk->GetNativeView()); 108 Attach(view_gtk->GetNativeView());
109 #else 109 #else
110 NOTIMPLEMENTED(); 110 NOTIMPLEMENTED();
111 #endif 111 #endif
112 112
113 host_->CreateRenderViewSoon(view); 113 host_->CreateRenderViewSoon(view);
114 SetVisible(false); 114 SetVisible(false);
115 } 115 }
116 116
117 void ExtensionView::ShowIfCompletelyLoaded() { 117 void ExtensionView::ShowIfCompletelyLoaded() {
118 if (IsVisible() || is_clipped_) 118 if (visible() || is_clipped_)
119 return; 119 return;
120 120
121 // We wait to show the ExtensionView until it has loaded, and the view has 121 // We wait to show the ExtensionView until it has loaded, and the view has
122 // actually been created. These can happen in different orders. 122 // actually been created. These can happen in different orders.
123 if (host_->did_stop_loading()) { 123 if (host_->did_stop_loading()) {
124 SetVisible(true); 124 SetVisible(true);
125 UpdatePreferredSize(pending_preferred_size_); 125 UpdatePreferredSize(pending_preferred_size_);
126 } 126 }
127 } 127 }
128 128
(...skipping 10 matching lines...) Expand all
139 render_view_host()->view()->SetBackground(background); 139 render_view_host()->view()->SetBackground(background);
140 } else { 140 } else {
141 pending_background_ = background; 141 pending_background_ = background;
142 } 142 }
143 ShowIfCompletelyLoaded(); 143 ShowIfCompletelyLoaded();
144 } 144 }
145 145
146 void ExtensionView::UpdatePreferredSize(const gfx::Size& new_size) { 146 void ExtensionView::UpdatePreferredSize(const gfx::Size& new_size) {
147 // Don't actually do anything with this information until we have been shown. 147 // Don't actually do anything with this information until we have been shown.
148 // Size changes will not be honored by lower layers while we are hidden. 148 // Size changes will not be honored by lower layers while we are hidden.
149 if (!IsVisible()) { 149 if (!visible()) {
150 pending_preferred_size_ = new_size; 150 pending_preferred_size_ = new_size;
151 return; 151 return;
152 } 152 }
153 153
154 gfx::Size preferred_size = GetPreferredSize(); 154 gfx::Size preferred_size = GetPreferredSize();
155 if (new_size != preferred_size) 155 if (new_size != preferred_size)
156 SetPreferredSize(new_size); 156 SetPreferredSize(new_size);
157 } 157 }
158 158
159 void ExtensionView::ViewHierarchyChanged(bool is_add, 159 void ExtensionView::ViewHierarchyChanged(bool is_add,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 render_view_host()->view()->SetBackground(pending_background_); 198 render_view_host()->view()->SetBackground(pending_background_);
199 pending_background_.reset(); 199 pending_background_.reset();
200 } 200 }
201 201
202 // Tell the renderer not to draw scroll bars in popups unless the 202 // Tell the renderer not to draw scroll bars in popups unless the
203 // popups are at the maximum allowed size. 203 // popups are at the maximum allowed size.
204 gfx::Size largest_popup_size(ExtensionPopup::kMaxWidth, 204 gfx::Size largest_popup_size(ExtensionPopup::kMaxWidth,
205 ExtensionPopup::kMaxHeight); 205 ExtensionPopup::kMaxHeight);
206 host_->DisableScrollbarsForSmallWindows(largest_popup_size); 206 host_->DisableScrollbarsForSmallWindows(largest_popup_size);
207 } 207 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/extensions/extension_installed_bubble.cc ('k') | chrome/browser/ui/views/find_bar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698