| 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/browser_commands.h" | 5 #include "chrome/browser/ui/browser_commands.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_editor.h" | 10 #include "chrome/browser/bookmarks/bookmark_editor.h" |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 void DuplicateTab(Browser* browser) { | 480 void DuplicateTab(Browser* browser) { |
| 481 content::RecordAction(UserMetricsAction("Duplicate")); | 481 content::RecordAction(UserMetricsAction("Duplicate")); |
| 482 DuplicateTabAt(browser, browser->active_index()); | 482 DuplicateTabAt(browser, browser->active_index()); |
| 483 } | 483 } |
| 484 | 484 |
| 485 bool CanDuplicateTab(const Browser* browser) { | 485 bool CanDuplicateTab(const Browser* browser) { |
| 486 WebContents* contents = GetActiveWebContents(browser); | 486 WebContents* contents = GetActiveWebContents(browser); |
| 487 return contents && contents->GetController().GetLastCommittedEntry(); | 487 return contents && contents->GetController().GetLastCommittedEntry(); |
| 488 } | 488 } |
| 489 | 489 |
| 490 void DuplicateTabAt(Browser* browser, int index) { | 490 TabContents* DuplicateTabAt(Browser* browser, int index) { |
| 491 TabContents* contents = GetTabContentsAt(browser, index); | 491 TabContents* contents = GetTabContentsAt(browser, index); |
| 492 CHECK(contents); | 492 CHECK(contents); |
| 493 TabContents* contents_dupe = contents->Clone(); | 493 TabContents* contents_dupe = contents->Clone(); |
| 494 | 494 |
| 495 bool pinned = false; | 495 bool pinned = false; |
| 496 if (browser->CanSupportWindowFeature(Browser::FEATURE_TABSTRIP)) { | 496 if (browser->CanSupportWindowFeature(Browser::FEATURE_TABSTRIP)) { |
| 497 // If this is a tabbed browser, just create a duplicate tab inside the same | 497 // If this is a tabbed browser, just create a duplicate tab inside the same |
| 498 // window next to the tab being duplicated. | 498 // window next to the tab being duplicated. |
| 499 int index = browser->tab_strip_model()->GetIndexOfTabContents(contents); | 499 int index = browser->tab_strip_model()->GetIndexOfTabContents(contents); |
| 500 pinned = browser->tab_strip_model()->IsTabPinned(index); | 500 pinned = browser->tab_strip_model()->IsTabPinned(index); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 529 browser->window()->Show(); | 529 browser->window()->Show(); |
| 530 | 530 |
| 531 // The page transition below is only for the purpose of inserting the tab. | 531 // The page transition below is only for the purpose of inserting the tab. |
| 532 AddTab(browser, contents_dupe, content::PAGE_TRANSITION_LINK); | 532 AddTab(browser, contents_dupe, content::PAGE_TRANSITION_LINK); |
| 533 } | 533 } |
| 534 | 534 |
| 535 SessionService* session_service = | 535 SessionService* session_service = |
| 536 SessionServiceFactory::GetForProfileIfExisting(browser->profile()); | 536 SessionServiceFactory::GetForProfileIfExisting(browser->profile()); |
| 537 if (session_service) | 537 if (session_service) |
| 538 session_service->TabRestored(contents_dupe, pinned); | 538 session_service->TabRestored(contents_dupe, pinned); |
| 539 return contents_dupe; |
| 539 } | 540 } |
| 540 | 541 |
| 541 bool CanDuplicateTabAt(Browser* browser, int index) { | 542 bool CanDuplicateTabAt(Browser* browser, int index) { |
| 542 content::NavigationController& nc = | 543 content::NavigationController& nc = |
| 543 GetWebContentsAt(browser, index)->GetController(); | 544 GetWebContentsAt(browser, index)->GetController(); |
| 544 return nc.GetWebContents() && nc.GetLastCommittedEntry(); | 545 return nc.GetWebContents() && nc.GetLastCommittedEntry(); |
| 545 } | 546 } |
| 546 | 547 |
| 547 void ConvertPopupToTabbedBrowser(Browser* browser) { | 548 void ConvertPopupToTabbedBrowser(Browser* browser) { |
| 548 content::RecordAction(UserMetricsAction("ShowAsTab")); | 549 content::RecordAction(UserMetricsAction("ShowAsTab")); |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 if (!tab_contents) | 990 if (!tab_contents) |
| 990 tab_contents = new TabContents(contents); | 991 tab_contents = new TabContents(contents); |
| 991 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); | 992 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); |
| 992 | 993 |
| 993 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 994 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 994 contents->GetRenderViewHost()->SyncRendererPrefs(); | 995 contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 995 app_browser->window()->Show(); | 996 app_browser->window()->Show(); |
| 996 } | 997 } |
| 997 | 998 |
| 998 } // namespace chrome | 999 } // namespace chrome |
| OLD | NEW |