Bug 849564 - Added view page source under the app bar settings icon. r=mbrubeck
authorKamil Jozwiak <kamiljoz@gmail.com>
Mon, 04 Nov 2013 14:18:21 -0800
changeset 168977 ed1e204e1bcbcddcdf158a037df6de7bb7e09762
parent 168976 f59871351191e1de64834afc64b55e8526ba8831
child 168978 eb06bfe7f9b6a7c7e3a43b062f65132001e3d24d
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
bugs849564
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 849564 - Added view page source under the app bar settings icon. r=mbrubeck
browser/metro/base/content/ContextCommands.js
browser/metro/base/content/appbar.js
browser/metro/base/content/browser.xul
browser/metro/locales/en-US/chrome/browser.dtd
--- a/browser/metro/base/content/ContextCommands.js
+++ b/browser/metro/base/content/ContextCommands.js
@@ -272,16 +272,31 @@ var ContextCommands = {
     let metaData = Browser.selectedBrowser.contentWindow.document.getElementsByTagName("meta");
     let msApplicationName = metaData.namedItem("msApplication-PackageFamilyName");
     if (msApplicationName) {
       return "ms-windows-store:PDP?PFN=" + msApplicationName.getAttribute("content");
     }
     return null;
   },
 
+  getPageSource: function cc_getPageSource() {
+    let uri = Services.io.newURI(Browser.selectedBrowser.currentURI.spec, null, null);
+    if (!uri.schemeIs("view-source")) {
+      return "view-source:" + Browser.selectedBrowser.currentURI.spec;
+    }
+    return null;
+  },
+
+  viewPageSource: function cc_viewPageSource() {
+    let uri = this.getPageSource();
+    if (uri) {
+      BrowserUI.addAndShowTab(uri);
+    }
+  },
+
   /*
    * Utilities
    */
 
   saveToWinLibrary: function cc_saveToWinLibrary(aType) {
     let popupState = ContextMenuUI.popupState;
     let browser = popupState.target;
 
--- a/browser/metro/base/content/appbar.js
+++ b/browser/metro/base/content/appbar.js
@@ -112,16 +112,18 @@ var Appbar = {
     }
   },
 
   onMenuButton: function(aEvent) {
       let typesArray = [];
 
       if (!BrowserUI.isStartTabVisible)
         typesArray.push("find-in-page");
+      if (ContextCommands.getPageSource())
+        typesArray.push("view-page-source");
       if (ContextCommands.getStoreLink())
         typesArray.push("ms-meta-data");
       if (ConsolePanelView.enabled)
         typesArray.push("open-error-console");
       if (!Services.metro.immersive)
         typesArray.push("open-jsshell");
 
       try {
--- a/browser/metro/base/content/browser.xul
+++ b/browser/metro/base/content/browser.xul
@@ -787,16 +787,19 @@
             <label value="&appbarFindInPage2.label;"/>
           </richlistitem>
           <richlistitem id="context-viewondesktop" type="view-on-desktop" onclick="ContextCommands.viewOnDesktop();">
             <label value="&appbarViewOnDesktop2.label;"/>
           </richlistitem>
           <richlistitem id="context-msmetadata" type="ms-meta-data" onclick="ContextCommands.openWindowsStoreLink();">
             <label value="&appbarMSMetaData2.label;"/>
           </richlistitem>
+          <richlistitem id="context-viewpagesource" type="view-page-source" onclick="ContextCommands.viewPageSource();">
+            <label value="&appbarViewPageSource.label;"/>
+          </richlistitem>
         </richlistbox>
       </vbox>
     </box>
 
     <vbox id="select-container" class="menu-container" hidden="true">
       <vbox id="select-popup" class="select-popup">
         <richlistbox id="select-commands" flex="1"/>
       </vbox>
--- a/browser/metro/locales/en-US/chrome/browser.dtd
+++ b/browser/metro/locales/en-US/chrome/browser.dtd
@@ -13,16 +13,17 @@
 
 <!ENTITY autocompleteResultsHeader.label  "Your Results">
 
 <!ENTITY appbarErrorConsole.label   "Open error console">
 <!ENTITY appbarJSShell.label        "Open JavaScript shell">
 <!ENTITY appbarFindInPage2.label    "Find in page">
 <!ENTITY appbarViewOnDesktop2.label "View on desktop">
 <!ENTITY appbarMSMetaData2.label    "Get app for this site">
+<!ENTITY appbarViewPageSource.label "View page source">
 
 <!ENTITY topSitesHeader.label        "Top Sites">
 <!ENTITY bookmarksHeader.label       "Bookmarks">
 <!ENTITY recentHistoryHeader.label   "Recent History">
 <!ENTITY remoteTabsHeader.label      "Tabs from Other Devices">
 
 <!-- LOCALIZATION NOTE (narrowTopSitesHeader.label,
                         narrowBookmarksHeader.label,