Chromium Code Reviews| Index: chrome/browser/ui/webui/html_dialog_tab_contents_delegate.cc |
| diff --git a/chrome/browser/ui/webui/html_dialog_tab_contents_delegate.cc b/chrome/browser/ui/webui/html_dialog_tab_contents_delegate.cc |
| index 65a39b04aadae84bd4d730ddcefa5b8af6de7746..aaa0193d79b043a0beb74624fdcc0a308c0b0272 100644 |
| --- a/chrome/browser/ui/webui/html_dialog_tab_contents_delegate.cc |
| +++ b/chrome/browser/ui/webui/html_dialog_tab_contents_delegate.cc |
| @@ -33,48 +33,75 @@ void HtmlDialogTabContentsDelegate::Detach() { |
| WebContents* HtmlDialogTabContentsDelegate::OpenURLFromTab( |
| WebContents* source, const OpenURLParams& params) { |
| - if (profile_) { |
| - // Specify a NULL browser for navigation. This will cause Navigate() |
| - // to find a browser matching params.profile or create a new one. |
| - Browser* browser = NULL; |
| - browser::NavigateParams nav_params(browser, params.url, params.transition); |
| - nav_params.profile = profile_; |
| - nav_params.referrer = params.referrer; |
| - if (source && source->IsCrashed() && |
| - params.disposition == CURRENT_TAB && |
| - params.transition == content::PAGE_TRANSITION_LINK) |
| - nav_params.disposition = NEW_FOREGROUND_TAB; |
| - else |
| - nav_params.disposition = params.disposition; |
| - nav_params.window_action = browser::NavigateParams::SHOW_WINDOW; |
| - nav_params.user_gesture = true; |
| - browser::Navigate(&nav_params); |
| - return nav_params.target_contents ? |
| - nav_params.target_contents->web_contents() : NULL; |
| - } |
| - return NULL; |
| + WebContents* new_contents = NULL; |
| + StaticOpenURLFromTab(profile_, source, params, &new_contents); |
| + return new_contents; |
| +} |
| + |
| +// static |
| +Browser* HtmlDialogTabContentsDelegate::StaticOpenURLFromTab( |
| + Profile* profile, |
| + WebContents* source, |
| + const OpenURLParams& params, |
| + WebContents** out_new_contents) { |
| + if (!profile) |
| + return NULL; |
| + |
| + // Specify a NULL browser for navigation. This will cause Navigate() |
| + // to find a browser matching params.profile or create a new one. |
| + Browser* browser = NULL; |
| + browser::NavigateParams nav_params(browser, params.url, params.transition); |
| + nav_params.profile = profile; |
| + nav_params.referrer = params.referrer; |
| + if (source && source->IsCrashed() && |
|
Dan Beam
2012/01/30 18:10:05
why are you asking if the source is crashed?
sail
2012/01/30 21:00:39
not sure, this isn't my code, this is existing cod
|
| + params.disposition == CURRENT_TAB && |
| + params.transition == content::PAGE_TRANSITION_LINK) |
|
Dan Beam
2012/01/30 18:10:05
curlies
sail
2012/01/30 21:00:39
Done.
|
| + nav_params.disposition = NEW_FOREGROUND_TAB; |
| + else |
| + nav_params.disposition = params.disposition; |
| + nav_params.window_action = browser::NavigateParams::SHOW_WINDOW; |
| + nav_params.user_gesture = true; |
|
Dan Beam
2012/01/30 18:10:05
what is this for?
sail
2012/01/30 21:00:39
not sure
|
| + browser::Navigate(&nav_params); |
| + *out_new_contents = nav_params.target_contents ? |
| + nav_params.target_contents->web_contents() : NULL; |
| + return nav_params.browser; |
| } |
| void HtmlDialogTabContentsDelegate::AddNewContents( |
| WebContents* source, WebContents* new_contents, |
| WindowOpenDisposition disposition, const gfx::Rect& initial_pos, |
| bool user_gesture) { |
| - if (profile_) { |
| - // Specify a NULL browser for navigation. This will cause Navigate() |
| - // to find a browser matching params.profile or create a new one. |
| - Browser* browser = NULL; |
| - |
| - TabContentsWrapper* wrapper = new TabContentsWrapper(new_contents); |
| - browser::NavigateParams params(browser, wrapper); |
| - params.profile = profile_; |
| - // TODO(pinkerton): no way to get a wrapper for this. |
| - // params.source_contents = source; |
| - params.disposition = disposition; |
| - params.window_bounds = initial_pos; |
| - params.window_action = browser::NavigateParams::SHOW_WINDOW; |
| - params.user_gesture = true; |
| - browser::Navigate(¶ms); |
| - } |
| + StaticAddNewContents(profile_, source, new_contents, disposition, |
| + initial_pos, user_gesture); |
| +} |
| + |
| +// static |
| +Browser* HtmlDialogTabContentsDelegate::StaticAddNewContents( |
| + Profile* profile, |
| + WebContents* source, |
| + WebContents* new_contents, |
| + WindowOpenDisposition disposition, |
| + const gfx::Rect& initial_pos, |
| + bool user_gesture) { |
| + if (!profile) |
| + return NULL; |
| + |
| + // Specify a NULL browser for navigation. This will cause Navigate() |
| + // to find a browser matching params.profile or create a new one. |
| + Browser* browser = NULL; |
| + |
| + TabContentsWrapper* wrapper = new TabContentsWrapper(new_contents); |
|
Dan Beam
2012/01/30 18:10:05
There's no chance of this leaking here, as ownersh
sail
2012/01/30 21:00:39
not sure (existing code)
|
| + browser::NavigateParams params(browser, wrapper); |
| + params.profile = profile; |
| + // TODO(pinkerton): no way to get a wrapper for this. |
| + // params.source_contents = source; |
| + params.disposition = disposition; |
| + params.window_bounds = initial_pos; |
| + params.window_action = browser::NavigateParams::SHOW_WINDOW; |
| + params.user_gesture = true; |
| + browser::Navigate(¶ms); |
| + |
| + return params.browser; |
| } |
| bool HtmlDialogTabContentsDelegate::IsPopupOrPanel( |