OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mandoline/ui/browser/android/android_ui.h" | 5 #include "mandoline/ui/browser/android/android_ui.h" |
6 | 6 |
7 #include "components/view_manager/public/cpp/view.h" | 7 #include "components/view_manager/public/cpp/view.h" |
| 8 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 9 #include "ui/gfx/geometry/rect.h" |
8 | 10 |
9 namespace mandoline { | 11 namespace mandoline { |
10 | 12 |
11 AndroidUI::AndroidUI(Browser* browser, mojo::Shell* shell) | 13 AndroidUI::AndroidUI(Browser* browser, mojo::Shell* shell) |
12 : browser_(browser), | 14 : browser_(browser), |
13 shell_(shell), | 15 shell_(shell), |
14 root_(nullptr), | 16 root_(nullptr), |
15 content_(nullptr) {} | 17 content_(nullptr) {} |
16 AndroidUI::~AndroidUI() {} | 18 |
| 19 AndroidUI::~AndroidUI() { |
| 20 root_->RemoveObserver(this); |
| 21 } |
17 | 22 |
18 void AndroidUI::Init(mojo::View* root, mojo::View* content) { | 23 void AndroidUI::Init(mojo::View* root, mojo::View* content) { |
19 root_ = root; | 24 root_ = root; |
| 25 root_->AddObserver(this); |
20 content_ = content; | 26 content_ = content; |
21 | 27 |
22 content_->SetBounds(root_->bounds()); | 28 content_->SetBounds(root_->bounds()); |
23 } | 29 } |
24 | 30 |
| 31 void AndroidUI::OnViewBoundsChanged(mojo::View* view, |
| 32 const mojo::Rect& old_bounds, |
| 33 const mojo::Rect& new_bounds) { |
| 34 content_->SetBounds( |
| 35 *mojo::Rect::From(gfx::Rect(0, 0, new_bounds.width, new_bounds.height))); |
| 36 } |
| 37 |
25 // static | 38 // static |
26 BrowserUI* BrowserUI::Create(Browser* browser, mojo::Shell* shell) { | 39 BrowserUI* BrowserUI::Create(Browser* browser, mojo::Shell* shell) { |
27 return new AndroidUI(browser, shell); | 40 return new AndroidUI(browser, shell); |
28 } | 41 } |
29 | 42 |
30 } // namespace mandoline | 43 } // namespace mandoline |
OLD | NEW |