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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/bookmarks_ui.h" 5 #include "chrome/browser/ui/webui/bookmarks_ui.h"
6 6
7 #include "base/memory/ref_counted_memory.h" 7 #include "base/memory/ref_counted_memory.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
12 #include "chrome/browser/bookmarks/bookmark_editor.h" 12 #include "chrome/browser/bookmarks/bookmark_editor.h"
13 #include "chrome/browser/bookmarks/bookmark_model.h" 13 #include "chrome/browser/bookmarks/bookmark_model.h"
14 #include "chrome/browser/bookmarks/bookmark_utils.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_list.h" 17 #include "chrome/browser/ui/browser_list.h"
17 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 18 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
18 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
19 #include "content/browser/tab_contents/tab_contents.h" 20 #include "content/browser/tab_contents/tab_contents.h"
20 #include "grit/theme_resources.h" 21 #include "grit/theme_resources.h"
21 #include "grit/theme_resources_standard.h" 22 #include "grit/theme_resources_standard.h"
22 #include "ui/base/resource/resource_bundle.h" 23 #include "ui/base/resource/resource_bundle.h"
23 #include "googleurl/src/gurl.h" 24 #include "googleurl/src/gurl.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 71
71 //////////////////////////////////////////////////////////////////////////////// 72 ////////////////////////////////////////////////////////////////////////////////
72 // 73 //
73 // BookmarkEditor 74 // BookmarkEditor
74 // 75 //
75 //////////////////////////////////////////////////////////////////////////////// 76 ////////////////////////////////////////////////////////////////////////////////
76 77
77 // static 78 // static
78 void BookmarkEditor::ShowWebUI(Profile* profile, 79 void BookmarkEditor::ShowWebUI(Profile* profile,
79 const EditDetails& details) { 80 const EditDetails& details) {
80 GURL url(chrome::kChromeUIBookmarksURL); 81 int64 editId = 0;
81 if (details.type == EditDetails::EXISTING_NODE) { 82 if (details.type == EditDetails::EXISTING_NODE) {
82 DCHECK(details.existing_node); 83 DCHECK(details.existing_node);
83 url = url.Resolve(StringPrintf("/#e=%s", 84 editId = details.existing_node->id();
84 base::Int64ToString(details.existing_node->id()).c_str()));
85 } else if (details.type == EditDetails::NEW_URL) { 85 } else if (details.type == EditDetails::NEW_URL) {
86 DCHECK(details.parent_node); 86 DCHECK(details.parent_node);
87 url = url.Resolve(StringPrintf("/#a=%s", 87 // Add a new bookmark with the title/URL of the current tab.
88 base::Int64ToString(details.parent_node->id()).c_str())); 88 GURL bmUrl;
89 string16 bmTitle;
90 bookmark_utils::GetURLAndTitleToBookmarkFromCurrentTab(profile, &bmUrl,
91 &bmTitle);
92 BookmarkModel* bm = profile->GetBookmarkModel();
93 const BookmarkNode* newNode = bm->AddURL(details.parent_node,
94 details.parent_node->child_count(), bmTitle, bmUrl);
95
96 // Just edit this bookmark like for editing an existing node.
97 // TODO(rbyers): This is to be replaced with a WebUI dialog to prevent
98 // the context switch to a different tab.
99 editId = newNode->id();
89 } else { 100 } else {
90 NOTREACHED() << "Unhandled bookmark edit details type"; 101 NOTREACHED() << "Unhandled bookmark edit details type";
91 } 102 }
92 // Get parent browser object. 103
104 GURL url = GURL(chrome::kChromeUIBookmarksURL).Resolve(StringPrintf("/#e=%s",
105 base::Int64ToString(editId).c_str()));
106
107 // Invoke the WebUI bookmark editor to edit the specified bookmark.
93 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); 108 Browser* browser = BrowserList::GetLastActiveWithProfile(profile);
94 DCHECK(browser); 109 DCHECK(browser);
95 browser::NavigateParams params( 110 browser::NavigateParams params(
96 browser->GetSingletonTabNavigateParams(url)); 111 browser->GetSingletonTabNavigateParams(url));
97 params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; 112 params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE;
98 browser->ShowSingletonTabOverwritingNTP(params); 113 browser->ShowSingletonTabOverwritingNTP(params);
99 } 114 }
OLDNEW
« 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