Hi Aaron,
Sorry for this late response. I was piled up in the past days. I did
some additional trials. It's quite random and it is hard to get unique
results. But let's handle it one by one. I am attaching a sample
toolstrip.html file. For a clean test make sure your bookmark list is
empty.
When the page is loaded it will check the existence of a folder and
create it (together w/ an item) if needed. In my test, the item will
never be created in the folder. It will be either created in the
bookmark bar, or under the root folder, or not at all.
You can also click on the icon in the toolstrip to manually check the
folder. In this case, I got correct result in one machine, but random
(as aforementioned) in another machine (note this another machine is
using a different language version).
Also, a folder is never found by chrome.bookmarks.search(). It is easy
for you to test it so I didn't include it in the html file.
-Jack
////////////////////////////////////////////
<html>
<script type="text/javascript">
var folderId = -1;
var helperItem = "What's This?";
var sampleSettingFolderName = "Sample Setting";
function noFolderCallback()
{
updateStatus("Not Found");
createFolder();
}
function hasFolderCallback()
{
updateStatus("Found! " + folderId);
}
function createFolder()
{
chrome.bookmarks.create({ 'title': sampleSettingFolderName }, function
(folder) {
folderId = folder.id;
updateStatus("Created folder: " + folder.title);
createItem(helperItem, 'http://www.google.com');
});
}
function createItem(name, value)
{
if(folderId < 0)
return;
chrome.bookmarks.create({ 'parentId': folderId, 'index' : 0, 'title':
name, 'url': value }, function(item) {
updateStatus("Created item: " + item.title);
});
}
function updateStatus(status)
{
document.getElementById("status").innerHTML = status;
}
function checkItem(checkName, yesFunc, noFunc)
{
updateStatus('Checking...');
chrome.bookmarks.search(checkName, function(results) {
if(results.length > 0)
{
updateStatus("Found Item with parent: " +
results[0].parentId);
folderId = results[0].parentId;
var aryId=new Array();
aryId[0]=results[0].parentId;
chrome.bookmarks.get(aryId, function(re) {
updateStatus("Found Folder - " + re[0].title);
yesFunc();
});
}
else
{
noFunc();
}
});
}
window.onload = function(){
checkItem(helperItem, hasFolderCallback, noFolderCallback);
};
function openSetting()
{
checkItem(helperItem, hasFolderCallback, noFolderCallback);
}
</script>
<body>
<a href="javascript:openSetting();" title="Click to create
folder"><img style="border: medium none; margin: 0px; padding: 0px;
padding-top:4px; display: block;" src="http://www.gogle.com/
favicon.ico" border="0" vspace="0" width="16" height="16" hspace="0"></
a>
<div style="padding-top:4px; margin-left:4px;" id="status">Dummy</div>
</body>
</html>
/////////////////////////////////////////
On May 15, 2:18 pm, Aaron Boodman <[email protected]> wrote:
> Hi Jack,
>
> On Fri, May 15, 2009 at 2:05 PM, jack <[email protected]> wrote:
> > I have spent some time playing around the new release of Chrome,
> > especially building user preference system using the bookmarking and
> > script/extension communication aspects. I have to say it is not
> > reliable enough yet to build a real system.
>
> Using the bookmark system for storage was just an idea for a quick
> hack, but I'm still interested in the bugs you found.
>
> > 1) Bookmarking: bookmarking system only works well for directly loaded
> > extension page (i.e., type or copy "chrome-extension://*/*.html" and
> > enter). If the extension page is loaded by hyperlink from other pages,
> > or by communication event (within onMessage), bookmarking is quite
> > unreliable. e.g., if the extension page contains some javascript
> > creating a bookmark item in onload(), by merely refreshing the page I
> > got different results randomly (sometime w/ the item created, sometime
> > in a different folder, sometime nothing at all).
>
> > 2) chrome.bookmarks.search will not find any folder
>
> I'll try and make some test cases for these two bugs and replicate them.
> Thanks.
>
> > 3) Open the communication channel between the script and extension
> > makes the whole Chrome much more vulnerable to crashing.
>
> Hm, if you can come up with a test case for this, I'd appreciate it.
> Otherwise, we'll just keep an eye out for crashes related to the
> communication channel.
>
> > 4) Transfer large amount of data (say 2K bytes) via postMessage is
> > extremely slow (multiple sec.)
>
> I'll try and create a test case for this, too.
>
> > 5) Is the "hidden_pages" in json still working, or not yet, or not any
> > longer? Hidden page is good for the communication w/o exposing any UI
> > as toolstrip does, but it didn't work for me so far.
>
> It's not fully baked yet, but it will be "background_page".
>
> Thanks for the feedback,
>
> - a
--~--~---------~--~----~------------~-------~--~----~
Chromium Developers mailing list: [email protected]
View archives, change email options, or unsubscribe:
http://groups.google.com/group/chromium-dev
-~----------~----~----~----~------~----~------~--~---