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

Side by Side Diff: examples/js/show_image.js

Issue 845103004: Mojo JS Bindings: add show_image example (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « examples/js/README.md ('k') | mojo/public/tools/bindings/generators/mojom_js_generator.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!mojo mojo:js_content_handler
2 // Demonstrate using the mojo window_manager application to "embed" a view that
3 // displays an image. To run this application set BUILD_DIR to the build
4 // directory (like "src/out/Debug") and append a PNG image URL as the url
5 // paramaeter for: absolute path for this directory, then:
6 // sky/tools/skydb start $BUILD_DIR examples/js/show_image.js?url=<PNG URL>
7 // The skydb application starts an HTTP server that points at the build and
8 // and source directories. It starts a simple - just one view - window manager
9 // and then embeds this application in its root view. This application just
10 // asks the same window manager to embed the PNG viewer. Doing so effectively
11 // removes this application from the window manager's root view.
12
13 define("main", [
14 "mojo/services/public/js/application",
15 "mojo/services/public/js/service_provider",
16 "mojo/services/window_manager/public/interfaces/window_manager.mojom",
17 ], function(application, serviceProvider, windowManager) {
18
19 const Application = application.Application;
20 const ServiceProvider = serviceProvider.ServiceProvider;
21 const WindowManager = windowManager.WindowManager;
22 const defaultImageURL =
23 "http://upload.wikimedia.org/wikipedia/commons/8/87/Google_Chrome_icon_%28 2011%29.png";
24
25 var windowManager;
26 var windowManagerSP;
27
28 class WindowManagerClientImpl {
29 // An empty stub for now.
30 }
31
32 class ShowImage extends Application {
33 initialize() {
34 var imageURLKey = "?url=";
35 var imageURLIndex = this.url.indexOf(imageURLKey);
36 var imageURL = (imageURLIndex == -1) ? defaultImageURL :
37 this.url.substring(imageURLIndex + imageURLKey.length);
38
39 windowManager = this.shell.connectToService(
40 "mojo:window_manager", WindowManager, new WindowManagerClientImpl);
41 windowManager.embed(imageURL, function(spProxy) {
42 windowManagerSP = new ServiceProvider(spProxy);
43 });
44
45 // Displaying imageURL is now the responsibility of the Mojo application
46 // launched by its content handler. We're done.
47 this.quit();
48 }
49 }
50
51 return ShowImage;
52 });
53
OLDNEW
« no previous file with comments | « examples/js/README.md ('k') | mojo/public/tools/bindings/generators/mojom_js_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698