OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/extensions/extension_host.h" | 5 #include "chrome/browser/extensions/extension_host.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 if (current_tab) { | 152 if (current_tab) { |
153 current_tab->AddInfoBar( | 153 current_tab->AddInfoBar( |
154 new CrashedExtensionInfobarDelegate(current_tab, this)); | 154 new CrashedExtensionInfobarDelegate(current_tab, this)); |
155 } | 155 } |
156 NotificationService::current()->Notify( | 156 NotificationService::current()->Notify( |
157 NotificationType::EXTENSION_PROCESS_CRASHED, | 157 NotificationType::EXTENSION_PROCESS_CRASHED, |
158 Source<Profile>(profile_), | 158 Source<Profile>(profile_), |
159 Details<ExtensionHost>(this)); | 159 Details<ExtensionHost>(this)); |
160 } | 160 } |
161 | 161 |
162 WebPreferences ExtensionHost::GetWebkitPrefs() { | |
163 PrefService* prefs = render_view_host()->process()->profile()->GetPrefs(); | |
164 const bool kIsDomUI = true; | |
165 return RenderViewHostDelegateHelper::GetWebkitPrefs(prefs, kIsDomUI); | |
166 } | |
167 | |
168 void ExtensionHost::RunJavaScriptMessage( | |
169 const std::wstring& message, | |
170 const std::wstring& default_prompt, | |
171 const GURL& frame_url, | |
172 const int flags, | |
173 IPC::Message* reply_msg, | |
174 bool* did_suppress_message) { | |
175 // Automatically cancel the javascript alert (otherwise the renderer hangs | |
176 // indefinitely). | |
177 *did_suppress_message = true; | |
178 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, true, L""); | |
179 } | |
180 | |
181 void ExtensionHost::DidStopLoading(RenderViewHost* render_view_host) { | 162 void ExtensionHost::DidStopLoading(RenderViewHost* render_view_host) { |
182 // TODO(aa): This is toolstrip-specific and should probably not be here. | 163 // TODO(aa): This is toolstrip-specific and should probably not be here. |
183 // ExtensionToolstrip in bookmark_bar_view.cc? | 164 // ExtensionToolstrip in bookmark_bar_view.cc? |
184 static const StringPiece toolstrip_css( | 165 static const StringPiece toolstrip_css( |
185 ResourceBundle::GetSharedInstance().GetRawDataResource( | 166 ResourceBundle::GetSharedInstance().GetRawDataResource( |
186 IDR_EXTENSIONS_TOOLSTRIP_CSS)); | 167 IDR_EXTENSIONS_TOOLSTRIP_CSS)); |
187 render_view_host->InsertCSSInWebFrame(L"", toolstrip_css.as_string()); | 168 render_view_host->InsertCSSInWebFrame(L"", toolstrip_css.as_string()); |
188 | 169 |
189 did_stop_loading_ = true; | 170 did_stop_loading_ = true; |
190 } | 171 } |
191 | 172 |
| 173 void ExtensionHost::RunJavaScriptMessage(const std::wstring& message, |
| 174 const std::wstring& default_prompt, |
| 175 const GURL& frame_url, |
| 176 const int flags, |
| 177 IPC::Message* reply_msg, |
| 178 bool* did_suppress_message) { |
| 179 // Automatically cancel the javascript alert (otherwise the renderer hangs |
| 180 // indefinitely). |
| 181 *did_suppress_message = true; |
| 182 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, true, L""); |
| 183 } |
| 184 |
| 185 GURL ExtensionHost::GetAlternateErrorPageURL() const { |
| 186 return GURL(); |
| 187 } |
| 188 |
| 189 RendererPreferences ExtensionHost::GetRendererPrefs() const { |
| 190 return RendererPreferences(); |
| 191 } |
| 192 |
| 193 WebPreferences ExtensionHost::GetWebkitPrefs() { |
| 194 PrefService* prefs = render_view_host()->process()->profile()->GetPrefs(); |
| 195 const bool kIsDomUI = true; |
| 196 return RenderViewHostDelegateHelper::GetWebkitPrefs(prefs, kIsDomUI); |
| 197 } |
| 198 |
| 199 void ExtensionHost::ProcessDOMUIMessage(const std::string& message, |
| 200 const std::string& content, |
| 201 int request_id, |
| 202 bool has_callback) { |
| 203 extension_function_dispatcher_->HandleRequest(message, content, request_id, |
| 204 has_callback); |
| 205 } |
| 206 |
192 void ExtensionHost::DidInsertCSS() { | 207 void ExtensionHost::DidInsertCSS() { |
193 #if defined(TOOLKIT_VIEWS) | 208 #if defined(TOOLKIT_VIEWS) |
194 if (view_.get()) | 209 if (view_.get()) |
195 view_->SetDidInsertCSS(true); | 210 view_->SetDidInsertCSS(true); |
196 #endif | 211 #endif |
197 } | 212 } |
198 | 213 |
199 RenderViewHostDelegate::View* ExtensionHost::GetViewDelegate() const { | 214 RenderViewHostDelegate::View* ExtensionHost::GetViewDelegate() const { |
200 // TODO(erikkay) this is unfortunate. The interface declares that this method | 215 // TODO(erikkay) this is unfortunate. The interface declares that this method |
201 // must be const (no good reason for it as far as I can tell) which means you | 216 // must be const (no good reason for it as far as I can tell) which means you |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 render_view_host()->process()->profile()); | 306 render_view_host()->process()->profile()); |
292 // NOTE(rafaelw): This can return NULL in some circumstances. In particular, | 307 // NOTE(rafaelw): This can return NULL in some circumstances. In particular, |
293 // a toolstrip or background_page onload chrome.tabs api call can make it | 308 // a toolstrip or background_page onload chrome.tabs api call can make it |
294 // into here before the browser is sufficiently initialized to return here. | 309 // into here before the browser is sufficiently initialized to return here. |
295 // A similar situation may arise during shutdown. | 310 // A similar situation may arise during shutdown. |
296 // TODO(rafaelw): Delay creation of background_page until the browser | 311 // TODO(rafaelw): Delay creation of background_page until the browser |
297 // is available. http://code.google.com/p/chromium/issues/detail?id=13284 | 312 // is available. http://code.google.com/p/chromium/issues/detail?id=13284 |
298 return browser; | 313 return browser; |
299 } | 314 } |
300 | 315 |
301 void ExtensionHost::ProcessDOMUIMessage(const std::string& message, | |
302 const std::string& content, | |
303 int request_id, | |
304 bool has_callback) { | |
305 extension_function_dispatcher_->HandleRequest(message, content, request_id, | |
306 has_callback); | |
307 } | |
308 | |
309 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { | 316 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { |
310 extension_function_dispatcher_.reset( | 317 extension_function_dispatcher_.reset( |
311 new ExtensionFunctionDispatcher(render_view_host_, this, url_)); | 318 new ExtensionFunctionDispatcher(render_view_host_, this, url_)); |
312 } | 319 } |
OLD | NEW |