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 <list> | 7 #include <list> |
8 | 8 |
9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 24 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
25 #include "chrome/browser/renderer_host/site_instance.h" | 25 #include "chrome/browser/renderer_host/site_instance.h" |
26 #include "chrome/common/bindings_policy.h" | 26 #include "chrome/common/bindings_policy.h" |
27 #include "chrome/common/extensions/extension.h" | 27 #include "chrome/common/extensions/extension.h" |
28 #include "chrome/common/notification_service.h" | 28 #include "chrome/common/notification_service.h" |
29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
30 #include "chrome/common/pref_service.h" | 30 #include "chrome/common/pref_service.h" |
31 #include "chrome/common/view_types.h" | 31 #include "chrome/common/view_types.h" |
32 #include "chrome/common/render_messages.h" | 32 #include "chrome/common/render_messages.h" |
33 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
34 | |
35 #include "grit/browser_resources.h" | 34 #include "grit/browser_resources.h" |
36 | 35 #include "views/widget/widget.h" |
37 #include "webkit/glue/context_menu.h" | 36 #include "webkit/glue/context_menu.h" |
38 | 37 |
39 using WebKit::WebDragOperation; | 38 using WebKit::WebDragOperation; |
40 using WebKit::WebDragOperationsMask; | 39 using WebKit::WebDragOperationsMask; |
41 | 40 |
42 // static | 41 // static |
43 bool ExtensionHost::enable_dom_automation_ = false; | 42 bool ExtensionHost::enable_dom_automation_ = false; |
44 | 43 |
45 static const char* kToolstripTextColorSubstitution = "$TEXT_COLOR$"; | 44 static const char* kToolstripTextColorSubstitution = "$TEXT_COLOR$"; |
46 | 45 |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 const GURL& frame_url, | 331 const GURL& frame_url, |
333 const int flags, | 332 const int flags, |
334 IPC::Message* reply_msg, | 333 IPC::Message* reply_msg, |
335 bool* did_suppress_message) { | 334 bool* did_suppress_message) { |
336 // Automatically cancel the javascript alert (otherwise the renderer hangs | 335 // Automatically cancel the javascript alert (otherwise the renderer hangs |
337 // indefinitely). | 336 // indefinitely). |
338 *did_suppress_message = true; | 337 *did_suppress_message = true; |
339 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, true, L""); | 338 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, true, L""); |
340 } | 339 } |
341 | 340 |
| 341 void ExtensionHost::Close(RenderViewHost* render_view_host) { |
| 342 if (extension_host_type_ == ViewType::EXTENSION_POPUP) { |
| 343 #if defined(TOOLKIT_VIEWS) |
| 344 // TODO(erikkay) This is a bit of a hack. By hiding the widget, we trigger |
| 345 // a deactivation which will then bubble into ExtensionPopup and actually |
| 346 // close the popup. Perhaps we should have a more explicit delegate to |
| 347 // ExtensionHost. |
| 348 view_->GetWidget()->Hide(); |
| 349 #endif |
| 350 } |
| 351 } |
| 352 |
342 WebPreferences ExtensionHost::GetWebkitPrefs() { | 353 WebPreferences ExtensionHost::GetWebkitPrefs() { |
343 PrefService* prefs = render_view_host()->process()->profile()->GetPrefs(); | 354 PrefService* prefs = render_view_host()->process()->profile()->GetPrefs(); |
344 const bool kIsDomUI = true; | 355 const bool kIsDomUI = true; |
345 return RenderViewHostDelegateHelper::GetWebkitPrefs(prefs, kIsDomUI); | 356 WebPreferences webkit_prefs = |
| 357 RenderViewHostDelegateHelper::GetWebkitPrefs(prefs, kIsDomUI); |
| 358 if (extension_host_type_ == ViewType::EXTENSION_POPUP) |
| 359 webkit_prefs.allow_scripts_to_close_windows = true; |
| 360 return webkit_prefs; |
346 } | 361 } |
347 | 362 |
348 void ExtensionHost::ProcessDOMUIMessage(const std::string& message, | 363 void ExtensionHost::ProcessDOMUIMessage(const std::string& message, |
349 const std::string& content, | 364 const std::string& content, |
350 int request_id, | 365 int request_id, |
351 bool has_callback) { | 366 bool has_callback) { |
352 if (extension_function_dispatcher_.get()) { | 367 if (extension_function_dispatcher_.get()) { |
353 extension_function_dispatcher_->HandleRequest(message, content, request_id, | 368 extension_function_dispatcher_->HandleRequest(message, content, request_id, |
354 has_callback); | 369 has_callback); |
355 } | 370 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 window_id = ExtensionTabUtil::GetWindowId( | 511 window_id = ExtensionTabUtil::GetWindowId( |
497 const_cast<ExtensionHost* >(this)->GetBrowser()); | 512 const_cast<ExtensionHost* >(this)->GetBrowser()); |
498 } else if (extension_host_type_ == ViewType::EXTENSION_BACKGROUND_PAGE) { | 513 } else if (extension_host_type_ == ViewType::EXTENSION_BACKGROUND_PAGE) { |
499 // Background page is not attached to any browser window, so pass -1. | 514 // Background page is not attached to any browser window, so pass -1. |
500 window_id = -1; | 515 window_id = -1; |
501 } else { | 516 } else { |
502 NOTREACHED(); | 517 NOTREACHED(); |
503 } | 518 } |
504 return window_id; | 519 return window_id; |
505 } | 520 } |
OLD | NEW |