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

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: Avoid annotaing share menu with null 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 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 public boolean onOptionsItemSelected(MenuItem item) { 904 public boolean onOptionsItemSelected(MenuItem item) {
905 if (item != null && onMenuOrKeyboardAction(item.getItemId(), true)) { 905 if (item != null && onMenuOrKeyboardAction(item.getItemId(), true)) {
906 return true; 906 return true;
907 } 907 }
908 return super.onOptionsItemSelected(item); 908 return super.onOptionsItemSelected(item);
909 } 909 }
910 910
911 /** 911 /**
912 * Triggered when the share menu item is selected. 912 * Triggered when the share menu item is selected.
913 * This creates and shows a share intent picker dialog or starts a share int ent directly. 913 * This creates and shows a share intent picker dialog or starts a share int ent directly.
914 *
915 * @param currentTab The {@link Tab} a user is watching.
916 * @param shareDirectly Whether it should share directly with the activity t hat was most 914 * @param shareDirectly Whether it should share directly with the activity t hat was most
917 * recently used to share. 915 * recently used to share.
918 * @param isIncognito Whether currentTab is incognito. 916 * @param isIncognito Whether currentTab is incognito.
919 */ 917 */
920 public void onShareMenuItemSelected(final Tab currentTab, 918 public void onShareMenuItemSelected(final boolean shareDirectly, boolean isI ncognito) {
921 final boolean shareDirectly, boolean isIncognito) { 919 final Tab currentTab = getActivityTab();
922 if (currentTab == null) return; 920 if (currentTab == null) return;
923 921
924 final Activity mainActivity = this; 922 final Activity mainActivity = this;
925 ContentBitmapCallback callback = new ContentBitmapCallback() { 923 ContentBitmapCallback callback = new ContentBitmapCallback() {
926 @Override 924 @Override
927 public void onFinishGetBitmap(Bitmap bitmap, int response) { 925 public void onFinishGetBitmap(Bitmap bitmap, int response) {
928 ShareHelper.share(shareDirectly, mainActivity, currentTa b.getTitle(), 926 ShareHelper.share(shareDirectly, mainActivity, currentTa b.getTitle(),
929 currentTab.getUrl(), bitmap); 927 currentTab.getUrl(), bitmap);
930 if (shareDirectly) { 928 if (shareDirectly) {
931 RecordUserAction.record("MobileMenuDirectShare"); 929 RecordUserAction.record("MobileMenuDirectShare");
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 RecordUserAction.record("MobileToolbarReload"); 1398 RecordUserAction.record("MobileToolbarReload");
1401 } 1399 }
1402 } else if (id == R.id.info_menu_id) { 1400 } else if (id == R.id.info_menu_id) {
1403 WebsiteSettingsPopup.show(this, currentTab.getProfile(), currentTab. getWebContents()); 1401 WebsiteSettingsPopup.show(this, currentTab.getProfile(), currentTab. getWebContents());
1404 } else if (id == R.id.open_history_menu_id) { 1402 } else if (id == R.id.open_history_menu_id) {
1405 currentTab.loadUrl( 1403 currentTab.loadUrl(
1406 new LoadUrlParams(UrlConstants.HISTORY_URL, PageTransition.A UTO_TOPLEVEL)); 1404 new LoadUrlParams(UrlConstants.HISTORY_URL, PageTransition.A UTO_TOPLEVEL));
1407 RecordUserAction.record("MobileMenuHistory"); 1405 RecordUserAction.record("MobileMenuHistory");
1408 StartupMetrics.getInstance().recordOpenedHistory(); 1406 StartupMetrics.getInstance().recordOpenedHistory();
1409 } else if (id == R.id.share_menu_id || id == R.id.direct_share_menu_id) { 1407 } else if (id == R.id.share_menu_id || id == R.id.direct_share_menu_id) {
1410 onShareMenuItemSelected(currentTab, id == R.id.direct_share_menu_id, 1408 onShareMenuItemSelected(id == R.id.direct_share_menu_id,
1411 getCurrentTabModel().isIncognito()); 1409 getCurrentTabModel().isIncognito());
1412 } else if (id == R.id.print_id) { 1410 } else if (id == R.id.print_id) {
1413 PrintingController printingController = getChromeApplication().getPr intingController(); 1411 PrintingController printingController = getChromeApplication().getPr intingController();
1414 if (printingController != null && !printingController.isBusy() 1412 if (printingController != null && !printingController.isBusy()
1415 && PrefServiceBridge.getInstance().isPrintingEnabled()) { 1413 && PrefServiceBridge.getInstance().isPrintingEnabled()) {
1416 printingController.startPrint(new TabPrinter(currentTab), 1414 printingController.startPrint(new TabPrinter(currentTab),
1417 new PrintManagerDelegateImpl(this)); 1415 new PrintManagerDelegateImpl(this));
1418 RecordUserAction.record("MobileMenuPrint"); 1416 RecordUserAction.record("MobileMenuPrint");
1419 } 1417 }
1420 } else if (id == R.id.add_to_homescreen_id) { 1418 } else if (id == R.id.add_to_homescreen_id) {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 public static int getThemeId() { 1637 public static int getThemeId() {
1640 boolean useLowEndTheme = 1638 boolean useLowEndTheme =
1641 SysUtils.isLowEndDevice() && Build.VERSION.SDK_INT >= Build.VERS ION_CODES.LOLLIPOP; 1639 SysUtils.isLowEndDevice() && Build.VERSION.SDK_INT >= Build.VERS ION_CODES.LOLLIPOP;
1642 return (useLowEndTheme ? R.style.MainTheme_LowEnd : R.style.MainTheme); 1640 return (useLowEndTheme ? R.style.MainTheme_LowEnd : R.style.MainTheme);
1643 } 1641 }
1644 1642
1645 private void setLowEndTheme() { 1643 private void setLowEndTheme() {
1646 if (getThemeId() == R.style.MainTheme_LowEnd) setTheme(R.style.MainTheme _LowEnd); 1644 if (getThemeId() == R.style.MainTheme_LowEnd) setTheme(R.style.MainTheme _LowEnd);
1647 } 1645 }
1648 } 1646 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698