| 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_tabstrip.h" | 5 #include "chrome/browser/ui/browser_tabstrip.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 9 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_navigator.h" | 11 #include "chrome/browser/ui/browser_navigator.h" |
| 12 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 13 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
| 15 #include "content/public/browser/navigation_entry.h" | 16 #include "content/public/browser/navigation_entry.h" |
| 16 #include "content/public/browser/render_view_host.h" | 17 #include "content/public/browser/render_view_host.h" |
| 17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 18 | 19 |
| 19 namespace chrome { | 20 namespace chrome { |
| 20 | 21 |
| 21 void AddBlankTabAt(Browser* browser, int index, bool foreground) { | 22 void AddBlankTabAt(Browser* browser, int index, bool foreground) { |
| 22 // Time new tab page creation time. We keep track of the timing data in | 23 // Time new tab page creation time. We keep track of the timing data in |
| 23 // WebContents, but we want to include the time it takes to create the | 24 // WebContents, but we want to include the time it takes to create the |
| 24 // WebContents object too. | 25 // WebContents object too. |
| 25 base::TimeTicks new_tab_start_time = base::TimeTicks::Now(); | 26 base::TimeTicks new_tab_start_time = base::TimeTicks::Now(); |
| 26 chrome::NavigateParams params(browser, GURL(chrome::kChromeUINewTabURL), | 27 chrome::NavigateParams params(browser, GURL(chrome::kChromeUINewTabURL), |
| 27 content::PAGE_TRANSITION_TYPED); | 28 content::PAGE_TRANSITION_TYPED); |
| 28 params.disposition = foreground ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; | 29 params.disposition = foreground ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; |
| 29 params.tabstrip_index = index; | 30 params.tabstrip_index = index; |
| 30 chrome::Navigate(¶ms); | 31 chrome::Navigate(¶ms); |
| 31 params.target_contents->SetNewTabStartTime(new_tab_start_time); | 32 CoreTabHelper* core_tab_helper = |
| 33 CoreTabHelper::FromWebContents(params.target_contents); |
| 34 core_tab_helper->set_new_tab_start_time(new_tab_start_time); |
| 32 } | 35 } |
| 33 | 36 |
| 34 content::WebContents* AddSelectedTabWithURL( | 37 content::WebContents* AddSelectedTabWithURL( |
| 35 Browser* browser, | 38 Browser* browser, |
| 36 const GURL& url, | 39 const GURL& url, |
| 37 content::PageTransition transition) { | 40 content::PageTransition transition) { |
| 38 NavigateParams params(browser, url, transition); | 41 NavigateParams params(browser, url, transition); |
| 39 params.disposition = NEW_FOREGROUND_TAB; | 42 params.disposition = NEW_FOREGROUND_TAB; |
| 40 Navigate(¶ms); | 43 Navigate(¶ms); |
| 41 return params.target_contents; | 44 return params.target_contents; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 return; | 107 return; |
| 105 } | 108 } |
| 106 | 109 |
| 107 browser->tab_strip_model()->CloseWebContentsAt( | 110 browser->tab_strip_model()->CloseWebContentsAt( |
| 108 index, | 111 index, |
| 109 add_to_history ? TabStripModel::CLOSE_CREATE_HISTORICAL_TAB | 112 add_to_history ? TabStripModel::CLOSE_CREATE_HISTORICAL_TAB |
| 110 : TabStripModel::CLOSE_NONE); | 113 : TabStripModel::CLOSE_NONE); |
| 111 } | 114 } |
| 112 | 115 |
| 113 } // namespace chrome | 116 } // namespace chrome |
| OLD | NEW |