| Index: mandoline/ui/desktop_ui/browser_window.cc
|
| diff --git a/mandoline/ui/desktop_ui/browser_window.cc b/mandoline/ui/desktop_ui/browser_window.cc
|
| index 65f51da17d7af2cdad371173d1c659211df0aab7..b8ed3f07dcace3aa04dbd986abbecfb99a764599 100644
|
| --- a/mandoline/ui/desktop_ui/browser_window.cc
|
| +++ b/mandoline/ui/desktop_ui/browser_window.cc
|
| @@ -14,7 +14,6 @@
|
| #include "mandoline/ui/desktop_ui/browser_commands.h"
|
| #include "mandoline/ui/desktop_ui/browser_manager.h"
|
| #include "mandoline/ui/desktop_ui/public/interfaces/omnibox.mojom.h"
|
| -#include "mandoline/ui/desktop_ui/toolbar_view.h"
|
| #include "mojo/common/common_type_converters.h"
|
| #include "mojo/converters/geometry/geometry_type_converters.h"
|
| #include "mojo/services/tracing/public/cpp/switches.h"
|
| @@ -72,7 +71,7 @@
|
| : app_(app),
|
| host_client_binding_(this),
|
| manager_(manager),
|
| - toolbar_view_(nullptr),
|
| + omnibox_launcher_(nullptr),
|
| progress_bar_(nullptr),
|
| root_(nullptr),
|
| content_(nullptr),
|
| @@ -108,31 +107,6 @@
|
| delete this;
|
| }
|
|
|
| -void BrowserWindow::ShowOmnibox() {
|
| - if (!omnibox_.get()) {
|
| - mojo::URLRequestPtr request(mojo::URLRequest::New());
|
| - request->url = mojo::String::From("mojo:omnibox");
|
| - omnibox_connection_ = app_->ConnectToApplication(request.Pass());
|
| - omnibox_connection_->AddService<ViewEmbedder>(this);
|
| - omnibox_connection_->ConnectToService(&omnibox_);
|
| - omnibox_connection_->SetRemoteServiceProviderConnectionErrorHandler(
|
| - [this]() {
|
| - // This will cause the connection to be re-established the next time
|
| - // we come through this codepath.
|
| - omnibox_.reset();
|
| - });
|
| - }
|
| - omnibox_->ShowForURL(mojo::String::From(current_url_.spec()));
|
| -}
|
| -
|
| -void BrowserWindow::GoBack() {
|
| - web_view_.web_view()->GoBack();
|
| -}
|
| -
|
| -void BrowserWindow::GoForward() {
|
| - web_view_.web_view()->GoForward();
|
| -}
|
| -
|
| BrowserWindow::~BrowserWindow() {
|
| DCHECK(!root_);
|
| manager_->BrowserWindowClosed(this);
|
| @@ -172,10 +146,6 @@
|
| mojo::KEYBOARD_CODE_L, mojo::EVENT_FLAGS_CONTROL_DOWN);
|
| host_->AddAccelerator(static_cast<uint32_t>(BrowserCommand::NEW_WINDOW),
|
| mojo::KEYBOARD_CODE_N, mojo::EVENT_FLAGS_CONTROL_DOWN);
|
| - host_->AddAccelerator(static_cast<uint32_t>(BrowserCommand::GO_BACK),
|
| - mojo::KEYBOARD_CODE_LEFT, mojo::EVENT_FLAGS_ALT_DOWN);
|
| - host_->AddAccelerator(static_cast<uint32_t>(BrowserCommand::GO_FORWARD),
|
| - mojo::KEYBOARD_CODE_RIGHT, mojo::EVENT_FLAGS_ALT_DOWN);
|
|
|
| // Now that we're ready, load the default url.
|
| LoadURL(default_url_);
|
| @@ -219,12 +189,6 @@
|
| case BrowserCommand::FOCUS_OMNIBOX:
|
| ShowOmnibox();
|
| break;
|
| - case BrowserCommand::GO_BACK:
|
| - GoBack();
|
| - break;
|
| - case BrowserCommand::GO_FORWARD:
|
| - GoForward();
|
| - break;
|
| default:
|
| NOTREACHED();
|
| break;
|
| @@ -244,14 +208,6 @@
|
|
|
| void BrowserWindow::ProgressChanged(double progress) {
|
| progress_bar_->SetProgress(progress);
|
| -}
|
| -
|
| -void BrowserWindow::BackForwardChanged(
|
| - web_view::mojom::ButtonState back_button,
|
| - web_view::mojom::ButtonState forward_button) {
|
| - toolbar_view_->SetBackForwardEnabled(
|
| - back_button == web_view::mojom::ButtonState::BUTTON_STATE_ENABLED,
|
| - forward_button == web_view::mojom::ButtonState::BUTTON_STATE_ENABLED);
|
| }
|
|
|
| void BrowserWindow::TitleChanged(const mojo::String& title) {
|
| @@ -276,7 +232,7 @@
|
| bool changed = current_url_ != gurl;
|
| current_url_ = gurl;
|
| if (changed)
|
| - toolbar_view_->SetOmniboxText(base::UTF8ToUTF16(current_url_.spec()));
|
| + omnibox_launcher_->SetText(base::UTF8ToUTF16(current_url_.spec()));
|
|
|
| web_view_.web_view()->LoadRequest(request.Pass());
|
| }
|
| @@ -302,13 +258,17 @@
|
| float inverse_device_pixel_ratio =
|
| 1.0f / root_->viewport_metrics().device_pixel_ratio;
|
|
|
| - gfx::Rect toolbar_bounds = gfx::ScaleToEnclosingRect(
|
| + gfx::Rect omnibox_launcher_bounds = gfx::ScaleToEnclosingRect(
|
| bounds_in_physical_pixels, inverse_device_pixel_ratio);
|
| - toolbar_bounds.Inset(10, 10, 10, toolbar_bounds.height() - 40);
|
| - toolbar_view_->SetBoundsRect(toolbar_bounds);
|
| -
|
| - gfx::Rect progress_bar_bounds(toolbar_bounds.x(), toolbar_bounds.bottom() + 2,
|
| - toolbar_bounds.width(), 5);
|
| + omnibox_launcher_bounds.Inset(10, 10, 10,
|
| + omnibox_launcher_bounds.height() - 40);
|
| + omnibox_launcher_->SetBoundsRect(omnibox_launcher_bounds);
|
| +
|
| + gfx::Rect progress_bar_bounds(omnibox_launcher_bounds.x(),
|
| + omnibox_launcher_bounds.bottom() + 2,
|
| + omnibox_launcher_bounds.width(),
|
| + 5);
|
| + progress_bar_->SetBoundsRect(progress_bar_bounds);
|
|
|
| // The content view bounds are in physical pixels.
|
| mojo::Rect content_bounds_mojo;
|
| @@ -323,6 +283,16 @@
|
| omnibox_view_->SetBounds(
|
| mojo::TypeConverter<mojo::Rect, gfx::Rect>::Convert(
|
| bounds_in_physical_pixels));
|
| +
|
| +}
|
| +
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// BrowserWindow, views::ButtonListener implementation:
|
| +
|
| +void BrowserWindow::ButtonPressed(views::Button* sender,
|
| + const ui::Event& event) {
|
| + DCHECK_EQ(sender, omnibox_launcher_);
|
| + ShowOmnibox();
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| @@ -340,9 +310,11 @@
|
| views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView;
|
| widget_delegate->GetContentsView()->set_background(
|
| views::Background::CreateSolidBackground(0xFFDDDDDD));
|
| - toolbar_view_ = new ToolbarView(this);
|
| + omnibox_launcher_ =
|
| + new views::LabelButton(this, base::ASCIIToUTF16("Open Omnibox"));
|
| progress_bar_ = new ProgressView;
|
| - widget_delegate->GetContentsView()->AddChildView(toolbar_view_);
|
| +
|
| + widget_delegate->GetContentsView()->AddChildView(omnibox_launcher_);
|
| widget_delegate->GetContentsView()->AddChildView(progress_bar_);
|
| widget_delegate->GetContentsView()->SetLayoutManager(this);
|
|
|
| @@ -358,6 +330,23 @@
|
| root_->SetFocus();
|
| }
|
|
|
| +void BrowserWindow::ShowOmnibox() {
|
| + if (!omnibox_.get()) {
|
| + mojo::URLRequestPtr request(mojo::URLRequest::New());
|
| + request->url = mojo::String::From("mojo:omnibox");
|
| + omnibox_connection_ = app_->ConnectToApplication(request.Pass());
|
| + omnibox_connection_->AddService<ViewEmbedder>(this);
|
| + omnibox_connection_->ConnectToService(&omnibox_);
|
| + omnibox_connection_->SetRemoteServiceProviderConnectionErrorHandler(
|
| + [this]() {
|
| + // This will cause the connection to be re-established the next time
|
| + // we come through this codepath.
|
| + omnibox_.reset();
|
| + });
|
| + }
|
| + omnibox_->ShowForURL(mojo::String::From(current_url_.spec()));
|
| +}
|
| +
|
| void BrowserWindow::EmbedOmnibox() {
|
| mojo::ViewTreeClientPtr view_tree_client;
|
| omnibox_->GetViewTreeClient(GetProxy(&view_tree_client));
|
|
|