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

Unified Diff: components/bookmarks/browser/bookmark_utils.cc

Issue 437423005: Show paste option on right click of bookmark bar if some URL is copied from outside browser or from… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Modified code as suggested. Created 6 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/bookmarks/browser/bookmark_utils.cc
diff --git a/components/bookmarks/browser/bookmark_utils.cc b/components/bookmarks/browser/bookmark_utils.cc
index 304d2befbd07d5b36d3286e8b1e24010a393f884..84f4d209e4533a4b1fbfe457b6db81abc76cee9c 100644
--- a/components/bookmarks/browser/bookmark_utils.cc
+++ b/components/bookmarks/browser/bookmark_utils.cc
@@ -194,7 +194,8 @@ void PasteFromClipboard(BookmarkModel* model,
if (!parent)
return;
- BookmarkNodeData bookmark_data;
+ if (BookmarkNodeData::ClipboardContainsBookmarks()) {
+ BookmarkNodeData bookmark_data;
if (!bookmark_data.ReadFromClipboard(ui::CLIPBOARD_TYPE_COPY_PASTE))
sky 2014/08/13 16:48:35 Fix indentation here.
return;
@@ -202,12 +203,23 @@ void PasteFromClipboard(BookmarkModel* model,
index = parent->child_count();
ScopedGroupBookmarkActions group_paste(model);
CloneBookmarkNode(model, bookmark_data.elements, parent, index, true);
+ }
+ if (ui::Clipboard::GetForCurrentThread()->IsFormatAvailable(
+ ui::Clipboard::GetUrlWFormatType(), ui::CLIPBOARD_TYPE_COPY_PASTE)) {
sky 2014/08/13 16:48:34 I think this path should convert to a BookmarkNode
+ base::string16 url_text;
+ ui::Clipboard::GetForCurrentThread()->ReadText(
+ ui::CLIPBOARD_TYPE_COPY_PASTE, &url_text);
+ GURL url(url_text);
+ model->AddURL(parent, index, url_text, url);
+ }
}
bool CanPasteFromClipboard(BookmarkModel* model, const BookmarkNode* node) {
if (!node || !model->client()->CanBeEditedByUser(node))
return false;
- return BookmarkNodeData::ClipboardContainsBookmarks();
+ return BookmarkNodeData::ClipboardContainsBookmarks() ||
+ ui::Clipboard::GetForCurrentThread()->IsFormatAvailable(
+ ui::Clipboard::GetUrlWFormatType(), ui::CLIPBOARD_TYPE_COPY_PASTE);
}
std::vector<const BookmarkNode*> GetMostRecentlyModifiedUserFolders(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698