Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Client used to connect to the remote ImageLoader extension. Client class runs | 8 * Client used to connect to the remote ImageLoader extension. Client class runs |
| 9 * in the extension, where the client.js is included (eg. Files.app). | 9 * in the extension, where the client.js is included (eg. Files.app). |
| 10 * It sends remote requests using IPC to the ImageLoader class and forwards | 10 * It sends remote requests using IPC to the ImageLoader class and forwards |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * Sends a message to the Image Loader extension. | 82 * Sends a message to the Image Loader extension. |
| 83 * @param {Object} request Hash array with request data. | 83 * @param {Object} request Hash array with request data. |
| 84 * @param {function(Object)=} opt_callback Response handling callback. | 84 * @param {function(Object)=} opt_callback Response handling callback. |
| 85 * The response is passed as a hash array. | 85 * The response is passed as a hash array. |
| 86 * @private | 86 * @private |
| 87 */ | 87 */ |
| 88 ImageLoaderClient.sendMessage_ = function(request, opt_callback) { | 88 ImageLoaderClient.sendMessage_ = function(request, opt_callback) { |
| 89 opt_callback = opt_callback || function(response) {}; | 89 opt_callback = opt_callback || function(response) {}; |
| 90 var sendMessage = chrome.runtime ? chrome.runtime.sendMessage : | 90 chrome.runtime.sendMessage( |
|
fukino
2014/10/07 09:52:44
I think we can use chrome.runtime.sendMessage safe
| |
| 91 chrome.extension.sendMessage; | 91 ImageLoaderClient.EXTENSION_ID, request, opt_callback); |
| 92 sendMessage(ImageLoaderClient.EXTENSION_ID, request, opt_callback); | |
| 93 }; | 92 }; |
| 94 | 93 |
| 95 /** | 94 /** |
| 96 * Handles a message from the remote image loader and calls the registered | 95 * Handles a message from the remote image loader and calls the registered |
| 97 * callback to pass the response back to the requester. | 96 * callback to pass the response back to the requester. |
| 98 * | 97 * |
| 99 * @param {Object} message Response message as a hash array. | 98 * @param {Object} message Response message as a hash array. |
| 100 * @private | 99 * @private |
| 101 */ | 100 */ |
| 102 ImageLoaderClient.prototype.handleMessage_ = function(message) { | 101 ImageLoaderClient.prototype.handleMessage_ = function(message) { |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 onError(); | 359 onError(); |
| 361 return; | 360 return; |
| 362 } | 361 } |
| 363 image.src = result.data; | 362 image.src = result.data; |
| 364 onSuccess(); | 363 onSuccess(); |
| 365 }; | 364 }; |
| 366 | 365 |
| 367 return ImageLoaderClient.getInstance().load( | 366 return ImageLoaderClient.getInstance().load( |
| 368 url, callback, options, opt_isValid); | 367 url, callback, options, opt_isValid); |
| 369 }; | 368 }; |
| OLD | NEW |