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/intents/web_intent_inline_disposition_delegate.h" | 5 #include "chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.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_tabstrip.h" |
10 #include "chrome/browser/ui/intents/web_intent_picker.h" | 11 #include "chrome/browser/ui/intents/web_intent_picker.h" |
11 #include "chrome/common/extensions/extension_messages.h" | 12 #include "chrome/common/extensions/extension_messages.h" |
12 #include "content/public/browser/navigation_controller.h" | 13 #include "content/public/browser/navigation_controller.h" |
13 #include "content/public/browser/render_view_host.h" | 14 #include "content/public/browser/render_view_host.h" |
14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
15 #include "content/public/common/renderer_preferences.h" | 16 #include "content/public/common/renderer_preferences.h" |
16 #include "ipc/ipc_message_macros.h" | 17 #include "ipc/ipc_message_macros.h" |
17 | 18 |
18 WebIntentInlineDispositionDelegate::WebIntentInlineDispositionDelegate( | 19 WebIntentInlineDispositionDelegate::WebIntentInlineDispositionDelegate( |
19 WebIntentPicker* picker, | 20 WebIntentPicker* picker, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 const gfx::Rect& initial_pos, | 70 const gfx::Rect& initial_pos, |
70 bool user_gesture) { | 71 bool user_gesture) { |
71 DCHECK_EQ(source, web_contents_); | 72 DCHECK_EQ(source, web_contents_); |
72 DCHECK_EQ(Profile::FromBrowserContext(new_contents->GetBrowserContext()), | 73 DCHECK_EQ(Profile::FromBrowserContext(new_contents->GetBrowserContext()), |
73 profile_); | 74 profile_); |
74 Browser* browser = browser::FindOrCreateTabbedBrowser(profile_); | 75 Browser* browser = browser::FindOrCreateTabbedBrowser(profile_); |
75 // Force all links to open in a new tab, even when different disposition is | 76 // Force all links to open in a new tab, even when different disposition is |
76 // requested. | 77 // requested. |
77 disposition = | 78 disposition = |
78 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB; | 79 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB; |
79 browser->AddWebContents( | 80 chrome::AddWebContents(browser, NULL, new_contents, disposition, initial_pos, |
80 new_contents, disposition, initial_pos, user_gesture); | 81 user_gesture); |
81 } | 82 } |
82 | 83 |
83 void WebIntentInlineDispositionDelegate::LoadingStateChanged( | 84 void WebIntentInlineDispositionDelegate::LoadingStateChanged( |
84 content::WebContents* source) { | 85 content::WebContents* source) { |
85 if (!source->IsLoading()) | 86 if (!source->IsLoading()) |
86 picker_->OnInlineDispositionWebContentsLoaded(source); | 87 picker_->OnInlineDispositionWebContentsLoaded(source); |
87 } | 88 } |
88 | 89 |
89 bool WebIntentInlineDispositionDelegate::OnMessageReceived( | 90 bool WebIntentInlineDispositionDelegate::OnMessageReceived( |
90 const IPC::Message& message) { | 91 const IPC::Message& message) { |
(...skipping 25 matching lines...) Expand all Loading... |
116 void WebIntentInlineDispositionDelegate::OnRequest( | 117 void WebIntentInlineDispositionDelegate::OnRequest( |
117 const ExtensionHostMsg_Request_Params& params) { | 118 const ExtensionHostMsg_Request_Params& params) { |
118 extension_function_dispatcher_.Dispatch(params, | 119 extension_function_dispatcher_.Dispatch(params, |
119 web_contents_->GetRenderViewHost()); | 120 web_contents_->GetRenderViewHost()); |
120 } | 121 } |
121 void WebIntentInlineDispositionDelegate::ResizeDueToAutoResize( | 122 void WebIntentInlineDispositionDelegate::ResizeDueToAutoResize( |
122 content::WebContents* source, const gfx::Size& pref_size) { | 123 content::WebContents* source, const gfx::Size& pref_size) { |
123 DCHECK(picker_); | 124 DCHECK(picker_); |
124 picker_->OnInlineDispositionAutoResize(pref_size); | 125 picker_->OnInlineDispositionAutoResize(pref_size); |
125 } | 126 } |
OLD | NEW |