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 153435 ed1e204e1bcbcddcdf158a037df6de7bb7e09762
parent 153434 f59871351191e1de64834afc64b55e8526ba8831
child 153436 eb06bfe7f9b6a7c7e3a43b062f65132001e3d24d
push id3333
push usermbrubeck@mozilla.com
push dateMon, 04 Nov 2013 22:19:01 +0000
treeherderfx-team@ed1e204e1bcb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
bugs849564
milestone28.0a1
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,