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

Unified Diff: mojo/examples/embedded_app/embedded_app.cc

Issue 684543003: Move //mojo/examples to //examples (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 2 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 | « mojo/examples/embedded_app/DEPS ('k') | mojo/examples/http_server/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/examples/embedded_app/embedded_app.cc
diff --git a/mojo/examples/embedded_app/embedded_app.cc b/mojo/examples/embedded_app/embedded_app.cc
deleted file mode 100644
index 98c418e93842e4c8a7359ff1ebf2cb635dc9c664..0000000000000000000000000000000000000000
--- a/mojo/examples/embedded_app/embedded_app.cc
+++ /dev/null
@@ -1,122 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/bind.h"
-#include "base/logging.h"
-#include "base/macros.h"
-#include "base/message_loop/message_loop.h"
-#include "base/strings/string_number_conversions.h"
-#include "mojo/application/application_runner_chromium.h"
-#include "mojo/examples/bitmap_uploader/bitmap_uploader.h"
-#include "mojo/public/c/system/main.h"
-#include "mojo/public/cpp/application/application_connection.h"
-#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/application_impl.h"
-#include "mojo/public/cpp/application/connect.h"
-#include "mojo/public/cpp/application/interface_factory_impl.h"
-#include "mojo/services/public/cpp/view_manager/view.h"
-#include "mojo/services/public/cpp/view_manager/view_manager.h"
-#include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h"
-#include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
-#include "mojo/services/public/cpp/view_manager/view_observer.h"
-#include "mojo/services/public/interfaces/navigation/navigation.mojom.h"
-#include "ui/events/event_constants.h"
-#include "url/gurl.h"
-#include "url/url_util.h"
-
-namespace mojo {
-namespace examples {
-
-const SkColor kColors[] = {SK_ColorYELLOW, SK_ColorRED, SK_ColorGREEN,
- SK_ColorMAGENTA};
-
-struct Window {
- Window(View* root,
- scoped_ptr<ServiceProvider> embedder_service_provider,
- Shell* shell)
- : root(root),
- embedder_service_provider(embedder_service_provider.Pass()),
- bitmap_uploader(root) {
- bitmap_uploader.Init(shell);
- }
-
- View* root;
- scoped_ptr<ServiceProvider> embedder_service_provider;
- BitmapUploader bitmap_uploader;
-};
-
-class EmbeddedApp
- : public ApplicationDelegate,
- public ViewManagerDelegate,
- public ViewObserver {
- public:
- EmbeddedApp() : shell_(nullptr) { url::AddStandardScheme("mojo"); }
- virtual ~EmbeddedApp() {}
-
- private:
-
- // Overridden from ApplicationDelegate:
- virtual void Initialize(ApplicationImpl* app) override {
- shell_ = app->shell();
- view_manager_client_factory_.reset(
- new ViewManagerClientFactory(app->shell(), this));
- }
-
- virtual bool ConfigureIncomingConnection(
- ApplicationConnection* connection) override {
- connection->AddService(view_manager_client_factory_.get());
- return true;
- }
-
- // Overridden from ViewManagerDelegate:
- virtual void OnEmbed(ViewManager* view_manager,
- View* root,
- ServiceProviderImpl* exported_services,
- scoped_ptr<ServiceProvider> imported_services) override {
- root->AddObserver(this);
- Window* window = new Window(root, imported_services.Pass(), shell_);
- windows_[root->id()] = window;
- window->bitmap_uploader.SetColor(
- kColors[next_color_++ % arraysize(kColors)]);
- }
- virtual void OnViewManagerDisconnected(ViewManager* view_manager) override {
- base::MessageLoop::current()->Quit();
- }
-
- // Overridden from ViewObserver:
- virtual void OnViewDestroyed(View* view) override {
- DCHECK(windows_.find(view->id()) != windows_.end());
- windows_.erase(view->id());
- }
- virtual void OnViewInputEvent(View* view, const EventPtr& event) override {
- if (event->action == EVENT_TYPE_MOUSE_RELEASED) {
- if (event->flags & EVENT_FLAGS_LEFT_MOUSE_BUTTON) {
- URLRequestPtr request(URLRequest::New());
- request->url = "http://www.aaronboodman.com/z_dropbox/test.html";
- NavigatorHostPtr navigator_host;
- ConnectToService(windows_[view->id()]->embedder_service_provider.get(),
- &navigator_host);
- navigator_host->RequestNavigate(TARGET_SOURCE_NODE, request.Pass());
- }
- }
- }
-
- Shell* shell_;
- scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_;
-
- typedef std::map<Id, Window*> WindowMap;
- WindowMap windows_;
-
- int next_color_;
-
- DISALLOW_COPY_AND_ASSIGN(EmbeddedApp);
-};
-
-} // namespace examples
-} // namespace mojo
-
-MojoResult MojoMain(MojoHandle shell_handle) {
- mojo::ApplicationRunnerChromium runner(new mojo::examples::EmbeddedApp);
- return runner.Run(shell_handle);
-}
« no previous file with comments | « mojo/examples/embedded_app/DEPS ('k') | mojo/examples/http_server/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698