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

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

Issue 1133893003: Omnibox app (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 52741a803c6751450b0747b6e156e51af2097831..16bc11d369050fbb0cdce77f1677da7854e28590 100644
--- a/mandoline/ui/browser/browser.cc
+++ b/mandoline/ui/browser/browser.cc
@@ -18,6 +18,7 @@ Browser::Browser()
: window_manager_app_(new window_manager::WindowManagerApp(this, this)),
root_(nullptr),
content_(nullptr),
+ omnibox_(nullptr),
navigator_host_(this),
ui_(nullptr),
weak_factory_(this) {
@@ -31,14 +32,13 @@ base::WeakPtr<Browser> Browser::GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
-// Convenience method:
void Browser::ReplaceContentWithURL(const mojo::String& url) {
Embed(url, nullptr, nullptr);
}
void Browser::Initialize(mojo::ApplicationImpl* app) {
window_manager_app_->Initialize(app);
- ui_.reset(BrowserUI::Create(this, app->shell()));
+ ui_.reset(BrowserUI::Create(this, app));
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
base::CommandLine::StringVector args = command_line->GetArgs();
@@ -77,7 +77,7 @@ void Browser::OnEmbed(
// the UI class.
root_ = root;
content_ = root->view_manager()->CreateView();
- ui_->Init(root_, content_);
+ ui_->Init(root_);
#if defined(OS_ANDROID)
// Resize to match the Nexus 5 aspect ratio:
@@ -108,6 +108,11 @@ void Browser::OnViewManagerDisconnected(
void Browser::Embed(const mojo::String& url,
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services) {
+ if (url == "mojo:omnibox") {
+ ShowOmnibox(url, services.Pass(), exposed_services.Pass());
+ return;
+ }
+
// We can get Embed calls before we've actually been
// embedded into the root view and content_ is created.
// Just save the last url, we'll embed it when we're ready.
@@ -116,6 +121,11 @@ void Browser::Embed(const mojo::String& url,
return;
}
+ bool changed = current_url_ != url;
+ current_url_ = url;
+ if (changed)
+ ui_->OnURLChanged();
+
merged_service_provider_.reset(
new MergedServiceProvider(exposed_services.Pass(), this));
content_->Embed(url, services.Pass(),
@@ -131,9 +141,27 @@ void Browser::OnAcceleratorPressed(mojo::View* view,
navigator_host_.RequestNavigateHistory(-1);
}
+void Browser::OpenURL(const mojo::String& url) {
+ omnibox_->SetVisible(false);
+ ReplaceContentWithURL(url);
+}
+
void Browser::Create(mojo::ApplicationConnection* connection,
mojo::InterfaceRequest<mojo::NavigatorHost> request) {
navigator_host_.Bind(request.Pass());
}
+void Browser::ShowOmnibox(
+ const mojo::String& url,
+ mojo::InterfaceRequest<mojo::ServiceProvider> services,
+ mojo::ServiceProviderPtr exposed_services) {
+ if (!omnibox_) {
+ omnibox_ = root_->view_manager()->CreateView();
+ root_->AddChild(omnibox_);
+ omnibox_->SetVisible(true);
+ omnibox_->SetBounds(root_->bounds());
+ }
+ omnibox_->Embed(url, services.Pass(), exposed_services.Pass());
+}
+
} // namespace mandoline

Powered by Google App Engine
This is Rietveld 408576698