OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.toolbar; |
| 6 |
| 7 import android.content.Context; |
| 8 import android.util.AttributeSet; |
| 9 import android.view.ContextMenu; |
| 10 import android.view.ContextMenu.ContextMenuInfo; |
| 11 import android.view.Menu; |
| 12 import android.view.MenuItem; |
| 13 import android.view.View; |
| 14 import android.view.View.OnCreateContextMenuListener; |
| 15 |
| 16 import com.google.android.apps.chrome.R; |
| 17 |
| 18 import org.chromium.chrome.browser.partnercustomizations.HomepageManager; |
| 19 import org.chromium.chrome.browser.widget.TintedImageButton; |
| 20 |
| 21 /** |
| 22 * View that displays the home page button. |
| 23 */ |
| 24 public class HomePageButton extends TintedImageButton |
| 25 implements OnCreateContextMenuListener, MenuItem.OnMenuItemClickListener
{ |
| 26 |
| 27 private static final int ID_REMOVE = 0; |
| 28 |
| 29 /** Constructor inflating from XML. */ |
| 30 public HomePageButton(Context context, AttributeSet attrs) { |
| 31 super(context, attrs); |
| 32 setOnCreateContextMenuListener(this); |
| 33 } |
| 34 |
| 35 @Override |
| 36 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo me
nuInfo) { |
| 37 menu.add(Menu.NONE, ID_REMOVE, Menu.NONE, R.string.remove) |
| 38 .setOnMenuItemClickListener(this); |
| 39 } |
| 40 |
| 41 @Override |
| 42 public boolean onMenuItemClick(MenuItem item) { |
| 43 assert item.getItemId() == ID_REMOVE; |
| 44 HomepageManager.getInstance(getContext()).setPrefHomepageEnabled(false); |
| 45 return true; |
| 46 } |
| 47 } |
OLD | NEW |