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

Unified Diff: chrome/browser/ui/browser.cc

Issue 7309006: Disable encoding menu item for chrome://bookmarks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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
« chrome/browser/ui/browser.h ('K') | « chrome/browser/ui/browser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser.cc
===================================================================
--- chrome/browser/ui/browser.cc (revision 91505)
+++ chrome/browser/ui/browser.cc (working copy)
@@ -3948,6 +3948,23 @@
#endif
}
+bool Browser::HasInternalURL(const NavigationEntry* entry) const {
brettw 2011/07/06 16:55:24 When you move this above, please be sure to write
+ if (!entry)
+ return false;
+
+ // Check the |virtual_url()| first. This catches regular chrome:// URLs
+ // including URLs that were rewritten (such as chrome://bookmarks).
+ if (entry->virtual_url().SchemeIs(chrome::kChromeUIScheme))
+ return true;
+
+ // If the |virtual_url()| isn't a chrome:// URL, check if it's actually
+ // view-source: of a chrome:// URL.
+ if (entry->virtual_url().SchemeIs(chrome::kViewSourceScheme))
+ return entry->url().SchemeIs(chrome::kChromeUIScheme);
+
+ return false;
+}
+
void Browser::UpdateCommandsForTabState() {
TabContents* current_tab = GetSelectedTabContents();
TabContentsWrapper* current_tab_wrapper = GetSelectedTabContentsWrapper();
@@ -3978,13 +3995,7 @@
command_updater_.UpdateCommandEnabled(IDC_OPEN_FILE, false);
// Changing the encoding is not possible on Chrome-internal webpages.
- // Instead of using GetURL here, we use url() (which is the "real" url of the
- // page) from the NavigationEntry because its reflects their origin rather
- // than the display one (returned by GetURL) which may be different (like
- // having "view-source:" on the front).
- NavigationEntry* active_entry = nc.GetActiveEntry();
- bool is_chrome_internal = (active_entry ?
- active_entry->url().SchemeIs(chrome::kChromeUIScheme) : false);
+ bool is_chrome_internal = HasInternalURL(nc.GetActiveEntry());
command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU,
!is_chrome_internal && SavePackage::IsSavableContents(
current_tab->contents_mime_type()));
« chrome/browser/ui/browser.h ('K') | « chrome/browser/ui/browser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698