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

Side by Side Diff: mojo/examples/embedded_app/embedded_app.cc

Issue 324753002: Fix ownership bug with ViewObserver::OnViewInputEvent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: no pass Created 6 years, 6 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
« no previous file with comments | « no previous file | mojo/examples/nesting_app/nesting_app.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "mojo/examples/window_manager/window_manager.mojom.h" 7 #include "mojo/examples/window_manager/window_manager.mojom.h"
8 #include "mojo/public/cpp/application/application.h" 8 #include "mojo/public/cpp/application/application.h"
9 #include "mojo/services/public/cpp/view_manager/view.h" 9 #include "mojo/services/public/cpp/view_manager/view.h"
10 #include "mojo/services/public/cpp/view_manager/view_manager.h" 10 #include "mojo/services/public/cpp/view_manager/view_manager.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } 59 }
60 virtual void OnRootRemoved(ViewManager* view_manager, 60 virtual void OnRootRemoved(ViewManager* view_manager,
61 ViewTreeNode* root) OVERRIDE { 61 ViewTreeNode* root) OVERRIDE {
62 std::map<ViewTreeNode*, View*>::const_iterator it = 62 std::map<ViewTreeNode*, View*>::const_iterator it =
63 views_to_reap_.find(root); 63 views_to_reap_.find(root);
64 if (it != views_to_reap_.end()) 64 if (it != views_to_reap_.end())
65 it->second->Destroy(); 65 it->second->Destroy();
66 } 66 }
67 67
68 // Overridden from ViewObserver: 68 // Overridden from ViewObserver:
69 virtual void OnViewInputEvent(View* view, EventPtr event) OVERRIDE { 69 virtual void OnViewInputEvent(View* view, const EventPtr& event) OVERRIDE {
70 if (event->action == ui::ET_MOUSE_RELEASED) 70 if (event->action == ui::ET_MOUSE_RELEASED)
71 window_manager_->CloseWindow(view->node()->id()); 71 window_manager_->CloseWindow(view->node()->id());
72 } 72 }
73 73
74 // Overridden from ViewTreeNodeObserver: 74 // Overridden from ViewTreeNodeObserver:
75 virtual void OnNodeActiveViewChange( 75 virtual void OnNodeActiveViewChange(
76 ViewTreeNode* node, 76 ViewTreeNode* node,
77 View* old_view, 77 View* old_view,
78 View* new_view, 78 View* new_view,
79 ViewTreeNodeObserver::DispositionChangePhase phase) OVERRIDE { 79 ViewTreeNodeObserver::DispositionChangePhase phase) OVERRIDE {
80 if (new_view == 0) 80 if (new_view == 0)
81 views_to_reap_[node] = old_view; 81 views_to_reap_[node] = old_view;
82 } 82 }
83 83
84 IWindowManagerPtr window_manager_; 84 IWindowManagerPtr window_manager_;
85 std::map<ViewTreeNode*, View*> views_to_reap_; 85 std::map<ViewTreeNode*, View*> views_to_reap_;
86 86
87 DISALLOW_COPY_AND_ASSIGN(EmbeddedApp); 87 DISALLOW_COPY_AND_ASSIGN(EmbeddedApp);
88 }; 88 };
89 89
90 } // namespace examples 90 } // namespace examples
91 91
92 // static 92 // static
93 Application* Application::Create() { 93 Application* Application::Create() {
94 return new examples::EmbeddedApp; 94 return new examples::EmbeddedApp;
95 } 95 }
96 96
97 } // namespace mojo 97 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/examples/nesting_app/nesting_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698