Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Side by Side Diff: chrome/browser/ui/browser_commands.cc

Issue 10697017: Tabs Extension: Implementation of tabs.duplicate api. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser_commands.h ('k') | chrome/common/extensions/api/tabs.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 void DuplicateTab(Browser* browser) { 484 void DuplicateTab(Browser* browser) {
485 content::RecordAction(UserMetricsAction("Duplicate")); 485 content::RecordAction(UserMetricsAction("Duplicate"));
486 DuplicateTabAt(browser, browser->active_index()); 486 DuplicateTabAt(browser, browser->active_index());
487 } 487 }
488 488
489 bool CanDuplicateTab(const Browser* browser) { 489 bool CanDuplicateTab(const Browser* browser) {
490 WebContents* contents = GetActiveWebContents(browser); 490 WebContents* contents = GetActiveWebContents(browser);
491 return contents && contents->GetController().GetLastCommittedEntry(); 491 return contents && contents->GetController().GetLastCommittedEntry();
492 } 492 }
493 493
494 void DuplicateTabAt(Browser* browser, int index) { 494 TabContents* DuplicateTabAt(Browser* browser, int index) {
495 TabContents* contents = GetTabContentsAt(browser, index); 495 TabContents* contents = GetTabContentsAt(browser, index);
496 CHECK(contents); 496 CHECK(contents);
497 TabContents* contents_dupe = 497 TabContents* contents_dupe =
498 BrowserCommandsTabContentsCreator::CloneTabContents(contents); 498 BrowserCommandsTabContentsCreator::CloneTabContents(contents);
499 499
500 bool pinned = false; 500 bool pinned = false;
501 if (browser->CanSupportWindowFeature(Browser::FEATURE_TABSTRIP)) { 501 if (browser->CanSupportWindowFeature(Browser::FEATURE_TABSTRIP)) {
502 // If this is a tabbed browser, just create a duplicate tab inside the same 502 // If this is a tabbed browser, just create a duplicate tab inside the same
503 // window next to the tab being duplicated. 503 // window next to the tab being duplicated.
504 int index = browser->tab_strip_model()->GetIndexOfTabContents(contents); 504 int index = browser->tab_strip_model()->GetIndexOfTabContents(contents);
(...skipping 29 matching lines...) Expand all
534 browser->window()->Show(); 534 browser->window()->Show();
535 535
536 // The page transition below is only for the purpose of inserting the tab. 536 // The page transition below is only for the purpose of inserting the tab.
537 AddTab(browser, contents_dupe, content::PAGE_TRANSITION_LINK); 537 AddTab(browser, contents_dupe, content::PAGE_TRANSITION_LINK);
538 } 538 }
539 539
540 SessionService* session_service = 540 SessionService* session_service =
541 SessionServiceFactory::GetForProfileIfExisting(browser->profile()); 541 SessionServiceFactory::GetForProfileIfExisting(browser->profile());
542 if (session_service) 542 if (session_service)
543 session_service->TabRestored(contents_dupe, pinned); 543 session_service->TabRestored(contents_dupe, pinned);
544 return contents_dupe;
544 } 545 }
545 546
546 bool CanDuplicateTabAt(Browser* browser, int index) { 547 bool CanDuplicateTabAt(Browser* browser, int index) {
547 content::NavigationController& nc = 548 content::NavigationController& nc =
548 GetWebContentsAt(browser, index)->GetController(); 549 GetWebContentsAt(browser, index)->GetController();
549 return nc.GetWebContents() && nc.GetLastCommittedEntry(); 550 return nc.GetWebContents() && nc.GetLastCommittedEntry();
550 } 551 }
551 552
552 void ConvertPopupToTabbedBrowser(Browser* browser) { 553 void ConvertPopupToTabbedBrowser(Browser* browser) {
553 content::RecordAction(UserMetricsAction("ShowAsTab")); 554 content::RecordAction(UserMetricsAction("ShowAsTab"));
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 BrowserCommandsTabContentsCreator::CreateTabContents(contents); 999 BrowserCommandsTabContentsCreator::CreateTabContents(contents);
999 } 1000 }
1000 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); 1001 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true);
1001 1002
1002 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 1003 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
1003 contents->GetRenderViewHost()->SyncRendererPrefs(); 1004 contents->GetRenderViewHost()->SyncRendererPrefs();
1004 app_browser->window()->Show(); 1005 app_browser->window()->Show();
1005 } 1006 }
1006 1007
1007 } // namespace chrome 1008 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_commands.h ('k') | chrome/common/extensions/api/tabs.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698