Bug 1022856 - Implement translator provider attribution. r=felipe a=lmandel
authorFlorian Quèze <florian@queze.net>
Fri, 20 Jun 2014 15:50:41 -0300
changeset 208275 8169edbeb8f7756d137e9ab484b87ada547f2fcb
parent 208274 b6bce4b37a2472531bc7b194941bceb511d03cdb
child 208276 f67bac5b213d21b26ba8cc433b821c8290d4d64c
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipe, lmandel
bugs1022856
milestone32.0a2
Bug 1022856 - Implement translator provider attribution. r=felipe a=lmandel Parts of the patch written by Felipe, with r=florian
browser/components/preferences/content.js
browser/components/preferences/content.xul
browser/components/preferences/in-content/content.js
browser/components/preferences/in-content/content.xul
browser/components/translation/Translation.jsm
browser/components/translation/jar.mn
browser/components/translation/microsoft-translator-attribution.png
browser/components/translation/translation-infobar.xml
browser/themes/linux/preferences/preferences.css
browser/themes/osx/preferences/preferences.css
browser/themes/shared/translation/infobar.inc.css
browser/themes/windows/browser.css
browser/themes/windows/preferences/preferences.css
--- a/browser/components/preferences/content.js
+++ b/browser/components/preferences/content.js
@@ -183,10 +183,16 @@ var gContentPane = {
    * Displays the translation exceptions dialog where specific site and language
    * translation preferences can be set.
    */
   showTranslationExceptions: function ()
   {
     document.documentElement.openWindow("Browser:TranslationExceptions",
                                         "chrome://browser/content/preferences/translation.xul",
                                         "", null);
+  },
+
+  openTranslationProviderAttribution: function ()
+  {
+    Components.utils.import("resource:///modules/translation/Translation.jsm");
+    Translation.openProviderAttribution();
   }
 };
--- a/browser/components/preferences/content.xul
+++ b/browser/components/preferences/content.xul
@@ -139,20 +139,26 @@
           <row id="preferredLanguageRow">
             <label flex="1" control="chooseLanguage">&chooseLanguage.label;</label>
             <button id="chooseLanguage"
                     label="&chooseButton.label;"
                     accesskey="&chooseButton.accesskey;"
                     oncommand="gContentPane.showLanguages();"/>
           </row>
           <row id="translationBox" hidden="true">
-            <checkbox id="translate" preference="browser.translation.detectLanguage" flex="1"
-                      label="&translateWebPages.label;" accesskey="&translateWebPages.accesskey;"
-                      onsyncfrompreference="return gContentPane.updateButtons('translateButton',
-                                            'browser.translation.detectLanguage');"/>
+            <hbox align="center">
+              <checkbox id="translate" preference="browser.translation.detectLanguage"
+                        label="&translateWebPages.label;." accesskey="&translateWebPages.accesskey;"
+                        onsyncfrompreference="return gContentPane.updateButtons('translateButton',
+                                              'browser.translation.detectLanguage');"/>
+              <label>Übersetzungen von</label>
+              <image id="translationAttributionImage" aria-label="Microsoft Translator"
+                     onclick="gContentPane.openTranslationProviderAttribution()"
+                     src="chrome://browser/content/microsoft-translator-attribution.png"/>
+            </hbox>
             <button id="translateButton" label="&translateExceptions.label;"
                     oncommand="gContentPane.showTranslationExceptions();"
                     accesskey="&translateExceptions.accesskey;"/>
           </row>
         </rows>
       </grid>
 
     </groupbox>
--- a/browser/components/preferences/in-content/content.js
+++ b/browser/components/preferences/in-content/content.js
@@ -181,10 +181,16 @@ var gContentPane = {
   /**
    * Displays the translation exceptions dialog where specific site and language
    * translation preferences can be set.
    */
   showTranslationExceptions: function ()
   {
     openDialog("chrome://browser/content/preferences/translation.xul",
                "Browser:TranslationExceptions", null);
+  },
+
+  openTranslationProviderAttribution: function ()
+  {
+    Components.utils.import("resource:///modules/translation/Translation.jsm");
+    Translation.openProviderAttribution();
   }
 };
--- a/browser/components/preferences/in-content/content.xul
+++ b/browser/components/preferences/in-content/content.xul
@@ -129,17 +129,24 @@
     <description flex="1" control="chooseLanguage">&chooseLanguage.label;</description>
     <button id="chooseLanguage"
             label="&chooseButton.label;"
             accesskey="&chooseButton.accesskey;"
             oncommand="gContentPane.showLanguages();"/>
   </hbox>
 
   <hbox id="translationBox" hidden="true">
-    <checkbox id="translate" preference="browser.translation.detectLanguage" flex="1"
-              label="&translateWebPages.label;" accesskey="&translateWebPages.accesskey;"
-              onsyncfrompreference="return gContentPane.updateButtons('translateButton',
-                                    'browser.translation.detectLanguage');"/>
+    <hbox align="center" flex="1">
+      <checkbox id="translate" preference="browser.translation.detectLanguage"
+                label="&translateWebPages.label;." accesskey="&translateWebPages.accesskey;"
+                onsyncfrompreference="return gContentPane.updateButtons('translateButton',
+                                              'browser.translation.detectLanguage');"/>
+      <label>Übersetzungen von</label>
+      <separator orient="vertical" class="thin"/>
+      <image id="translationAttributionImage" aria-label="Microsoft Translator"
+             onclick="gContentPane.openTranslationProviderAttribution()"
+             src="chrome://browser/content/microsoft-translator-attribution.png"/>
+    </hbox>
     <button id="translateButton" label="&translateExceptions.label;"
             oncommand="gContentPane.showTranslationExceptions();"
             accesskey="&translateExceptions.accesskey;"/>
   </hbox>
 </groupbox>
--- a/browser/components/translation/Translation.jsm
+++ b/browser/components/translation/Translation.jsm
@@ -75,16 +75,22 @@ this.Translation = {
     trUI.translatedFrom = aData.translatedFrom;
     trUI.translatedTo = aData.translatedTo;
     trUI.originalShown = aData.originalShown;
 
     trUI.showURLBarIcon();
 
     if (trUI.shouldShowInfoBar(aBrowser.currentURI))
       trUI.showTranslationInfoBar();
+  },
+
+  openProviderAttribution: function() {
+    Cu.import("resource:///modules/RecentWindow.jsm");
+    RecentWindow.getMostRecentBrowserWindow().openUILinkIn(
+      "http://aka.ms/MicrosoftTranslatorAttribution", "tab");
   }
 };
 
 /* TranslationUI objects keep the information related to translation for
  * a specific browser.  This object is passed to the translation
  * infobar so that it can initialize itself.  The properties exposed to
  * the infobar are:
  * - detectedLanguage, code of the language detected on the web page.
--- a/browser/components/translation/jar.mn
+++ b/browser/components/translation/jar.mn
@@ -1,5 +1,6 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 browser.jar:
        content/browser/translation-infobar.xml
+       content/browser/microsoft-translator-attribution.png
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d9d277461b4b66b92f47e420649f8a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+++ b/browser/components/translation/translation-infobar.xml
@@ -93,27 +93,35 @@
 
           </xul:deck>
           <xul:spacer flex="1"/>
 
           <xul:button type="menu"
                       class="translate-infobar-element options-menu-button"
                       anonid="options"
                       label="&translation.options.menu;">
-            <xul:menupopup onpopupshowing="document.getBindingParent(this).optionsShowing();">
+            <xul:menupopup class="translation-menupopup cui-widget-panel cui-widget-panelview
+                                  cui-widget-panelWithFooter PanelUI-subView"
+                           onpopupshowing="document.getBindingParent(this).optionsShowing();">
               <xul:menuitem anonid="neverForLanguage"
                             oncommand="document.getBindingParent(this).neverForLanguage();"/>
               <xul:menuitem anonid="neverForSite"
                             oncommand="document.getBindingParent(this).neverForSite();"
                             label="&translation.options.neverForSite.label;"
                             accesskey="&translation.options.neverForSite.accesskey;"/>
               <xul:menuseparator/>
               <xul:menuitem oncommand="openPreferences('paneContent');"
                             label="&translation.options.preferences.label;"
                             accesskey="&translation.options.preferences.accesskey;"/>
+              <xul:menuitem class="translation-attribution subviewbutton panel-subview-footer"
+                            oncommand="document.getBindingParent(this).openProviderAttribution();">
+                <xul:label>Übersetzungen von</xul:label>
+                <xul:image src="chrome://browser/content/microsoft-translator-attribution.png"
+                           aria-label="Microsoft Translator"/>
+              </xul:menuitem>
             </xul:menupopup>
           </xul:button>
 
         </xul:hbox>
         <xul:toolbarbutton ondblclick="event.stopPropagation();"
                            class="messageCloseButton close-icon tabbable"
                            xbl:inherits="hidden=hideclose"
                            tooltiptext="&closeNotification.tooltip;"
@@ -310,11 +318,19 @@
             let perms = Services.perms;
             perms.add(uri, "translate", perms.DENY_ACTION);
 
             this.close();
           ]]>
         </body>
       </method>
 
+      <method name="openProviderAttribution">
+        <body>
+          <![CDATA[
+            Translation.openProviderAttribution();
+          ]]>
+        </body>
+      </method>
+
     </implementation>
   </binding>
 </bindings>
--- a/browser/themes/linux/preferences/preferences.css
+++ b/browser/themes/linux/preferences/preferences.css
@@ -49,16 +49,22 @@ radio[pane=paneSync] {
 label.small {
   font-size: smaller;
 }
 
 #tabPrefsBox {
   margin: 5px;
 }
 
+/* Content Pane */
+#translationAttributionImage {
+  width: 70px;
+  cursor: pointer;
+}
+
 /* Applications Pane */
 #BrowserPreferences[animated="true"] #handlersView {
   height: 25em;
 }
 
 #BrowserPreferences[animated="false"] #handlersView {
   -moz-box-flex: 1;
 }
--- a/browser/themes/osx/preferences/preferences.css
+++ b/browser/themes/osx/preferences/preferences.css
@@ -137,16 +137,21 @@ caption {
 #popupPolicyRow,
 #enableSoftwareInstallRow,
 #enableImagesRow {
   margin-bottom: 4px !important;
   padding-bottom: 4px !important;
   border-bottom: 1px solid #ccc;
 }
 
+#translationAttributionImage {
+  width: 70px;
+  cursor: pointer;
+}
+
 #browserUseCurrent,
 #browserUseBookmark,
 #browserUseBlank {
   margin-top: 10px;
 }
 
 #advancedPrefs {
   margin: 0 8px;
--- a/browser/themes/shared/translation/infobar.inc.css
+++ b/browser/themes/shared/translation/infobar.inc.css
@@ -41,8 +41,26 @@ notification[value="translation"] menuli
 
 notification[value="translation"] menulist > .menulist-dropmarker {
   -moz-appearance: toolbarbutton-dropdown;
   border: none;
   background-color: transparent;
   margin: auto;
   padding: 5px 0;
 }
+
+.translation-menupopup arrowscrollbox {
+  padding-bottom: 0;
+}
+
+.translation-attribution {
+  cursor: pointer;
+  -moz-box-align: end;
+  font-size: small;
+}
+
+.translation-attribution > label {
+  margin-bottom: 0;
+}
+
+.translation-attribution > image {
+  width: 70px;
+}
--- a/browser/themes/windows/browser.css
+++ b/browser/themes/windows/browser.css
@@ -2420,16 +2420,20 @@ notification[value="translation"] {
 }
 
 .translated-notification-icon,
 #translated-notification-icon {
   list-style-image: url(chrome://browser/skin/translation-16.png);
   -moz-image-region: rect(0px, 32px, 16px, 16px);
 }
 
+.translation-menupopup {
+  -moz-appearance: none;
+}
+
 /* Bookmarks roots menu-items */
 #subscribeToPageMenuitem:not([disabled]),
 #subscribeToPageMenupopup,
 #BMB_subscribeToPageMenuitem:not([disabled]),
 #BMB_subscribeToPageMenupopup {
   list-style-image: url("chrome://browser/skin/feeds/feedIcon16.png");
 }
 
--- a/browser/themes/windows/preferences/preferences.css
+++ b/browser/themes/windows/preferences/preferences.css
@@ -48,16 +48,22 @@ radio[pane=paneSync] {
 label.small {
   font-size: smaller;
 }
 
 #tabPrefsBox {
   margin: 6px;
 }
 
+/* Content Pane */
+#translationAttributionImage {
+  width: 70px;
+  cursor: pointer;
+}
+
 /* Applications Pane */
 #BrowserPreferences[animated="true"] #handlersView {
   height: 25em;
 }
 
 #BrowserPreferences[animated="false"] #handlersView {
   -moz-box-flex: 1;
 }