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

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

Issue 1136593004: Add a simple browser UI (with url bar) (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
Index: mandoline/ui/browser/browser.cc
diff --git a/mandoline/ui/browser/browser.cc b/mandoline/ui/browser/browser.cc
index b09411d1880895b4cb4494789377ab90becf8be4..c64101046d73e08915ec315f10cda9bfacaa07b1 100644
--- a/mandoline/ui/browser/browser.cc
+++ b/mandoline/ui/browser/browser.cc
@@ -6,9 +6,12 @@
#include "base/command_line.h"
#include "base/strings/utf_string_conversions.h"
+#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 {
@@ -18,6 +21,7 @@ Browser::Browser()
root_(nullptr),
content_(nullptr),
navigator_host_(this),
+ ui_(nullptr),
weak_factory_(this) {
exposed_services_impl_.AddService(this);
}
@@ -31,6 +35,7 @@ base::WeakPtr<Browser> Browser::GetWeakPtr() {
void Browser::Initialize(mojo::ApplicationImpl* app) {
window_manager_app_->Initialize(app);
+ ui_.reset(BrowserUI::Create(this, app->shell()));
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
base::CommandLine::StringVector args = command_line->GetArgs();
@@ -64,8 +69,12 @@ void Browser::OnEmbed(
// Browser does not support being embedded more than once.
CHECK(!root_);
+ // TODO(beng): still unhappy with the fact that both this class & the UI class
+ // 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_);
#if defined(OS_ANDROID)
// Resize to match the Nexus 5 aspect ratio:
@@ -74,8 +83,6 @@ void Browser::OnEmbed(
window_manager_app_->SetViewportSize(gfx::Size(1280, 800));
#endif
- content_ = root->view_manager()->CreateView();
- content_->SetBounds(root_->bounds());
root_->AddChild(content_);
content_->SetVisible(true);
@@ -125,16 +132,6 @@ void Browser::OnViewManagerDisconnected(
root_ = nullptr;
}
-void Browser::OnViewDestroyed(mojo::View* view) {
- view->RemoveObserver(this);
-}
-
-void Browser::OnViewBoundsChanged(mojo::View* view,
- const mojo::Rect& old_bounds,
- const mojo::Rect& new_bounds) {
- content_->SetBounds(new_bounds);
-}
-
// Convenience method:
void Browser::ReplaceContentWithURL(const mojo::String& url) {
Embed(url, nullptr, nullptr);

Powered by Google App Engine
This is Rietveld 408576698