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_context_menu_controller.h" | 5 #include "chrome/browser/bookmarks/bookmark_context_menu_controller.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
9 #include "chrome/browser/bookmarks/bookmark_editor.h" | 9 #include "chrome/browser/bookmarks/bookmark_editor.h" |
10 #include "chrome/browser/bookmarks/bookmark_folder_editor_controller.h" | 10 #include "chrome/browser/bookmarks/bookmark_folder_editor_controller.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 case IDC_BOOKMARK_BAR_EDIT: | 131 case IDC_BOOKMARK_BAR_EDIT: |
132 UserMetrics::RecordAction( | 132 UserMetrics::RecordAction( |
133 UserMetricsAction("BookmarkBar_ContextMenu_Edit")); | 133 UserMetricsAction("BookmarkBar_ContextMenu_Edit")); |
134 | 134 |
135 if (selection_.size() != 1) { | 135 if (selection_.size() != 1) { |
136 NOTREACHED(); | 136 NOTREACHED(); |
137 break; | 137 break; |
138 } | 138 } |
139 | 139 |
140 if (selection_[0]->is_url()) { | 140 if (selection_[0]->is_url()) { |
| 141 #if defined(WEBUI_BOOKMARK_EDITOR) |
| 142 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); |
| 143 DCHECK(browser); |
| 144 browser->OpenBookmarkManagerEditNode(selection_[0]->id()); |
| 145 #else |
141 BookmarkEditor::Show(parent_window_, profile_, parent_, | 146 BookmarkEditor::Show(parent_window_, profile_, parent_, |
142 BookmarkEditor::EditDetails(selection_[0]), | 147 BookmarkEditor::EditDetails(selection_[0]), |
143 BookmarkEditor::SHOW_TREE); | 148 BookmarkEditor::SHOW_TREE); |
| 149 #endif |
144 } else { | 150 } else { |
145 BookmarkFolderEditorController::Show(profile_, parent_window_, | 151 BookmarkFolderEditorController::Show(profile_, parent_window_, |
146 selection_[0], -1, | 152 selection_[0], -1, |
147 BookmarkFolderEditorController::EXISTING_BOOKMARK); | 153 BookmarkFolderEditorController::EXISTING_BOOKMARK); |
148 } | 154 } |
149 break; | 155 break; |
150 | 156 |
151 case IDC_BOOKMARK_BAR_REMOVE: { | 157 case IDC_BOOKMARK_BAR_REMOVE: { |
152 UserMetrics::RecordAction( | 158 UserMetrics::RecordAction( |
153 UserMetricsAction("BookmarkBar_ContextMenu_Remove")); | 159 UserMetricsAction("BookmarkBar_ContextMenu_Remove")); |
154 | 160 |
155 for (size_t i = 0; i < selection_.size(); ++i) { | 161 for (size_t i = 0; i < selection_.size(); ++i) { |
156 int index = selection_[i]->parent()->GetIndexOf(selection_[i]); | 162 int index = selection_[i]->parent()->GetIndexOf(selection_[i]); |
157 if (index > -1) | 163 if (index > -1) |
158 model_->Remove(selection_[i]->parent(), index); | 164 model_->Remove(selection_[i]->parent(), index); |
159 } | 165 } |
160 selection_.clear(); | 166 selection_.clear(); |
161 break; | 167 break; |
162 } | 168 } |
163 | 169 |
164 case IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK: { | 170 case IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK: { |
165 UserMetrics::RecordAction( | 171 UserMetrics::RecordAction( |
166 UserMetricsAction("BookmarkBar_ContextMenu_Add")); | 172 UserMetricsAction("BookmarkBar_ContextMenu_Add")); |
167 | 173 |
| 174 #if defined(WEBUI_BOOKMARK_EDITOR) |
| 175 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); |
| 176 DCHECK(browser); |
| 177 browser->OpenBookmarkManagerAddNodeIn(selection_[0]->id()); |
| 178 #else |
168 // TODO: this should honor the index from GetParentForNewNodes. | 179 // TODO: this should honor the index from GetParentForNewNodes. |
169 BookmarkEditor::Show( | 180 BookmarkEditor::Show( |
170 parent_window_, profile_, | 181 parent_window_, profile_, |
171 bookmark_utils::GetParentForNewNodes(parent_, selection_, NULL), | 182 bookmark_utils::GetParentForNewNodes(parent_, selection_, NULL), |
172 BookmarkEditor::EditDetails(), BookmarkEditor::SHOW_TREE); | 183 BookmarkEditor::EditDetails(), BookmarkEditor::SHOW_TREE); |
| 184 #endif |
173 break; | 185 break; |
174 } | 186 } |
175 | 187 |
176 case IDC_BOOKMARK_BAR_NEW_FOLDER: { | 188 case IDC_BOOKMARK_BAR_NEW_FOLDER: { |
177 UserMetrics::RecordAction( | 189 UserMetrics::RecordAction( |
178 UserMetricsAction("BookmarkBar_ContextMenu_NewFolder")); | 190 UserMetricsAction("BookmarkBar_ContextMenu_NewFolder")); |
179 int index; | 191 int index; |
180 const BookmarkNode* parent = | 192 const BookmarkNode* parent = |
181 bookmark_utils::GetParentForNewNodes(parent_, selection_, &index); | 193 bookmark_utils::GetParentForNewNodes(parent_, selection_, &index); |
182 BookmarkFolderEditorController::Show(profile_, parent_window_, parent, | 194 BookmarkFolderEditorController::Show(profile_, parent_window_, parent, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 delegate_->CloseMenu(); | 310 delegate_->CloseMenu(); |
299 } | 311 } |
300 | 312 |
301 bool BookmarkContextMenuController::HasURLs() const { | 313 bool BookmarkContextMenuController::HasURLs() const { |
302 for (size_t i = 0; i < selection_.size(); ++i) { | 314 for (size_t i = 0; i < selection_.size(); ++i) { |
303 if (bookmark_utils::NodeHasURLs(selection_[i])) | 315 if (bookmark_utils::NodeHasURLs(selection_[i])) |
304 return true; | 316 return true; |
305 } | 317 } |
306 return false; | 318 return false; |
307 } | 319 } |
OLD | NEW |