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

Unified Diff: mandoline/ui/browser/browser.cc

Issue 1141453002: Makes browser resize content when root bounds change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mandoline/ui/browser/browser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mandoline/ui/browser/browser.cc
diff --git a/mandoline/ui/browser/browser.cc b/mandoline/ui/browser/browser.cc
index d62d1272e29c4d4524bd641499af556a9f9b71e8..8fe98389d81adb1c5b75f5c6a8d68f54abc5b5ea 100644
--- a/mandoline/ui/browser/browser.cc
+++ b/mandoline/ui/browser/browser.cc
@@ -9,7 +9,9 @@
#include "mandoline/ui/browser/browser_ui.h"
#include "mandoline/ui/browser/merged_service_provider.h"
#include "mojo/application/application_runner_chromium.h"
+#include "mojo/converters/geometry/geometry_type_converters.h"
#include "third_party/mojo/src/mojo/public/c/system/main.h"
+#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
namespace mandoline {
@@ -25,12 +27,21 @@ Browser::Browser()
}
Browser::~Browser() {
+ if (root_) {
+ root_->RemoveObserver(this);
+ root_ = nullptr;
+ }
}
base::WeakPtr<Browser> Browser::GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
+// Convenience method:
+void Browser::ReplaceContentWithURL(const mojo::String& url) {
sky 2015/05/11 22:01:27 I moved a couple of things to match declaration or
+ Embed(url, nullptr, nullptr);
+}
+
void Browser::Initialize(mojo::ApplicationImpl* app) {
window_manager_app_->Initialize(app);
ui_.reset(BrowserUI::Create(this, app->shell()));
@@ -71,6 +82,7 @@ void Browser::OnEmbed(
// know so much about these views. Figure out how to shift more to
// the UI class.
root_ = root;
+ root_->AddObserver(this);
content_ = root->view_manager()->CreateView();
ui_->Init(root_, content_);
@@ -94,6 +106,12 @@ void Browser::OnEmbed(
Embed(default_url_, services.Pass(), exposed_services.Pass());
}
+void Browser::OnViewManagerDisconnected(
+ mojo::ViewManager* view_manager) {
+ root_->RemoveObserver(this);
+ root_ = nullptr;
+}
+
void Browser::Embed(const mojo::String& url,
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services) {
@@ -125,14 +143,11 @@ void Browser::Create(mojo::ApplicationConnection* connection,
navigator_host_.Bind(request.Pass());
}
-void Browser::OnViewManagerDisconnected(
- mojo::ViewManager* view_manager) {
- root_ = nullptr;
-}
-
-// Convenience method:
-void Browser::ReplaceContentWithURL(const mojo::String& url) {
- Embed(url, nullptr, nullptr);
+void Browser::OnViewBoundsChanged(mojo::View* view,
+ const mojo::Rect& old_bounds,
+ const mojo::Rect& new_bounds) {
+ content_->SetBounds(
+ *mojo::Rect::From(gfx::Rect(0, 0, new_bounds.width, new_bounds.height)));
}
} // namespace mandoline
« no previous file with comments | « mandoline/ui/browser/browser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698