| 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/string_number_conversions.h" | 8 #include "base/string_number_conversions.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" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 return l10n_util::GetStringUTF16(string_id); | 184 return l10n_util::GetStringUTF16(string_id); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void RecentTabsSubMenuModel::ExecuteCommand(int command_id) { | 187 void RecentTabsSubMenuModel::ExecuteCommand(int command_id) { |
| 188 ExecuteCommand(command_id, 0); | 188 ExecuteCommand(command_id, 0); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void RecentTabsSubMenuModel::ExecuteCommand(int command_id, int event_flags) { | 191 void RecentTabsSubMenuModel::ExecuteCommand(int command_id, int event_flags) { |
| 192 if (command_id == IDC_RESTORE_TAB) { | 192 if (command_id == IDC_RESTORE_TAB) { |
| 193 chrome::ExecuteCommandWithDisposition(browser_, command_id, | 193 chrome::ExecuteCommandWithDisposition(browser_, command_id, |
| 194 chrome::DispositionFromEventFlags(event_flags)); | 194 ui::DispositionFromEventFlags(event_flags)); |
| 195 return; | 195 return; |
| 196 } | 196 } |
| 197 | 197 |
| 198 DCHECK_NE(kDisabledCommandId, command_id); | 198 DCHECK_NE(kDisabledCommandId, command_id); |
| 199 DCHECK_NE(IDC_RECENT_TABS_NO_DEVICE_TABS, command_id); | 199 DCHECK_NE(IDC_RECENT_TABS_NO_DEVICE_TABS, command_id); |
| 200 | 200 |
| 201 int model_idx = CommandIdToModelIndex(command_id); | 201 int model_idx = CommandIdToModelIndex(command_id); |
| 202 DCHECK(model_idx >= 0 && model_idx < static_cast<int>(model_.size())); | 202 DCHECK(model_idx >= 0 && model_idx < static_cast<int>(model_.size())); |
| 203 const NavigationItem& item = model_[model_idx]; | 203 const NavigationItem& item = model_[model_idx]; |
| 204 DCHECK(item.tab_id > -1 && item.url.is_valid()); | 204 DCHECK(item.tab_id > -1 && item.url.is_valid()); |
| 205 | 205 |
| 206 WindowOpenDisposition disposition = | 206 WindowOpenDisposition disposition = |
| 207 chrome::DispositionFromEventFlags(event_flags); | 207 ui::DispositionFromEventFlags(event_flags); |
| 208 if (disposition == CURRENT_TAB) // Force to open a new foreground tab. | 208 if (disposition == CURRENT_TAB) // Force to open a new foreground tab. |
| 209 disposition = NEW_FOREGROUND_TAB; | 209 disposition = NEW_FOREGROUND_TAB; |
| 210 | 210 |
| 211 if (item.session_tag.empty()) { // Restore tab of local session. | 211 if (item.session_tag.empty()) { // Restore tab of local session. |
| 212 TabRestoreService* service = | 212 TabRestoreService* service = |
| 213 TabRestoreServiceFactory::GetForProfile(browser_->profile()); | 213 TabRestoreServiceFactory::GetForProfile(browser_->profile()); |
| 214 if (!service) | 214 if (!service) |
| 215 return; | 215 return; |
| 216 TabRestoreServiceDelegate* delegate = | 216 TabRestoreServiceDelegate* delegate = |
| 217 TabRestoreServiceDelegate::FindDelegateForWebContents( | 217 TabRestoreServiceDelegate::FindDelegateForWebContents( |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 RecentTabsSubMenuModel::GetModelAssociator() { | 448 RecentTabsSubMenuModel::GetModelAssociator() { |
| 449 if (!associator_) { | 449 if (!associator_) { |
| 450 ProfileSyncService* service = ProfileSyncServiceFactory::GetInstance()-> | 450 ProfileSyncService* service = ProfileSyncServiceFactory::GetInstance()-> |
| 451 GetForProfile(browser_->profile()); | 451 GetForProfile(browser_->profile()); |
| 452 // Only return the associator if it exists and it is done syncing sessions. | 452 // Only return the associator if it exists and it is done syncing sessions. |
| 453 if (service && service->ShouldPushChanges()) | 453 if (service && service->ShouldPushChanges()) |
| 454 associator_ = service->GetSessionModelAssociator(); | 454 associator_ = service->GetSessionModelAssociator(); |
| 455 } | 455 } |
| 456 return associator_; | 456 return associator_; |
| 457 } | 457 } |
| OLD | NEW |