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/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
13 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 13 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/common/url_constants.h" |
16 #include "content/public/browser/navigation_entry.h" | 17 #include "content/public/browser/navigation_entry.h" |
17 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
18 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
19 | 20 |
20 namespace chrome { | 21 namespace chrome { |
21 | 22 |
22 int GetIndexOfTab(const Browser* browser, | 23 int GetIndexOfTab(const Browser* browser, |
23 const content::WebContents* contents) { | 24 const content::WebContents* contents) { |
24 return browser->tab_strip_model()->GetIndexOfWebContents(contents); | 25 return browser->tab_strip_model()->GetIndexOfWebContents(contents); |
25 } | 26 } |
(...skipping 13 matching lines...) Expand all Loading... |
39 | 40 |
40 content::WebContents* GetWebContentsAt(const Browser* browser, int index) { | 41 content::WebContents* GetWebContentsAt(const Browser* browser, int index) { |
41 TabContents* tab = GetTabContentsAt(browser, index); | 42 TabContents* tab = GetTabContentsAt(browser, index); |
42 return tab ? tab->web_contents() : NULL; | 43 return tab ? tab->web_contents() : NULL; |
43 } | 44 } |
44 | 45 |
45 void ActivateTabAt(Browser* browser, int index, bool user_gesture) { | 46 void ActivateTabAt(Browser* browser, int index, bool user_gesture) { |
46 browser->tab_strip_model()->ActivateTabAt(index, user_gesture); | 47 browser->tab_strip_model()->ActivateTabAt(index, user_gesture); |
47 } | 48 } |
48 | 49 |
| 50 TabContents* AddBlankTab(Browser* browser, bool foreground) { |
| 51 return AddBlankTabAt(browser, -1, foreground); |
| 52 } |
| 53 |
| 54 TabContents* AddBlankTabAt(Browser* browser, int index, bool foreground) { |
| 55 // Time new tab page creation time. We keep track of the timing data in |
| 56 // WebContents, but we want to include the time it takes to create the |
| 57 // WebContents object too. |
| 58 base::TimeTicks new_tab_start_time = base::TimeTicks::Now(); |
| 59 chrome::NavigateParams params(browser, GURL(chrome::kChromeUINewTabURL), |
| 60 content::PAGE_TRANSITION_TYPED); |
| 61 params.disposition = foreground ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; |
| 62 params.tabstrip_index = index; |
| 63 chrome::Navigate(¶ms); |
| 64 params.target_contents->web_contents()->SetNewTabStartTime( |
| 65 new_tab_start_time); |
| 66 return params.target_contents; |
| 67 } |
| 68 |
49 bool IsTabStripEditable(Browser* browser) { | 69 bool IsTabStripEditable(Browser* browser) { |
50 return browser->window()->IsTabStripEditable(); | 70 return browser->window()->IsTabStripEditable(); |
51 } | 71 } |
52 | 72 |
53 TabContents* AddSelectedTabWithURL(Browser* browser, | 73 TabContents* AddSelectedTabWithURL(Browser* browser, |
54 const GURL& url, | 74 const GURL& url, |
55 content::PageTransition transition) { | 75 content::PageTransition transition) { |
56 NavigateParams params(browser, url, transition); | 76 NavigateParams params(browser, url, transition); |
57 params.disposition = NEW_FOREGROUND_TAB; | 77 params.disposition = NEW_FOREGROUND_TAB; |
58 Navigate(¶ms); | 78 Navigate(¶ms); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 content::SessionStorageNamespace* session_storage_namespace) { | 164 content::SessionStorageNamespace* session_storage_namespace) { |
145 return new TabContents(content::WebContents::Create( | 165 return new TabContents(content::WebContents::Create( |
146 profile, | 166 profile, |
147 site_instance, | 167 site_instance, |
148 routing_id, | 168 routing_id, |
149 base_web_contents, | 169 base_web_contents, |
150 session_storage_namespace)); | 170 session_storage_namespace)); |
151 } | 171 } |
152 | 172 |
153 } // namespace chrome | 173 } // namespace chrome |
OLD | NEW |