Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java

Issue 1509713004: Add a default share button to the menu of Custom Tabs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser; 5 package org.chromium.chrome.browser;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.annotation.TargetApi; 8 import android.annotation.TargetApi;
9 import android.app.Activity; 9 import android.app.Activity;
10 import android.app.SearchManager; 10 import android.app.SearchManager;
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 public boolean onOptionsItemSelected(MenuItem item) { 894 public boolean onOptionsItemSelected(MenuItem item) {
895 if (item != null && onMenuOrKeyboardAction(item.getItemId(), true)) { 895 if (item != null && onMenuOrKeyboardAction(item.getItemId(), true)) {
896 return true; 896 return true;
897 } 897 }
898 return super.onOptionsItemSelected(item); 898 return super.onOptionsItemSelected(item);
899 } 899 }
900 900
901 /** 901 /**
902 * Triggered when the share menu item is selected. 902 * Triggered when the share menu item is selected.
903 * This creates and shows a share intent picker dialog or starts a share int ent directly. 903 * This creates and shows a share intent picker dialog or starts a share int ent directly.
904 *
905 * @param currentTab The {@link Tab} a user is watching.
906 * @param shareDirectly Whether it should share directly with the activity t hat was most 904 * @param shareDirectly Whether it should share directly with the activity t hat was most
907 * recently used to share. 905 * recently used to share.
908 * @param isIncognito Whether currentTab is incognito. 906 * @param isIncognito Whether currentTab is incognito.
909 */ 907 */
910 public void onShareMenuItemSelected(final Tab currentTab, 908 public void onShareMenuItemSelected(final boolean shareDirectly, boolean isI ncognito) {
911 final boolean shareDirectly, boolean isIncognito) { 909 final Tab currentTab = getActivityTab();
912 if (currentTab == null) return; 910 if (currentTab == null) return;
913 911
914 final Activity mainActivity = this; 912 final Activity mainActivity = this;
915 ContentBitmapCallback callback = new ContentBitmapCallback() { 913 ContentBitmapCallback callback = new ContentBitmapCallback() {
916 @Override 914 @Override
917 public void onFinishGetBitmap(Bitmap bitmap, int response) { 915 public void onFinishGetBitmap(Bitmap bitmap, int response) {
918 ShareHelper.share(shareDirectly, mainActivity, currentTa b.getTitle(), 916 ShareHelper.share(shareDirectly, mainActivity, currentTa b.getTitle(),
919 currentTab.getUrl(), bitmap); 917 currentTab.getUrl(), bitmap);
920 if (shareDirectly) { 918 if (shareDirectly) {
921 RecordUserAction.record("MobileMenuDirectShare"); 919 RecordUserAction.record("MobileMenuDirectShare");
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 RecordUserAction.record("MobileToolbarReload"); 1406 RecordUserAction.record("MobileToolbarReload");
1409 } 1407 }
1410 } else if (id == R.id.info_menu_id) { 1408 } else if (id == R.id.info_menu_id) {
1411 WebsiteSettingsPopup.show(this, currentTab.getProfile(), currentTab. getWebContents()); 1409 WebsiteSettingsPopup.show(this, currentTab.getProfile(), currentTab. getWebContents());
1412 } else if (id == R.id.open_history_menu_id) { 1410 } else if (id == R.id.open_history_menu_id) {
1413 currentTab.loadUrl( 1411 currentTab.loadUrl(
1414 new LoadUrlParams(UrlConstants.HISTORY_URL, PageTransition.A UTO_TOPLEVEL)); 1412 new LoadUrlParams(UrlConstants.HISTORY_URL, PageTransition.A UTO_TOPLEVEL));
1415 RecordUserAction.record("MobileMenuHistory"); 1413 RecordUserAction.record("MobileMenuHistory");
1416 StartupMetrics.getInstance().recordOpenedHistory(); 1414 StartupMetrics.getInstance().recordOpenedHistory();
1417 } else if (id == R.id.share_menu_id || id == R.id.direct_share_menu_id) { 1415 } else if (id == R.id.share_menu_id || id == R.id.direct_share_menu_id) {
1418 onShareMenuItemSelected(currentTab, id == R.id.direct_share_menu_id, 1416 onShareMenuItemSelected(id == R.id.direct_share_menu_id,
1419 getCurrentTabModel().isIncognito()); 1417 getCurrentTabModel().isIncognito());
1420 } else if (id == R.id.print_id) { 1418 } else if (id == R.id.print_id) {
1421 PrintingController printingController = getChromeApplication().getPr intingController(); 1419 PrintingController printingController = getChromeApplication().getPr intingController();
1422 if (printingController != null && !printingController.isBusy() 1420 if (printingController != null && !printingController.isBusy()
1423 && PrefServiceBridge.getInstance().isPrintingEnabled()) { 1421 && PrefServiceBridge.getInstance().isPrintingEnabled()) {
1424 printingController.startPrint(new TabPrinter(currentTab), 1422 printingController.startPrint(new TabPrinter(currentTab),
1425 new PrintManagerDelegateImpl(this)); 1423 new PrintManagerDelegateImpl(this));
1426 RecordUserAction.record("MobileMenuPrint"); 1424 RecordUserAction.record("MobileMenuPrint");
1427 } 1425 }
1428 } else if (id == R.id.add_to_homescreen_id) { 1426 } else if (id == R.id.add_to_homescreen_id) {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 public static int getThemeId() { 1645 public static int getThemeId() {
1648 boolean useLowEndTheme = 1646 boolean useLowEndTheme =
1649 SysUtils.isLowEndDevice() && Build.VERSION.SDK_INT >= Build.VERS ION_CODES.LOLLIPOP; 1647 SysUtils.isLowEndDevice() && Build.VERSION.SDK_INT >= Build.VERS ION_CODES.LOLLIPOP;
1650 return (useLowEndTheme ? R.style.MainTheme_LowEnd : R.style.MainTheme); 1648 return (useLowEndTheme ? R.style.MainTheme_LowEnd : R.style.MainTheme);
1651 } 1649 }
1652 1650
1653 private void setLowEndTheme() { 1651 private void setLowEndTheme() {
1654 if (getThemeId() == R.style.MainTheme_LowEnd) setTheme(R.style.MainTheme _LowEnd); 1652 if (getThemeId() == R.style.MainTheme_LowEnd) setTheme(R.style.MainTheme _LowEnd);
1655 } 1653 }
1656 } 1654 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698