OLD | NEW |
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 "examples/wm_flow/wm/frame_controller.h" | 5 #include "examples/wm_flow/wm/frame_controller.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "mojo/converters/geometry/geometry_type_converters.h" | 9 #include "mojo/converters/geometry/geometry_type_converters.h" |
10 #include "mojo/services/public/cpp/view_manager/view.h" | 10 #include "mojo/services/public/cpp/view_manager/view.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 DISALLOW_COPY_AND_ASSIGN(FrameEventHandler); | 92 DISALLOW_COPY_AND_ASSIGN(FrameEventHandler); |
93 }; | 93 }; |
94 | 94 |
95 //////////////////////////////////////////////////////////////////////////////// | 95 //////////////////////////////////////////////////////////////////////////////// |
96 // FrameController, public: | 96 // FrameController, public: |
97 | 97 |
98 FrameController::FrameController( | 98 FrameController::FrameController( |
99 mojo::Shell* shell, | 99 mojo::Shell* shell, |
100 mojo::View* view, | 100 mojo::View* view, |
101 mojo::View** app_view, | 101 mojo::View** app_view, |
102 aura::client::ActivationClient* activation_client, | |
103 mojo::WindowManagerApp* window_manager_app) | 102 mojo::WindowManagerApp* window_manager_app) |
104 : view_(view), | 103 : view_(view), |
105 app_view_(mojo::View::Create(view->view_manager())), | 104 app_view_(mojo::View::Create(view->view_manager())), |
106 frame_view_(new views::View), | 105 frame_view_(new views::View), |
107 frame_view_layout_manager_(new LayoutManager(this)), | 106 frame_view_layout_manager_(new LayoutManager(this)), |
108 widget_(new views::Widget), | 107 widget_(new views::Widget), |
109 maximized_(false), | 108 maximized_(false), |
110 activation_client_(activation_client), | |
111 window_manager_app_(window_manager_app) { | 109 window_manager_app_(window_manager_app) { |
112 view_->AddChild(app_view_); | 110 view_->AddChild(app_view_); |
113 view_->AddObserver(this); | 111 view_->AddObserver(this); |
114 *app_view = app_view_; | 112 *app_view = app_view_; |
115 frame_view_->set_background( | 113 frame_view_->set_background( |
116 views::Background::CreateSolidBackground(SK_ColorBLUE)); | 114 views::Background::CreateSolidBackground(SK_ColorBLUE)); |
117 frame_view_->SetLayoutManager(frame_view_layout_manager_); | 115 frame_view_->SetLayoutManager(frame_view_layout_manager_); |
118 frame_event_handler_.reset(new FrameEventHandler(this)); | 116 frame_event_handler_.reset(new FrameEventHandler(this)); |
119 frame_view_->AddPreTargetHandler(frame_event_handler_.get()); | 117 frame_view_->AddPreTargetHandler(frame_event_handler_.get()); |
120 views::Widget::InitParams params( | 118 views::Widget::InitParams params( |
(...skipping 18 matching lines...) Expand all Loading... |
139 if (!maximized_) | 137 if (!maximized_) |
140 restored_bounds_ = view_->bounds().To<gfx::Rect>(); | 138 restored_bounds_ = view_->bounds().To<gfx::Rect>(); |
141 maximized_ = !maximized_; | 139 maximized_ = !maximized_; |
142 if (maximized_) | 140 if (maximized_) |
143 view_->SetBounds(view_->parent()->bounds()); | 141 view_->SetBounds(view_->parent()->bounds()); |
144 else | 142 else |
145 view_->SetBounds(*mojo::Rect::From(restored_bounds_)); | 143 view_->SetBounds(*mojo::Rect::From(restored_bounds_)); |
146 } | 144 } |
147 | 145 |
148 void FrameController::ActivateWindow() { | 146 void FrameController::ActivateWindow() { |
149 aura::Window* window = window_manager_app_->GetWindowForViewId(view_->id()); | 147 window_manager_app_->focus_controller()->ActivateView(view_); |
150 activation_client_->ActivateWindow(window); | |
151 } | 148 } |
152 | 149 |
153 //////////////////////////////////////////////////////////////////////////////// | 150 //////////////////////////////////////////////////////////////////////////////// |
154 // FrameController, mojo::ViewObserver implementation: | 151 // FrameController, mojo::ViewObserver implementation: |
155 | 152 |
156 void FrameController::OnViewDestroyed(mojo::View* view) { | 153 void FrameController::OnViewDestroyed(mojo::View* view) { |
157 view_->RemoveObserver(this); | 154 view_->RemoveObserver(this); |
158 delete this; | 155 delete this; |
159 } | 156 } |
OLD | NEW |