<commit_before>// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/extensions/extension_action_context_menu_model.h"

#include "app/l10n_util.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/profile.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/url_constants.h"
#include "grit/generated_resources.h"

enum MenuEntries {
  NAME = 0,
  CONFIGURE,
  DISABLE,
  UNINSTALL,
  MANAGE,
};

ExtensionActionContextMenuModel::ExtensionActionContextMenuModel(
    Extension* extension)
  : ALLOW_THIS_IN_INITIALIZER_LIST(SimpleMenuModel(this)),
    extension_(extension) {
  AddItem(NAME, UTF8ToUTF16(extension->name()));
  AddSeparator();
  AddItemWithStringId(CONFIGURE, IDS_EXTENSIONS_OPTIONS);
  AddItemWithStringId(DISABLE, IDS_EXTENSIONS_DISABLE);
  AddItemWithStringId(UNINSTALL, IDS_EXTENSIONS_UNINSTALL);
  AddSeparator();

  AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSIONS);
}

ExtensionActionContextMenuModel::~ExtensionActionContextMenuModel() {
}

bool ExtensionActionContextMenuModel::IsCommandIdChecked(int command_id) const {
  return false;
}

bool ExtensionActionContextMenuModel::IsCommandIdEnabled(int command_id) const {
  if (command_id == CONFIGURE)
    return extension_->options_url().spec().length() > 0;
  return true;
}

bool ExtensionActionContextMenuModel::GetAcceleratorForCommandId(<commit_msg>Fix 33138: Clicking on the extension name for an extension downloaded off the web (non-gallery) goes to the Gallery page (and shows id not found). We now disable this link for non-gallery extensions.<commit_after>// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/extensions/extension_action_context_menu_model.h"

#include "app/l10n_util.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/profile.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/url_constants.h"
#include "grit/generated_resources.h"

enum MenuEntries {
  NAME = 0,
  CONFIGURE,
  DISABLE,
  UNINSTALL,
  MANAGE,
};

ExtensionActionContextMenuModel::ExtensionActionContextMenuModel(
    Extension* extension)
  : ALLOW_THIS_IN_INITIALIZER_LIST(SimpleMenuModel(this)),
    extension_(extension) {
  AddItem(NAME, UTF8ToUTF16(extension->name()));
  AddSeparator();
  AddItemWithStringId(CONFIGURE, IDS_EXTENSIONS_OPTIONS);
  AddItemWithStringId(DISABLE, IDS_EXTENSIONS_DISABLE);
  AddItemWithStringId(UNINSTALL, IDS_EXTENSIONS_UNINSTALL);
  AddSeparator();

  AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSIONS);
}

ExtensionActionContextMenuModel::~ExtensionActionContextMenuModel() {
}

bool ExtensionActionContextMenuModel::IsCommandIdChecked(int command_id) const {
  return false;
}

bool ExtensionActionContextMenuModel::IsCommandIdEnabled(int command_id) const {
  if (command_id == CONFIGURE) {
    return extension_->options_url().spec().length() > 0;
  } else if (command_id == NAME) {
    // The NAME links to the gallery page, which only makes sense if Google is
    // hosting the extension. For other 3rd party extensions we don't have a
    // homepage url, so we just disable this menu item on those cases, at least
    // for now.
    return extension_->update_url().DomainIs("google.com");
  }
  return true;
}

bool ExtensionActionContextMenuModel::GetAcceleratorForCommandId(
{'fraction_non_alphanumeric': 0.10007737941707506, 'fraction_numerical': 0.007222078927005417, 'mean_word_length': 6.063752276867031, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6646898', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1181, 'n_words': 269}