| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/apps/chrome_app_delegate.h" | 5 #include "chrome/browser/ui/apps/chrome_app_delegate.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 bool disable_external_open_for_testing_ = false; | 59 bool disable_external_open_for_testing_ = false; |
| 60 | 60 |
| 61 // Opens a URL with Chromium (not external browser) with the right profile. | 61 // Opens a URL with Chromium (not external browser) with the right profile. |
| 62 content::WebContents* OpenURLFromTabInternal( | 62 content::WebContents* OpenURLFromTabInternal( |
| 63 content::BrowserContext* context, | 63 content::BrowserContext* context, |
| 64 const content::OpenURLParams& params) { | 64 const content::OpenURLParams& params) { |
| 65 // Force all links to open in a new tab, even if they were trying to open a | 65 // Force all links to open in a new tab, even if they were trying to open a |
| 66 // window. | 66 // window. |
| 67 chrome::NavigateParams new_tab_params( | 67 chrome::NavigateParams new_tab_params( |
| 68 static_cast<Browser*>(NULL), params.url, params.transition); | 68 static_cast<Browser*>(NULL), params.url, params.transition); |
| 69 if (params.disposition == NEW_BACKGROUND_TAB) { | 69 if (params.disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB) { |
| 70 new_tab_params.disposition = NEW_BACKGROUND_TAB; | 70 new_tab_params.disposition = WindowOpenDisposition::NEW_BACKGROUND_TAB; |
| 71 } else { | 71 } else { |
| 72 new_tab_params.disposition = NEW_FOREGROUND_TAB; | 72 new_tab_params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
| 73 new_tab_params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 73 new_tab_params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 74 } | 74 } |
| 75 | 75 |
| 76 new_tab_params.initiating_profile = Profile::FromBrowserContext(context); | 76 new_tab_params.initiating_profile = Profile::FromBrowserContext(context); |
| 77 chrome::Navigate(&new_tab_params); | 77 chrome::Navigate(&new_tab_params); |
| 78 | 78 |
| 79 return new_tab_params.target_contents; | 79 return new_tab_params.target_contents; |
| 80 } | 80 } |
| 81 | 81 |
| 82 void OnCheckIsDefaultBrowserFinished( | 82 void OnCheckIsDefaultBrowserFinished( |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 // capture its intended navigation. Here we give ownership to the | 237 // capture its intended navigation. Here we give ownership to the |
| 238 // NewWindowContentsDelegate, which will dispose of the contents once | 238 // NewWindowContentsDelegate, which will dispose of the contents once |
| 239 // a navigation is captured. | 239 // a navigation is captured. |
| 240 new_contents->SetDelegate(new_window_contents_delegate_.get()); | 240 new_contents->SetDelegate(new_window_contents_delegate_.get()); |
| 241 return; | 241 return; |
| 242 } | 242 } |
| 243 chrome::ScopedTabbedBrowserDisplayer displayer( | 243 chrome::ScopedTabbedBrowserDisplayer displayer( |
| 244 Profile::FromBrowserContext(context)); | 244 Profile::FromBrowserContext(context)); |
| 245 // Force all links to open in a new tab, even if they were trying to open a | 245 // Force all links to open in a new tab, even if they were trying to open a |
| 246 // new window. | 246 // new window. |
| 247 disposition = | 247 disposition = disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB |
| 248 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB; | 248 ? disposition |
| 249 : WindowOpenDisposition::NEW_FOREGROUND_TAB; |
| 249 chrome::AddWebContents(displayer.browser(), | 250 chrome::AddWebContents(displayer.browser(), |
| 250 NULL, | 251 NULL, |
| 251 new_contents, | 252 new_contents, |
| 252 disposition, | 253 disposition, |
| 253 initial_rect, | 254 initial_rect, |
| 254 user_gesture, | 255 user_gesture, |
| 255 was_blocked); | 256 was_blocked); |
| 256 } | 257 } |
| 257 | 258 |
| 258 content::ColorChooser* ChromeAppDelegate::ShowColorChooser( | 259 content::ColorChooser* ChromeAppDelegate::ShowColorChooser( |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 KeepAliveRestartOption::DISABLED)); | 340 KeepAliveRestartOption::DISABLED)); |
| 340 } | 341 } |
| 341 | 342 |
| 342 void ChromeAppDelegate::Observe(int type, | 343 void ChromeAppDelegate::Observe(int type, |
| 343 const content::NotificationSource& source, | 344 const content::NotificationSource& source, |
| 344 const content::NotificationDetails& details) { | 345 const content::NotificationDetails& details) { |
| 345 DCHECK_EQ(chrome::NOTIFICATION_APP_TERMINATING, type); | 346 DCHECK_EQ(chrome::NOTIFICATION_APP_TERMINATING, type); |
| 346 if (!terminating_callback_.is_null()) | 347 if (!terminating_callback_.is_null()) |
| 347 terminating_callback_.Run(); | 348 terminating_callback_.Run(); |
| 348 } | 349 } |
| OLD | NEW |