| 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/web_dialog_web_contents_delegate.h" | 5 #include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.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_navigator.h" | 10 #include "chrome/browser/ui/browser_navigator.h" |
| 10 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 11 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 12 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 13 | 14 |
| 14 using content::OpenURLParams; | 15 using content::OpenURLParams; |
| 15 using content::WebContents; | 16 using content::WebContents; |
| 16 | 17 |
| 17 // Incognito profiles are not long-lived, so we always want to store a | 18 // Incognito profiles are not long-lived, so we always want to store a |
| 18 // non-incognito profile. | 19 // non-incognito profile. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 41 return new_contents; | 42 return new_contents; |
| 42 } | 43 } |
| 43 | 44 |
| 44 // static | 45 // static |
| 45 Browser* WebDialogWebContentsDelegate::StaticOpenURLFromTab( | 46 Browser* WebDialogWebContentsDelegate::StaticOpenURLFromTab( |
| 46 Profile* profile, WebContents* source, const OpenURLParams& params, | 47 Profile* profile, WebContents* source, const OpenURLParams& params, |
| 47 WebContents** out_new_contents) { | 48 WebContents** out_new_contents) { |
| 48 if (!profile) | 49 if (!profile) |
| 49 return NULL; | 50 return NULL; |
| 50 | 51 |
| 51 // Specify a NULL browser for navigation. This will cause Navigate() | 52 Browser* browser = browser::FindOrCreateTabbedBrowser(profile); |
| 52 // to find a browser matching params.profile or create a new one. | |
| 53 Browser* browser = NULL; | |
| 54 chrome::NavigateParams nav_params(browser, params.url, params.transition); | 53 chrome::NavigateParams nav_params(browser, params.url, params.transition); |
| 55 nav_params.profile = profile; | |
| 56 nav_params.referrer = params.referrer; | 54 nav_params.referrer = params.referrer; |
| 57 if (source && source->IsCrashed() && | 55 if (source && source->IsCrashed() && |
| 58 params.disposition == CURRENT_TAB && | 56 params.disposition == CURRENT_TAB && |
| 59 params.transition == content::PAGE_TRANSITION_LINK) { | 57 params.transition == content::PAGE_TRANSITION_LINK) { |
| 60 nav_params.disposition = NEW_FOREGROUND_TAB; | 58 nav_params.disposition = NEW_FOREGROUND_TAB; |
| 61 } else { | 59 } else { |
| 62 nav_params.disposition = params.disposition; | 60 nav_params.disposition = params.disposition; |
| 63 } | 61 } |
| 64 nav_params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 62 nav_params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 65 nav_params.user_gesture = true; | 63 nav_params.user_gesture = true; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 81 Browser* WebDialogWebContentsDelegate::StaticAddNewContents( | 79 Browser* WebDialogWebContentsDelegate::StaticAddNewContents( |
| 82 Profile* profile, | 80 Profile* profile, |
| 83 WebContents* source, | 81 WebContents* source, |
| 84 WebContents* new_contents, | 82 WebContents* new_contents, |
| 85 WindowOpenDisposition disposition, | 83 WindowOpenDisposition disposition, |
| 86 const gfx::Rect& initial_pos, | 84 const gfx::Rect& initial_pos, |
| 87 bool user_gesture) { | 85 bool user_gesture) { |
| 88 if (!profile) | 86 if (!profile) |
| 89 return NULL; | 87 return NULL; |
| 90 | 88 |
| 91 // Specify a NULL browser for navigation. This will cause Navigate() | 89 Browser* browser = browser::FindOrCreateTabbedBrowser(profile); |
| 92 // to find a browser matching params.profile or create a new one. | |
| 93 Browser* browser = NULL; | |
| 94 | |
| 95 TabContents* tab_contents = new TabContents(new_contents); | 90 TabContents* tab_contents = new TabContents(new_contents); |
| 96 chrome::NavigateParams params(browser, tab_contents); | 91 chrome::NavigateParams params(browser, tab_contents); |
| 97 params.profile = profile; | |
| 98 // TODO(pinkerton): no way to get a TabContents for this. | 92 // TODO(pinkerton): no way to get a TabContents for this. |
| 99 // params.source_contents = source; | 93 // params.source_contents = source; |
| 100 params.disposition = disposition; | 94 params.disposition = disposition; |
| 101 params.window_bounds = initial_pos; | 95 params.window_bounds = initial_pos; |
| 102 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 96 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 103 params.user_gesture = true; | 97 params.user_gesture = true; |
| 104 chrome::Navigate(¶ms); | 98 chrome::Navigate(¶ms); |
| 105 | 99 |
| 106 return params.browser; | 100 return params.browser; |
| 107 } | 101 } |
| 108 | 102 |
| 109 bool WebDialogWebContentsDelegate::IsPopupOrPanel( | 103 bool WebDialogWebContentsDelegate::IsPopupOrPanel( |
| 110 const WebContents* source) const { | 104 const WebContents* source) const { |
| 111 // This needs to return true so that we are allowed to be resized by our | 105 // This needs to return true so that we are allowed to be resized by our |
| 112 // contents. | 106 // contents. |
| 113 return true; | 107 return true; |
| 114 } | 108 } |
| 115 | 109 |
| 116 bool WebDialogWebContentsDelegate::ShouldAddNavigationToHistory( | 110 bool WebDialogWebContentsDelegate::ShouldAddNavigationToHistory( |
| 117 const history::HistoryAddPageArgs& add_page_args, | 111 const history::HistoryAddPageArgs& add_page_args, |
| 118 content::NavigationType navigation_type) { | 112 content::NavigationType navigation_type) { |
| 119 return false; | 113 return false; |
| 120 } | 114 } |
| OLD | NEW |