summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 15:22:11 +0000
committererikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 15:22:11 +0000
commit5351dbc9a7ec62aa9db14e6040856f56a9d01c0f (patch)
tree75310029e7bfdb333e11b117f4af1a5f98c7d955
parent5e38ff3d12a83ae0925ef00c3da37ce9718ac29d (diff)
downloadchromium_src-5351dbc9a7ec62aa9db14e6040856f56a9d01c0f.zip
chromium_src-5351dbc9a7ec62aa9db14e6040856f56a9d01c0f.tar.gz
chromium_src-5351dbc9a7ec62aa9db14e6040856f56a9d01c0f.tar.bz2
When the browser doesn't have connectivity to a hosted app, display a prettier error page by default.
TEST=none BUG=41281 Review URL: http://codereview.chromium.org/3174024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57680 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd4
-rw-r--r--chrome/browser/cocoa/extensions/extension_infobar_controller.mm5
-rw-r--r--chrome/browser/dom_ui/app_launcher_handler.cc3
-rw-r--r--chrome/browser/extensions/app_process_apitest.cc12
-rw-r--r--chrome/browser/extensions/extension_dom_ui.cc2
-rw-r--r--chrome/browser/extensions/extension_icon_manager.cc4
-rw-r--r--chrome/browser/extensions/extension_install_ui.cc2
-rw-r--r--chrome/browser/extensions/image_loading_tracker_unittest.cc4
-rw-r--r--chrome/browser/gtk/extension_infobar_gtk.cc5
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc27
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.h5
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc2
-rw-r--r--chrome/browser/views/app_launched_animation_win.cc2
-rw-r--r--chrome/browser/views/infobars/extension_infobar.cc5
-rw-r--r--chrome/chrome_renderer.gypi2
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--chrome/common/extensions/extension.cc45
-rw-r--r--chrome/common/extensions/extension.h13
-rw-r--r--chrome/common/render_messages.h5
-rw-r--r--chrome/common/render_messages_internal.h6
-rw-r--r--chrome/common/render_messages_params.cc38
-rw-r--r--chrome/common/render_messages_params.h19
-rw-r--r--chrome/renderer/extensions/chrome_app_bindings.cc5
-rw-r--r--chrome/renderer/extensions/extension_renderer_info.cc86
-rw-r--r--chrome/renderer/extensions/extension_renderer_info.h60
-rw-r--r--chrome/renderer/extensions/extension_renderer_info_unittest.cc70
-rw-r--r--chrome/renderer/localized_error.cc25
-rw-r--r--chrome/renderer/localized_error.h10
-rw-r--r--chrome/renderer/render_thread.cc48
-rw-r--r--chrome/renderer/render_thread.h19
-rw-r--r--chrome/renderer/render_view.cc73
-rw-r--r--chrome/renderer/renderer_resources.grd1
-rw-r--r--chrome/renderer/resources/error_app.html53
33 files changed, 479 insertions, 182 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 1253a50c..95b2daf6 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -5325,6 +5325,10 @@ Keep your key file in a safe place. You will need it to create new versions of y
This web page requires data that you entered earlier in order to be properly displayed. You can send this data again, but by doing so you will repeat any action this page previously performed. Press Reload to resend that data and display this page.
</message>
+ <message name="IDS_ERRORPAGES_APP_WARNING" desc="The error message displayed when the browser can not reach the requested page from an app.">
+ The app is currently unreachable.
+ </message>
+
<message name="IDS_SAVEAS_ALL_FILES" desc="Save As dialog box default text">
All Files
</message>
diff --git a/chrome/browser/cocoa/extensions/extension_infobar_controller.mm b/chrome/browser/cocoa/extensions/extension_infobar_controller.mm
index f9599fa..5011a24 100644
--- a/chrome/browser/cocoa/extensions/extension_infobar_controller.mm
+++ b/chrome/browser/cocoa/extensions/extension_infobar_controller.mm
@@ -66,9 +66,8 @@ class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver,
void LoadIcon() {
ExtensionResource icon_resource;
Extension* extension = delegate_->extension_host()->extension();
- Extension::Icons size =
- extension->GetIconPathAllowLargerSize(&icon_resource,
- Extension::EXTENSION_ICON_BITTY);
+ Extension::Icons size = extension->GetIconResourceAllowLargerSize(
+ &icon_resource, Extension::EXTENSION_ICON_BITTY);
if (!icon_resource.relative_path().empty()) {
tracker_.LoadImage(extension, icon_resource, gfx::Size(size, size),
ImageLoadingTracker::DONT_CACHE);
diff --git a/chrome/browser/dom_ui/app_launcher_handler.cc b/chrome/browser/dom_ui/app_launcher_handler.cc
index d05ebf7..1592528 100644
--- a/chrome/browser/dom_ui/app_launcher_handler.cc
+++ b/chrome/browser/dom_ui/app_launcher_handler.cc
@@ -87,7 +87,8 @@ void AppLauncherHandler::CreateAppInfo(Extension* extension,
value->SetString("options_url", extension->options_url().spec());
FilePath relative_path =
- extension->GetIconPath(Extension::EXTENSION_ICON_LARGE).relative_path();
+ extension->GetIconResource(
+ Extension::EXTENSION_ICON_LARGE).relative_path();
#if defined(OS_POSIX)
std::string path = relative_path.value();
diff --git a/chrome/browser/extensions/app_process_apitest.cc b/chrome/browser/extensions/app_process_apitest.cc
index 2062b10..1ca01cc 100644
--- a/chrome/browser/extensions/app_process_apitest.cc
+++ b/chrome/browser/extensions/app_process_apitest.cc
@@ -115,16 +115,4 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcess) {
browser()->GetTabContentsAt(2)->render_view_host()->process());
EXPECT_EQ(host->process(),
browser()->GetTabContentsAt(3)->render_view_host()->process());
-
- // Navigate the non-app tab into the browse extent. It should not enter the
- // app process.
- // Navigate the app tab into the browse extent. It should stay in the app
- // process.
- const GURL& browse_url(base_url.Resolve("path4/empty.html"));
- NavigateTabHelper(browser()->GetTabContentsAt(2), browse_url);
- NavigateTabHelper(browser()->GetTabContentsAt(3), browse_url);
- EXPECT_NE(host->process(),
- browser()->GetTabContentsAt(2)->render_view_host()->process());
- EXPECT_EQ(host->process(),
- browser()->GetTabContentsAt(3)->render_view_host()->process());
}
diff --git a/chrome/browser/extensions/extension_dom_ui.cc b/chrome/browser/extensions/extension_dom_ui.cc
index c9560cf..1315330 100644
--- a/chrome/browser/extensions/extension_dom_ui.cc
+++ b/chrome/browser/extensions/extension_dom_ui.cc
@@ -71,7 +71,7 @@ class ExtensionDOMUIImageLoadingTracker : public ImageLoadingTracker::Observer {
void Init() {
if (extension_) {
ExtensionResource icon_resource =
- extension_->GetIconPath(Extension::EXTENSION_ICON_BITTY);
+ extension_->GetIconResource(Extension::EXTENSION_ICON_BITTY);
tracker_.LoadImage(extension_, icon_resource,
gfx::Size(kFavIconSize, kFavIconSize),
diff --git a/chrome/browser/extensions/extension_icon_manager.cc b/chrome/browser/extensions/extension_icon_manager.cc
index 1e3befc..ecdca47 100644
--- a/chrome/browser/extensions/extension_icon_manager.cc
+++ b/chrome/browser/extensions/extension_icon_manager.cc
@@ -23,8 +23,8 @@ ExtensionIconManager::ExtensionIconManager()
void ExtensionIconManager::LoadIcon(Extension* extension) {
ExtensionResource icon_resource;
- extension->GetIconPathAllowLargerSize(&icon_resource,
- Extension::EXTENSION_ICON_BITTY);
+ extension->GetIconResourceAllowLargerSize(&icon_resource,
+ Extension::EXTENSION_ICON_BITTY);
if (!icon_resource.extension_root().empty()) {
image_tracker_.LoadImage(extension,
icon_resource,
diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc
index 741e58a..4586cce 100644
--- a/chrome/browser/extensions/extension_install_ui.cc
+++ b/chrome/browser/extensions/extension_install_ui.cc
@@ -354,7 +354,7 @@ void ExtensionInstallUI::ShowConfirmation(PromptType prompt_type) {
// Load the image asynchronously. For the response, check OnImageLoaded.
prompt_type_ = prompt_type;
ExtensionResource image =
- extension_->GetIconPath(Extension::EXTENSION_ICON_LARGE);
+ extension_->GetIconResource(Extension::EXTENSION_ICON_LARGE);
tracker_.LoadImage(extension_, image,
gfx::Size(Extension::EXTENSION_ICON_LARGE,
Extension::EXTENSION_ICON_LARGE),
diff --git a/chrome/browser/extensions/image_loading_tracker_unittest.cc b/chrome/browser/extensions/image_loading_tracker_unittest.cc
index 7522838..6c5d329 100644
--- a/chrome/browser/extensions/image_loading_tracker_unittest.cc
+++ b/chrome/browser/extensions/image_loading_tracker_unittest.cc
@@ -102,7 +102,7 @@ TEST_F(ImageLoadingTrackerTest, Cache) {
ASSERT_TRUE(extension.get() != NULL);
ExtensionResource image_resource =
- extension->GetIconPath(Extension::EXTENSION_ICON_SMALLISH);
+ extension->GetIconResource(Extension::EXTENSION_ICON_SMALLISH);
gfx::Size max_size(Extension::EXTENSION_ICON_SMALLISH,
Extension::EXTENSION_ICON_SMALLISH);
ImageLoadingTracker loader(static_cast<ImageLoadingTracker::Observer*>(this));
@@ -148,7 +148,7 @@ TEST_F(ImageLoadingTrackerTest, DeleteExtensionWhileWaitingForCache) {
ASSERT_TRUE(extension.get() != NULL);
ExtensionResource image_resource =
- extension->GetIconPath(Extension::EXTENSION_ICON_SMALLISH);
+ extension->GetIconResource(Extension::EXTENSION_ICON_SMALLISH);
ImageLoadingTracker loader(static_cast<ImageLoadingTracker::Observer*>(this));
loader.LoadImage(extension.get(),
image_resource,
diff --git a/chrome/browser/gtk/extension_infobar_gtk.cc b/chrome/browser/gtk/extension_infobar_gtk.cc
index cdc9561..8bf2991 100644
--- a/chrome/browser/gtk/extension_infobar_gtk.cc
+++ b/chrome/browser/gtk/extension_infobar_gtk.cc
@@ -48,9 +48,8 @@ void ExtensionInfoBarGtk::BuildWidgets() {
// Start loading the image for the menu button.
ExtensionResource icon_resource;
Extension* extension = delegate_->extension_host()->extension();
- Extension::Icons size =
- extension->GetIconPathAllowLargerSize(&icon_resource,
- Extension::EXTENSION_ICON_BITTY);
+ Extension::Icons size = extension->GetIconResourceAllowLargerSize(
+ &icon_resource, Extension::EXTENSION_ICON_BITTY);
if (!icon_resource.relative_path().empty()) {
// Create a tracker to load the image. It will report back on OnImageLoaded.
tracker_.LoadImage(extension, icon_resource, gfx::Size(size, size),
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index 4352f1d..5fd4b72 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -651,7 +651,7 @@ void BrowserRenderProcessHost::SendUserScriptsUpdate(
}
}
-void BrowserRenderProcessHost::SendExtensionExtentsUpdate() {
+void BrowserRenderProcessHost::SendExtensionInfo() {
// Check if the process is still starting and we don't have a handle for it
// yet, in which case this will happen later when InitVisitedLinks is called.
if (!run_renderer_in_process() &&
@@ -662,19 +662,19 @@ void BrowserRenderProcessHost::SendExtensionExtentsUpdate() {
ExtensionsService* service = profile()->GetExtensionsService();
if (!service)
return;
- ViewMsg_ExtensionExtentsUpdated_Params params;
+ ViewMsg_ExtensionsUpdated_Params params;
for (size_t i = 0; i < service->extensions()->size(); ++i) {
Extension* extension = service->extensions()->at(i);
- if (!extension->web_extent().is_empty()) {
- ViewMsg_ExtensionExtentInfo info;
- info.extension_id = extension->id();
- info.web_extent = extension->web_extent();
- info.browse_extent = extension->browse_extent();
- params.extension_apps.push_back(info);
- }
+ ViewMsg_ExtensionRendererInfo info;
+ info.id = extension->id();
+ info.web_extent = extension->web_extent();
+ info.name = extension->name();
+ info.icon_url =
+ extension->GetIconUrlAllowLargerSize(Extension::EXTENSION_ICON_MEDIUM);
+ params.extensions.push_back(info);
}
- Send(new ViewMsg_ExtensionExtentsUpdated(params));
+ Send(new ViewMsg_ExtensionsUpdated(params));
}
bool BrowserRenderProcessHost::FastShutdownIfPossible() {
@@ -944,9 +944,7 @@ void BrowserRenderProcessHost::Observe(NotificationType type,
}
case NotificationType::EXTENSION_LOADED:
case NotificationType::EXTENSION_UNLOADED: {
- Extension* extension = Details<Extension>(details).ptr();
- if (!extension->web_extent().is_empty())
- SendExtensionExtentsUpdate();
+ SendExtensionInfo();
break;
}
case NotificationType::SPELLCHECK_HOST_REINITIALIZED: {
@@ -981,7 +979,8 @@ void BrowserRenderProcessHost::OnProcessLaunched() {
InitVisitedLinks();
InitUserScripts();
InitExtensions();
- SendExtensionExtentsUpdate();
+ SendExtensionInfo();
+
// We don't want to initialize the spellchecker unless SpellCheckHost has been
// created. In InitSpellChecker(), we know if GetSpellCheckHost() is NULL
// then the spellchecker has been turned off, but here, we don't know if
diff --git a/chrome/browser/renderer_host/browser_render_process_host.h b/chrome/browser/renderer_host/browser_render_process_host.h
index 5f20f0e..3200947 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.h
+++ b/chrome/browser/renderer_host/browser_render_process_host.h
@@ -127,8 +127,9 @@ class BrowserRenderProcessHost : public RenderProcessHost,
// Sends the renderer process a new set of user scripts.
void SendUserScriptsUpdate(base::SharedMemory* shared_memory);
- // Sends the renderer process a new set of extension extents.
- void SendExtensionExtentsUpdate();
+ // Sends the renderer process the list of all loaded extensions along with a
+ // subset of information the renderer needs about them.
+ void SendExtensionInfo();
// Generates a command line to be used to spawn a renderer and appends the
// results to |*command_line|.
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index d0bcf56..a21ea8f 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -3057,7 +3057,7 @@ void TabContents::UpdateExtensionAppIcon(Extension* extension) {
extension_app_image_loader_.reset(new ImageLoadingTracker(this));
extension_app_image_loader_->LoadImage(
extension,
- extension->GetIconPath(Extension::EXTENSION_ICON_SMALLISH),
+ extension->GetIconResource(Extension::EXTENSION_ICON_SMALLISH),
gfx::Size(Extension::EXTENSION_ICON_SMALLISH,
Extension::EXTENSION_ICON_SMALLISH),
ImageLoadingTracker::CACHE);
diff --git a/chrome/browser/views/app_launched_animation_win.cc b/chrome/browser/views/app_launched_animation_win.cc
index 239157e..a3d0a57 100644
--- a/chrome/browser/views/app_launched_animation_win.cc
+++ b/chrome/browser/views/app_launched_animation_win.cc
@@ -72,7 +72,7 @@ AppLaunchedAnimationWin::AppLaunchedAnimationWin(Extension* extension,
DCHECK(extension);
app_icon_loader_.LoadImage(
extension,
- extension->GetIconPath(Extension::EXTENSION_ICON_LARGE),
+ extension->GetIconResource(Extension::EXTENSION_ICON_LARGE),
rect_.size(),
ImageLoadingTracker::DONT_CACHE);
}
diff --git a/chrome/browser/views/infobars/extension_infobar.cc b/chrome/browser/views/infobars/extension_infobar.cc
index cfbe829..3a98740 100644
--- a/chrome/browser/views/infobars/extension_infobar.cc
+++ b/chrome/browser/views/infobars/extension_infobar.cc
@@ -165,9 +165,8 @@ void ExtensionInfoBar::SetupIconAndMenu() {
ExtensionResource icon_resource;
Extension* extension = delegate_->extension_host()->extension();
- Extension::Icons size =
- extension->GetIconPathAllowLargerSize(&icon_resource,
- Extension::EXTENSION_ICON_BITTY);
+ Extension::Icons size = extension->GetIconResourceAllowLargerSize(
+ &icon_resource, Extension::EXTENSION_ICON_BITTY);
if (!icon_resource.relative_path().empty()) {
// Create a tracker to load the image. It will report back on OnImageLoaded.
tracker_.LoadImage(extension, icon_resource, gfx::Size(size, size),
diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi
index 3a632bd..c62b7af 100644
--- a/chrome/chrome_renderer.gypi
+++ b/chrome/chrome_renderer.gypi
@@ -53,6 +53,8 @@
'renderer/extensions/bindings_utils.h',
'renderer/extensions/chrome_app_bindings.cc',
'renderer/extensions/chrome_app_bindings.h',
+ 'renderer/extensions/extension_renderer_info.cc',
+ 'renderer/extensions/extension_renderer_info.h',
'renderer/extensions/event_bindings.cc',
'renderer/extensions/event_bindings.h',
'renderer/extensions/extension_process_bindings.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 34fc4cd..a8fb62b 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1338,6 +1338,7 @@
'gpu/gpu_info_unittest_win.cc',
'renderer/audio_message_filter_unittest.cc',
'renderer/extensions/extension_api_json_validity_unittest.cc',
+ 'renderer/extensions/extension_renderer_info_unittest.cc',
'renderer/extensions/json_schema_unittest.cc',
'renderer/media/audio_renderer_impl_unittest.cc',
'renderer/net/predictor_queue_unittest.cc',
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index b735004..a3f3fe5 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -916,7 +916,7 @@ bool Extension::HasEffectiveBrowsingHistoryPermission() const {
void Extension::DecodeIcon(Extension* extension,
Icons icon_size,
scoped_ptr<SkBitmap>* result) {
- FilePath icon_path = extension->GetIconPath(icon_size).GetFilePath();
+ FilePath icon_path = extension->GetIconResource(icon_size).GetFilePath();
DecodeIconFromPath(icon_path, icon_size, result);
}
@@ -1667,28 +1667,51 @@ SkBitmap* Extension::GetCachedImageImpl(const ExtensionResource& source,
return NULL;
}
-
-ExtensionResource Extension::GetIconPath(Icons icon) {
+std::string Extension::GetIconPath(Icons icon) {
std::map<int, std::string>::const_iterator iter = icons_.find(icon);
if (iter == icons_.end())
- return ExtensionResource();
- return GetResource(iter->second);
+ return std::string();
+ return iter->second;
}
Extension::Icons Extension::GetIconPathAllowLargerSize(
- ExtensionResource* resource, Icons icon) {
- *resource = GetIconPath(icon);
- if (!resource->relative_path().empty())
+ std::string* path, Icons icon) {
+ *path = GetIconPath(icon);
+ if (!path->empty())
return icon;
if (icon == EXTENSION_ICON_BITTY)
- return GetIconPathAllowLargerSize(resource, EXTENSION_ICON_SMALL);
+ return GetIconPathAllowLargerSize(path, EXTENSION_ICON_SMALL);
if (icon == EXTENSION_ICON_SMALL)
- return GetIconPathAllowLargerSize(resource, EXTENSION_ICON_MEDIUM);
+ return GetIconPathAllowLargerSize(path, EXTENSION_ICON_MEDIUM);
if (icon == EXTENSION_ICON_MEDIUM)
- return GetIconPathAllowLargerSize(resource, EXTENSION_ICON_LARGE);
+ return GetIconPathAllowLargerSize(path, EXTENSION_ICON_LARGE);
return EXTENSION_ICON_LARGE;
}
+ExtensionResource Extension::GetIconResource(Icons icon) {
+ std::string path = GetIconPath(icon);
+ if (path.empty())
+ return ExtensionResource();
+ return GetResource(path);
+}
+
+Extension::Icons Extension::GetIconResourceAllowLargerSize(
+ ExtensionResource* resource, Icons icon) {
+ std::string path;
+ Extension::Icons ret = GetIconPathAllowLargerSize(&path, icon);
+ if (path.empty())
+ *resource = ExtensionResource();
+ else
+ *resource = GetResource(path);
+ return ret;
+}
+
+GURL Extension::GetIconUrlAllowLargerSize(Icons icon) {
+ std::string path;
+ GetIconPathAllowLargerSize(&path, icon);
+ return GetResourceURL(path);
+}
+
bool Extension::CanAccessURL(const URLPattern pattern) const {
if (pattern.MatchesScheme(chrome::kChromeUIScheme)) {
// Only allow access to chrome://favicon to regular extensions. Component
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index cad7dbd..e9a25cc 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -323,14 +323,18 @@ class Extension {
// Returns an absolute path to the given icon inside of the extension. Returns
// an empty FilePath if the extension does not have that icon.
- ExtensionResource GetIconPath(Icons icon);
+ ExtensionResource GetIconResource(Icons icon);
// Looks for an extension icon of dimension |icon|. If not found, checks if
// the next larger size exists (until one is found or the end is reached). If
// an icon is found, the path is returned in |resource| and the dimension
// found is returned to the caller (as function return value).
// NOTE: |resource| is not guaranteed to be non-empty.
- Icons GetIconPathAllowLargerSize(ExtensionResource* resource, Icons icon);
+ Icons GetIconResourceAllowLargerSize(ExtensionResource* resource, Icons icon);
+
+ // See GetIconPathAllowLargerSize. Returns a chrome-extension:// URL
+ // instead of an ExtensionResource.
+ GURL GetIconUrlAllowLargerSize(Icons icon);
const DictionaryValue* manifest_value() const {
return manifest_value_.get();
@@ -440,6 +444,11 @@ class Extension {
// kPermissionNames).
bool IsAPIPermission(const std::string& permission);
+ // Utility functions to get the icon relative path used to create an
+ // ExtensionResource or URL.
+ std::string GetIconPath(Icons icon);
+ Icons GetIconPathAllowLargerSize(std::string* path, Icons icon);
+
// The absolute path to the directory the extension is stored in.
FilePath path_;
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 33f98ad..c5113d6 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -103,8 +103,8 @@ struct ViewHostMsg_ShowNotification_Params;
struct ViewMsg_New_Params;
struct ViewHostMsg_CreateWindow_Params;
struct ViewHostMsg_RunFileChooser_Params;
-struct ViewMsg_ExtensionExtentInfo;
-struct ViewMsg_ExtensionExtentsUpdated_Params;
+struct ViewMsg_ExtensionRendererInfo;
+struct ViewMsg_ExtensionsUpdated_Params;
struct ViewMsg_DeviceOrientationUpdated_Params;
struct ViewHostMsg_DomMessage_Params;
struct ViewHostMsg_OpenFileSystemRequest_Params;
@@ -711,6 +711,7 @@ struct ParamTraits<ExtensionExtent> {
static void Log(const param_type& p, std::string* l);
};
+
template<>
struct ParamTraits<appcache::AppCacheResourceInfo> {
typedef appcache::AppCacheResourceInfo param_type;
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index bc78fd0..64d5f6c 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -966,9 +966,9 @@ IPC_BEGIN_MESSAGES(View)
IPC_MESSAGE_CONTROL1(ViewMsg_SetIsIncognitoProcess,
bool /* is_incognito_processs */)
- // Notification that the list of extensions with web extents has been updated.
- IPC_MESSAGE_CONTROL1(ViewMsg_ExtensionExtentsUpdated,
- ViewMsg_ExtensionExtentsUpdated_Params)
+ // Notification that the list of extensions has been updated.
+ IPC_MESSAGE_CONTROL1(ViewMsg_ExtensionsUpdated,
+ ViewMsg_ExtensionsUpdated_Params)
// Request a tree of Accessibility data from the render process.
IPC_MESSAGE_ROUTED0(ViewMsg_GetAccessibilityTree)
diff --git a/chrome/common/render_messages_params.cc b/chrome/common/render_messages_params.cc
index dcb592b..5ad995e 100644
--- a/chrome/common/render_messages_params.cc
+++ b/chrome/common/render_messages_params.cc
@@ -1263,43 +1263,45 @@ void ParamTraits<ViewHostMsg_RunFileChooser_Params>::Log(
LogParam(p.default_file_name, l);
}
-void ParamTraits<ViewMsg_ExtensionExtentInfo>::Write(Message* m,
- const param_type& p) {
- WriteParam(m, p.extension_id);
+void ParamTraits<ViewMsg_ExtensionRendererInfo>::Write(Message* m,
+ const param_type& p) {
+ WriteParam(m, p.id);
WriteParam(m, p.web_extent);
- WriteParam(m, p.browse_extent);
+ WriteParam(m, p.name);
+ WriteParam(m, p.icon_url);
}
-bool ParamTraits<ViewMsg_ExtensionExtentInfo>::Read(const Message* m,
- void** iter,
- param_type* p) {
- return ReadParam(m, iter, &p->extension_id) &&
+bool ParamTraits<ViewMsg_ExtensionRendererInfo>::Read(const Message* m,
+ void** iter,
+ param_type* p) {
+ return ReadParam(m, iter, &p->id) &&
ReadParam(m, iter, &p->web_extent) &&
- ReadParam(m, iter, &p->browse_extent);
+ ReadParam(m, iter, &p->name) &&
+ ReadParam(m, iter, &p->icon_url);
}
-void ParamTraits<ViewMsg_ExtensionExtentInfo>::Log(const param_type& p,
- std::string* l) {
- LogParam(p.extension_id, l);
+void ParamTraits<ViewMsg_ExtensionRendererInfo>::Log(const param_type& p,
+ std::string* l) {
+ LogParam(p.id, l);
}
-void ParamTraits<ViewMsg_ExtensionExtentsUpdated_Params>::Write(
+void ParamTraits<ViewMsg_ExtensionsUpdated_Params>::Write(
Message* m,
const param_type& p) {
- WriteParam(m, p.extension_apps);
+ WriteParam(m, p.extensions);
}
-bool ParamTraits<ViewMsg_ExtensionExtentsUpdated_Params>::Read(
+bool ParamTraits<ViewMsg_ExtensionsUpdated_Params>::Read(
const Message* m,
void** iter,
param_type* p) {
- return ReadParam(m, iter, &p->extension_apps);
+ return ReadParam(m, iter, &p->extensions);
}
-void ParamTraits<ViewMsg_ExtensionExtentsUpdated_Params>::Log(
+void ParamTraits<ViewMsg_ExtensionsUpdated_Params>::Log(
const param_type& p,
std::string* l) {
- LogParam(p.extension_apps, l);
+ LogParam(p.extensions, l);
}
void ParamTraits<ViewMsg_DeviceOrientationUpdated_Params>::Write(
diff --git a/chrome/common/render_messages_params.h b/chrome/common/render_messages_params.h
index 65b071e..141e7f9 100644
--- a/chrome/common/render_messages_params.h
+++ b/chrome/common/render_messages_params.h
@@ -785,15 +785,16 @@ struct ViewHostMsg_RunFileChooser_Params {
FilePath default_file_name;
};
-struct ViewMsg_ExtensionExtentInfo {
- std::string extension_id;
+struct ViewMsg_ExtensionRendererInfo {
+ std::string id;
ExtensionExtent web_extent;
- ExtensionExtent browse_extent;
+ std::string name;
+ GURL icon_url;
};
-struct ViewMsg_ExtensionExtentsUpdated_Params {
+struct ViewMsg_ExtensionsUpdated_Params {
// Describes the installed extension apps and the URLs they cover.
- std::vector<ViewMsg_ExtensionExtentInfo> extension_apps;
+ std::vector<ViewMsg_ExtensionRendererInfo> extensions;
};
struct ViewMsg_DeviceOrientationUpdated_Params {
@@ -1058,16 +1059,16 @@ struct ParamTraits<ViewHostMsg_RunFileChooser_Params> {
};
template <>
-struct ParamTraits<ViewMsg_ExtensionExtentInfo> {
- typedef ViewMsg_ExtensionExtentInfo param_type;
+struct ParamTraits<ViewMsg_ExtensionRendererInfo> {
+ typedef ViewMsg_ExtensionRendererInfo param_type;
static void Write(Message* m, const param_type& p);
static bool Read(const Message* m, void** iter, param_type* p);
static void Log(const param_type& p, std::string* l);
};
template <>
-struct ParamTraits<ViewMsg_ExtensionExtentsUpdated_Params> {
- typedef ViewMsg_ExtensionExtentsUpdated_Params param_type;
+struct ParamTraits<ViewMsg_ExtensionsUpdated_Params> {
+ typedef ViewMsg_ExtensionsUpdated_Params param_type;
static void Write(Message* m, const param_type& p);
static bool Read(const Message* m, void** iter, param_type* p);
static void Log(const param_type& p, std::string* l);
diff --git a/chrome/renderer/extensions/chrome_app_bindings.cc b/chrome/renderer/extensions/chrome_app_bindings.cc
index 37558dc..401a37c 100644
--- a/chrome/renderer/extensions/chrome_app_bindings.cc
+++ b/chrome/renderer/extensions/chrome_app_bindings.cc
@@ -4,6 +4,7 @@
#include "chrome/renderer/extensions/chrome_app_bindings.h"
+#include "chrome/renderer/extensions/extension_renderer_info.h"
#include "chrome/renderer/render_thread.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "v8/include/v8.h"
@@ -47,9 +48,7 @@ class ChromeAppExtensionWrapper : public v8::Extension {
!(url.SchemeIs("http") || url.SchemeIs("https")))
return v8::Boolean::New(false);
- bool has_web_extent =
- !RenderThread::current()->GetExtensionIdByURL(url).empty();
-
+ bool has_web_extent = !ExtensionRendererInfo::GetByURL(url);
return v8::Boolean::New(has_web_extent);
}
};
diff --git a/chrome/renderer/extensions/extension_renderer_info.cc b/chrome/renderer/extensions/extension_renderer_info.cc
new file mode 100644
index 0000000..9abd4f5
--- /dev/null
+++ b/chrome/renderer/extensions/extension_renderer_info.cc
@@ -0,0 +1,86 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/extensions/extension_renderer_info.h"
+
+#include "base/logging.h"
+#include "chrome/common/render_messages_params.h"
+#include "chrome/common/url_constants.h"
+
+// static
+std::vector<ExtensionRendererInfo>* ExtensionRendererInfo::extensions_ = NULL;
+
+ExtensionRendererInfo::ExtensionRendererInfo() {
+}
+
+ExtensionRendererInfo::ExtensionRendererInfo(
+ const ExtensionRendererInfo& that) {
+ id_ = that.id_;
+ web_extent_ = that.web_extent_;
+ name_ = that.name_;
+ icon_url_ = that.icon_url_;
+}
+
+ExtensionRendererInfo::~ExtensionRendererInfo() {
+}
+
+void ExtensionRendererInfo::Update(const ViewMsg_ExtensionRendererInfo& info) {
+ id_ = info.id;
+ web_extent_ = info.web_extent;
+ name_ = info.name;
+ icon_url_ = info.icon_url;
+}
+
+// static
+void ExtensionRendererInfo::UpdateExtensions(
+ const ViewMsg_ExtensionsUpdated_Params& params) {
+ size_t count = params.extensions.size();
+ if (!extensions_)
+ extensions_ = new std::vector<ExtensionRendererInfo>(count);
+ else
+ extensions_->resize(count);
+
+ for (size_t i = 0; i < count; ++i)
+ extensions_->at(i).Update(params.extensions[i]);
+}
+
+// static
+ExtensionRendererInfo* ExtensionRendererInfo::GetByURL(const GURL& url) {
+ if (url.SchemeIs(chrome::kExtensionScheme))
+ return GetByID(url.host());
+
+ if (!extensions_)
+ return NULL;
+
+ std::vector<ExtensionRendererInfo>::iterator i = extensions_->begin();
+ for (; i != extensions_->end(); ++i) {
+ if (i->web_extent_.ContainsURL(url))
+ return &(*i);
+ }
+
+ return NULL;
+}
+
+// static
+bool ExtensionRendererInfo::InSameExtent(const GURL& old_url,
+ const GURL& new_url) {
+ return GetByURL(old_url) == GetByURL(new_url);
+}
+
+// static
+ExtensionRendererInfo* ExtensionRendererInfo::GetByID(
+ const std::string& id) {
+
+ if (!extensions_) {
+ NOTREACHED();
+ return NULL;
+ }
+
+ std::vector<ExtensionRendererInfo>::iterator i = extensions_->begin();
+ for (; i != extensions_->end(); ++i) {
+ if (i->id() == id)
+ return &(*i);
+ }
+ return NULL;
+}
diff --git a/chrome/renderer/extensions/extension_renderer_info.h b/chrome/renderer/extensions/extension_renderer_info.h
new file mode 100644
index 0000000..ec0d9a3
--- /dev/null
+++ b/chrome/renderer/extensions/extension_renderer_info.h
@@ -0,0 +1,60 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_RENDERER_EXTENSIONS_EXTENSION_RENDERER_INFO_H_
+#define CHROME_RENDERER_EXTENSIONS_EXTENSION_RENDERER_INFO_H_
+#pragma once
+
+#include <string>
+#include <vector>
+
+#include "base/gtest_prod_util.h"
+#include "chrome/common/extensions/extension_extent.h"
+#include "googleurl/src/gurl.h"
+
+struct ViewMsg_ExtensionsUpdated_Params;
+struct ViewMsg_ExtensionRendererInfo;
+
+// Extension information needed in the renderer process along with static
+// methods to look up information about the currently loaded extensions.
+class ExtensionRendererInfo {
+ public:
+ ExtensionRendererInfo();
+ ExtensionRendererInfo(const ExtensionRendererInfo& that);
+ ~ExtensionRendererInfo();
+
+ const std::string& id() const { return id_; }
+ const ExtensionExtent& web_extent() const { return web_extent_; }
+ const std::string& name() const { return name_; }
+ const GURL& icon_url() const { return icon_url_; }
+
+ // Replace the list of extensions with those provided in |params|.
+ static void UpdateExtensions(const ViewMsg_ExtensionsUpdated_Params& params);
+
+ // Returns the extension ID that the given URL is a part of, or empty if
+ // none. This includes web URLs that are part of an extension's web extent.
+ static ExtensionRendererInfo* GetByURL(const GURL& url);
+
+ // Returns true if |new_url| is in the extent of the same extension as
+ // |old_url|. Also returns true if neither URL is in an app.
+ static bool InSameExtent(const GURL& old_url, const GURL& new_url);
+
+ // Look up an ExtensionInfo object by id.
+ static ExtensionRendererInfo* GetByID(const std::string& id);
+
+ private:
+ void Update(const ViewMsg_ExtensionRendererInfo& info);
+
+ FRIEND_TEST_ALL_PREFIXES(ExtensionRendererInfoTest, ExtensionRendererInfo);
+
+ std::string id_;
+ ExtensionExtent web_extent_;
+ std::string name_;
+ GURL icon_url_;
+
+ // static
+ static std::vector<ExtensionRendererInfo>* extensions_;
+};
+
+#endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_RENDERER_INFO_H_
diff --git a/chrome/renderer/extensions/extension_renderer_info_unittest.cc b/chrome/renderer/extensions/extension_renderer_info_unittest.cc
new file mode 100644
index 0000000..79d5cbd
--- /dev/null
+++ b/chrome/renderer/extensions/extension_renderer_info_unittest.cc
@@ -0,0 +1,70 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/extensions/extension_extent.h"
+#include "chrome/common/render_messages_params.h"
+#include "chrome/renderer/extensions/extension_renderer_info.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+static void AddPattern(ExtensionExtent* extent, const std::string& pattern) {
+ int schemes = URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS;
+ extent->AddPattern(URLPattern(schemes, pattern));
+}
+
+TEST(ExtensionRendererInfoTest, ExtensionRendererInfo) {
+ std::string one("1"), two("2"), three("3");
+
+ ViewMsg_ExtensionsUpdated_Params msg;
+ msg.extensions.resize(3);
+
+ msg.extensions[0].id = one;
+ ExtensionExtent web1;
+ AddPattern(&web1, "https://chrome.google.com/*");
+ msg.extensions[0].web_extent = web1;
+
+ msg.extensions[1].id = two;
+ ExtensionExtent web2;
+ AddPattern(&web2, "http://code.google.com/p/chromium/*");
+ msg.extensions[1].web_extent = web2;
+
+ msg.extensions[2].id = three;
+ ExtensionExtent web3;
+ AddPattern(&web3, "http://dev.chromium.org/*");
+ msg.extensions[2].web_extent = web3;
+
+ ExtensionRendererInfo::UpdateExtensions(msg);
+ EXPECT_EQ(ExtensionRendererInfo::extensions_->size(), 3u);
+
+ ExtensionRendererInfo* ext1 = &ExtensionRendererInfo::extensions_->at(0);
+ ExtensionRendererInfo* ext2 = &ExtensionRendererInfo::extensions_->at(1);
+ ExtensionRendererInfo* ext3 = &ExtensionRendererInfo::extensions_->at(2);
+ EXPECT_EQ(ext1->id(), one);
+ EXPECT_EQ(ext2->id(), two);
+ EXPECT_EQ(ext3->id(), three);
+
+ EXPECT_EQ(ext1, ExtensionRendererInfo::GetByID(one));
+ EXPECT_EQ(ext1, ExtensionRendererInfo::GetByURL(
+ GURL("https://chrome.google.com/extensions/")));
+ EXPECT_EQ(ext2, ExtensionRendererInfo::GetByURL(
+ GURL("http://code.google.com/p/chromium/issues/")));
+ EXPECT_EQ(ext3, ExtensionRendererInfo::GetByURL(
+ GURL("http://dev.chromium.org/design-docs/")));
+ EXPECT_EQ(NULL, ExtensionRendererInfo::GetByURL(
+ GURL("http://blog.chromium.org/")));
+
+ EXPECT_TRUE(ExtensionRendererInfo::InSameExtent(
+ GURL("https://chrome.google.com/extensions/"),
+ GURL("https://chrome.google.com/")));
+ EXPECT_FALSE(ExtensionRendererInfo::InSameExtent(
+ GURL("https://chrome.google.com/extensions/"),
+ GURL("http://chrome.google.com/")));
+ EXPECT_FALSE(ExtensionRendererInfo::InSameExtent(
+ GURL("https://chrome.google.com/extensions/"),
+ GURL("http://dev.chromium.org/design-docs/")));
+
+ // Both of these should be NULL, which mean true for InSameExtent.
+ EXPECT_TRUE(ExtensionRendererInfo::InSameExtent(
+ GURL("http://www.google.com/"),
+ GURL("http://blog.chromium.org/")));
+}
diff --git a/chrome/renderer/localized_error.cc b/chrome/renderer/localized_error.cc
index 386e75b3..2bf9841 100644
--- a/chrome/renderer/localized_error.cc
+++ b/chrome/renderer/localized_error.cc
@@ -11,6 +11,7 @@
#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
+#include "chrome/renderer/extensions/extension_renderer_info.h"
#include "googleurl/src/gurl.h"
#include "grit/generated_resources.h"
#include "net/base/escape.h"
@@ -260,3 +261,27 @@ void GetFormRepostErrorValues(const GURL& display_url,
"msg", l10n_util::GetStringUTF16(IDS_ERRORPAGES_HTTP_POST_WARNING));
error_strings->Set("summary", summary);
}
+
+void GetAppErrorValues(const WebURLError& error,
+ const GURL& display_url,
+ const ExtensionRendererInfo* app,
+ DictionaryValue* error_strings) {
+ DCHECK(app);
+
+ bool rtl = LocaleIsRTL();
+ error_strings->SetString("textdirection", rtl ? "rtl" : "ltr");
+
+ string16 failed_url(ASCIIToUTF16(display_url.spec()));
+ // URLs are always LTR.
+ if (rtl)
+ base::i18n::WrapStringWithLTRFormatting(&failed_url);
+ error_strings->SetString(
+ "url", l10n_util::GetStringFUTF16(IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
+ failed_url.c_str()));
+
+ error_strings->SetString("title", app->name());
+ error_strings->SetString("icon", app->icon_url().spec());
+ error_strings->SetString("name", app->name());
+ error_strings->SetString("msg",
+ l10n_util::GetStringUTF16(IDS_ERRORPAGES_APP_WARNING));
+}
diff --git a/chrome/renderer/localized_error.h b/chrome/renderer/localized_error.h
index 3acf3d4..4fa5304 100644
--- a/chrome/renderer/localized_error.h
+++ b/chrome/renderer/localized_error.h
@@ -7,6 +7,7 @@
#pragma once
class DictionaryValue;
+class ExtensionRendererInfo;
class GURL;
namespace WebKit {
@@ -25,4 +26,13 @@ void GetLocalizedErrorValues(const WebKit::WebURLError& error,
void GetFormRepostErrorValues(const GURL& display_url,
DictionaryValue* error_strings);
+// Fills |error_strings| with values to be used to build an error page used
+// on HTTP errors, like 404 or connection reset, but using information from
+// the associated |app| in order to make the error page look like it's more
+// part of the app.
+void GetAppErrorValues(const WebKit::WebURLError& error,
+ const GURL& display_url,
+ const ExtensionRendererInfo* app,
+ DictionaryValue* error_strings);
+
#endif // CHROME_RENDERER_LOCALIZED_ERROR_H_
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index 83754f7..e6658eb 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -28,7 +28,6 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/db_message_filter.h"
#include "chrome/common/dom_storage_common.h"
-#include "chrome/common/extensions/extension_extent.h"
#include "chrome/common/plugin_messages.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/render_messages_params.h"
@@ -48,6 +47,7 @@
#include "chrome/renderer/devtools_agent_filter.h"
#include "chrome/renderer/extension_groups.h"
#include "chrome/renderer/extensions/chrome_app_bindings.h"
+#include "chrome/renderer/extensions/extension_renderer_info.h"
#include "chrome/renderer/extensions/event_bindings.h"
#include "chrome/renderer/extensions/extension_process_bindings.h"
#include "chrome/renderer/extensions/js_only_v8_extensions.h"
@@ -207,15 +207,6 @@ class RenderViewZoomer : public RenderViewVisitor {
};
} // namespace
-// Contains extension-related data that the renderer needs to know about.
-// TODO(mpcomplete): this doesn't feel like it belongs here. Find a better
-// place.
-struct RenderThread::ExtensionInfo {
- std::string extension_id;
- ExtensionExtent web_extent;
- ExtensionExtent browse_extent;
-};
-
// When we run plugins in process, we actually run them on the render thread,
// which means that we need to make the render thread pump UI events.
RenderThread::RenderThread() {
@@ -520,15 +511,9 @@ void RenderThread::OnSetExtensionFunctionNames(
ExtensionProcessBindings::SetFunctionNames(names);
}
-void RenderThread::OnExtensionExtentsUpdated(
- const ViewMsg_ExtensionExtentsUpdated_Params& params) {
- extension_extents_.resize(params.extension_apps.size());
- for (size_t i = 0; i < params.extension_apps.size(); ++i) {
- extension_extents_[i].extension_id = params.extension_apps[i].extension_id;
- extension_extents_[i].web_extent = params.extension_apps[i].web_extent;
- extension_extents_[i].browse_extent =
- params.extension_apps[i].browse_extent;
- }
+void RenderThread::OnExtensionsUpdated(
+ const ViewMsg_ExtensionsUpdated_Params& params) {
+ ExtensionRendererInfo::UpdateExtensions(params);
}
void RenderThread::OnPageActionsUpdated(
@@ -607,8 +592,8 @@ void RenderThread::OnControlMessageReceived(const IPC::Message& msg) {
OnExtensionMessageInvoke)
IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetFunctionNames,
OnSetExtensionFunctionNames)
- IPC_MESSAGE_HANDLER(ViewMsg_ExtensionExtentsUpdated,
- OnExtensionExtentsUpdated)
+ IPC_MESSAGE_HANDLER(ViewMsg_ExtensionsUpdated,
+ OnExtensionsUpdated)
IPC_MESSAGE_HANDLER(ViewMsg_PurgeMemory, OnPurgeMemory)
IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache,
OnPurgePluginListCache)
@@ -1085,27 +1070,6 @@ void RenderThread::OnGpuChannelEstablished(
}
}
-std::string RenderThread::GetExtensionIdByURL(const GURL& url) {
- if (url.SchemeIs(chrome::kExtensionScheme))
- return url.host();
-
- for (size_t i = 0; i < extension_extents_.size(); ++i) {
- if (extension_extents_[i].web_extent.ContainsURL(url))
- return extension_extents_[i].extension_id;
- }
-
- return std::string();
-}
-
-std::string RenderThread::GetExtensionIdByBrowseExtent(const GURL& url) {
- for (size_t i = 0; i < extension_extents_.size(); ++i) {
- if (extension_extents_[i].browse_extent.ContainsURL(url))
- return extension_extents_[i].extension_id;
- }
-
- return std::string();
-}
-
scoped_refptr<base::MessageLoopProxy>
RenderThread::GetFileThreadMessageLoopProxy() {
DCHECK(message_loop() == MessageLoop::current());
diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h
index 308bb17..b90f883 100644
--- a/chrome/renderer/render_thread.h
+++ b/chrome/renderer/render_thread.h
@@ -42,7 +42,7 @@ class WebDatabaseObserverImpl;
struct ContentSettings;
struct RendererPreferences;
struct ViewMsg_DOMStorageEvent_Params;
-struct ViewMsg_ExtensionExtentsUpdated_Params;
+struct ViewMsg_ExtensionsUpdated_Params;
struct ViewMsg_New_Params;
struct WebPreferences;
@@ -224,14 +224,6 @@ class RenderThread : public RenderThreadBase,
// has been lost.
GpuChannelHost* GetGpuChannel();
- // Returns the extension ID that the given URL is a part of, or empty if
- // none. This includes web URLs that are part of an extension's web extent.
- // TODO(mpcomplete): this doesn't feel like it belongs here. Find a better
- // place.
- std::string GetExtensionIdByURL(const GURL& url);
-
- std::string GetExtensionIdByBrowseExtent(const GURL& url);
-
// Returns a MessageLoopProxy instance corresponding to the message loop
// of the thread on which file operations should be run. Must be called
// on the renderer's main thread.
@@ -250,8 +242,8 @@ class RenderThread : public RenderThreadBase,
const GURL& url, const ContentSettings& content_settings);
void OnUpdateUserScripts(base::SharedMemoryHandle table);
void OnSetExtensionFunctionNames(const std::vector<std::string>& names);
- void OnExtensionExtentsUpdated(
- const ViewMsg_ExtensionExtentsUpdated_Params& params);
+ void OnExtensionsUpdated(
+ const ViewMsg_ExtensionsUpdated_Params& params);
void OnPageActionsUpdated(const std::string& extension_id,
const std::vector<std::string>& page_actions);
void OnDOMStorageEvent(const ViewMsg_DOMStorageEvent_Params& params);
@@ -370,11 +362,6 @@ class RenderThread : public RenderThreadBase,
// The channel from the renderer process to the GPU process.
scoped_refptr<GpuChannelHost> gpu_channel_;
- // A list of extension web extents, which tells us which URLs belong to an
- // installed app.
- struct ExtensionInfo;
- std::vector<ExtensionInfo> extension_extents_;
-
// A lazily initiated thread on which file operations are run.
scoped_ptr<base::Thread> file_thread_;
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index d778def..76d062a 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -49,6 +49,7 @@
#include "chrome/renderer/devtools_agent.h"
#include "chrome/renderer/devtools_client.h"
#include "chrome/renderer/extension_groups.h"
+#include "chrome/renderer/extensions/extension_renderer_info.h"
#include "chrome/renderer/extensions/event_bindings.h"
#include "chrome/renderer/extensions/extension_process_bindings.h"
#include "chrome/renderer/extensions/renderer_extension_bindings.h"
@@ -368,18 +369,7 @@ static bool CrossesExtensionExtents(WebFrame* frame, const GURL& new_url) {
if (old_url.is_empty() && frame->opener())
old_url = frame->opener()->url();
- std::string old_extension =
- RenderThread::current()->GetExtensionIdByURL(old_url);
- if (!old_extension.empty()) {
- if (RenderThread::current()->GetExtensionIdByBrowseExtent(new_url) ==
- old_extension) {
- return false;
- }
- }
-
- std::string new_extension =
- RenderThread::current()->GetExtensionIdByURL(new_url);
- return old_extension != new_extension;
+ return !ExtensionRendererInfo::InSameExtent(old_url, new_url);
}
// Returns the ISO 639_1 language code of the specified |text|, or 'unknown'
@@ -1512,19 +1502,30 @@ void RenderView::LoadNavigationErrorPage(WebFrame* frame,
const std::string& html,
bool replace) {
GURL failed_url = error.unreachableURL;
-
std::string alt_html;
+ ExtensionRendererInfo* extension;
if (html.empty()) {
// Use a local error page.
int resource_id;
DictionaryValue error_strings;
- if (error.reason == net::ERR_CACHE_MISS &&
- EqualsASCII(failed_request.httpMethod(), "POST")) {
- GetFormRepostErrorValues(failed_url, &error_strings);
- resource_id = IDR_ERROR_NO_DETAILS_HTML;
+
+ if (failed_url.is_valid())
+ extension = ExtensionRendererInfo::GetByURL(failed_url);
+ if (extension) {
+ GetAppErrorValues(error, failed_url, extension, &error_strings);
+
+ // TODO(erikkay): Should we use a different template for different
+ // error messages?
+ resource_id = IDR_ERROR_APP_HTML;
} else {
- GetLocalizedErrorValues(error, &error_strings);
- resource_id = IDR_NET_ERROR_HTML;
+ if (error.reason == net::ERR_CACHE_MISS &&
+ EqualsASCII(failed_request.httpMethod(), "POST")) {
+ GetFormRepostErrorValues(failed_url, &error_strings);
+ resource_id = IDR_ERROR_NO_DETAILS_HTML;
+ } else {
+ GetLocalizedErrorValues(error, &error_strings);
+ resource_id = IDR_NET_ERROR_HTML;
+ }
}
alt_html = GetAltHTMLForTemplate(error_strings, resource_id);
@@ -2580,24 +2581,36 @@ WebNavigationPolicy RenderView::decidePolicyForNavigation(
!url.SchemeIs(chrome::kAboutScheme)) {
// When we received such unsolicited navigations, we sometimes want to
// punt them up to the browser to handle.
- if (CrossesExtensionExtents(frame, url) ||
- BindingsPolicy::is_dom_ui_enabled(enabled_bindings_) ||
+ if (BindingsPolicy::is_dom_ui_enabled(enabled_bindings_) ||
frame->isViewSourceModeEnabled() ||
url.SchemeIs(chrome::kViewSourceScheme)) {
+ // We don't send referrer from these special pages.
OpenURL(url, GURL(), default_policy);
return WebKit::WebNavigationPolicyIgnore; // Suppress the load here.
}
- // We forward navigations from extensions to the browser if they are
- // top-level events, even if the browser hasn't expressed interest.
- //
- // Note that we've already forwarded cross-extension extents navigations
- // above.
+ // We forward non-local navigations from extensions to the browser if they
+ // are top-level events, even if the browser hasn't expressed interest.
if (BindingsPolicy::is_extension_enabled(enabled_bindings_) &&
IsNonLocalTopLevelNavigation(url, frame, type)) {
+ // We don't send referrer from extensions.
OpenURL(url, GURL(), default_policy);
return WebKit::WebNavigationPolicyIgnore; // Suppress the load here.
}
+
+ // If the navigation would cross an app extent boundary, we also need
+ // to defer to the browser to ensure process isolation.
+ // TODO(erikkay) This is happening inside of a check to is_content_initiated
+ // which means that things like the back button won't trigger it. Is that
+ // OK?
+ if (CrossesExtensionExtents(frame, url)) {
+ // Include the referrer in this case since we're going from a hosted web
+ // page. (the packaged case is handled previously by the extension
+ // navigation test)
+ GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer")));
+ OpenURL(url, referrer, default_policy);
+ return WebKit::WebNavigationPolicyIgnore; // Suppress the load here.
+ }
}
// Detect when a page is "forking" a new tab that can be safely rendered in
@@ -3476,14 +3489,14 @@ webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate(
// TODO(cbiffle): need browser test for this before M7 (bug 45881)
GURL main_frame_url(webview()->mainFrame()->url());
- const std::string &extension_id =
- RenderThread::current()->GetExtensionIdByURL(main_frame_url);
- bool in_ext = extension_id != "";
+ ExtensionRendererInfo* extension =
+ ExtensionRendererInfo::GetByURL(main_frame_url);
+ bool in_ext = extension != NULL;
bool explicit_enable =
CommandLine::ForCurrentProcess()->HasSwitch(switches::kInternalNaCl);
if (in_ext) {
- if (ExtensionProcessBindings::HasPermission(extension_id,
+ if (ExtensionProcessBindings::HasPermission(extension->id(),
Extension::kNativeClientPermission)) {
in_process_plugin = true;
use_pepper_host = true;
diff --git a/chrome/renderer/renderer_resources.grd b/chrome/renderer/renderer_resources.grd
index a084b31..8d1432c 100644
--- a/chrome/renderer/renderer_resources.grd
+++ b/chrome/renderer/renderer_resources.grd
@@ -23,6 +23,7 @@ without changes to the corresponding grd file. fb9 -->
<include name="IDR_NET_ERROR_HTML" file="resources\neterror.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_RENDERER_EXTENSION_BINDINGS_JS" file="resources\renderer_extension_bindings.js" type="BINDATA" />
<include name="IDR_SAD_PLUGIN" file="resources\sadplugin.png" type="BINDATA" />
+ <include name="IDR_ERROR_APP_HTML" file="resources\error_app.html" flattenhtml="true" type="BINDATA" />
</includes>
</release>
</grit>
diff --git a/chrome/renderer/resources/error_app.html b/chrome/renderer/resources/error_app.html
new file mode 100644
index 0000000..18265cef
--- /dev/null
+++ b/chrome/renderer/resources/error_app.html
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html i18n-values="dir:textdirection">
+<head>
+<title i18n-content="title">
+</title>
+<style>
+html {
+ height: 100%;
+}
+body {
+ color: #000;
+ font-family: Helvetica, Arial, sans-serif;
+ background-image: -webkit-gradient(
+ linear,
+ left bottom,
+ left top,
+ color-stop(0, rgb(236,244,255)),
+ color-stop(0.50, rgb(255,255,255))
+ );
+ height: 100%;
+ padding: 0px;
+ margin: 0px;
+}
+#error {
+ position: absolute;
+ left: 180px;
+ top: 150px;
+ font-size: 24px;
+}
+#error img {
+ margin-right: 10px;
+ vertical-align: middle;
+}
+#name {
+ font-weight: bold;
+}
+#msg {
+}
+</style>
+</head>
+
+<body id="t">
+
+<div id="error" jsvalues=".title:url">
+<img jsvalues=".src:icon" width="96" height="96">
+<div style="display:inline-block; vertical-align: middle;">
+<div id="name" jsvalues=".innerText:name"></div>
+<div id="msg" jsvalues=".innerText:msg"></div>
+</div>
+</div>
+
+</body>
+</html>