OLD | NEW |
1 // Copyright (c) 2010 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/bookmarks/bookmark_editor.h" | 5 #include "chrome/browser/bookmarks/bookmark_editor.h" |
| 6 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 7 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
6 | 8 |
7 #include "googleurl/src/gurl.h" | 9 BookmarkEditor::EditDetails::EditDetails(Type node_type) |
8 | 10 : type(node_type) { |
9 BookmarkEditor::EditDetails::EditDetails() | |
10 : type(NEW_URL), | |
11 existing_node(NULL) { | |
12 } | 11 } |
13 | 12 |
14 BookmarkEditor::EditDetails::EditDetails(const BookmarkNode* node) | 13 BookmarkEditor::EditDetails BookmarkEditor::EditDetails::EditNode( |
15 : type(EXISTING_NODE), | 14 const BookmarkNode* node) { |
16 existing_node(node) { | 15 EditDetails details(EXISTING_NODE); |
| 16 details.existing_node = node; |
| 17 return details; |
| 18 } |
| 19 |
| 20 BookmarkEditor::EditDetails BookmarkEditor::EditDetails::AddNodeInFolder( |
| 21 const BookmarkNode* parent_node) { |
| 22 EditDetails details(NEW_URL); |
| 23 details.parent_node = parent_node; |
| 24 return details; |
| 25 } |
| 26 |
| 27 BookmarkEditor::EditDetails BookmarkEditor::EditDetails::AddFolder( |
| 28 const BookmarkNode* parent_node) { |
| 29 EditDetails details(NEW_FOLDER); |
| 30 details.parent_node = parent_node; |
| 31 return details; |
17 } | 32 } |
18 | 33 |
19 BookmarkEditor::EditDetails::~EditDetails() { | 34 BookmarkEditor::EditDetails::~EditDetails() { |
20 } | 35 } |
| 36 |
| 37 void BookmarkEditor::Show(gfx::NativeWindow parent_window, |
| 38 Profile* profile, |
| 39 const EditDetails& details, |
| 40 Configuration configuration) { |
| 41 // TODO(flackr): Implement NEW_FOLDER type in WebUI and remove the type check. |
| 42 if (ChromeWebUI::IsMoreWebUI() && ( |
| 43 details.type == EditDetails::EXISTING_NODE || |
| 44 details.type == EditDetails::NEW_URL)) { |
| 45 ShowWebUI(profile, details); |
| 46 return; |
| 47 } |
| 48 |
| 49 // Delegate to the platform native bookmark editor code. |
| 50 ShowNative(parent_window, profile, details.parent_node, details, |
| 51 configuration); |
| 52 } |
OLD | NEW |