summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-29 20:32:03 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-29 20:32:03 +0000
commit2bfd94d8ca8da6407190f97c3c27007e068bdaaa (patch)
tree15dcb37a334b56a0a7e2330e6594251e82267135 /chrome
parent02f58f54e138f44d26743fa1f8bef78fc705ae80 (diff)
downloadchromium_src-2bfd94d8ca8da6407190f97c3c27007e068bdaaa.zip
chromium_src-2bfd94d8ca8da6407190f97c3c27007e068bdaaa.tar.gz
chromium_src-2bfd94d8ca8da6407190f97c3c27007e068bdaaa.tar.bz2
Patch from <yuzo@google.com>:
Disable view-source if the page source is not viewable as text. For example, a page of content type application/x-shockwave-flash is not viewable. http://crbug.com/9562 Review URL: http://codereview.chromium.org/66061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14880 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index ace2369..f931187 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -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"
@@ -2179,6 +2180,10 @@ void Browser::UpdateCommandsForTabState() {
{
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();
@@ -2188,9 +2193,11 @@ void Browser::UpdateCommandsForTabState() {
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()));