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/ui/gtk/global_history_menu.h" | 5 #include "chrome/browser/ui/gtk/global_history_menu.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 WindowOpenDisposition disposition = | 375 WindowOpenDisposition disposition = |
376 gtk_util::DispositionForCurrentButtonPressEvent(); | 376 gtk_util::DispositionForCurrentButtonPressEvent(); |
377 HistoryItem* item = HistoryItemForMenuItem(sender); | 377 HistoryItem* item = HistoryItemForMenuItem(sender); |
378 | 378 |
379 // If this item can be restored using TabRestoreService, do so. Otherwise, | 379 // If this item can be restored using TabRestoreService, do so. Otherwise, |
380 // just load the URL. | 380 // just load the URL. |
381 TabRestoreService* service = | 381 TabRestoreService* service = |
382 TabRestoreServiceFactory::GetForProfile(browser_->profile()); | 382 TabRestoreServiceFactory::GetForProfile(browser_->profile()); |
383 if (item->session_id && service) { | 383 if (item->session_id && service) { |
384 service->RestoreEntryById(browser_->tab_restore_service_delegate(), | 384 service->RestoreEntryById(browser_->tab_restore_service_delegate(), |
385 item->session_id, false); | 385 item->session_id, UNKNOWN); |
386 } else { | 386 } else { |
387 DCHECK(item->url.is_valid()); | 387 DCHECK(item->url.is_valid()); |
388 browser_->OpenURL(OpenURLParams(item->url, GURL(), disposition, | 388 browser_->OpenURL(OpenURLParams(item->url, GURL(), disposition, |
389 content::PAGE_TRANSITION_AUTO_BOOKMARK, false)); | 389 content::PAGE_TRANSITION_AUTO_BOOKMARK, false)); |
390 } | 390 } |
391 } | 391 } |
392 | 392 |
393 void GlobalHistoryMenu::OnMenuActivate(GtkWidget* sender) { | 393 void GlobalHistoryMenu::OnMenuActivate(GtkWidget* sender) { |
394 if (!tab_restore_service_) { | 394 if (!tab_restore_service_) { |
395 tab_restore_service_ = TabRestoreServiceFactory::GetForProfile(profile_); | 395 tab_restore_service_ = TabRestoreServiceFactory::GetForProfile(profile_); |
396 if (tab_restore_service_) { | 396 if (tab_restore_service_) { |
397 tab_restore_service_->LoadTabsFromLastSession(); | 397 tab_restore_service_->LoadTabsFromLastSession(); |
398 tab_restore_service_->AddObserver(this); | 398 tab_restore_service_->AddObserver(this); |
399 | 399 |
400 // If LoadTabsFromLastSession doesn't load tabs, it won't call | 400 // If LoadTabsFromLastSession doesn't load tabs, it won't call |
401 // TabRestoreServiceChanged(). This ensures that all new windows after | 401 // TabRestoreServiceChanged(). This ensures that all new windows after |
402 // the first one will have their menus populated correctly. | 402 // the first one will have their menus populated correctly. |
403 TabRestoreServiceChanged(tab_restore_service_); | 403 TabRestoreServiceChanged(tab_restore_service_); |
404 } | 404 } |
405 } | 405 } |
406 } | 406 } |
OLD | NEW |