| 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, |
| 102 mojo::WindowManagerApp* window_manager_app) | 103 mojo::WindowManagerApp* window_manager_app) |
| 103 : view_(view), | 104 : view_(view), |
| 104 app_view_(mojo::View::Create(view->view_manager())), | 105 app_view_(mojo::View::Create(view->view_manager())), |
| 105 frame_view_(new views::View), | 106 frame_view_(new views::View), |
| 106 frame_view_layout_manager_(new LayoutManager(this)), | 107 frame_view_layout_manager_(new LayoutManager(this)), |
| 107 widget_(new views::Widget), | 108 widget_(new views::Widget), |
| 108 maximized_(false), | 109 maximized_(false), |
| 110 activation_client_(activation_client), |
| 109 window_manager_app_(window_manager_app) { | 111 window_manager_app_(window_manager_app) { |
| 110 view_->AddChild(app_view_); | 112 view_->AddChild(app_view_); |
| 111 view_->AddObserver(this); | 113 view_->AddObserver(this); |
| 112 *app_view = app_view_; | 114 *app_view = app_view_; |
| 113 frame_view_->set_background( | 115 frame_view_->set_background( |
| 114 views::Background::CreateSolidBackground(SK_ColorBLUE)); | 116 views::Background::CreateSolidBackground(SK_ColorBLUE)); |
| 115 frame_view_->SetLayoutManager(frame_view_layout_manager_); | 117 frame_view_->SetLayoutManager(frame_view_layout_manager_); |
| 116 frame_event_handler_.reset(new FrameEventHandler(this)); | 118 frame_event_handler_.reset(new FrameEventHandler(this)); |
| 117 frame_view_->AddPreTargetHandler(frame_event_handler_.get()); | 119 frame_view_->AddPreTargetHandler(frame_event_handler_.get()); |
| 118 views::Widget::InitParams params( | 120 views::Widget::InitParams params( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 137 if (!maximized_) | 139 if (!maximized_) |
| 138 restored_bounds_ = view_->bounds().To<gfx::Rect>(); | 140 restored_bounds_ = view_->bounds().To<gfx::Rect>(); |
| 139 maximized_ = !maximized_; | 141 maximized_ = !maximized_; |
| 140 if (maximized_) | 142 if (maximized_) |
| 141 view_->SetBounds(view_->parent()->bounds()); | 143 view_->SetBounds(view_->parent()->bounds()); |
| 142 else | 144 else |
| 143 view_->SetBounds(*mojo::Rect::From(restored_bounds_)); | 145 view_->SetBounds(*mojo::Rect::From(restored_bounds_)); |
| 144 } | 146 } |
| 145 | 147 |
| 146 void FrameController::ActivateWindow() { | 148 void FrameController::ActivateWindow() { |
| 147 window_manager_app_->focus_controller()->ActivateView(view_); | 149 aura::Window* window = window_manager_app_->GetWindowForViewId(view_->id()); |
| 150 activation_client_->ActivateWindow(window); |
| 148 } | 151 } |
| 149 | 152 |
| 150 //////////////////////////////////////////////////////////////////////////////// | 153 //////////////////////////////////////////////////////////////////////////////// |
| 151 // FrameController, mojo::ViewObserver implementation: | 154 // FrameController, mojo::ViewObserver implementation: |
| 152 | 155 |
| 153 void FrameController::OnViewDestroyed(mojo::View* view) { | 156 void FrameController::OnViewDestroyed(mojo::View* view) { |
| 154 view_->RemoveObserver(this); | 157 view_->RemoveObserver(this); |
| 155 delete this; | 158 delete this; |
| 156 } | 159 } |
| OLD | NEW |