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" |
11 #include "chrome/browser/infobars/infobar_tab_helper.h" | 11 #include "chrome/browser/infobars/infobar_tab_helper.h" |
12 #include "chrome/browser/intents/web_intents_util.h" | 12 #include "chrome/browser/intents/web_intents_util.h" |
13 #include "chrome/browser/lifetime/application_lifetime.h" | 13 #include "chrome/browser/lifetime/application_lifetime.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/sessions/session_id.h" | 15 #include "chrome/browser/sessions/session_id.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/browser_finder.h" | 17 #include "chrome/browser/ui/browser_finder.h" |
| 18 #include "chrome/browser/ui/browser_tabstrip.h" |
18 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
19 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" | 20 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" |
20 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 21 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
21 #include "chrome/browser/view_type_utils.h" | 22 #include "chrome/browser/view_type_utils.h" |
22 #include "chrome/common/chrome_notification_types.h" | 23 #include "chrome/common/chrome_notification_types.h" |
23 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
24 #include "chrome/common/extensions/extension_messages.h" | 25 #include "chrome/common/extensions/extension_messages.h" |
25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
26 #include "content/public/browser/invalidate_type.h" | 27 #include "content/public/browser/invalidate_type.h" |
27 #include "content/public/browser/navigation_entry.h" | 28 #include "content/public/browser/navigation_entry.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 const gfx::Rect& initial_pos, | 223 const gfx::Rect& initial_pos, |
223 bool user_gesture) { | 224 bool user_gesture) { |
224 DCHECK(source == web_contents_); | 225 DCHECK(source == web_contents_); |
225 DCHECK(Profile::FromBrowserContext(new_contents->GetBrowserContext()) == | 226 DCHECK(Profile::FromBrowserContext(new_contents->GetBrowserContext()) == |
226 profile_); | 227 profile_); |
227 Browser* browser = browser::FindOrCreateTabbedBrowser(profile_); | 228 Browser* browser = browser::FindOrCreateTabbedBrowser(profile_); |
228 // Force all links to open in a new tab, even if they were trying to open a | 229 // Force all links to open in a new tab, even if they were trying to open a |
229 // new window. | 230 // new window. |
230 disposition = | 231 disposition = |
231 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB; | 232 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB; |
232 browser->AddWebContents( | 233 chrome::AddWebContents(browser, NULL, new_contents, disposition, initial_pos, |
233 new_contents, disposition, initial_pos, user_gesture); | 234 user_gesture); |
234 } | 235 } |
235 | 236 |
236 void ShellWindow::OnNativeClose() { | 237 void ShellWindow::OnNativeClose() { |
237 ShellWindowRegistry::Get(profile_)->RemoveShellWindow(this); | 238 ShellWindowRegistry::Get(profile_)->RemoveShellWindow(this); |
238 delete this; | 239 delete this; |
239 } | 240 } |
240 | 241 |
241 string16 ShellWindow::GetTitle() const { | 242 string16 ShellWindow::GetTitle() const { |
242 // WebContents::GetTitle() will return the page's URL if there's no <title> | 243 // WebContents::GetTitle() will return the page's URL if there's no <title> |
243 // specified. However, we'd prefer to show the name of the extension in that | 244 // specified. However, we'd prefer to show the name of the extension in that |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 extension_function_dispatcher_.Dispatch(params, | 351 extension_function_dispatcher_.Dispatch(params, |
351 web_contents_->GetRenderViewHost()); | 352 web_contents_->GetRenderViewHost()); |
352 } | 353 } |
353 | 354 |
354 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level, | 355 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level, |
355 const std::string& message) { | 356 const std::string& message) { |
356 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); | 357 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); |
357 rvh->Send(new ExtensionMsg_AddMessageToConsole( | 358 rvh->Send(new ExtensionMsg_AddMessageToConsole( |
358 rvh->GetRoutingID(), level, message)); | 359 rvh->GetRoutingID(), level, message)); |
359 } | 360 } |
OLD | NEW |