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/webui/chrome_web_contents_handler.h" | 5 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h" |
6 | 6 |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
10 #include "chrome/browser/ui/browser_navigator.h" | 10 #include "chrome/browser/ui/browser_navigator.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 // browser. | 31 // browser. |
32 WebContents* ChromeWebContentsHandler::OpenURLFromTab( | 32 WebContents* ChromeWebContentsHandler::OpenURLFromTab( |
33 content::BrowserContext* context, | 33 content::BrowserContext* context, |
34 WebContents* source, | 34 WebContents* source, |
35 const OpenURLParams& params) { | 35 const OpenURLParams& params) { |
36 if (!context) | 36 if (!context) |
37 return NULL; | 37 return NULL; |
38 | 38 |
39 Profile* profile = Profile::FromBrowserContext(context); | 39 Profile* profile = Profile::FromBrowserContext(context); |
40 | 40 |
41 chrome::HostDesktopType desktop_type = chrome::HOST_DESKTOP_TYPE_NATIVE; | |
42 if (source) { | |
43 Browser* source_browser = chrome::FindBrowserWithWebContents(source); | |
44 if (source_browser) | |
45 desktop_type = source_browser->host_desktop_type(); | |
46 } | |
47 | |
48 Browser* browser = chrome::FindTabbedBrowser(profile, false); | 41 Browser* browser = chrome::FindTabbedBrowser(profile, false); |
49 const bool browser_created = !browser; | 42 const bool browser_created = !browser; |
50 if (!browser) | 43 if (!browser) |
51 browser = new Browser( | 44 browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, profile)); |
52 Browser::CreateParams(Browser::TYPE_TABBED, profile, desktop_type)); | |
53 chrome::NavigateParams nav_params(browser, params.url, params.transition); | 45 chrome::NavigateParams nav_params(browser, params.url, params.transition); |
54 nav_params.referrer = params.referrer; | 46 nav_params.referrer = params.referrer; |
55 if (source && source->IsCrashed() && | 47 if (source && source->IsCrashed() && |
56 params.disposition == CURRENT_TAB && | 48 params.disposition == CURRENT_TAB && |
57 params.transition == ui::PAGE_TRANSITION_LINK) { | 49 params.transition == ui::PAGE_TRANSITION_LINK) { |
58 nav_params.disposition = NEW_FOREGROUND_TAB; | 50 nav_params.disposition = NEW_FOREGROUND_TAB; |
59 } else { | 51 } else { |
60 nav_params.disposition = params.disposition; | 52 nav_params.disposition = params.disposition; |
61 } | 53 } |
62 nav_params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 54 nav_params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
(...skipping 18 matching lines...) Expand all Loading... |
81 WebContents* source, | 73 WebContents* source, |
82 WebContents* new_contents, | 74 WebContents* new_contents, |
83 WindowOpenDisposition disposition, | 75 WindowOpenDisposition disposition, |
84 const gfx::Rect& initial_rect, | 76 const gfx::Rect& initial_rect, |
85 bool user_gesture) { | 77 bool user_gesture) { |
86 if (!context) | 78 if (!context) |
87 return; | 79 return; |
88 | 80 |
89 Profile* profile = Profile::FromBrowserContext(context); | 81 Profile* profile = Profile::FromBrowserContext(context); |
90 | 82 |
91 chrome::HostDesktopType desktop_type = chrome::HOST_DESKTOP_TYPE_NATIVE; | |
92 if (source) { | |
93 Browser* source_browser = chrome::FindBrowserWithWebContents(source); | |
94 if (source_browser) | |
95 desktop_type = source_browser->host_desktop_type(); | |
96 } | |
97 | |
98 Browser* browser = chrome::FindTabbedBrowser(profile, false); | 83 Browser* browser = chrome::FindTabbedBrowser(profile, false); |
99 const bool browser_created = !browser; | 84 const bool browser_created = !browser; |
100 if (!browser) | 85 if (!browser) |
101 browser = new Browser( | 86 browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, profile)); |
102 Browser::CreateParams(Browser::TYPE_TABBED, profile, desktop_type)); | |
103 chrome::NavigateParams params(browser, new_contents); | 87 chrome::NavigateParams params(browser, new_contents); |
104 params.source_contents = source; | 88 params.source_contents = source; |
105 params.disposition = disposition; | 89 params.disposition = disposition; |
106 params.window_bounds = initial_rect; | 90 params.window_bounds = initial_rect; |
107 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 91 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
108 params.user_gesture = true; | 92 params.user_gesture = true; |
109 chrome::Navigate(¶ms); | 93 chrome::Navigate(¶ms); |
110 | 94 |
111 // Close the browser if chrome::Navigate created a new one. | 95 // Close the browser if chrome::Navigate created a new one. |
112 if (browser_created && (browser != params.browser)) | 96 if (browser_created && (browser != params.browser)) |
113 browser->window()->Close(); | 97 browser->window()->Close(); |
114 } | 98 } |
OLD | NEW |