| 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/extensions/shell_window.h" | 5 #include "chrome/browser/ui/extensions/shell_window.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/extension_process_manager.h" | 8 #include "chrome/browser/extensions/extension_process_manager.h" |
| 9 #include "chrome/browser/extensions/shell_window_registry.h" | 9 #include "chrome/browser/extensions/shell_window_registry.h" |
| 10 #include "chrome/browser/file_select_helper.h" | 10 #include "chrome/browser/file_select_helper.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 // window. | 208 // window. |
| 209 content::OpenURLParams new_tab_params = params; | 209 content::OpenURLParams new_tab_params = params; |
| 210 new_tab_params.disposition = | 210 new_tab_params.disposition = |
| 211 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB; | 211 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB; |
| 212 Browser* browser = browser::FindOrCreateTabbedBrowser(profile_); | 212 Browser* browser = browser::FindOrCreateTabbedBrowser(profile_); |
| 213 WebContents* new_tab = browser->OpenURL(new_tab_params); | 213 WebContents* new_tab = browser->OpenURL(new_tab_params); |
| 214 browser->window()->Show(); | 214 browser->window()->Show(); |
| 215 return new_tab; | 215 return new_tab; |
| 216 } | 216 } |
| 217 | 217 |
| 218 void ShellWindow::AddNewContents(WebContents* source, | 218 bool ShellWindow::AddNewContents(WebContents* source, |
| 219 WebContents* new_contents, | 219 WebContents* new_contents, |
| 220 WindowOpenDisposition disposition, | 220 WindowOpenDisposition disposition, |
| 221 const gfx::Rect& initial_pos, | 221 const gfx::Rect& initial_pos, |
| 222 bool user_gesture) { | 222 bool user_gesture) { |
| 223 DCHECK(source == web_contents_); | 223 DCHECK(source == web_contents_); |
| 224 DCHECK(Profile::FromBrowserContext(new_contents->GetBrowserContext()) == | 224 DCHECK(Profile::FromBrowserContext(new_contents->GetBrowserContext()) == |
| 225 profile_); | 225 profile_); |
| 226 Browser* browser = browser::FindOrCreateTabbedBrowser(profile_); | 226 Browser* browser = browser::FindOrCreateTabbedBrowser(profile_); |
| 227 // Force all links to open in a new tab, even if they were trying to open a | 227 // Force all links to open in a new tab, even if they were trying to open a |
| 228 // new window. | 228 // new window. |
| 229 disposition = | 229 disposition = |
| 230 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB; | 230 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB; |
| 231 chrome::AddWebContents(browser, NULL, new_contents, disposition, initial_pos, | 231 return chrome::AddWebContents( |
| 232 user_gesture); | 232 browser, NULL, new_contents, disposition, initial_pos, user_gesture); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void ShellWindow::HandleKeyboardEvent( | 235 void ShellWindow::HandleKeyboardEvent( |
| 236 WebContents* source, | 236 WebContents* source, |
| 237 const content::NativeWebKeyboardEvent& event) { | 237 const content::NativeWebKeyboardEvent& event) { |
| 238 DCHECK_EQ(source, web_contents_); | 238 DCHECK_EQ(source, web_contents_); |
| 239 native_window_->HandleKeyboardEvent(event); | 239 native_window_->HandleKeyboardEvent(event); |
| 240 } | 240 } |
| 241 | 241 |
| 242 void ShellWindow::OnNativeClose() { | 242 void ShellWindow::OnNativeClose() { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 extension_function_dispatcher_.Dispatch(params, | 369 extension_function_dispatcher_.Dispatch(params, |
| 370 web_contents_->GetRenderViewHost()); | 370 web_contents_->GetRenderViewHost()); |
| 371 } | 371 } |
| 372 | 372 |
| 373 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level, | 373 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level, |
| 374 const std::string& message) { | 374 const std::string& message) { |
| 375 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); | 375 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); |
| 376 rvh->Send(new ExtensionMsg_AddMessageToConsole( | 376 rvh->Send(new ExtensionMsg_AddMessageToConsole( |
| 377 rvh->GetRoutingID(), level, message)); | 377 rvh->GetRoutingID(), level, message)); |
| 378 } | 378 } |
| OLD | NEW |