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

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: Fixed indentation and incorporated other comments. 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..dc443e7fff8ba429e13bd42768e168fbaa24c061 100644
--- a/components/bookmarks/browser/bookmark_utils.cc
+++ b/components/bookmarks/browser/bookmark_utils.cc
@@ -193,11 +193,24 @@ void PasteFromClipboard(BookmarkModel* model,
int index) {
if (!parent)
return;
-
BookmarkNodeData bookmark_data;
- if (!bookmark_data.ReadFromClipboard(ui::CLIPBOARD_TYPE_COPY_PASTE))
+ if (BookmarkNodeData::ClipboardContainsBookmarks()) {
+ if (!bookmark_data.ReadFromClipboard(ui::CLIPBOARD_TYPE_COPY_PASTE))
return;
sky 2014/08/15 18:24:55 spacing is off. But I think this would be clearer
ankit 2014/08/16 07:43:57 Please correct if my understanding is not correct.
-
+ } else if (ui::Clipboard::GetForCurrentThread()->IsFormatAvailable(
+ ui::Clipboard::GetUrlWFormatType(),
+ ui::CLIPBOARD_TYPE_COPY_PASTE)) {
+ base::string16 url_text;
+ ui::Clipboard::GetForCurrentThread()->ReadText(
+ ui::CLIPBOARD_TYPE_COPY_PASTE, &url_text);
+ GURL url(url_text);
+ if (!url.is_valid())
+ return;
+ BookmarkNode node(url);
+ node.SetTitle(url_text);
+ BookmarkNodeData bookmark(&node);
+ bookmark_data = bookmark;
+ }
if (index == -1)
index = parent->child_count();
ScopedGroupBookmarkActions group_paste(model);
@@ -207,7 +220,18 @@ void PasteFromClipboard(BookmarkModel* model,
bool CanPasteFromClipboard(BookmarkModel* model, const BookmarkNode* node) {
if (!node || !model->client()->CanBeEditedByUser(node))
return false;
- return BookmarkNodeData::ClipboardContainsBookmarks();
+ if (BookmarkNodeData::ClipboardContainsBookmarks())
+ return true;
+ if (ui::Clipboard::GetForCurrentThread()->IsFormatAvailable(
sky 2014/08/15 18:24:55 223-233 is nearly identical to 200-208, refactor t
+ ui::Clipboard::GetUrlWFormatType(), ui::CLIPBOARD_TYPE_COPY_PASTE)) {
+ base::string16 url_text;
+ ui::Clipboard::GetForCurrentThread()->ReadText(
+ ui::CLIPBOARD_TYPE_COPY_PASTE, &url_text);
+ GURL url(url_text);
+ if (url.is_valid())
+ return true;
+ }
+ return false;
}
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