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 21 matching lines...) Expand all Loading... |
32 content::BrowserContext* context, | 32 content::BrowserContext* context, |
33 WebContents* source, | 33 WebContents* source, |
34 const OpenURLParams& params) { | 34 const OpenURLParams& params) { |
35 if (!context) | 35 if (!context) |
36 return NULL; | 36 return NULL; |
37 | 37 |
38 Profile* profile = Profile::FromBrowserContext(context); | 38 Profile* profile = Profile::FromBrowserContext(context); |
39 | 39 |
40 Browser* browser = chrome::FindTabbedBrowser(profile, false); | 40 Browser* browser = chrome::FindTabbedBrowser(profile, false); |
41 const bool browser_created = !browser; | 41 const bool browser_created = !browser; |
42 if (!browser) | 42 if (!browser) { |
43 browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, profile)); | 43 // TODO(erg): OpenURLParams should pass a user_gesture flag, pass it to |
| 44 // CreateParams, and pass the real value to nav_params below. |
| 45 browser = |
| 46 new Browser(Browser::CreateParams(Browser::TYPE_TABBED, profile, true)); |
| 47 } |
44 chrome::NavigateParams nav_params(browser, params.url, params.transition); | 48 chrome::NavigateParams nav_params(browser, params.url, params.transition); |
45 nav_params.referrer = params.referrer; | 49 nav_params.referrer = params.referrer; |
46 if (source && source->IsCrashed() && | 50 if (source && source->IsCrashed() && |
47 params.disposition == WindowOpenDisposition::CURRENT_TAB && | 51 params.disposition == WindowOpenDisposition::CURRENT_TAB && |
48 ui::PageTransitionCoreTypeIs(params.transition, | 52 ui::PageTransitionCoreTypeIs(params.transition, |
49 ui::PAGE_TRANSITION_LINK)) { | 53 ui::PAGE_TRANSITION_LINK)) { |
50 nav_params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; | 54 nav_params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
51 } else { | 55 } else { |
52 nav_params.disposition = params.disposition; | 56 nav_params.disposition = params.disposition; |
53 } | 57 } |
(...skipping 21 matching lines...) Expand all Loading... |
75 WindowOpenDisposition disposition, | 79 WindowOpenDisposition disposition, |
76 const gfx::Rect& initial_rect, | 80 const gfx::Rect& initial_rect, |
77 bool user_gesture) { | 81 bool user_gesture) { |
78 if (!context) | 82 if (!context) |
79 return; | 83 return; |
80 | 84 |
81 Profile* profile = Profile::FromBrowserContext(context); | 85 Profile* profile = Profile::FromBrowserContext(context); |
82 | 86 |
83 Browser* browser = chrome::FindTabbedBrowser(profile, false); | 87 Browser* browser = chrome::FindTabbedBrowser(profile, false); |
84 const bool browser_created = !browser; | 88 const bool browser_created = !browser; |
85 if (!browser) | 89 if (!browser) { |
86 browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, profile)); | 90 browser = new Browser( |
| 91 Browser::CreateParams(Browser::TYPE_TABBED, profile, user_gesture)); |
| 92 } |
87 chrome::NavigateParams params(browser, new_contents); | 93 chrome::NavigateParams params(browser, new_contents); |
88 params.source_contents = source; | 94 params.source_contents = source; |
89 params.disposition = disposition; | 95 params.disposition = disposition; |
90 params.window_bounds = initial_rect; | 96 params.window_bounds = initial_rect; |
91 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 97 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
92 params.user_gesture = true; | 98 params.user_gesture = user_gesture; |
93 chrome::Navigate(¶ms); | 99 chrome::Navigate(¶ms); |
94 | 100 |
95 // Close the browser if chrome::Navigate created a new one. | 101 // Close the browser if chrome::Navigate created a new one. |
96 if (browser_created && (browser != params.browser)) | 102 if (browser_created && (browser != params.browser)) |
97 browser->window()->Close(); | 103 browser->window()->Close(); |
98 } | 104 } |
OLD | NEW |