Bug 1389829 - Part 1 - Add "View Page Source" to the Page menu in the UI. r=nechen

The Page menu is disabled when no tab is open, so not doing a null-check on the
currently selected tab in the menu click handler is safe.

MozReview-Commit-ID: CYKHJ5N1q8I

--HG--
extra : rebase_source : 3ec7b1a9708a905785850feb44b48723c24f1363
This commit is contained in:
Jan Henning 2017-08-13 16:15:26 +02:00
Родитель 49a11036dc
Коммит 1f2597dca1
6 изменённых файлов: 24 добавлений и 2 удалений

Просмотреть файл

@ -86,6 +86,9 @@
<item android:id="@+id/set_as_homepage"
android:title="@string/contextmenu_set_as_homepage"/>
<item android:id="@+id/view_page_source"
android:title="@string/view_page_source"/>
</menu>
</item>

Просмотреть файл

@ -87,6 +87,9 @@
<item android:id="@+id/set_as_homepage"
android:title="@string/contextmenu_set_as_homepage"/>
<item android:id="@+id/view_page_source"
android:title="@string/view_page_source"/>
</menu>
</item>

Просмотреть файл

@ -86,6 +86,9 @@
<item android:id="@+id/set_as_homepage"
android:title="@string/contextmenu_set_as_homepage"/>
<item android:id="@+id/view_page_source"
android:title="@string/view_page_source"/>
</menu>
</item>

Просмотреть файл

@ -3540,6 +3540,7 @@ public class BrowserApp extends GeckoApp
final MenuItem historyList = aMenu.findItem(R.id.history_list);
final MenuItem saveAsPDF = aMenu.findItem(R.id.save_as_pdf);
final MenuItem print = aMenu.findItem(R.id.print);
final MenuItem viewPageSource = aMenu.findItem(R.id.view_page_source);
final MenuItem charEncoding = aMenu.findItem(R.id.char_encoding);
final MenuItem findInPage = aMenu.findItem(R.id.find_in_page);
final MenuItem desktopMode = aMenu.findItem(R.id.desktop_mode);
@ -3568,6 +3569,7 @@ public class BrowserApp extends GeckoApp
saveAsPDF.setEnabled(false);
print.setEnabled(false);
findInPage.setEnabled(false);
viewPageSource.setEnabled(false);
// NOTE: Use MenuUtils.safeSetEnabled because some actions might
// be on the BrowserToolbar context menu.
@ -3730,8 +3732,10 @@ public class BrowserApp extends GeckoApp
print.setEnabled(allowPDF);
print.setVisible(Versions.feature19Plus);
// Disable find in page for about:home, since it won't work on Java content.
findInPage.setEnabled(!isAboutHome(tab));
// Disable find in page and view source for about:home, since it won't work on Java content.
final boolean notInAboutHome = !isAboutHome(tab);
findInPage.setEnabled(notInAboutHome);
viewPageSource.setEnabled(notInAboutHome);
charEncoding.setVisible(GeckoPreferences.getCharEncodingState());
@ -3929,6 +3933,13 @@ public class BrowserApp extends GeckoApp
return true;
}
if (itemId == R.id.view_page_source) {
tab = Tabs.getInstance().getSelectedTab();
final GeckoBundle args = new GeckoBundle(1);
args.putInt("tabId", tab.getId());
getAppEventDispatcher().dispatch("Tab:ViewSource", args);
}
if (itemId == R.id.settings) {
intent = new Intent(this, GeckoPreferences.class);

Просмотреть файл

@ -453,6 +453,7 @@
<!ENTITY share_image_failed "Unable to share this image">
<!ENTITY save_as_pdf "Save as PDF">
<!ENTITY print "Print">
<!ENTITY view_page_source "View Page Source">
<!ENTITY find_in_page "Find in page">
<!ENTITY desktop_mode "Request desktop site">
<!ENTITY page "Page">

Просмотреть файл

@ -107,6 +107,7 @@
<string name="share_image_failed">&share_image_failed;</string>
<string name="save_as_pdf">&save_as_pdf;</string>
<string name="print">&print;</string>
<string name="view_page_source">&view_page_source;</string>
<string name="find_in_page">&find_in_page;</string>
<string name="desktop_mode">&desktop_mode;</string>
<string name="page">&page;</string>