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/singleton_tabs.h" | 5 #include "chrome/browser/ui/singleton_tabs.h" |
6 | 6 |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/search/search.h" | 8 #include "chrome/browser/search/search.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" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 DCHECK(browser); | 47 DCHECK(browser); |
48 NavigateParams local_params(params); | 48 NavigateParams local_params(params); |
49 content::WebContents* contents = | 49 content::WebContents* contents = |
50 browser->tab_strip_model()->GetActiveWebContents(); | 50 browser->tab_strip_model()->GetActiveWebContents(); |
51 if (contents) { | 51 if (contents) { |
52 const GURL& contents_url = contents->GetURL(); | 52 const GURL& contents_url = contents->GetURL(); |
53 if ((contents_url == GURL(kChromeUINewTabURL) || | 53 if ((contents_url == GURL(kChromeUINewTabURL) || |
54 search::IsInstantNTP(contents) || | 54 search::IsInstantNTP(contents) || |
55 contents_url == GURL(url::kAboutBlankURL)) && | 55 contents_url == GURL(url::kAboutBlankURL)) && |
56 GetIndexOfSingletonTab(&local_params) < 0) { | 56 GetIndexOfSingletonTab(&local_params) < 0) { |
57 local_params.disposition = CURRENT_TAB; | 57 local_params.disposition = WindowOpenDisposition::CURRENT_TAB; |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 Navigate(&local_params); | 61 Navigate(&local_params); |
62 } | 62 } |
63 | 63 |
64 NavigateParams GetSingletonTabNavigateParams(Browser* browser, | 64 NavigateParams GetSingletonTabNavigateParams(Browser* browser, |
65 const GURL& url) { | 65 const GURL& url) { |
66 NavigateParams params(browser, url, ui::PAGE_TRANSITION_AUTO_BOOKMARK); | 66 NavigateParams params(browser, url, ui::PAGE_TRANSITION_AUTO_BOOKMARK); |
67 params.disposition = SINGLETON_TAB; | 67 params.disposition = WindowOpenDisposition::SINGLETON_TAB; |
68 params.window_action = NavigateParams::SHOW_WINDOW; | 68 params.window_action = NavigateParams::SHOW_WINDOW; |
69 params.user_gesture = true; | 69 params.user_gesture = true; |
70 params.tabstrip_add_types |= TabStripModel::ADD_INHERIT_OPENER; | 70 params.tabstrip_add_types |= TabStripModel::ADD_INHERIT_OPENER; |
71 return params; | 71 return params; |
72 } | 72 } |
73 | 73 |
74 // Returns the index of an existing singleton tab in |params->browser| matching | 74 // Returns the index of an existing singleton tab in |params->browser| matching |
75 // the URL specified in |params|. | 75 // the URL specified in |params|. |
76 int GetIndexOfSingletonTab(NavigateParams* params) { | 76 int GetIndexOfSingletonTab(NavigateParams* params) { |
77 if (params->disposition != SINGLETON_TAB) | 77 if (params->disposition != WindowOpenDisposition::SINGLETON_TAB) |
78 return -1; | 78 return -1; |
79 | 79 |
80 // In case the URL was rewritten by the BrowserURLHandler we need to ensure | 80 // In case the URL was rewritten by the BrowserURLHandler we need to ensure |
81 // that we do not open another URL that will get redirected to the rewritten | 81 // that we do not open another URL that will get redirected to the rewritten |
82 // URL. | 82 // URL. |
83 GURL rewritten_url(params->url); | 83 GURL rewritten_url(params->url); |
84 bool reverse_on_redirect = false; | 84 bool reverse_on_redirect = false; |
85 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 85 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
86 &rewritten_url, | 86 &rewritten_url, |
87 params->browser->profile(), | 87 params->browser->profile(), |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 replacements)) { | 124 replacements)) { |
125 params->target_contents = tab; | 125 params->target_contents = tab; |
126 return tab_index; | 126 return tab_index; |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 return -1; | 130 return -1; |
131 } | 131 } |
132 | 132 |
133 } // namespace chrome | 133 } // namespace chrome |
OLD | NEW |