| 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/gtk/bookmarks/bookmark_sub_menu_model_gtk.h" | 5 #include "chrome/browser/ui/gtk/bookmarks/bookmark_sub_menu_model_gtk.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/string16.h" | 8 #include "base/string16.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_model.h" | 11 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 13 #include "chrome/browser/event_disposition.h" | |
| 14 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" | 15 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" |
| 17 #include "chrome/browser/ui/gtk/menu_gtk.h" | 16 #include "chrome/browser/ui/gtk/menu_gtk.h" |
| 18 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 19 #include "ui/base/gtk/menu_label_accelerator_util.h" | 18 #include "ui/base/gtk/menu_label_accelerator_util.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "ui/base/window_open_disposition.h" |
| 21 | 21 |
| 22 using content::OpenURLParams; | 22 using content::OpenURLParams; |
| 23 using content::PageNavigator; | 23 using content::PageNavigator; |
| 24 | 24 |
| 25 // Per chrome/app/chrome_command_ids.h, values < 4000 are for "dynamic menu | 25 // Per chrome/app/chrome_command_ids.h, values < 4000 are for "dynamic menu |
| 26 // items". We only use one command id for all the bookmarks, because we handle | 26 // items". We only use one command id for all the bookmarks, because we handle |
| 27 // bookmark item activations directly. So we pick a suitably large random value | 27 // bookmark item activations directly. So we pick a suitably large random value |
| 28 // and use that to avoid accidental conflicts with other dynamic items. | 28 // and use that to avoid accidental conflicts with other dynamic items. |
| 29 static const int kBookmarkItemCommandId = 1759; | 29 static const int kBookmarkItemCommandId = 1759; |
| 30 | 30 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 56 | 56 |
| 57 void BookmarkNodeMenuModel::MenuClosed() { | 57 void BookmarkNodeMenuModel::MenuClosed() { |
| 58 Clear(); | 58 Clear(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void BookmarkNodeMenuModel::ActivatedAt(int index) { | 61 void BookmarkNodeMenuModel::ActivatedAt(int index) { |
| 62 NavigateToMenuItem(index, CURRENT_TAB); | 62 NavigateToMenuItem(index, CURRENT_TAB); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void BookmarkNodeMenuModel::ActivatedAt(int index, int event_flags) { | 65 void BookmarkNodeMenuModel::ActivatedAt(int index, int event_flags) { |
| 66 NavigateToMenuItem(index, chrome::DispositionFromEventFlags(event_flags)); | 66 NavigateToMenuItem(index, ui::DispositionFromEventFlags(event_flags)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void BookmarkNodeMenuModel::PopulateMenu() { | 69 void BookmarkNodeMenuModel::PopulateMenu() { |
| 70 DCHECK(submenus_.empty()); | 70 DCHECK(submenus_.empty()); |
| 71 for (int i = 0; i < node_->child_count(); ++i) { | 71 for (int i = 0; i < node_->child_count(); ++i) { |
| 72 const BookmarkNode* child = node_->GetChild(i); | 72 const BookmarkNode* child = node_->GetChild(i); |
| 73 if (child->is_folder()) { | 73 if (child->is_folder()) { |
| 74 AddSubMenuForNode(child); | 74 AddSubMenuForNode(child); |
| 75 } else { | 75 } else { |
| 76 // Ironically the label will end up getting converted back to UTF8 later. | 76 // Ironically the label will end up getting converted back to UTF8 later. |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 221 |
| 222 bool BookmarkSubMenuModel::IsVisibleAt(int index) const { | 222 bool BookmarkSubMenuModel::IsVisibleAt(int index) const { |
| 223 // We don't want the delegate interfering with bookmark items. | 223 // We don't want the delegate interfering with bookmark items. |
| 224 return index >= fixed_items_ || SimpleMenuModel::IsVisibleAt(index); | 224 return index >= fixed_items_ || SimpleMenuModel::IsVisibleAt(index); |
| 225 } | 225 } |
| 226 | 226 |
| 227 // static | 227 // static |
| 228 bool BookmarkSubMenuModel::IsBookmarkItemCommandId(int command_id) { | 228 bool BookmarkSubMenuModel::IsBookmarkItemCommandId(int command_id) { |
| 229 return command_id == kBookmarkItemCommandId; | 229 return command_id == kBookmarkItemCommandId; |
| 230 } | 230 } |
| OLD | NEW |