This repository has been archived by the owner. It is now read-only.
Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
15 changed files
with
271 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* weinre is available under *either* the terms of the modified BSD license *or* the | ||
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text. | ||
* | ||
* Copyright (c) 2011 IBM Corporation | ||
*/ | ||
|
||
package weinre.server; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.MalformedURLException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.eclipse.jetty.util.resource.Resource; | ||
|
||
//------------------------------------------------------------------- | ||
public class ExtensionManager { | ||
static private File weinreHomeDir = null; | ||
static private File weinreExtDir = null; | ||
static private long weinreExtDate = 0L; | ||
static private String[] extensions = null; | ||
|
||
static private String[] EMPTY_STRING_ARRAY = {}; | ||
|
||
//--------------------------------------------------------------- | ||
static { | ||
initExtensions(); | ||
} | ||
|
||
//--------------------------------------------------------------- | ||
static public String[] getExtensions() { | ||
if (weinreExtDate != weinreExtDir.lastModified()) { | ||
initExtensions(); | ||
} | ||
|
||
return extensions; | ||
} | ||
|
||
//--------------------------------------------------------------- | ||
// path: /client/extensions/weinre-ext-sample/extension.html | ||
static public Resource getResource(String path) throws MalformedURLException { | ||
File resourceFile = new File(weinreExtDir, path.substring(18)); | ||
if (!resourceFile.exists()) return null; | ||
|
||
try { | ||
return Resource.newResource(resourceFile.toURI().toURL().toExternalForm(), false); | ||
} | ||
catch (IOException e) { | ||
throw new MalformedURLException(); | ||
} | ||
} | ||
|
||
//--------------------------------------------------------------- | ||
static private void initExtensions() { | ||
|
||
weinreHomeDir = new File(System.getProperty("user.home"), ".weinre"); | ||
if (!weinreHomeDir.isDirectory()) { | ||
Main.info("extensions not enabled: ~/.weinre is not a directory"); | ||
return; | ||
} | ||
|
||
weinreExtDir = new File(weinreHomeDir, "extensions"); | ||
weinreExtDate = weinreExtDir.lastModified(); | ||
if (!weinreExtDir.isDirectory()) { | ||
Main.info("extensions not enabled: ~/.weinre/extensions is not a directory"); | ||
return; | ||
} | ||
|
||
extensions = EMPTY_STRING_ARRAY; | ||
|
||
List<String> extensionList = new ArrayList<String>(); | ||
|
||
String[] entries = weinreExtDir.list(); | ||
for (String entry: entries) { | ||
if (entry.startsWith(".")) continue; | ||
|
||
File extDir = new File(weinreExtDir, entry); | ||
if (!extDir.isDirectory()) continue; | ||
|
||
File extensionHtml = new File(extDir, "extension.html"); | ||
if (!extensionHtml.isFile()) continue; | ||
|
||
extensionList.add(entry); | ||
} | ||
|
||
extensions = extensionList.toArray(EMPTY_STRING_ARRAY); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* weinre is available under *either* the terms of the modified BSD license *or* the | ||
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text. | ||
* | ||
* Copyright (c) 2011 IBM Corporation | ||
*/ | ||
|
||
(function() { | ||
var ExtensionRegistryImpl = require("weinre/client/ExtensionRegistryImpl").getClass() | ||
window.InspectorExtensionRegistry = new ExtensionRegistryImpl() | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* weinre is available under *either* the terms of the modified BSD license *or* the | ||
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text. | ||
* | ||
* Copyright (c) 2011 IBM Corporation | ||
*/ | ||
|
||
eval(window.top.installWebInspectorAPIsource()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
/* | ||
* weinre is available under *either* the terms of the modified BSD license *or* the | ||
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text. | ||
* | ||
* Copyright (c) 2011 IBM Corporation | ||
*/ | ||
|
||
requireClass ../common/Ex | ||
requireClass ../common/Binding | ||
requireClass ../common/Weinre | ||
|
||
//----------------------------------------------------------------------------- | ||
class ExtensionRegistryImpl | ||
|
||
//----------------------------------------------------------------------------- | ||
init | ||
var extensions = [] | ||
|
||
//----------------------------------------------------------------------------- | ||
method getExtensionsAsync | ||
if (extensions.length) return | ||
|
||
Weinre.WeinreClientCommands.getExtensions(Binding(this, this._cb_getExtensions)) | ||
|
||
//----------------------------------------------------------------------------- | ||
method _cb_getExtensions(extensionsResult) | ||
extensions = extensionsResult | ||
this._installExtensions() | ||
|
||
//----------------------------------------------------------------------------- | ||
method _installExtensions | ||
WebInspector.addExtensions(extensions) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.