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

Unified Diff: chrome/browser/browser.cc

Issue 66061: Disable view-source if the page source is not viewable as text.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser.cc
===================================================================
--- chrome/browser/browser.cc (revision 13671)
+++ chrome/browser/browser.cc (working copy)
@@ -49,6 +49,7 @@
#include "grit/locale_settings.h"
#include "net/base/cookie_monster.h"
#include "net/base/cookie_policy.h"
+#include "net/base/mime_util.h"
#include "net/base/net_util.h"
#include "net/base/registry_controlled_domain.h"
#include "net/url_request/url_request_context.h"
@@ -2182,6 +2183,10 @@
{
WebContents* web_contents = current_tab->AsWebContents();
bool is_web_contents = web_contents != NULL;
+ bool is_source_viewable =
+ is_web_contents &&
+ net::IsSupportedNonImageMimeType(
+ web_contents->contents_mime_type().c_str());
// Current navigation entry, may be NULL.
NavigationEntry* active_entry = current_tab->controller()->GetActiveEntry();
@@ -2191,9 +2196,11 @@
command_updater_.UpdateCommandEnabled(IDC_STAR,
is_web_contents && (type() == TYPE_NORMAL));
window_->SetStarredState(is_web_contents && web_contents->is_starred());
- // View-source should not be enabled if already in view-source mode.
+ // View-source should not be enabled if already in view-source mode or
+ // the source is not viewable.
command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE,
- is_web_contents && active_entry && !active_entry->IsViewSourceMode());
+ is_web_contents && active_entry && !active_entry->IsViewSourceMode() &&
+ is_source_viewable);
command_updater_.UpdateCommandEnabled(IDC_PRINT, is_web_contents);
command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE,
is_web_contents && SavePackage::IsSavableURL(current_tab->GetURL()));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698