OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bookmarks/bookmark_context_menu_controller.h" | 5 #include "chrome/browser/ui/bookmarks/bookmark_context_menu_controller.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 AddItem(IDC_BOOKMARK_MANAGER, IDS_BOOKMARK_MANAGER); | 106 AddItem(IDC_BOOKMARK_MANAGER, IDS_BOOKMARK_MANAGER); |
107 // Use the native host desktop type in tests. | 107 // Use the native host desktop type in tests. |
108 if (chrome::IsAppsShortcutEnabled( | 108 if (chrome::IsAppsShortcutEnabled( |
109 profile_, | 109 profile_, |
110 browser_ ? browser_->host_desktop_type() | 110 browser_ ? browser_->host_desktop_type() |
111 : chrome::HOST_DESKTOP_TYPE_NATIVE)) { | 111 : chrome::HOST_DESKTOP_TYPE_NATIVE)) { |
112 AddCheckboxItem(IDC_BOOKMARK_BAR_SHOW_APPS_SHORTCUT, | 112 AddCheckboxItem(IDC_BOOKMARK_BAR_SHOW_APPS_SHORTCUT, |
113 IDS_BOOKMARK_BAR_SHOW_APPS_SHORTCUT); | 113 IDS_BOOKMARK_BAR_SHOW_APPS_SHORTCUT); |
114 } | 114 } |
115 AddCheckboxItem(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS, | 115 AddCheckboxItem(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS, |
116 IDS_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS); | 116 IDS_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS_DEFAULT_NAME); |
117 AddCheckboxItem(IDC_BOOKMARK_BAR_ALWAYS_SHOW, IDS_SHOW_BOOKMARK_BAR); | 117 AddCheckboxItem(IDC_BOOKMARK_BAR_ALWAYS_SHOW, IDS_SHOW_BOOKMARK_BAR); |
118 } | 118 } |
119 | 119 |
120 void BookmarkContextMenuController::AddItem(int id, int localization_id) { | 120 void BookmarkContextMenuController::AddItem(int id, int localization_id) { |
121 menu_model_->AddItemWithStringId(id, localization_id); | 121 menu_model_->AddItemWithStringId(id, localization_id); |
122 } | 122 } |
123 | 123 |
124 void BookmarkContextMenuController::AddSeparator() { | 124 void BookmarkContextMenuController::AddSeparator() { |
125 menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); | 125 menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); |
126 } | 126 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 NOTREACHED(); | 295 NOTREACHED(); |
296 } | 296 } |
297 | 297 |
298 if (delegate_) | 298 if (delegate_) |
299 delegate_->DidExecuteCommand(id); | 299 delegate_->DidExecuteCommand(id); |
300 } | 300 } |
301 | 301 |
302 bool BookmarkContextMenuController::IsItemForCommandIdDynamic(int command_id) | 302 bool BookmarkContextMenuController::IsItemForCommandIdDynamic(int command_id) |
303 const { | 303 const { |
304 return command_id == IDC_BOOKMARK_BAR_UNDO || | 304 return command_id == IDC_BOOKMARK_BAR_UNDO || |
305 command_id == IDC_BOOKMARK_BAR_REDO; | 305 command_id == IDC_BOOKMARK_BAR_REDO || |
| 306 command_id == IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS; |
306 } | 307 } |
307 | 308 |
308 base::string16 BookmarkContextMenuController::GetLabelForCommandId( | 309 base::string16 BookmarkContextMenuController::GetLabelForCommandId( |
309 int command_id) const { | 310 int command_id) const { |
310 if (command_id == IDC_BOOKMARK_BAR_UNDO) { | 311 if (command_id == IDC_BOOKMARK_BAR_UNDO) { |
311 return BookmarkUndoServiceFactory::GetForProfile(profile_)-> | 312 return BookmarkUndoServiceFactory::GetForProfile(profile_)-> |
312 undo_manager()->GetUndoLabel(); | 313 undo_manager()->GetUndoLabel(); |
313 } | 314 } |
314 if (command_id == IDC_BOOKMARK_BAR_REDO) { | 315 if (command_id == IDC_BOOKMARK_BAR_REDO) { |
315 return BookmarkUndoServiceFactory::GetForProfile(profile_)-> | 316 return BookmarkUndoServiceFactory::GetForProfile(profile_)-> |
316 undo_manager()->GetRedoLabel(); | 317 undo_manager()->GetRedoLabel(); |
317 } | 318 } |
| 319 if (command_id == IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS) { |
| 320 ChromeBookmarkClient* client = |
| 321 ChromeBookmarkClientFactory::GetForProfile(profile_); |
| 322 return l10n_util::GetStringFUTF16(IDS_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS, |
| 323 client->managed_node()->GetTitle()); |
| 324 } |
318 | 325 |
319 NOTREACHED(); | 326 NOTREACHED(); |
320 return base::string16(); | 327 return base::string16(); |
321 } | 328 } |
322 | 329 |
323 bool BookmarkContextMenuController::IsCommandIdChecked(int command_id) const { | 330 bool BookmarkContextMenuController::IsCommandIdChecked(int command_id) const { |
324 PrefService* prefs = profile_->GetPrefs(); | 331 PrefService* prefs = profile_->GetPrefs(); |
325 if (command_id == IDC_BOOKMARK_BAR_ALWAYS_SHOW) | 332 if (command_id == IDC_BOOKMARK_BAR_ALWAYS_SHOW) |
326 return prefs->GetBoolean(prefs::kShowBookmarkBar); | 333 return prefs->GetBoolean(prefs::kShowBookmarkBar); |
327 if (command_id == IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS) | 334 if (command_id == IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 bool BookmarkContextMenuController::GetAcceleratorForCommandId( | 425 bool BookmarkContextMenuController::GetAcceleratorForCommandId( |
419 int command_id, | 426 int command_id, |
420 ui::Accelerator* accelerator) { | 427 ui::Accelerator* accelerator) { |
421 return false; | 428 return false; |
422 } | 429 } |
423 | 430 |
424 void BookmarkContextMenuController::BookmarkModelChanged() { | 431 void BookmarkContextMenuController::BookmarkModelChanged() { |
425 if (delegate_) | 432 if (delegate_) |
426 delegate_->CloseMenu(); | 433 delegate_->CloseMenu(); |
427 } | 434 } |
OLD | NEW |