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

Side by Side Diff: chrome/browser/resources/file_manager/js/image_editor/gallery_demo.js

Issue 8819013: Add UMA metrics to Photo Editor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Better trace Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var metadataProvider = new MetadataProvider('../metadata_dispatcher.js'); 5 var metadataProvider = new MetadataProvider('../metadata_dispatcher.js');
6 6
7 function toggleSize(check) { 7 function toggleSize(check) {
8 var iframe = document.querySelector('.gallery-frame'); 8 var iframe = document.querySelector('.gallery-frame');
9 iframe.classList.toggle('chromebook'); 9 iframe.classList.toggle('chromebook');
10 } 10 }
11 11
12 var mockActions = [ 12 var mockActions = [
13 { 13 {
14 title: 'Send', 14 title: 'Send',
15 iconUrl: 'http://google.com/favicon.ico', 15 iconUrl: 'http://google.com/favicon.ico',
16 execute: function() { alert('Sending is not supported') } 16 execute: function() { alert('Sending is not supported') }
17 }]; 17 }];
18 18
19 19
20 var mockDisplayStrings = { 20 // For quick access from JS console. Use trace.dump() to print all lines.
21 GALLERY_EDIT: 'Edit', 21 var trace;
22 GALLERY_SHARE: 'Share',
23 GALLERY_ENTER_WHEN_DONE: 'Press Enter when done',
24 GALLERY_AUTOFIX: 'Auto-fix',
25 GALLERY_FIXED: 'Fixed',
26 GALLERY_CROP: 'Crop',
27 GALLERY_EXPOSURE: 'Brightness',
28 GALLERY_BRIGHTNESS: 'Brightness',
29 GALLERY_CONTRAST: 'Contrast',
30 GALLERY_ROTATE_LEFT: 'Left',
31 GALLERY_ROTATE_RIGHT: 'Right',
32 GALLERY_UNDO: 'Undo',
33 GALLERY_REDO: 'Redo'
34 };
35 22
36 function loadGallery(items) { 23 function loadGallery(items) {
37 if (!items) items = [createTestGrid()]; 24 if (!items) items = [createTestGrid()];
38 25
39 var iframe = document.querySelector('.gallery-frame'); 26 var iframe = document.querySelector('.gallery-frame');
40 var contentWindow = iframe.contentWindow; 27 var contentWindow = iframe.contentWindow;
28 trace = contentWindow.ImageUtil.trace;
29 trace.bindToDOM(document.querySelector('.debug-output'));
41 30
42 contentWindow.ImageUtil.trace.bindToDOM( 31 contentWindow.ImageUtil.metrics = metrics;
43 document.querySelector('.debug-output'));
44 32
45 contentWindow.Gallery.open( 33 chrome.fileBrowserPrivate.getStrings(function(strings) {
46 null, // No local file access 34 contentWindow.Gallery.open(
47 items, 35 null, // No local file access
48 items[0], 36 items,
49 function() {}, // Do nothing on Close 37 items[0],
50 metadataProvider, 38 function() {}, // Do nothing on Close
51 mockActions, 39 metadataProvider,
52 function(id) { return mockDisplayStrings[id] || id } ); 40 mockActions,
41 function(id) { return strings[id] || id } );
53 42
54 iframe.focus(); 43 iframe.focus();
44 });
55 } 45 }
56 46
57 function createTestGrid() { 47 function createTestGrid() {
58 var canvas = document.createElement('canvas'); 48 var canvas = document.createElement('canvas');
59 canvas.width = 1000; 49 canvas.width = 1000;
60 canvas.height = 1000; 50 canvas.height = 1000;
61 51
62 var context = canvas.getContext('2d'); 52 var context = canvas.getContext('2d');
63 53
64 var imageData = context.getImageData(0, 0, canvas.width, canvas.height); 54 var imageData = context.getImageData(0, 0, canvas.width, canvas.height);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 context.textBaseline = 'top'; 90 context.textBaseline = 'top';
101 91
102 const STEP = 100; 92 const STEP = 100;
103 for (var y = 0; y < height; y+= STEP) { 93 for (var y = 0; y < height; y+= STEP) {
104 for (var x = 0; x < width; x+= STEP) { 94 for (var x = 0; x < width; x+= STEP) {
105 context.strokeRect(x + 0.5, y + 0.5, STEP, STEP); 95 context.strokeRect(x + 0.5, y + 0.5, STEP, STEP);
106 context.strokeText(x + ',' + y, x + 2, y); 96 context.strokeText(x + ',' + y, x + 2, y);
107 } 97 }
108 } 98 }
109 } 99 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698