summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_host.cc
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-06 03:00:40 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-06 03:00:40 +0000
commite8345245dbeed71eed592c8a89e4b70403019e47 (patch)
tree5b9e56c874df5de0cee3656c8c901a2f41f51c32 /chrome/browser/extensions/extension_host.cc
parent622b74522b0ee8aa0343dd48fbbd0230e9806d5e (diff)
downloadchromium_src-e8345245dbeed71eed592c8a89e4b70403019e47.zip
chromium_src-e8345245dbeed71eed592c8a89e4b70403019e47.tar.gz
chromium_src-e8345245dbeed71eed592c8a89e4b70403019e47.tar.bz2
Initial support for web-extent background pages.
This patch adds a new RVH container: BackgroundContents. The idea is that apps can open a live web-page as a "background" page using window.open('<url>', '<name>', 'background'); If 'background' is specified and the opener is within the app's extent, a BackgroundContents will be used. Otherwise, the 'background' feature is ignored and it is treated as a regular popup call. Note that as of this patch the following are explicitly not-yet addressed: 1) Session storage for BackgroundContents 2) SSL (or other failures) requiring UI 3) Javascript messages (alert, etc...) 4) Session restore TEST=All tests should pass BUG=41275 Review URL: http://codereview.chromium.org/1734014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46544 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_host.cc')
-rw-r--r--chrome/browser/extensions/extension_host.cc32
1 files changed, 18 insertions, 14 deletions
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index e62f6bb..3921aa6 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/dom_ui/dom_ui_factory.h"
#include "chrome/browser/extensions/extension_message_service.h"
#include "chrome/browser/extensions/extension_tabs_module.h"
+#include "chrome/browser/extensions/extension_tabs_module_constants.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/in_process_webkit/dom_storage_context.h"
#include "chrome/browser/in_process_webkit/webkit_context.h"
@@ -38,6 +39,7 @@
#include "chrome/browser/tab_contents/tab_contents_view.h"
#include "chrome/common/bindings_policy.h"
#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/view_types.h"
@@ -298,11 +300,8 @@ void ExtensionHost::RenderViewGone(RenderViewHost* render_view_host) {
void ExtensionHost::DidNavigate(RenderViewHost* render_view_host,
const ViewHostMsg_FrameNavigate_Params& params) {
// We only care when the outer frame changes.
- switch (params.transition) {
- case PageTransition::AUTO_SUBFRAME:
- case PageTransition::MANUAL_SUBFRAME:
- return;
- }
+ if (!PageTransition::IsMainFrame(params.transition))
+ return;
if (!params.url.SchemeIs(chrome::kExtensionScheme)) {
extension_function_dispatcher_.reset(NULL);
@@ -516,9 +515,14 @@ RendererPreferences ExtensionHost::GetRendererPrefs(Profile* profile) const {
WebPreferences ExtensionHost::GetWebkitPrefs() {
Profile* profile = render_view_host()->process()->profile();
- const bool kIsDomUI = true;
WebPreferences webkit_prefs =
- RenderViewHostDelegateHelper::GetWebkitPrefs(profile, kIsDomUI);
+ RenderViewHostDelegateHelper::GetWebkitPrefs(profile,
+ false); // is_dom_ui
+ // Extensions are trusted so we override any user preferences for disabling
+ // javascript or images.
+ webkit_prefs.loads_images_automatically = true;
+ webkit_prefs.javascript_enabled = true;
+
if (extension_host_type_ == ViewType::EXTENSION_POPUP ||
extension_host_type_ == ViewType::EXTENSION_INFOBAR)
webkit_prefs.allow_scripts_to_close_windows = true;
@@ -551,8 +555,11 @@ void ExtensionHost::CreateNewWindow(
int route_id,
WindowContainerType window_container_type) {
delegate_view_helper_.CreateNewWindow(
- route_id, render_view_host()->process()->profile(),
- site_instance(), DOMUIFactory::GetDOMUIType(url_), NULL,
+ route_id,
+ render_view_host()->process()->profile(),
+ site_instance(),
+ DOMUIFactory::GetDOMUIType(url_),
+ this,
window_container_type);
}
@@ -580,10 +587,7 @@ void ExtensionHost::ShowCreatedWindow(int route_id,
if (!browser)
return;
- // TODO(aa): It seems like this means popup windows don't work via
- // window.open() from ExtensionHost?
- browser->AddTabContents(contents, disposition, initial_pos,
- user_gesture);
+ browser->AddTabContents(contents, disposition, initial_pos, user_gesture);
}
void ExtensionHost::ShowCreatedWidget(int route_id,
@@ -713,7 +717,7 @@ void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) {
int ExtensionHost::GetBrowserWindowID() const {
// Hosts not attached to any browser window have an id of -1. This includes
// those mentioned below, and background pages.
- int window_id = -1;
+ int window_id = extension_misc::kUnknownWindowId;
if (extension_host_type_ == ViewType::EXTENSION_TOOLSTRIP ||
extension_host_type_ == ViewType::EXTENSION_MOLE ||
extension_host_type_ == ViewType::EXTENSION_POPUP ||