Chromium Code Reviews| Index: chrome/browser/bookmarks/bookmark_editor.cc |
| diff --git a/chrome/browser/bookmarks/bookmark_editor.cc b/chrome/browser/bookmarks/bookmark_editor.cc |
| index 2e940fcfc9c6b5313b27854fd008cf9da45cde02..a425cb01b02afb746b3034b61dce038676adae3f 100644 |
| --- a/chrome/browser/bookmarks/bookmark_editor.cc |
| +++ b/chrome/browser/bookmarks/bookmark_editor.cc |
| @@ -2,19 +2,80 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include "base/string_number_conversions.h" |
| +#include "base/stringprintf.h" |
| #include "chrome/browser/bookmarks/bookmark_editor.h" |
| +#include "chrome/browser/bookmarks/bookmark_model.h" |
| +#include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/browser_list.h" |
| +#include "chrome/browser/ui/webui/chrome_web_ui.h" |
| +#include "chrome/common/url_constants.h" |
| #include "googleurl/src/gurl.h" |
| -BookmarkEditor::EditDetails::EditDetails() |
| - : type(NEW_URL), |
| - existing_node(NULL) { |
| +// TODO(flackr): Remove this and create runtime flag for webui dialogs |
|
Rick Byers
2011/08/18 19:25:30
I'm confused, I thought creating a runtime flag is
flackr
2011/08/23 17:41:44
Oops that was leftover from when I was using --use
|
| +#include "views/widget/widget.h" |
| + |
| +BookmarkEditor::EditDetails::EditDetails() { |
| +} |
| + |
| +BookmarkEditor::EditDetails BookmarkEditor::EditDetails::EditNode( |
| + const BookmarkNode* node) { |
| + EditDetails details; |
| + details.type = EXISTING_NODE; |
| + details.existing_node = node; |
| + return details; |
| +} |
| + |
| +BookmarkEditor::EditDetails BookmarkEditor::EditDetails::AddNodeInFolder( |
| + const BookmarkNode* parent_node) { |
| + EditDetails details; |
| + details.type = NEW_URL; |
| + details.parent_node = parent_node; |
| + return details; |
| } |
| -BookmarkEditor::EditDetails::EditDetails(const BookmarkNode* node) |
| - : type(EXISTING_NODE), |
| - existing_node(node) { |
| +BookmarkEditor::EditDetails BookmarkEditor::EditDetails::AddFolder( |
| + const BookmarkNode* parent_node) { |
| + EditDetails details; |
| + details.type = NEW_FOLDER; |
| + details.parent_node = parent_node; |
| + return details; |
| } |
| BookmarkEditor::EditDetails::~EditDetails() { |
| } |
| + |
| +void BookmarkEditor::Show(gfx::NativeWindow parent_window, |
| + Profile* profile, |
| + const EditDetails& details, |
| + Configuration configuration) { |
| + if (ChromeWebUI::IsMoreWebUI() && ( |
|
Rick Byers
2011/08/18 19:25:30
Minor, but it might be nice to split the WebUI por
flackr
2011/08/23 17:41:44
Done.
|
| + details.type == EditDetails::EXISTING_NODE || |
|
Rick Byers
2011/08/18 19:25:30
This is (very) temporary, right? Add a TODO for i
Rick Byers
2011/08/18 19:25:30
Is this indentation level right? Off the top of m
flackr
2011/08/23 17:41:44
Done.
flackr
2011/08/23 17:41:44
Done.
|
| + details.type == EditDetails::NEW_URL)) { |
| + GURL url(chrome::kChromeUIBookmarksURL); |
| + if (details.type == EditDetails::EXISTING_NODE) { |
| + DCHECK(details.existing_node); |
| + url = url.Resolve(StringPrintf("/#e=%s", |
| + base::Int64ToString(details.existing_node->id()).c_str())); |
| + } 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())); |
| + } else { |
| + NOTREACHED() << "Unhandled bookmark edit details type"; |
| + } |
| + // Get parent browser object. |
| + Browser* browser = BrowserList::GetLastActiveWithProfile(profile); |
| + DCHECK(browser); |
| + browser::NavigateParams params( |
| + browser->GetSingletonTabNavigateParams(url)); |
| + params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
| + browser->ShowSingletonTabOverwritingNTP(params); |
| + return; |
| + } |
| + |
| + // Delegate to the platform native bookmark editor code. |
| + ShowNative(parent_window, profile, details.parent_node, details, |
| + configuration); |
| +} |