From: Serg <serg.zhukovsky@gmail.com>
Date: Tue, 31 Jan 2017 22:12:27 -0500
Subject: Add exit menu item

Corrected Exit functionality
---
 chrome/android/java/res/menu/main_menu.xml                          | 2 ++
 .../java/src/org/chromium/chrome/browser/ChromeActivity.java        | 2 ++
 .../org/chromium/chrome/browser/init/ChromeLifetimeController.java  | 6 +++++-
 chrome/android/java/strings/android_chrome_strings.grd              | 3 +++
 4 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/chrome/android/java/res/menu/main_menu.xml b/chrome/android/java/res/menu/main_menu.xml
--- a/chrome/android/java/res/menu/main_menu.xml
+++ b/chrome/android/java/res/menu/main_menu.xml
@@ -80,6 +80,8 @@
             android:title="@string/menu_help" />
         <item android:id="@+id/enter_vr_id"
             android:title="@string/enter_vr" />
+        <item android:id="@+id/exit_id"
+            android:title="@string/menu_exit" />
     </group>
 
     <!-- Items shown only in the tab switcher -->
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
@@ -2116,6 +2116,8 @@ public abstract class ChromeActivity<C extends ChromeActivityComponent>
             RecordUserAction.record("MobileMenuSettings");
         } else if (id == R.id.show_menu) {
             showAppMenuForKeyboardEvent();
+        } else if (id == R.id.exit_id) {
+            ApplicationLifetime.terminate(false);
         } else if (id == R.id.find_in_page_id) {
             if (mFindToolbarManager == null) return false;
 
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/init/ChromeLifetimeController.java b/chrome/android/java/src/org/chromium/chrome/browser/init/ChromeLifetimeController.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/init/ChromeLifetimeController.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/init/ChromeLifetimeController.java
@@ -82,7 +82,11 @@ class ChromeLifetimeController implements ApplicationLifetime.Observer,
 
         // Kick off a timer to kill the process after a delay, which fires only if the Activities
         // take too long to be finished.
-        mHandler.postDelayed(mRestartRunnable, WATCHDOG_DELAY_MS);
+        if (restart) {
+            mHandler.postDelayed(mRestartRunnable, WATCHDOG_DELAY_MS);
+        } else {
+            fireBrowserRestartActivityIntent();
+        }
     }
 
     @Override
diff --git a/chrome/android/java/strings/android_chrome_strings.grd b/chrome/android/java/strings/android_chrome_strings.grd
--- a/chrome/android/java/strings/android_chrome_strings.grd
+++ b/chrome/android/java/strings/android_chrome_strings.grd
@@ -3075,6 +3075,9 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
       <message name="IDS_MENU_PREFERENCES" desc="Menu item for opening browser preferences. [CHAR-LIMIT=27]">
         Settings
       </message>
+      <message name="IDS_MENU_EXIT" desc="Menu item for exit browser. [CHAR-LIMIT=27]">
+        Exit
+      </message>
       <message name="IDS_MENU_CLOSE_ALL_TABS" desc="Menu item for closing all open tabs. [CHAR-LIMIT=27]">
         Close all tabs
       </message>
-- 
2.11.0

