Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(665)

Unified Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 11028019: Browser plugin: Implement loadRedirect event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge conflicts. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/browser_plugin/browser_plugin_guest.cc
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc
index 716801735cdce5efdc43cda24884a5fad9e2872a..7d05750e55f26a61fd723538d1c45e1149e90566 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.cc
+++ b/content/browser/browser_plugin/browser_plugin_guest.cc
@@ -14,13 +14,17 @@
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/browser_plugin_messages.h"
#include "content/common/view_messages.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_widget_host_view.h"
+#include "content/public/browser/resource_request_details.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/common/result_codes.h"
#include "content/browser/browser_plugin/browser_plugin_host_factory.h"
#include "net/base/net_errors.h"
#include "ui/surface/transport_dib.h"
+#include "webkit/glue/resource_type.h"
namespace content {
@@ -47,6 +51,10 @@ BrowserPluginGuest::BrowserPluginGuest(int instance_id,
DCHECK(web_contents);
// |render_view_host| manages the ownership of this BrowserPluginGuestHelper.
new BrowserPluginGuestHelper(this, render_view_host);
+
+ notification_registrar_.Add(
+ this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT,
+ content::Source<content::WebContents>(web_contents));
}
BrowserPluginGuest::~BrowserPluginGuest() {
@@ -66,6 +74,27 @@ BrowserPluginGuest* BrowserPluginGuest::Create(
return new BrowserPluginGuest(instance_id, web_contents, render_view_host);
}
+void BrowserPluginGuest::Observe(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ switch (type) {
+ case NOTIFICATION_RESOURCE_RECEIVED_REDIRECT: {
+ DCHECK_EQ(Source<WebContents>(source).ptr(), web_contents());
+ ResourceRedirectDetails* resource_redirect_details =
+ Details<ResourceRedirectDetails>(details).ptr();
+ bool is_top_level =
+ resource_redirect_details->resource_type == ResourceType::MAIN_FRAME;
+ LoadRedirect(resource_redirect_details->url,
+ resource_redirect_details->new_url,
+ is_top_level);
+ break;
+ }
+ default:
+ NOTREACHED() << "Unexpected notification sent.";
+ break;
+ }
+}
+
bool BrowserPluginGuest::ViewTakeFocus(bool reverse) {
SendMessageToEmbedder(
new BrowserPluginMsg_AdvanceFocus(instance_id(), reverse));
@@ -321,6 +350,15 @@ void BrowserPluginGuest::DidFailProvisionalLoad(
error_type));
}
+void BrowserPluginGuest::LoadRedirect(
+ const GURL& old_url,
+ const GURL& new_url,
+ bool is_top_level) {
+ SendMessageToEmbedder(
+ new BrowserPluginMsg_LoadRedirect(
+ instance_id(), old_url, new_url, is_top_level));
+}
+
void BrowserPluginGuest::DidCommitProvisionalLoadForFrame(
int64 frame_id,
bool is_main_frame,

Powered by Google App Engine
This is Rietveld 408576698