Provide bookmark service function for changing URL of bookmark

RESOLVED FIXED in Firefox 2 alpha2

Status

()

Firefox
Bookmarks & History
P2
normal
RESOLVED FIXED
12 years ago
8 years ago

People

(Reporter: Brett Wilson, Assigned: Joe Hughes)

Tracking

({fixed1.8.1})

unspecified
Firefox 2 alpha2
x86
All
fixed1.8.1
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 3 obsolete attachments)

(Reporter)

Description

12 years ago
This would handle migrating annotations, favicons, and conflict resolution. Perhaps there should be an option to just change one instance in one folder or to change all instances of this bookmark.
Priority: -- → P2
Target Milestone: --- → Firefox 2 alpha2
(Assignee)

Comment 1

12 years ago
Created attachment 215940 [details] [diff] [review]
Moves changeBookmarkURI into nsINavBookmarks C++ land, and adds a tagRoot to nsINavBookmarks
Attachment #215940 - Flags: superreview?(bugs)
Attachment #215940 - Flags: review?
(Assignee)

Updated

12 years ago
Attachment #215940 - Flags: review? → review?(brettw)
(Assignee)

Comment 2

12 years ago
Created attachment 215952 [details] [diff] [review]
Added brett's copyAnnotations patch from 329861 and a GetAnnotationService() method
Attachment #215940 - Attachment is obsolete: true
Attachment #215952 - Flags: review?(brettw)
Attachment #215940 - Flags: superreview?(bugs)
Attachment #215940 - Flags: review?(brettw)
Attachment #215952 - Flags: superreview+
(Reporter)

Comment 3

12 years ago
Comment on attachment 215952 [details] [diff] [review]
Added brett's copyAnnotations patch from 329861 and a GetAnnotationService() method

>+  // Now that we're satisfied with the quality of our input, the
>+  // actual work starts here.
>+
>+  PRInt64 *folders;
>+  PRUint32 folderCount;
>+  rv = GetBookmarkFolders(aOldURI, &folderCount, &folders);
>+  NS_ENSURE_SUCCESS(rv, rv);

All the error conditions will cause this array to leak. And, since you never even free it at the botton, success will also cause this array to leak :)

>+  
>+  rv = BeginUpdateBatch();

Use the nsBookmarksUpdateBatcher to do this instead. Every error condition from here on will exit without ending the batch, which will make all kinds of bad things happen. What I suggest is changing GetBookmarkFolders. Create a new version GetBookmarkFoldersTArray or something that returns a TArray and copy the TArray-filling code from GetBookmarkFolders into that. Then GetBookmarkFolders just becomes the raw-array-based wrapper. Then you can just call the TArray version here and not worry about the memory.

>+  NS_ENSURE_SUCCESS(rv, rv);
>+
>+  // in folders, replace all instances of old URI with new URI
>+  for (PRUint32 i = 0; i < folderCount; i++) {
>+    rv = ReplaceItem(folders[i], aOldURI, aNewURI);
>+    NS_ENSURE_SUCCESS(rv, rv);
>+  }
>+
>+  // copy title from old URI to new URI
>+  nsAutoString title;
>+  rv = GetItemTitle(aOldURI, title);
>+  NS_ENSURE_SUCCESS(rv, rv);
>+  rv = SetItemTitle(aNewURI, title);
>+  NS_ENSURE_SUCCESS(rv, rv);
>+
>+  // copy keyword (shortcut) from old URI to new URI
>+  nsAutoString keyword;
>+  rv = GetKeywordForURI(aOldURI, keyword);
>+  NS_ENSURE_SUCCESS(rv, rv);
>+  rv = SetKeywordForURI(aNewURI, keyword);
>+  NS_ENSURE_SUCCESS(rv, rv);

You probably don't want to set the keyword if the oldURI keyword is empty. If they already have a keyword for the new URI, this will delete it.

>+  // copy annotations from old URI to new URI
>+  nsAnnotationService* annoService =
>+    nsAnnotationService::GetAnnotationService();
>+  NS_ENSURE_TRUE(annoService, NS_ERROR_UNEXPECTED);
>+  rv = annoService->CopyAnnotations(aOldURI, aNewURI, PR_TRUE);
>+  NS_ENSURE_SUCCESS(rv, rv);
>+  rv = annoService->RemovePageAnnotations(aOldURI);
>+  NS_ENSURE_SUCCESS(rv, rv);

I don't think we should remove the old annotations. Many annotations may not be associated with the bookmark, but rather the page. Leaving it there will essentially fork the annotations, which I think is fine. You should document this, however.

>+  // associate favicon from old URI (if present) with new URI
>+  nsFaviconService* faviconService = nsFaviconService::GetFaviconService();
>+  NS_ENSURE_TRUE(faviconService, NS_ERROR_UNEXPECTED);
>+  nsCOMPtr<nsIURI> faviconURI;
>+  rv = faviconService->GetFaviconForPage(aOldURI, getter_AddRefs(faviconURI));
>+  if (NS_SUCCEEDED(rv)) {
>+    rv = faviconService->SetFaviconUrlForPage(aNewURI, faviconURI);
>+    NS_ENSURE_SUCCESS(rv, rv);
>+  }

I don't think you should overwrite a favicon if the newURI already has one. The favicon is really associated with the URI and not the bookmark. It will be reset next time they visit the page. Better to keep it what we already knew it was.
Attachment #215952 - Flags: review?(brettw) → review-
(Assignee)

Comment 4

12 years ago
Created attachment 215963 [details] [diff] [review]
Updated to incorporate brettw's feedback
Attachment #215952 - Attachment is obsolete: true
Attachment #215963 - Flags: review?(brettw)
(Assignee)

Updated

12 years ago
Blocks: 329861
(Reporter)

Comment 5

12 years ago
Comment on attachment 215963 [details] [diff] [review]
Updated to incorporate brettw's feedback

Looks good. When you checkin, can you add a comment above the tagRoot in the .idl file that explains it's currently 0. I don't want people getting confused before we're done implementing it.
Attachment #215963 - Flags: review?(brettw) → review+
(Assignee)

Comment 6

12 years ago
Created attachment 215983 [details] [diff] [review]
Changes as landed (post merge, adds quick fix for 329546 breakage)
Attachment #215963 - Attachment is obsolete: true
(Assignee)

Comment 7

12 years ago
Landed on branch & trunk.
Status: NEW → RESOLVED
Last Resolved: 12 years ago
Keywords: fixed1.8.1
Resolution: --- → FIXED

Updated

8 years ago
Depends on: 524972
Bug 451915 - move Firefox/Places bugs to Firefox/Bookmarks and History. Remove all bugspam from this move by filtering for the string "places-to-b-and-h".

In Thunderbird 3.0b, you do that as follows:
Tools | Message Filters
Make sure the correct account is selected. Click "New"
Conditions: Body   contains   places-to-b-and-h
Change the action to "Delete Message".
Select "Manually Run" from the dropdown at the top.
Click OK.

Select the filter in the list, make sure "Inbox" is selected at the bottom, and click "Run Now". This should delete all the bugspam. You can then delete the filter.

Gerv
Component: Places → Bookmarks & History
QA Contact: places → bookmarks
You need to log in before you can comment on or make changes to this bug.