| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/toolbar/recent_tabs_sub_menu_model.h" | 5 #include "chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
| 13 #include "chrome/browser/favicon/favicon_service_factory.h" | 13 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/search/search.h" | 15 #include "chrome/browser/search/search.h" |
| 16 #include "chrome/browser/sessions/session_restore.h" | 16 #include "chrome/browser/sessions/session_restore.h" |
| 17 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 17 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 18 #include "chrome/browser/sync/profile_sync_service.h" | 18 #include "chrome/browser/sync/profile_sync_service.h" |
| 19 #include "chrome/browser/sync/profile_sync_service_factory.h" | 19 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 20 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 21 #include "chrome/browser/ui/browser_commands.h" | 21 #include "chrome/browser/ui/browser_commands.h" |
| 22 #include "chrome/browser/ui/browser_live_tab_context.h" | 22 #include "chrome/browser/ui/browser_live_tab_context.h" |
| 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 24 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 24 #include "chrome/browser/ui/toolbar/app_menu_model.h" |
| 25 #include "chrome/grit/generated_resources.h" | 25 #include "chrome/grit/generated_resources.h" |
| 26 #include "components/favicon_base/favicon_types.h" | 26 #include "components/favicon_base/favicon_types.h" |
| 27 #include "components/sessions/core/tab_restore_service.h" | 27 #include "components/sessions/core/tab_restore_service.h" |
| 28 #include "components/sync_driver/glue/synced_session.h" | 28 #include "components/sync_driver/glue/synced_session.h" |
| 29 #include "components/sync_driver/open_tabs_ui_delegate.h" | 29 #include "components/sync_driver/open_tabs_ui_delegate.h" |
| 30 #include "content/public/browser/user_metrics.h" | 30 #include "content/public/browser/user_metrics.h" |
| 31 #include "grit/browser_resources.h" | 31 #include "grit/browser_resources.h" |
| 32 #include "grit/theme_resources.h" | 32 #include "grit/theme_resources.h" |
| 33 #include "ui/base/accelerators/accelerator.h" | 33 #include "ui/base/accelerators/accelerator.h" |
| 34 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 56 // only have navigatabale/executable tab items. | 56 // only have navigatabale/executable tab items. |
| 57 // - |local_window_items_| only has executable open window items. | 57 // - |local_window_items_| only has executable open window items. |
| 58 // Using initial command IDs for local tab, local window and other devices' tab | 58 // Using initial command IDs for local tab, local window and other devices' tab |
| 59 // items makes it easier and less error-prone to manipulate the menumodel and | 59 // items makes it easier and less error-prone to manipulate the menumodel and |
| 60 // storage structures. These ids must be bigger than the maximum possible | 60 // storage structures. These ids must be bigger than the maximum possible |
| 61 // number of items in the menumodel, so that index of the last menu item doesn't | 61 // number of items in the menumodel, so that index of the last menu item doesn't |
| 62 // clash with these values when menu items are retrieved via | 62 // clash with these values when menu items are retrieved via |
| 63 // GetIndexOfCommandId(). | 63 // GetIndexOfCommandId(). |
| 64 // The range of all command ID's used in RecentTabsSubMenuModel, including the | 64 // The range of all command ID's used in RecentTabsSubMenuModel, including the |
| 65 // "Recently closed" headers, must be between | 65 // "Recently closed" headers, must be between |
| 66 // |WrenchMenuModel::kMinRecentTabsCommandId| i.e. 1001 and 1200 | 66 // |AppMenuModel::kMinRecentTabsCommandId| i.e. 1001 and 1200 |
| 67 // (|WrenchMenuModel::kMaxRecentTabsCommandId|) inclusively. | 67 // (|AppMenuModel::kMaxRecentTabsCommandId|) inclusively. |
| 68 const int kFirstLocalTabCommandId = WrenchMenuModel::kMinRecentTabsCommandId; | 68 const int kFirstLocalTabCommandId = AppMenuModel::kMinRecentTabsCommandId; |
| 69 const int kFirstLocalWindowCommandId = 1031; | 69 const int kFirstLocalWindowCommandId = 1031; |
| 70 const int kFirstOtherDevicesTabCommandId = 1051; | 70 const int kFirstOtherDevicesTabCommandId = 1051; |
| 71 const int kMinDeviceNameCommandId = 1100; | 71 const int kMinDeviceNameCommandId = 1100; |
| 72 const int kMaxDeviceNameCommandId = 1110; | 72 const int kMaxDeviceNameCommandId = 1110; |
| 73 | 73 |
| 74 // The maximum number of local recently closed entries (tab or window) to be | 74 // The maximum number of local recently closed entries (tab or window) to be |
| 75 // shown in the menu. | 75 // shown in the menu. |
| 76 const int kMaxLocalEntries = 8; | 76 const int kMaxLocalEntries = 8; |
| 77 | 77 |
| 78 // Index of the separator that follows the history menu item. Used as a | 78 // Index of the separator that follows the history menu item. Used as a |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 | 716 |
| 717 ui::MenuModelDelegate* menu_model_delegate = GetMenuModelDelegate(); | 717 ui::MenuModelDelegate* menu_model_delegate = GetMenuModelDelegate(); |
| 718 if (menu_model_delegate) | 718 if (menu_model_delegate) |
| 719 menu_model_delegate->OnMenuStructureChanged(); | 719 menu_model_delegate->OnMenuStructureChanged(); |
| 720 } | 720 } |
| 721 | 721 |
| 722 void RecentTabsSubMenuModel::TabRestoreServiceDestroyed( | 722 void RecentTabsSubMenuModel::TabRestoreServiceDestroyed( |
| 723 sessions::TabRestoreService* service) { | 723 sessions::TabRestoreService* service) { |
| 724 TabRestoreServiceChanged(service); | 724 TabRestoreServiceChanged(service); |
| 725 } | 725 } |
| OLD | NEW |