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/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_navigator.h" | 10 #include "chrome/browser/ui/browser_navigator.h" |
11 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 11 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
15 #include "content/public/browser/navigation_entry.h" | 15 #include "content/public/browser/navigation_entry.h" |
16 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
18 | 18 |
| 19 #if defined(TOOLKIT_VIEWS) && defined(OS_WIN) |
| 20 #include "chrome/browser/ui/views/settings_api_bubble_helper_views.h" |
| 21 #endif // TOOLKIT_VIEWS && OS_WIN |
| 22 |
19 namespace chrome { | 23 namespace chrome { |
20 | 24 |
21 void AddTabAt(Browser* browser, const GURL& url, int idx, bool foreground) { | 25 void AddTabAt(Browser* browser, const GURL& url, int idx, bool foreground) { |
22 // Time new tab page creation time. We keep track of the timing data in | 26 // 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 | 27 // WebContents, but we want to include the time it takes to create the |
24 // WebContents object too. | 28 // WebContents object too. |
25 base::TimeTicks new_tab_start_time = base::TimeTicks::Now(); | 29 base::TimeTicks new_tab_start_time = base::TimeTicks::Now(); |
26 chrome::NavigateParams params(browser, | 30 chrome::NavigateParams params(browser, |
27 url.is_empty() ? GURL(chrome::kChromeUINewTabURL) : url, | 31 url.is_empty() ? GURL(chrome::kChromeUINewTabURL) : url, |
28 content::PAGE_TRANSITION_TYPED); | 32 content::PAGE_TRANSITION_TYPED); |
29 params.disposition = foreground ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; | 33 params.disposition = foreground ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; |
30 params.tabstrip_index = idx; | 34 params.tabstrip_index = idx; |
31 chrome::Navigate(¶ms); | 35 chrome::Navigate(¶ms); |
32 CoreTabHelper* core_tab_helper = | 36 CoreTabHelper* core_tab_helper = |
33 CoreTabHelper::FromWebContents(params.target_contents); | 37 CoreTabHelper::FromWebContents(params.target_contents); |
34 core_tab_helper->set_new_tab_start_time(new_tab_start_time); | 38 core_tab_helper->set_new_tab_start_time(new_tab_start_time); |
| 39 |
| 40 #if defined(TOOLKIT_VIEWS) && defined(OS_WIN) |
| 41 if (url.is_empty()) |
| 42 extensions::MaybeShowExtensionControlledNewTabPage(browser); |
| 43 #endif |
35 } | 44 } |
36 | 45 |
37 content::WebContents* AddSelectedTabWithURL( | 46 content::WebContents* AddSelectedTabWithURL( |
38 Browser* browser, | 47 Browser* browser, |
39 const GURL& url, | 48 const GURL& url, |
40 content::PageTransition transition) { | 49 content::PageTransition transition) { |
41 NavigateParams params(browser, url, transition); | 50 NavigateParams params(browser, url, transition); |
42 params.disposition = NEW_FOREGROUND_TAB; | 51 params.disposition = NEW_FOREGROUND_TAB; |
43 Navigate(¶ms); | 52 Navigate(¶ms); |
44 return params.target_contents; | 53 return params.target_contents; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 return; | 86 return; |
78 } | 87 } |
79 | 88 |
80 browser->tab_strip_model()->CloseWebContentsAt( | 89 browser->tab_strip_model()->CloseWebContentsAt( |
81 index, | 90 index, |
82 add_to_history ? TabStripModel::CLOSE_CREATE_HISTORICAL_TAB | 91 add_to_history ? TabStripModel::CLOSE_CREATE_HISTORICAL_TAB |
83 : TabStripModel::CLOSE_NONE); | 92 : TabStripModel::CLOSE_NONE); |
84 } | 93 } |
85 | 94 |
86 } // namespace chrome | 95 } // namespace chrome |
OLD | NEW |