summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
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 /chrome/renderer
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
Diffstat (limited to 'chrome/renderer')
-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
11 files changed, 359 insertions, 91 deletions
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>