summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjnd@google.com <jnd@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-18 21:24:29 +0000
committerjnd@google.com <jnd@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-18 21:24:29 +0000
commit72c94f309664498277eee70eeccc05b44f0f255a (patch)
tree65d2fedf4b6907c4971dae0e8526d3c20efe9264
parentea8c4104164fcb225003bf074d3d4693929e00da (diff)
downloadchromium_src-72c94f309664498277eee70eeccc05b44f0f255a.zip
chromium_src-72c94f309664498277eee70eeccc05b44f0f255a.tar.gz
chromium_src-72c94f309664498277eee70eeccc05b44f0f255a.tar.bz2
The CL is consist of CLs(1624,1580) for bug:1281734 which are reviewed and LG by brett. I just merge them to single one for passing compilation.
The CL is to fix bug http://b/issue?id=1281734. FireFox uses encoding used by the original webpage to decode the source of the webpage, Chrome does not. We need to add a new parameter which carries the override encoding when opening a view-source URL for viewing its source. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@997 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser.cc11
-rw-r--r--chrome/browser/browser.h7
-rw-r--r--chrome/browser/debugger/debugger_view.cc7
-rw-r--r--chrome/browser/debugger/debugger_view.h3
-rw-r--r--chrome/browser/external_tab_container.cc10
-rw-r--r--chrome/browser/external_tab_container.h3
-rw-r--r--chrome/browser/navigation_controller_unittest.cc3
-rw-r--r--chrome/browser/render_view_context_menu_controller.cc21
-rw-r--r--chrome/browser/render_view_context_menu_controller.h11
-rw-r--r--chrome/browser/tab_contents.cc17
-rw-r--r--chrome/browser/tab_contents.h6
-rw-r--r--chrome/browser/tab_contents_delegate.h8
-rw-r--r--chrome/browser/tabs/dragged_tab_controller.cc13
-rw-r--r--chrome/browser/tabs/dragged_tab_controller.h3
-rw-r--r--chrome/browser/views/constrained_window_impl.cc10
-rw-r--r--chrome/browser/views/constrained_window_impl.h3
-rw-r--r--chrome/browser/views/html_dialog_view.cc6
-rw-r--r--chrome/browser/views/html_dialog_view.h3
-rw-r--r--chrome/browser/web_contents.cc9
-rw-r--r--chrome/browser/web_contents.h7
-rw-r--r--chrome/common/render_messages.h7
-rw-r--r--chrome/renderer/render_view.cc11
-rw-r--r--chrome/renderer/render_view.h3
-rw-r--r--webkit/glue/context_menu_client_impl.cc6
-rw-r--r--webkit/glue/webframe.h5
-rw-r--r--webkit/glue/webframe_impl.cc9
-rw-r--r--webkit/glue/webframe_impl.h3
-rw-r--r--webkit/glue/webview_delegate.h5
-rw-r--r--webkit/pending/FrameLoader.h1
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.cc3
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.h3
31 files changed, 169 insertions, 48 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index bc8408f..63c91ea 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -533,7 +533,8 @@ void Browser::ProcessPendingUIUpdates() {
void Browser::OpenURLFromTab(TabContents* source,
const GURL& url,
WindowOpenDisposition disposition,
- PageTransition::Type transition) {
+ PageTransition::Type transition,
+ const std::wstring& override_encoding) {
// No code for these yet
DCHECK((disposition != NEW_POPUP) && (disposition != SAVE_TO_DISK));
@@ -648,6 +649,14 @@ void Browser::OpenURLFromTab(TabContents* source,
// front-most.
new_contents->Focus();
}
+
+ if (!override_encoding.empty()) {
+ // The new tab needs a special encoding, such as a view source page
+ // which should use the same encoding as the original page.
+ WebContents* web_contents = new_contents->AsWebContents();
+ if (web_contents)
+ web_contents->set_override_encoding(override_encoding);
+ }
}
void Browser::NavigationStateChanged(const TabContents* source,
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 6b467183..b2c29aa 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -292,9 +292,10 @@ class Browser : public TabStripModelDelegate,
// Overridden from TabContentsDelegate:
virtual void OpenURLFromTab(TabContents* source,
- const GURL& url,
- WindowOpenDisposition disposition,
- PageTransition::Type transition);
+ const GURL& url,
+ WindowOpenDisposition disposition,
+ PageTransition::Type transition,
+ const std::wstring& override_encoding);
virtual void NavigationStateChanged(const TabContents* source,
unsigned changed_flags);
virtual void ReplaceContents(TabContents* source, TabContents* new_contents);
diff --git a/chrome/browser/debugger/debugger_view.cc b/chrome/browser/debugger/debugger_view.cc
index b594861..46bdbdb 100644
--- a/chrome/browser/debugger/debugger_view.cc
+++ b/chrome/browser/debugger/debugger_view.cc
@@ -153,9 +153,10 @@ void DebuggerView::SetDebuggerBreak(bool is_broken) {
}
void DebuggerView::OpenURLFromTab(TabContents* source,
- const GURL& url,
- WindowOpenDisposition disposition,
- PageTransition::Type transition) {
+ const GURL& url,
+ WindowOpenDisposition disposition,
+ PageTransition::Type transition,
+ const std::wstring& override_encoding) {
BrowserList::GetLastActive()->OpenURL(url, disposition, transition);
}
diff --git a/chrome/browser/debugger/debugger_view.h b/chrome/browser/debugger/debugger_view.h
index f866651..16213ed 100644
--- a/chrome/browser/debugger/debugger_view.h
+++ b/chrome/browser/debugger/debugger_view.h
@@ -84,7 +84,8 @@ class DebuggerView : public ChromeViews::View,
virtual void OpenURLFromTab(TabContents* source,
const GURL& url,
WindowOpenDisposition disposition,
- PageTransition::Type transition);
+ PageTransition::Type transition,
+ const std::wstring& override_encoding);
// Overridden from TabContentsDelegate:
virtual void NavigationStateChanged(const TabContents* source,
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc
index 13bb2a7..bb56384 100644
--- a/chrome/browser/external_tab_container.cc
+++ b/chrome/browser/external_tab_container.cc
@@ -149,10 +149,12 @@ LRESULT ExternalTabContainer::OnSize(UINT, WPARAM, LPARAM, BOOL& handled) {
// needs to be fully fleshed out based on the requirements of the
// "Chrome tab in external browser" feature.
-void ExternalTabContainer::OpenURLFromTab(TabContents* source,
- const GURL& url,
- WindowOpenDisposition disposition,
- PageTransition::Type transition) {
+void ExternalTabContainer::OpenURLFromTab(
+ TabContents* source,
+ const GURL& url,
+ WindowOpenDisposition disposition,
+ PageTransition::Type transition,
+ const std::wstring& override_encoding) {
switch (disposition) {
case CURRENT_TAB:
case NEW_FOREGROUND_TAB:
diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h
index b8ccc8c..7bfb213 100644
--- a/chrome/browser/external_tab_container.h
+++ b/chrome/browser/external_tab_container.h
@@ -80,7 +80,8 @@ class ExternalTabContainer : public TabContentsDelegate,
virtual void OpenURLFromTab(TabContents* source,
const GURL& url,
WindowOpenDisposition disposition,
- PageTransition::Type transition);
+ PageTransition::Type transition,
+ const std::wstring& override_encoding);
virtual void NavigationStateChanged(const TabContents* source,
unsigned changed_flags);
virtual void ReplaceContents(TabContents* source, TabContents* new_contents);
diff --git a/chrome/browser/navigation_controller_unittest.cc b/chrome/browser/navigation_controller_unittest.cc
index cce2cf9..9176df6 100644
--- a/chrome/browser/navigation_controller_unittest.cc
+++ b/chrome/browser/navigation_controller_unittest.cc
@@ -154,7 +154,8 @@ class NavigationControllerTest : public testing::Test,
virtual void OpenURLFromTab(TabContents*,
const GURL&,
WindowOpenDisposition,
- PageTransition::Type) {}
+ PageTransition::Type,
+ const std::wstring& override_encoding) {}
virtual void NavigationStateChanged(const TabContents*,
unsigned flags) {}
virtual void ReplaceContents(TabContents* source,
diff --git a/chrome/browser/render_view_context_menu_controller.cc b/chrome/browser/render_view_context_menu_controller.cc
index 790f641..c4ec6ad 100644
--- a/chrome/browser/render_view_context_menu_controller.cc
+++ b/chrome/browser/render_view_context_menu_controller.cc
@@ -67,6 +67,15 @@ RenderViewContextMenuController::~RenderViewContextMenuController() {
///////////////////////////////////////////////////////////////////////////////
// Controller methods
+void RenderViewContextMenuController::OpenURLWithOverrideEncoding(
+ const GURL& url,
+ WindowOpenDisposition disposition,
+ PageTransition::Type transition,
+ const std::wstring& override_encoding) {
+ source_web_contents_->OpenURLWithOverrideEncoding(url, disposition,
+ transition, override_encoding);
+}
+
void RenderViewContextMenuController::OpenURL(
const GURL& url,
WindowOpenDisposition disposition,
@@ -298,8 +307,10 @@ void RenderViewContextMenuController::ExecuteCommand(int id) {
break;
case IDS_CONTENT_CONTEXT_VIEWPAGESOURCE:
- OpenURL(GURL("view-source:" + params_.page_url.spec()),
- NEW_FOREGROUND_TAB, PageTransition::GENERATED);
+ OpenURLWithOverrideEncoding(
+ GURL("view-source:" + params_.page_url.spec()),
+ NEW_FOREGROUND_TAB, PageTransition::GENERATED,
+ source_web_contents_->GetEncoding());
break;
case IDS_CONTENT_CONTEXT_INSPECTELEMENT:
@@ -334,8 +345,10 @@ void RenderViewContextMenuController::ExecuteCommand(int id) {
break;
case IDS_CONTENT_CONTEXT_VIEWFRAMESOURCE:
- OpenURL(GURL("view-source:" + params_.frame_url.spec()),
- NEW_FOREGROUND_TAB, PageTransition::GENERATED);
+ OpenURLWithOverrideEncoding(
+ GURL("view-source:" + params_.frame_url.spec()),
+ NEW_FOREGROUND_TAB, PageTransition::GENERATED,
+ params_.frame_encoding);
break;
case IDS_CONTENT_CONTEXT_VIEWFRAMEINFO:
diff --git a/chrome/browser/render_view_context_menu_controller.h b/chrome/browser/render_view_context_menu_controller.h
index f4cc15b..3817dd6 100644
--- a/chrome/browser/render_view_context_menu_controller.h
+++ b/chrome/browser/render_view_context_menu_controller.h
@@ -48,12 +48,19 @@ class RenderViewContextMenuController : public Menu::Delegate {
virtual bool GetAcceleratorInfo(int id, ChromeViews::Accelerator* accel);
private:
- // Opens the specified URL string in a new tab. If |in_current_window| is
- // false, a new window is created to hold the new tab.
+ // Opens the specified URL string with a disposition specified by parameter
+ // |disposition|.
void OpenURL(const GURL& url,
WindowOpenDisposition disposition,
PageTransition::Type transition);
+ // Opens the specified URL string with a disposition specified by parameter
+ // |disposition| and forces the new page on using |override_encoding|.
+ void OpenURLWithOverrideEncoding(const GURL& url,
+ WindowOpenDisposition disposition,
+ PageTransition::Type transition,
+ const std::wstring& override_encoding);
+
// Copy to the clipboard an image located at a point in the RenderView
void CopyImageAt(int x, int y);
diff --git a/chrome/browser/tab_contents.cc b/chrome/browser/tab_contents.cc
index 419a796..62f6fb1 100644
--- a/chrome/browser/tab_contents.cc
+++ b/chrome/browser/tab_contents.cc
@@ -424,11 +424,24 @@ void TabContents::DidMoveOrResize(ConstrainedWindow* window) {
///////////////////////////////////////////////////////////////////////////////
// PageNavigator methods
+void TabContents::OpenURLWithOverrideEncoding(
+ const GURL& url,
+ WindowOpenDisposition disposition,
+ PageTransition::Type transition,
+ const std::wstring& override_encoding) {
+ if (delegate_) {
+ delegate_->OpenURLFromTab(this, url, disposition, transition,
+ override_encoding);
+ }
+}
+
void TabContents::OpenURL(const GURL& url,
WindowOpenDisposition disposition,
PageTransition::Type transition) {
- if (delegate_)
- delegate_->OpenURLFromTab(this, url, disposition, transition);
+ if (delegate_) {
+ delegate_->OpenURLFromTab(this, url, disposition, transition,
+ std::wstring());
+ }
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/tab_contents.h b/chrome/browser/tab_contents.h
index 5a56f5e..2b3338a 100644
--- a/chrome/browser/tab_contents.h
+++ b/chrome/browser/tab_contents.h
@@ -373,6 +373,12 @@ class TabContents : public PageNavigator,
WindowOpenDisposition disposition,
PageTransition::Type transition);
+ virtual void OpenURLWithOverrideEncoding(
+ const GURL& url,
+ WindowOpenDisposition disposition,
+ PageTransition::Type transition,
+ const std::wstring& override_encoding);
+
// NotificationObserver implementation.
virtual void Observe(NotificationType type,
const NotificationSource& source,
diff --git a/chrome/browser/tab_contents_delegate.h b/chrome/browser/tab_contents_delegate.h
index 7bd4137..2b94e34 100644
--- a/chrome/browser/tab_contents_delegate.h
+++ b/chrome/browser/tab_contents_delegate.h
@@ -53,13 +53,13 @@ class TabContentsDelegate : public PageNavigator {
virtual void OpenURLFromTab(TabContents* source,
const GURL& url,
WindowOpenDisposition disposition,
- PageTransition::Type transition) = 0;
+ PageTransition::Type transition,
+ const std::wstring& override_encoding) = 0;
virtual void OpenURL(const GURL& url,
WindowOpenDisposition disposition,
- PageTransition::Type transition)
- {
- OpenURLFromTab(NULL, url, disposition, transition);
+ PageTransition::Type transition) {
+ OpenURLFromTab(NULL, url, disposition, transition, std::wstring());
}
// Called to inform the delegate that the tab content's navigation state
diff --git a/chrome/browser/tabs/dragged_tab_controller.cc b/chrome/browser/tabs/dragged_tab_controller.cc
index 6a17a459..cdfb8df 100644
--- a/chrome/browser/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/tabs/dragged_tab_controller.cc
@@ -166,15 +166,18 @@ bool DraggedTabController::IsDragSourceTab(Tab* tab) const {
///////////////////////////////////////////////////////////////////////////////
// DraggedTabController, PageNavigator implementation:
-void DraggedTabController::OpenURLFromTab(TabContents* source,
- const GURL& url,
- WindowOpenDisposition disposition,
- PageTransition::Type transition) {
+void DraggedTabController::OpenURLFromTab(
+ TabContents* source,
+ const GURL& url,
+ WindowOpenDisposition disposition,
+ PageTransition::Type transition,
+ const std::wstring& override_encoding) {
if (original_delegate_) {
if (disposition == CURRENT_TAB)
disposition = NEW_WINDOW;
- original_delegate_->OpenURLFromTab(source, url, disposition, transition);
+ original_delegate_->OpenURLFromTab(source, url, disposition, transition,
+ override_encoding);
}
}
diff --git a/chrome/browser/tabs/dragged_tab_controller.h b/chrome/browser/tabs/dragged_tab_controller.h
index d3352c5..e95776d 100644
--- a/chrome/browser/tabs/dragged_tab_controller.h
+++ b/chrome/browser/tabs/dragged_tab_controller.h
@@ -106,7 +106,8 @@ class DraggedTabController : public TabContentsDelegate,
virtual void OpenURLFromTab(TabContents* source,
const GURL& url,
WindowOpenDisposition disposition,
- PageTransition::Type transition);
+ PageTransition::Type transition,
+ const std::wstring& override_encoding);
virtual void NavigationStateChanged(const TabContents* source,
unsigned changed_flags);
virtual void ReplaceContents(TabContents* source,
diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc
index 7524debc..3dfdc20 100644
--- a/chrome/browser/views/constrained_window_impl.cc
+++ b/chrome/browser/views/constrained_window_impl.cc
@@ -1041,10 +1041,12 @@ void ConstrainedWindowImpl::ActivateContents(TabContents* contents) {
ActivateConstrainedWindow();
}
-void ConstrainedWindowImpl::OpenURLFromTab(TabContents* source,
- const GURL& url,
- WindowOpenDisposition disposition,
- PageTransition::Type transition) {
+void ConstrainedWindowImpl::OpenURLFromTab(
+ TabContents* source,
+ const GURL& url,
+ WindowOpenDisposition disposition,
+ PageTransition::Type transition,
+ const std::wstring& override_encoding) {
// We ignore source right now.
owner_->OpenURL(this, url, disposition, transition);
}
diff --git a/chrome/browser/views/constrained_window_impl.h b/chrome/browser/views/constrained_window_impl.h
index 5a37e10..a91586b 100644
--- a/chrome/browser/views/constrained_window_impl.h
+++ b/chrome/browser/views/constrained_window_impl.h
@@ -80,7 +80,8 @@ class ConstrainedWindowImpl : public ConstrainedWindow,
virtual void OpenURLFromTab(TabContents* source,
const GURL& url,
WindowOpenDisposition disposition,
- PageTransition::Type transition);
+ PageTransition::Type transition,
+ const std::wstring& override_encoding);
// Overridden from TabContentsDelegate:
virtual void NavigationStateChanged(const TabContents* source,
diff --git a/chrome/browser/views/html_dialog_view.cc b/chrome/browser/views/html_dialog_view.cc
index 890d5a4..07f89c4 100644
--- a/chrome/browser/views/html_dialog_view.cc
+++ b/chrome/browser/views/html_dialog_view.cc
@@ -110,11 +110,13 @@ void HtmlDialogView::OnDialogClosed(const std::string& json_retval) {
void HtmlDialogView::OpenURLFromTab(TabContents* source,
const GURL& url,
WindowOpenDisposition disposition,
- PageTransition::Type transition) {
+ PageTransition::Type transition,
+ const std::wstring& override_encoding) {
// Force all links to open in a new window, ignoring the incoming
// disposition. This is a tabless, modal dialog so we can't just
// open it in the current frame.
- parent_browser_->OpenURLFromTab(source, url, NEW_WINDOW, transition);
+ parent_browser_->OpenURLFromTab(source, url, NEW_WINDOW, transition,
+ override_encoding);
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/views/html_dialog_view.h b/chrome/browser/views/html_dialog_view.h
index a07e5e3..51e9abb 100644
--- a/chrome/browser/views/html_dialog_view.h
+++ b/chrome/browser/views/html_dialog_view.h
@@ -82,7 +82,8 @@ class HtmlDialogView
virtual void OpenURLFromTab(TabContents* source,
const GURL& url,
WindowOpenDisposition disposition,
- PageTransition::Type transition);
+ PageTransition::Type transition,
+ const std::wstring& override_encoding);
virtual void NavigationStateChanged(const TabContents* source,
unsigned changed_flags);
virtual void ReplaceContents(TabContents* source,
diff --git a/chrome/browser/web_contents.cc b/chrome/browser/web_contents.cc
index 96834dc..891ec4b 100644
--- a/chrome/browser/web_contents.cc
+++ b/chrome/browser/web_contents.cc
@@ -1766,6 +1766,15 @@ void WebContents::DidStartLoading(RenderViewHost* rvh, int32 page_id) {
if (plugin_installer_ != NULL)
plugin_installer_->OnStartLoading();
SetIsLoading(true, NULL);
+
+ // Overrides the page's encoding if we need to open this page with specified
+ // encoding.
+ if (!override_encoding_.empty()) {
+ SetPageEncoding(override_encoding_);
+ // Once we override the new encoding, we need to clear the encoding value
+ // for avoiding overriding it again.
+ override_encoding_.clear();
+ }
}
void WebContents::DidStopLoading(RenderViewHost* rvh, int32 page_id) {
diff --git a/chrome/browser/web_contents.h b/chrome/browser/web_contents.h
index 09a07d0..865cfab 100644
--- a/chrome/browser/web_contents.h
+++ b/chrome/browser/web_contents.h
@@ -359,6 +359,10 @@ class WebContents : public TabContents,
// Returns true if this WebContents will notify about disconnection.
bool notify_disconnection() const { return notify_disconnection_; }
+ void set_override_encoding(const std::wstring& override_encoding) {
+ override_encoding_ = override_encoding;
+ }
+
protected:
FRIEND_TEST(WebContentsTest, OnMessageReceived);
@@ -822,6 +826,9 @@ class WebContents : public TabContents,
// Non-null if we're displaying content for a web app.
scoped_refptr<WebApp> web_app_;
+ // Specified encoding which is used to override current tab's encoding.
+ std::wstring override_encoding_;
+
DISALLOW_COPY_AND_ASSIGN(WebContents);
};
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 8beb013..5ef5cd0 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -175,6 +175,9 @@ struct ViewHostMsg_ContextMenu_Params {
// These flags indicate to the browser whether the renderer believes it is
// able to perform the corresponding action.
int edit_flags;
+
+ // |frame_encoding|indicates the encoding of current focused sub frame.
+ std::wstring frame_encoding;
};
// Values that may be OR'd together to form the 'flags' parameter of a
@@ -791,6 +794,7 @@ struct ParamTraits<ViewHostMsg_ContextMenu_Params> {
WriteParam(m, p.misspelled_word);
WriteParam(m, p.dictionary_suggestions);
WriteParam(m, p.edit_flags);
+ WriteParam(m, p.frame_encoding);
}
static bool Read(const Message* m, void** iter, param_type* p) {
return
@@ -804,7 +808,8 @@ struct ParamTraits<ViewHostMsg_ContextMenu_Params> {
ReadParam(m, iter, &p->selection_text) &&
ReadParam(m, iter, &p->misspelled_word) &&
ReadParam(m, iter, &p->dictionary_suggestions) &&
- ReadParam(m, iter, &p->edit_flags);
+ ReadParam(m, iter, &p->edit_flags) &&
+ ReadParam(m, iter, &p->frame_encoding);
}
static void Log(const param_type& p, std::wstring* l) {
l->append(L"<ViewHostMsg_ContextMenu_Params>");
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 22dd829..7153ed2 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -1439,6 +1439,13 @@ WindowOpenDisposition RenderView::DispositionForNavigationAction(
// Webkit is asking whether to navigate to a new URL.
// This is fine normally, except if we're showing UI from one security
// context and they're trying to navigate to a different context.
+ //
+ // Reload allowing stale data is used for encoding changes which will never
+ // appear in a new tab. So we should return disposition as CURRENT_TAB when
+ // encountering this situation.
+ if (frame->IsReloadAllowingStaleData())
+ return CURRENT_TAB;
+
const GURL& url = request->GetURL();
// We only care about navigations that are within the current tab (as opposed
// to, for example, opening a new window).
@@ -1808,7 +1815,8 @@ void RenderView::ShowContextMenu(WebView* webview,
const GURL& frame_url,
const std::wstring& selection_text,
const std::wstring& misspelled_word,
- int edit_flags) {
+ int edit_flags,
+ const std::wstring& frame_encoding) {
ViewHostMsg_ContextMenu_Params params;
params.type = type;
params.x = x;
@@ -1820,6 +1828,7 @@ void RenderView::ShowContextMenu(WebView* webview,
params.selection_text = selection_text;
params.misspelled_word = misspelled_word;
params.edit_flags = edit_flags;
+ params.frame_encoding = frame_encoding;
Send(new ViewHostMsg_ContextMenu(routing_id_, params));
}
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index f774ff2..b94f849 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -231,7 +231,8 @@ class RenderView : public RenderWidget, public WebViewDelegate,
const GURL& frame_url,
const std::wstring& selection_text,
const std::wstring& misspelled_word,
- int edit_flags);
+ int edit_flags,
+ const std::wstring& frame_encoding);
virtual void StartDragging(WebView* webview,
const WebDropData& drag_data);
diff --git a/webkit/glue/context_menu_client_impl.cc b/webkit/glue/context_menu_client_impl.cc
index c5227676..ea6d800 100644
--- a/webkit/glue/context_menu_client_impl.cc
+++ b/webkit/glue/context_menu_client_impl.cc
@@ -184,6 +184,7 @@ WebCore::PlatformMenuDescription
GURL frame_url;
GURL page_url;
+ std::wstring frame_encoding;
// Send the frame and page URLs in any case.
ContextNode::Type frame_type = ContextNode::NONE;
ContextNode::Type page_type =
@@ -194,6 +195,8 @@ WebCore::PlatformMenuDescription
frame_type = GetTypeAndURLFromFrame(selected_frame,
&frame_url,
ContextNode::FRAME);
+ frame_encoding = webkit_glue::StringToStdWString(
+ selected_frame->loader()->encoding());
}
if (type == ContextNode::NONE) {
@@ -244,7 +247,8 @@ WebCore::PlatformMenuDescription
frame_url,
selection_text_string,
misspelled_word_string,
- edit_flags);
+ edit_flags,
+ frame_encoding);
}
return NULL;
}
diff --git a/webkit/glue/webframe.h b/webkit/glue/webframe.h
index d417563b..dde853d 100644
--- a/webkit/glue/webframe.h
+++ b/webkit/glue/webframe.h
@@ -370,6 +370,11 @@ class WebFrame : public base::RefCounted<WebFrame> {
// Does this frame have an onunload or unbeforeunload event listener?
virtual bool HasUnloadListener() = 0;
+ // Is this frame reloading with allowing stale data? This will be true when
+ // the encoding of the page is changed and it needs to be re-interpreted,
+ // but no additional loads should occur.
+ virtual bool IsReloadAllowingStaleData() const = 0;
+
private:
DISALLOW_EVIL_CONSTRUCTORS(WebFrame);
};
diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc
index c8627d1..8d08a5d 100644
--- a/webkit/glue/webframe_impl.cc
+++ b/webkit/glue/webframe_impl.cc
@@ -1736,3 +1736,12 @@ bool WebFrameImpl::HasUnloadListener() {
}
return false;
}
+
+bool WebFrameImpl::IsReloadAllowingStaleData() const {
+ FrameLoader* loader = frame() ? frame()->loader() : NULL;
+ if (loader) {
+ return WebCore::FrameLoadTypeReloadAllowingStaleData ==
+ loader->policyLoadType();
+ }
+ return false;
+}
diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h
index c466b16..31de146 100644
--- a/webkit/glue/webframe_impl.h
+++ b/webkit/glue/webframe_impl.h
@@ -198,7 +198,7 @@ class WebFrameImpl : public WebFrame {
plugin_delegate_ = plugin_delegate;
}
- WebCore::Frame* frame() {
+ WebCore::Frame* frame() const {
return frame_.get();
}
@@ -259,6 +259,7 @@ class WebFrameImpl : public WebFrame {
bool printing() const { return printing_; }
virtual bool HasUnloadListener();
+ virtual bool IsReloadAllowingStaleData() const;
protected:
friend class WebFrameLoaderClient;
diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h
index 5e4cc6c..7160c0f 100644
--- a/webkit/glue/webview_delegate.h
+++ b/webkit/glue/webview_delegate.h
@@ -554,6 +554,8 @@ class WebViewDelegate : virtual public WebWidgetDelegate {
// @param misspelled_word The editable (possibily) misspelled word
// in the Editor on which dictionary lookup for suggestions will be done.
// @param edit_flags Which edit operations the renderer believes are available
+ // @param frame_encoding Which indicates the encoding of current focused
+ // sub frame.
virtual void ShowContextMenu(WebView* webview,
ContextNode::Type type,
int x,
@@ -564,7 +566,8 @@ class WebViewDelegate : virtual public WebWidgetDelegate {
const GURL& frame_url,
const std::wstring& selection_text,
const std::wstring& misspelled_word,
- int edit_flags) {
+ int edit_flags,
+ const std::wstring& frame_encoding) {
}
// Starts a drag session with the supplied contextual information.
diff --git a/webkit/pending/FrameLoader.h b/webkit/pending/FrameLoader.h
index 61002f2..bdcf233 100644
--- a/webkit/pending/FrameLoader.h
+++ b/webkit/pending/FrameLoader.h
@@ -247,6 +247,7 @@ namespace WebCore {
void didChangeTitle(DocumentLoader*);
FrameLoadType loadType() const;
+ FrameLoadType policyLoadType() const { return m_policyLoadType; }
void didFirstLayout();
bool firstLayoutDone() const;
diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc
index 231415f..3e23252 100644
--- a/webkit/tools/test_shell/test_webview_delegate.cc
+++ b/webkit/tools/test_shell/test_webview_delegate.cc
@@ -507,7 +507,8 @@ void TestWebViewDelegate::ShowContextMenu(WebView* webview,
const GURL& frame_url,
const std::wstring& selection_text,
const std::wstring& misspelled_word,
- int edit_flags) {
+ int edit_flags,
+ const std::wstring& frame_encoding) {
CapturedContextMenuEvent context(type, x, y);
captured_context_menu_events_.push_back(context);
}
diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h
index 9a6f5e7..e21ee53 100644
--- a/webkit/tools/test_shell/test_webview_delegate.h
+++ b/webkit/tools/test_shell/test_webview_delegate.h
@@ -115,7 +115,8 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, public
const GURL& frame_url,
const std::wstring& selection_text,
const std::wstring& misspelled_word,
- int edit_flags);
+ int edit_flags,
+ const std::wstring& frame_encoding);
virtual void DidStartProvisionalLoadForFrame(
WebView* webview,
WebFrame* frame,