OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 #endif | 179 #endif |
180 | 180 |
181 // Based on |disposition|, creates a new tab as necessary, and returns the | 181 // Based on |disposition|, creates a new tab as necessary, and returns the |
182 // appropriate tab to navigate. If that tab is the current tab, reverts the | 182 // appropriate tab to navigate. If that tab is the current tab, reverts the |
183 // location bar contents, since all browser-UI-triggered navigations should | 183 // location bar contents, since all browser-UI-triggered navigations should |
184 // revert any omnibox edits in the current tab. | 184 // revert any omnibox edits in the current tab. |
185 WebContents* GetTabAndRevertIfNecessary(Browser* browser, | 185 WebContents* GetTabAndRevertIfNecessary(Browser* browser, |
186 WindowOpenDisposition disposition) { | 186 WindowOpenDisposition disposition) { |
187 WebContents* current_tab = browser->tab_strip_model()->GetActiveWebContents(); | 187 WebContents* current_tab = browser->tab_strip_model()->GetActiveWebContents(); |
188 switch (disposition) { | 188 switch (disposition) { |
189 case NEW_FOREGROUND_TAB: | 189 case WindowOpenDisposition::NEW_FOREGROUND_TAB: |
190 case NEW_BACKGROUND_TAB: { | 190 case WindowOpenDisposition::NEW_BACKGROUND_TAB: { |
191 WebContents* new_tab = current_tab->Clone(); | 191 WebContents* new_tab = current_tab->Clone(); |
192 if (disposition == NEW_BACKGROUND_TAB) | 192 if (disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB) |
193 new_tab->WasHidden(); | 193 new_tab->WasHidden(); |
194 browser->tab_strip_model()->AddWebContents( | 194 browser->tab_strip_model()->AddWebContents( |
195 new_tab, -1, ui::PAGE_TRANSITION_LINK, | 195 new_tab, -1, ui::PAGE_TRANSITION_LINK, |
196 (disposition == NEW_FOREGROUND_TAB) ? | 196 (disposition == WindowOpenDisposition::NEW_FOREGROUND_TAB) |
197 TabStripModel::ADD_ACTIVE : TabStripModel::ADD_NONE); | 197 ? TabStripModel::ADD_ACTIVE |
| 198 : TabStripModel::ADD_NONE); |
198 return new_tab; | 199 return new_tab; |
199 } | 200 } |
200 case NEW_WINDOW: { | 201 case WindowOpenDisposition::NEW_WINDOW: { |
201 WebContents* new_tab = current_tab->Clone(); | 202 WebContents* new_tab = current_tab->Clone(); |
202 Browser* new_browser = | 203 Browser* new_browser = |
203 new Browser(Browser::CreateParams(browser->profile())); | 204 new Browser(Browser::CreateParams(browser->profile())); |
204 new_browser->tab_strip_model()->AddWebContents( | 205 new_browser->tab_strip_model()->AddWebContents( |
205 new_tab, -1, ui::PAGE_TRANSITION_LINK, | 206 new_tab, -1, ui::PAGE_TRANSITION_LINK, |
206 TabStripModel::ADD_ACTIVE); | 207 TabStripModel::ADD_ACTIVE); |
207 new_browser->window()->Show(); | 208 new_browser->window()->Show(); |
208 return new_tab; | 209 return new_tab; |
209 } | 210 } |
210 default: | 211 default: |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 extensions::ExtensionRegistry::Get(browser->profile()) | 463 extensions::ExtensionRegistry::Get(browser->profile()) |
463 ->GetExtensionById( | 464 ->GetExtensionById( |
464 web_app::GetExtensionIdFromApplicationName(browser->app_name()), | 465 web_app::GetExtensionIdFromApplicationName(browser->app_name()), |
465 extensions::ExtensionRegistry::EVERYTHING); | 466 extensions::ExtensionRegistry::EVERYTHING); |
466 if (!extension) | 467 if (!extension) |
467 return; | 468 return; |
468 | 469 |
469 url = extensions::AppLaunchInfo::GetLaunchWebURL(extension); | 470 url = extensions::AppLaunchInfo::GetLaunchWebURL(extension); |
470 } | 471 } |
471 | 472 |
472 if (disposition == CURRENT_TAB || disposition == NEW_FOREGROUND_TAB) | 473 if (disposition == WindowOpenDisposition::CURRENT_TAB || |
| 474 disposition == WindowOpenDisposition::NEW_FOREGROUND_TAB) |
473 extensions::MaybeShowExtensionControlledHomeNotification(browser); | 475 extensions::MaybeShowExtensionControlledHomeNotification(browser); |
474 #endif | 476 #endif |
475 | 477 |
476 OpenURLParams params( | 478 OpenURLParams params( |
477 url, Referrer(), disposition, | 479 url, Referrer(), disposition, |
478 ui::PageTransitionFromInt( | 480 ui::PageTransitionFromInt( |
479 ui::PAGE_TRANSITION_AUTO_BOOKMARK | | 481 ui::PAGE_TRANSITION_AUTO_BOOKMARK | |
480 ui::PAGE_TRANSITION_HOME_PAGE), | 482 ui::PAGE_TRANSITION_HOME_PAGE), |
481 false); | 483 false); |
482 params.extra_headers = extra_headers; | 484 params.extra_headers = extra_headers; |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 app_name, true /* trusted_source */, gfx::Rect(), browser->profile())); | 1292 app_name, true /* trusted_source */, gfx::Rect(), browser->profile())); |
1291 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1293 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
1292 | 1294 |
1293 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1295 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
1294 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1296 contents->GetRenderViewHost()->SyncRendererPrefs(); |
1295 app_browser->window()->Show(); | 1297 app_browser->window()->Show(); |
1296 } | 1298 } |
1297 #endif // defined(ENABLE_EXTENSIONS) | 1299 #endif // defined(ENABLE_EXTENSIONS) |
1298 | 1300 |
1299 } // namespace chrome | 1301 } // namespace chrome |
OLD | NEW |