diff options
author | sky <sky@chromium.org> | 2015-05-14 16:55:57 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-14 23:56:42 +0000 |
commit | 6bf3a1ac1e2973e9ae382178f95fe153d021b20a (patch) | |
tree | 99f579a9f00ddd80529aba42db6f0aad3af3d2bd /mandoline | |
parent | 0db9185ce7bc14d96ce262978912a41941f46522 (diff) | |
download | chromium_src-6bf3a1ac1e2973e9ae382178f95fe153d021b20a.zip chromium_src-6bf3a1ac1e2973e9ae382178f95fe153d021b20a.tar.gz chromium_src-6bf3a1ac1e2973e9ae382178f95fe153d021b20a.tar.bz2 |
Nukes the windowmanager interface
What was WindowManagerInternal* is now ViewManagerRoot*.
The initial bootstrap is:
. App connects to view_manager and asks for ViewManagerService.
. ViewManager asks this connection for ViewManagerClient, and calls
OnEmbed.
. The ViewManager exposes the services ViewManagerRoot to the initial
connection.
All of this is handled for you if you use ViewManagerInit.
As WindowManager is no more, Embed with just a url is lost. I'm
assuming you'll add that back.
BUG=487870
TEST=none
R=ben@chromium.org
Review URL: https://codereview.chromium.org/1138073007
Cr-Commit-Position: refs/heads/master@{#329977}
Diffstat (limited to 'mandoline')
-rw-r--r-- | mandoline/BUILD.gn | 1 | ||||
-rw-r--r-- | mandoline/ui/browser/BUILD.gn | 1 | ||||
-rw-r--r-- | mandoline/ui/browser/DEPS | 1 | ||||
-rw-r--r-- | mandoline/ui/browser/browser.cc | 95 | ||||
-rw-r--r-- | mandoline/ui/browser/browser.h | 24 | ||||
-rw-r--r-- | mandoline/ui/omnibox/BUILD.gn | 1 | ||||
-rw-r--r-- | mandoline/ui/omnibox/DEPS | 1 | ||||
-rw-r--r-- | mandoline/ui/omnibox/omnibox_impl.cc | 5 |
8 files changed, 66 insertions, 63 deletions
diff --git a/mandoline/BUILD.gn b/mandoline/BUILD.gn index db956d3..9d91977 100644 --- a/mandoline/BUILD.gn +++ b/mandoline/BUILD.gn @@ -31,7 +31,6 @@ group("tests") { "//components/resource_provider:tests", "//components/view_manager:apptests", "//components/view_manager:tests", - "//components/window_manager:apptests", ] } } diff --git a/mandoline/ui/browser/BUILD.gn b/mandoline/ui/browser/BUILD.gn index f9f3bac..48149ee 100644 --- a/mandoline/ui/browser/BUILD.gn +++ b/mandoline/ui/browser/BUILD.gn @@ -53,7 +53,6 @@ source_set("kiosk_wm_lib") { ":interfaces", "//base", "//components/view_manager/public/cpp", - "//components/window_manager:lib", "//mandoline/services/navigation/public/interfaces", "//mojo/application/public/interfaces", "//mojo/converters/geometry", diff --git a/mandoline/ui/browser/DEPS b/mandoline/ui/browser/DEPS index d9b36c3..e793f5e 100644 --- a/mandoline/ui/browser/DEPS +++ b/mandoline/ui/browser/DEPS @@ -1,6 +1,5 @@ include_rules = [ "+components/view_manager", - "+components/window_manager", "+mandoline/services", "+mojo/application", "+mojo/common", diff --git a/mandoline/ui/browser/browser.cc b/mandoline/ui/browser/browser.cc index 202c76c..741346a 100644 --- a/mandoline/ui/browser/browser.cc +++ b/mandoline/ui/browser/browser.cc @@ -6,18 +6,32 @@ #include "base/command_line.h" #include "base/strings/utf_string_conversions.h" +#include "components/view_manager/public/cpp/view.h" +#include "components/view_manager/public/cpp/view_manager_init.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/common/common_type_converters.h" +#include "mojo/converters/geometry/geometry_type_converters.h" #include "third_party/mojo/src/mojo/public/c/system/main.h" #include "ui/gfx/geometry/size.h" namespace mandoline { +namespace { + +gfx::Size GetInitialViewportSize() { +#if defined(OS_ANDROID) + // Resize to match the Nexus 5 aspect ratio: + return gfx::Size(320, 640); +#else + return gfx::Size(1280, 800); +#endif +} + +} // namespace Browser::Browser() - : window_manager_app_(new window_manager::WindowManagerApp(this, this)), - root_(nullptr), + : root_(nullptr), content_(nullptr), omnibox_(nullptr), navigator_host_(this), @@ -33,7 +47,8 @@ void Browser::ReplaceContentWithURL(const mojo::String& url) { } void Browser::Initialize(mojo::ApplicationImpl* app) { - window_manager_app_->Initialize(app); + view_manager_init_.reset(new mojo::ViewManagerInit(app, this, this)); + ui_.reset(BrowserUI::Create(this, app)); base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); @@ -51,13 +66,12 @@ void Browser::Initialize(mojo::ApplicationImpl* app) { bool Browser::ConfigureIncomingConnection( mojo::ApplicationConnection* connection) { - window_manager_app_->ConfigureIncomingConnection(connection); + // TODO: register embed interface here. return true; } bool Browser::ConfigureOutgoingConnection( mojo::ApplicationConnection* connection) { - window_manager_app_->ConfigureOutgoingConnection(connection); return true; } @@ -75,18 +89,14 @@ void Browser::OnEmbed( content_ = root->view_manager()->CreateView(); ui_->Init(root_); -#if defined(OS_ANDROID) - // Resize to match the Nexus 5 aspect ratio: - window_manager_app_->SetViewportSize(gfx::Size(320, 640)); -#else - window_manager_app_->SetViewportSize(gfx::Size(1280, 800)); -#endif + view_manager_init_->view_manager_root()->SetViewportSize( + mojo::Size::From(GetInitialViewportSize())); root_->AddChild(content_); content_->SetVisible(true); - window_manager_app_->AddAccelerator(mojo::KEYBOARD_CODE_BROWSER_BACK, - mojo::EVENT_FLAGS_NONE); + view_manager_init_->view_manager_root()->AddAccelerator( + mojo::KEYBOARD_CODE_BROWSER_BACK, mojo::EVENT_FLAGS_NONE); // Now that we're ready, either load a pending url or the default url. if (!pending_url_.empty()) @@ -101,6 +111,35 @@ void Browser::OnViewManagerDisconnected( root_ = nullptr; } +void Browser::OnAccelerator(mojo::EventPtr event) { + DCHECK_EQ(mojo::KEYBOARD_CODE_BROWSER_BACK, + event->key_data->windows_key_code); + 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()); +} + void Browser::Embed(const mojo::String& url, mojo::InterfaceRequest<mojo::ServiceProvider> services, mojo::ServiceProviderPtr exposed_services) { @@ -131,34 +170,4 @@ void Browser::Embed(const mojo::String& url, navigator_host_.RecordNavigation(url); } -void Browser::OnAcceleratorPressed(mojo::View* view, - mojo::KeyboardCode keyboard_code, - mojo::EventFlags flags) { - DCHECK_EQ(mojo::KEYBOARD_CODE_BROWSER_BACK, keyboard_code); - 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 diff --git a/mandoline/ui/browser/browser.h b/mandoline/ui/browser/browser.h index d8f22cc..a972509 100644 --- a/mandoline/ui/browser/browser.h +++ b/mandoline/ui/browser/browser.h @@ -7,8 +7,7 @@ #include "components/view_manager/public/cpp/view_manager.h" #include "components/view_manager/public/cpp/view_manager_delegate.h" -#include "components/window_manager/window_manager_app.h" -#include "components/window_manager/window_manager_delegate.h" +#include "components/view_manager/public/interfaces/view_manager_root.mojom.h" #include "mandoline/services/navigation/public/interfaces/navigation.mojom.h" #include "mandoline/ui/browser/navigator_host_impl.h" #include "mandoline/ui/browser/omnibox.mojom.h" @@ -19,6 +18,10 @@ #include "ui/mojo/events/input_events.mojom.h" #include "url/gurl.h" +namespace mojo { +class ViewManagerInit; +} + namespace mandoline { class BrowserUI; @@ -26,7 +29,7 @@ class MergedServiceProvider; class Browser : public mojo::ApplicationDelegate, public mojo::ViewManagerDelegate, - public window_manager::WindowManagerDelegate, + public mojo::ViewManagerRootClient, public OmniboxClient, public mojo::InterfaceFactory<mojo::NavigatorHost> { public: @@ -54,13 +57,8 @@ class Browser : public mojo::ApplicationDelegate, mojo::ServiceProviderPtr exposed_services) override; void OnViewManagerDisconnected(mojo::ViewManager* view_manager) override; - // Overridden from WindowManagerDelegate: - void Embed(const mojo::String& url, - mojo::InterfaceRequest<mojo::ServiceProvider> services, - mojo::ServiceProviderPtr exposed_services) override; - void OnAcceleratorPressed(mojo::View* view, - mojo::KeyboardCode keyboard_code, - mojo::EventFlags flags) override; + // Overridden from ViewManagerRootClient: + void OnAccelerator(mojo::EventPtr event) override; // Overridden from OmniboxClient: void OpenURL(const mojo::String& url) override; @@ -69,11 +67,15 @@ class Browser : public mojo::ApplicationDelegate, void Create(mojo::ApplicationConnection* connection, mojo::InterfaceRequest<mojo::NavigatorHost> request) override; + void Embed(const mojo::String& url, + mojo::InterfaceRequest<mojo::ServiceProvider> services, + mojo::ServiceProviderPtr exposed_services); + void ShowOmnibox(const mojo::String& url, mojo::InterfaceRequest<mojo::ServiceProvider> services, mojo::ServiceProviderPtr exposed_services); - scoped_ptr<window_manager::WindowManagerApp> window_manager_app_; + scoped_ptr<mojo::ViewManagerInit> view_manager_init_; // Only support being embedded once, so both application-level // and embedding-level state are shared on the same object. diff --git a/mandoline/ui/omnibox/BUILD.gn b/mandoline/ui/omnibox/BUILD.gn index 1f6ffa3..a53755a 100644 --- a/mandoline/ui/omnibox/BUILD.gn +++ b/mandoline/ui/omnibox/BUILD.gn @@ -30,7 +30,6 @@ source_set("lib") { deps = [ "//base", "//components/view_manager/public/cpp", - "//components/window_manager:lib", "//mandoline/services/navigation/public/interfaces", "//mandoline/ui/aura", "//mandoline/ui/browser:interfaces", diff --git a/mandoline/ui/omnibox/DEPS b/mandoline/ui/omnibox/DEPS index 6dea49ea..eecf3ed 100644 --- a/mandoline/ui/omnibox/DEPS +++ b/mandoline/ui/omnibox/DEPS @@ -1,6 +1,5 @@ include_rules = [ "+components/view_manager/public", - "+components/window_manager/public", "+mojo/application", "+mojo/common", "+mojo/converters", diff --git a/mandoline/ui/omnibox/omnibox_impl.cc b/mandoline/ui/omnibox/omnibox_impl.cc index 2cf054b..e41149d 100644 --- a/mandoline/ui/omnibox/omnibox_impl.cc +++ b/mandoline/ui/omnibox/omnibox_impl.cc @@ -6,7 +6,6 @@ #include "base/strings/string16.h" #include "components/view_manager/public/cpp/view_manager_client_factory.h" -#include "components/window_manager/public/interfaces/window_manager.mojom.h" #include "mandoline/ui/aura/aura_init.h" #include "mandoline/ui/aura/native_widget_view_manager.h" #include "mojo/application/public/cpp/application_impl.h" @@ -130,9 +129,7 @@ void OmniboxImpl::SetClient(OmniboxClientPtr client) { void OmniboxImpl::ShowForURL(const mojo::String& url) { url_ = url; - mojo::WindowManagerPtr window_manager; - app_impl_->ConnectToService("mojo:window_manager", &window_manager); - window_manager->Embed("mojo:omnibox", nullptr, nullptr); + // TODO: get embedding working. } } // namespace mandoline |