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 "chrome/browser/ui/browser_list.h" | 7 #include "chrome/browser/ui/browser_list.h" |
8 #include "chrome/browser/extensions/extension_process_manager.h" | 8 #include "chrome/browser/extensions/extension_process_manager.h" |
9 #include "chrome/browser/extensions/extension_tabs_module_constants.h" | 9 #include "chrome/browser/extensions/extension_tabs_module_constants.h" |
10 #include "chrome/browser/extensions/extension_window_controller.h" | 10 #include "chrome/browser/extensions/extension_window_controller.h" |
11 #include "chrome/browser/extensions/shell_window_registry.h" | 11 #include "chrome/browser/extensions/shell_window_registry.h" |
12 #include "chrome/browser/intents/web_intents_util.h" | 12 #include "chrome/browser/intents/web_intents_util.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/sessions/session_id.h" | 14 #include "chrome/browser/sessions/session_id.h" |
15 #include "chrome/browser/ui/browser.h" | |
15 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" | 16 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" |
16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
17 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
18 #include "chrome/common/chrome_view_type.h" | 19 #include "chrome/common/chrome_view_type.h" |
19 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
20 #include "chrome/common/extensions/extension_messages.h" | 21 #include "chrome/common/extensions/extension_messages.h" |
21 #include "content/public/browser/notification_details.h" | 22 #include "content/public/browser/notification_details.h" |
22 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
23 #include "content/public/browser/notification_source.h" | 24 #include "content/public/browser/notification_source.h" |
24 #include "content/public/browser/notification_types.h" | 25 #include "content/public/browser/notification_types.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) | 146 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) |
146 IPC_MESSAGE_UNHANDLED(handled = false) | 147 IPC_MESSAGE_UNHANDLED(handled = false) |
147 IPC_END_MESSAGE_MAP() | 148 IPC_END_MESSAGE_MAP() |
148 return handled; | 149 return handled; |
149 } | 150 } |
150 | 151 |
151 void ShellWindow::CloseContents(WebContents* contents) { | 152 void ShellWindow::CloseContents(WebContents* contents) { |
152 Close(); | 153 Close(); |
153 } | 154 } |
154 | 155 |
155 // TODO(benwells): Rearrange so users of this can call | |
benwells
2012/05/17 00:46:46
Turns out some implementers of ShouldSuppressDialo
| |
156 // WebContents::set_should_suppress_dialogs(bool) instead of overriding | |
157 // this delegate function. | |
158 bool ShellWindow::ShouldSuppressDialogs() { | 156 bool ShellWindow::ShouldSuppressDialogs() { |
159 return true; | 157 return true; |
160 } | 158 } |
161 | 159 |
162 void ShellWindow::WebIntentDispatch( | 160 void ShellWindow::WebIntentDispatch( |
163 content::WebContents* web_contents, | 161 content::WebContents* web_contents, |
164 content::WebIntentsDispatcher* intents_dispatcher) { | 162 content::WebIntentsDispatcher* intents_dispatcher) { |
165 if (!web_intents::IsWebIntentsEnabled(profile_)) | 163 if (!web_intents::IsWebIntentsEnabled(profile_)) |
166 return; | 164 return; |
167 | 165 |
168 contents_wrapper_->web_intent_picker_controller()->SetIntentsDispatcher( | 166 contents_wrapper_->web_intent_picker_controller()->SetIntentsDispatcher( |
169 intents_dispatcher); | 167 intents_dispatcher); |
170 contents_wrapper_->web_intent_picker_controller()->ShowDialog( | 168 contents_wrapper_->web_intent_picker_controller()->ShowDialog( |
171 intents_dispatcher->GetIntent().action, | 169 intents_dispatcher->GetIntent().action, |
172 intents_dispatcher->GetIntent().type); | 170 intents_dispatcher->GetIntent().type); |
173 } | 171 } |
174 | 172 |
173 void ShellWindow::RunFileChooser(WebContents* tab, | |
174 const content::FileChooserParams& params) { | |
175 Browser::RunFileChooserHelper(tab, params); | |
Mihai Parparita -not on Chrome
2012/05/17 00:51:44
Huh, Browser seems like an odd place for this help
benwells
2012/05/17 01:02:26
There are a bunch of helpers like this on Browser:
sky
2012/05/17 03:57:37
How about a static method on FileSelectHelper? And
| |
176 } | |
177 | |
175 void ShellWindow::Observe(int type, | 178 void ShellWindow::Observe(int type, |
176 const content::NotificationSource& source, | 179 const content::NotificationSource& source, |
177 const content::NotificationDetails& details) { | 180 const content::NotificationDetails& details) { |
178 switch (type) { | 181 switch (type) { |
179 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { | 182 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { |
180 const Extension* unloaded_extension = | 183 const Extension* unloaded_extension = |
181 content::Details<UnloadedExtensionInfo>(details)->extension; | 184 content::Details<UnloadedExtensionInfo>(details)->extension; |
182 if (extension_ == unloaded_extension) | 185 if (extension_ == unloaded_extension) |
183 Close(); | 186 Close(); |
184 break; | 187 break; |
185 } | 188 } |
186 case content::NOTIFICATION_APP_TERMINATING: | 189 case content::NOTIFICATION_APP_TERMINATING: |
187 Close(); | 190 Close(); |
188 break; | 191 break; |
189 default: | 192 default: |
190 NOTREACHED() << "Received unexpected notification"; | 193 NOTREACHED() << "Received unexpected notification"; |
191 } | 194 } |
192 } | 195 } |
193 | 196 |
194 ExtensionWindowController* ShellWindow::GetExtensionWindowController() const { | 197 ExtensionWindowController* ShellWindow::GetExtensionWindowController() const { |
195 return extension_window_controller_.get(); | 198 return extension_window_controller_.get(); |
196 } | 199 } |
197 | 200 |
198 void ShellWindow::OnRequest(const ExtensionHostMsg_Request_Params& params) { | 201 void ShellWindow::OnRequest(const ExtensionHostMsg_Request_Params& params) { |
199 extension_function_dispatcher_.Dispatch(params, | 202 extension_function_dispatcher_.Dispatch(params, |
200 web_contents_->GetRenderViewHost()); | 203 web_contents_->GetRenderViewHost()); |
201 } | 204 } |
OLD | NEW |