| 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 "mandoline/ui/browser/browser.h" | 8 #include "mandoline/ui/browser/browser.h" |
| 9 #include "mojo/converters/geometry/geometry_type_converters.h" | 9 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 10 #include "ui/gfx/geometry/rect.h" | 10 #include "ui/gfx/geometry/rect.h" |
| 11 | 11 |
| 12 namespace mandoline { | 12 namespace mandoline { |
| 13 | 13 |
| 14 class Browser; | 14 class Browser; |
| 15 | 15 |
| 16 AndroidUI::AndroidUI(Browser* browser, mojo::ApplicationImpl* application_impl) | 16 AndroidUI::AndroidUI(Browser* browser, mojo::ApplicationImpl* application_impl) |
| 17 : browser_(browser), | 17 : browser_(browser), |
| 18 application_impl_(application_impl), | 18 application_impl_(application_impl), |
| 19 root_(nullptr), | 19 root_(nullptr) {} |
| 20 content_(nullptr) {} | |
| 21 | 20 |
| 22 AndroidUI::~AndroidUI() { | 21 AndroidUI::~AndroidUI() { |
| 23 root_->RemoveObserver(this); | 22 root_->RemoveObserver(this); |
| 24 } | 23 } |
| 25 | 24 |
| 26 void AndroidUI::Init(mojo::View* root) { | 25 void AndroidUI::Init(mojo::View* root) { |
| 27 root_ = root; | 26 root_ = root; |
| 28 root_->AddObserver(this); | 27 root_->AddObserver(this); |
| 29 | 28 |
| 30 browser_->content()->SetBounds(root_->bounds()); | 29 browser_->content()->SetBounds(root_->bounds()); |
| 31 } | 30 } |
| 32 | 31 |
| 33 void AndroidUI::OnURLChanged() { | 32 void AndroidUI::OnURLChanged() { |
| 34 } | 33 } |
| 35 | 34 |
| 36 void AndroidUI::OnViewBoundsChanged(mojo::View* view, | 35 void AndroidUI::OnViewBoundsChanged(mojo::View* view, |
| 37 const mojo::Rect& old_bounds, | 36 const mojo::Rect& old_bounds, |
| 38 const mojo::Rect& new_bounds) { | 37 const mojo::Rect& new_bounds) { |
| 39 content_->SetBounds( | 38 browser_->content()->SetBounds( |
| 40 *mojo::Rect::From(gfx::Rect(0, 0, new_bounds.width, new_bounds.height))); | 39 *mojo::Rect::From(gfx::Rect(0, 0, new_bounds.width, new_bounds.height))); |
| 41 } | 40 } |
| 42 | 41 |
| 43 // static | 42 // static |
| 44 BrowserUI* BrowserUI::Create(Browser* browser, | 43 BrowserUI* BrowserUI::Create(Browser* browser, |
| 45 mojo::ApplicationImpl* application_impl) { | 44 mojo::ApplicationImpl* application_impl) { |
| 46 return new AndroidUI(browser, application_impl); | 45 return new AndroidUI(browser, application_impl); |
| 47 } | 46 } |
| 48 | 47 |
| 49 } // namespace mandoline | 48 } // namespace mandoline |
| OLD | NEW |