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

Side by Side Diff: views/controls/native/native_view_host.cc

Issue 510004: Fix crash/leak issue in native_view_host_gtk.cc. (Closed)
Patch Set: " Created 10 years, 12 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
« no previous file with comments | « views/controls/native/native_view_host.h ('k') | views/controls/native/native_view_host_gtk.h » ('j') | 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 "views/controls/native/native_view_host.h" 5 #include "views/controls/native/native_view_host.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "app/gfx/canvas.h" 8 #include "app/gfx/canvas.h"
9 #include "views/controls/native/native_view_host_wrapper.h" 9 #include "views/controls/native/native_view_host_wrapper.h"
10 #include "views/widget/widget.h" 10 #include "views/widget/widget.h"
(...skipping 22 matching lines...) Expand all
33 // The native widget is placed relative to the root. As such, we need to 33 // The native widget is placed relative to the root. As such, we need to
34 // know when the position of any ancestor changes, or our visibility relative 34 // know when the position of any ancestor changes, or our visibility relative
35 // to other views changed as it'll effect our position relative to the root. 35 // to other views changed as it'll effect our position relative to the root.
36 SetNotifyWhenVisibleBoundsInRootChanges(true); 36 SetNotifyWhenVisibleBoundsInRootChanges(true);
37 } 37 }
38 38
39 NativeViewHost::~NativeViewHost() { 39 NativeViewHost::~NativeViewHost() {
40 } 40 }
41 41
42 void NativeViewHost::Attach(gfx::NativeView native_view) { 42 void NativeViewHost::Attach(gfx::NativeView native_view) {
43 DCHECK(native_view);
43 DCHECK(!native_view_); 44 DCHECK(!native_view_);
44 native_view_ = native_view; 45 native_view_ = native_view;
45 // If set_focus_view() has not been invoked, this view is the one that should 46 // If set_focus_view() has not been invoked, this view is the one that should
46 // be seen as focused when the native view receives focus. 47 // be seen as focused when the native view receives focus.
47 if (!focus_view_) 48 if (!focus_view_)
48 focus_view_ = this; 49 focus_view_ = this;
49 native_wrapper_->NativeViewAttached(); 50 native_wrapper_->NativeViewAttached();
50 } 51 }
51 52
52 void NativeViewHost::Detach() { 53 void NativeViewHost::Detach() {
53 DCHECK(native_view_); 54 Detach(false);
54 native_wrapper_->NativeViewDetaching();
55 native_view_ = NULL;
56 } 55 }
57 56
58 void NativeViewHost::SetPreferredSize(const gfx::Size& size) { 57 void NativeViewHost::SetPreferredSize(const gfx::Size& size) {
59 preferred_size_ = size; 58 preferred_size_ = size;
60 PreferredSizeChanged(); 59 PreferredSizeChanged();
61 } 60 }
62 61
63 void NativeViewHost::NativeViewDestroyed() { 62 void NativeViewHost::NativeViewDestroyed() {
64 // Detach so we can clear our state and notify the native_wrapper_ to release 63 // Detach so we can clear our state and notify the native_wrapper_ to release
65 // ref on the native view. 64 // ref on the native view.
66 Detach(); 65 Detach(true);
67 } 66 }
68 67
69 //////////////////////////////////////////////////////////////////////////////// 68 ////////////////////////////////////////////////////////////////////////////////
70 // NativeViewHost, View overrides: 69 // NativeViewHost, View overrides:
71 70
72 gfx::Size NativeViewHost::GetPreferredSize() { 71 gfx::Size NativeViewHost::GetPreferredSize() {
73 return preferred_size_; 72 return preferred_size_;
74 } 73 }
75 74
76 void NativeViewHost::Layout() { 75 void NativeViewHost::Layout() {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 138 }
140 139
141 std::string NativeViewHost::GetClassName() const { 140 std::string NativeViewHost::GetClassName() const {
142 return kViewClassName; 141 return kViewClassName;
143 } 142 }
144 143
145 void NativeViewHost::Focus() { 144 void NativeViewHost::Focus() {
146 native_wrapper_->SetFocus(); 145 native_wrapper_->SetFocus();
147 } 146 }
148 147
148 ////////////////////////////////////////////////////////////////////////////////
149 // NativeViewHost, private:
150
151 void NativeViewHost::Detach(bool destroyed) {
152 DCHECK(native_view_);
153 native_wrapper_->NativeViewDetaching(destroyed);
154 native_view_ = NULL;
155 }
156
149 } // namespace views 157 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/native/native_view_host.h ('k') | views/controls/native/native_view_host_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698