| OLD | NEW |
| 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/bookmarks/bookmark_editor.h" | 5 #include "chrome/browser/bookmarks/bookmark_editor.h" |
| 6 #include "chrome/browser/bookmarks/bookmark_input_window_dialog_controller.h" |
| 6 #include "chrome/browser/bookmarks/bookmark_model.h" | 7 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 7 #include "chrome/browser/ui/webui/chrome_web_ui.h" | 8 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
| 8 | 9 |
| 9 BookmarkEditor::EditDetails::EditDetails(Type node_type) | 10 BookmarkEditor::EditDetails::EditDetails(Type node_type) |
| 10 : type(node_type), existing_node(NULL), parent_node(NULL) { | 11 : type(node_type), existing_node(NULL), parent_node(NULL) { |
| 11 } | 12 } |
| 12 | 13 |
| 13 BookmarkEditor::EditDetails BookmarkEditor::EditDetails::EditNode( | 14 BookmarkEditor::EditDetails BookmarkEditor::EditDetails::EditNode( |
| 14 const BookmarkNode* node) { | 15 const BookmarkNode* node) { |
| 15 EditDetails details(EXISTING_NODE); | 16 EditDetails details(EXISTING_NODE); |
| 16 details.existing_node = node; | 17 details.existing_node = node; |
| 17 if (node) | 18 if (node) |
| 18 details.parent_node = node->parent(); | 19 details.parent_node = node->parent(); |
| 19 return details; | 20 return details; |
| 20 } | 21 } |
| 21 | 22 |
| 22 BookmarkEditor::EditDetails BookmarkEditor::EditDetails::AddNodeInFolder( | 23 BookmarkEditor::EditDetails BookmarkEditor::EditDetails::AddNodeInFolder( |
| 23 const BookmarkNode* parent_node) { | 24 const BookmarkNode* parent_node, |
| 25 int index) { |
| 24 EditDetails details(NEW_URL); | 26 EditDetails details(NEW_URL); |
| 25 details.parent_node = parent_node; | 27 details.parent_node = parent_node; |
| 28 details.index = index; |
| 26 return details; | 29 return details; |
| 27 } | 30 } |
| 28 | 31 |
| 29 BookmarkEditor::EditDetails BookmarkEditor::EditDetails::AddFolder( | 32 BookmarkEditor::EditDetails BookmarkEditor::EditDetails::AddFolder( |
| 30 const BookmarkNode* parent_node) { | 33 const BookmarkNode* parent_node, |
| 34 int index) { |
| 31 EditDetails details(NEW_FOLDER); | 35 EditDetails details(NEW_FOLDER); |
| 32 details.parent_node = parent_node; | 36 details.parent_node = parent_node; |
| 37 details.index = index; |
| 33 return details; | 38 return details; |
| 34 } | 39 } |
| 35 | 40 |
| 36 BookmarkEditor::EditDetails::~EditDetails() { | 41 BookmarkEditor::EditDetails::~EditDetails() { |
| 37 } | 42 } |
| 38 | 43 |
| 39 void BookmarkEditor::Show(gfx::NativeWindow parent_window, | 44 void BookmarkEditor::Show(gfx::NativeWindow parent_window, |
| 40 Profile* profile, | 45 Profile* profile, |
| 41 const EditDetails& details, | 46 const EditDetails& details, |
| 42 Configuration configuration) { | 47 Configuration configuration) { |
| 43 #if defined(USE_AURA) | 48 #if defined(USE_AURA) |
| 44 // TODO(saintlou): Aura uses always "more WebUI". Remove test when flackr is | 49 // TODO(saintlou): Aura uses always "more WebUI". Remove test when flackr is |
| 45 // done as per his note below. | 50 // done as per his note below. |
| 46 if (details.type == EditDetails::EXISTING_NODE || | 51 if (details.type != EditDetails::NEW_FOLDER || details.urls.empty()) { |
| 47 details.type == EditDetails::NEW_URL) { | 52 BookmarkInputWindowDialogController::Show(profile, parent_window, details); |
| 48 ShowWebUI(profile, details); | |
| 49 } | 53 } |
| 50 #else | 54 #else |
| 51 // TODO(flackr): Implement NEW_FOLDER type in WebUI and remove the type check. | 55 // TODO(flackr): Implement NEW_FOLDER type with non-empty |details.urls| in |
| 52 if (ChromeWebUI::IsMoreWebUI() && ( | 56 // WebUI and remove the type check. |
| 53 details.type == EditDetails::EXISTING_NODE || | 57 if ((ChromeWebUI::IsMoreWebUI() && |
| 54 details.type == EditDetails::NEW_URL)) { | 58 (details.type != EditDetails::NEW_FOLDER || details.urls.empty())) || |
| 55 ShowWebUI(profile, details); | 59 (details.type == EditDetails::EXISTING_NODE && |
| 60 details.existing_node->is_folder()) || |
| 61 (details.type == EditDetails::NEW_FOLDER && |
| 62 details.urls.empty())) { |
| 63 BookmarkInputWindowDialogController::Show(profile, parent_window, details); |
| 56 return; | 64 return; |
| 57 } | 65 } |
| 58 | 66 |
| 59 // Delegate to the platform native bookmark editor code. | 67 // Delegate to the platform native bookmark editor code. |
| 60 ShowNative(parent_window, profile, details.parent_node, details, | 68 ShowNative(parent_window, profile, details.parent_node, details, |
| 61 configuration); | 69 configuration); |
| 62 #endif | 70 #endif |
| 63 } | 71 } |
| OLD | NEW |