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

Unified Diff: chrome/browser/ui/webui/bookmarks_ui.cc

Issue 8314017: Fix minor WebUI dialog issues, mostly with bookmark management (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweaks from flackr CR Created 9 years, 2 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 | « chrome/browser/ui/cocoa/browser_window_controller.mm ('k') | chrome/browser/ui/webui/certificate_viewer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/bookmarks_ui.cc
diff --git a/chrome/browser/ui/webui/bookmarks_ui.cc b/chrome/browser/ui/webui/bookmarks_ui.cc
index c42002295f931cc52ad5d41622df88b5d5e93534..76739974beaf4e1e11dce8562c87a09aeaad914f 100644
--- a/chrome/browser/ui/webui/bookmarks_ui.cc
+++ b/chrome/browser/ui/webui/bookmarks_ui.cc
@@ -11,6 +11,7 @@
#include "base/stringprintf.h"
#include "chrome/browser/bookmarks/bookmark_editor.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
+#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
@@ -77,19 +78,33 @@ RefCountedMemory* BookmarksUI::GetFaviconResourceBytes() {
// static
void BookmarkEditor::ShowWebUI(Profile* profile,
const EditDetails& details) {
- GURL url(chrome::kChromeUIBookmarksURL);
+ int64 editId = 0;
if (details.type == EditDetails::EXISTING_NODE) {
DCHECK(details.existing_node);
- url = url.Resolve(StringPrintf("/#e=%s",
- base::Int64ToString(details.existing_node->id()).c_str()));
+ editId = details.existing_node->id();
} else if (details.type == EditDetails::NEW_URL) {
DCHECK(details.parent_node);
- url = url.Resolve(StringPrintf("/#a=%s",
- base::Int64ToString(details.parent_node->id()).c_str()));
+ // Add a new bookmark with the title/URL of the current tab.
+ GURL bmUrl;
+ string16 bmTitle;
+ bookmark_utils::GetURLAndTitleToBookmarkFromCurrentTab(profile, &bmUrl,
+ &bmTitle);
+ BookmarkModel* bm = profile->GetBookmarkModel();
+ const BookmarkNode* newNode = bm->AddURL(details.parent_node,
+ details.parent_node->child_count(), bmTitle, bmUrl);
+
+ // Just edit this bookmark like for editing an existing node.
+ // TODO(rbyers): This is to be replaced with a WebUI dialog to prevent
+ // the context switch to a different tab.
+ editId = newNode->id();
} else {
NOTREACHED() << "Unhandled bookmark edit details type";
}
- // Get parent browser object.
+
+ GURL url = GURL(chrome::kChromeUIBookmarksURL).Resolve(StringPrintf("/#e=%s",
+ base::Int64ToString(editId).c_str()));
+
+ // Invoke the WebUI bookmark editor to edit the specified bookmark.
Browser* browser = BrowserList::GetLastActiveWithProfile(profile);
DCHECK(browser);
browser::NavigateParams params(
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.mm ('k') | chrome/browser/ui/webui/certificate_viewer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698