Logo Search packages:      
Sourcecode: chromium-browser version File versions  Download package

render_view_context_menu_external_win.cc

// 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/views/tab_contents/render_view_context_menu_external_win.h"

#include <algorithm>

#include "chrome/browser/tab_contents/tab_contents.h"
#include "grit/generated_resources.h"

RenderViewContextMenuExternalWin::RenderViewContextMenuExternalWin(
    TabContents* tab_contents,
    const ContextMenuParams& params,
    const std::vector<int> disabled_ids)
    : RenderViewContextMenuWin(tab_contents, params),
      disabled_menu_ids_(disabled_ids) {
}

void RenderViewContextMenuExternalWin::AppendMenuItem(int id) {
  std::vector<int>::iterator found =
      std::find(disabled_menu_ids_.begin(), disabled_menu_ids_.end(), id);

  if (found == disabled_menu_ids_.end()) {
    RenderViewContextMenuWin::AppendMenuItem(id);
  }
}

void RenderViewContextMenuExternalWin::DoInit() {
  RenderViewContextMenuWin::DoInit();
  // The external tab container needs to be notified by command
  // and not by index. So we are turning off the MNS_NOTIFYBYPOS
  // style.
  HMENU menu = GetMenuHandle();
  DCHECK(menu != NULL);

  MENUINFO mi = {0};
  mi.cbSize = sizeof(mi);
  mi.fMask = MIM_STYLE | MIM_MENUDATA;
  mi.dwMenuData = reinterpret_cast<ULONG_PTR>(this);
  SetMenuInfo(menu, &mi);
}

void RenderViewContextMenuExternalWin::ExecuteItemCommand(int id) {
  switch (id) {
    case IDS_CONTENT_CONTEXT_RELOAD:
      // Prevent the modal "Resubmit form post" dialog from appearing in the
      // context of an external context menu.
      source_tab_contents_->controller().Reload(false);
      break;
    default:
      RenderViewContextMenu::ExecuteItemCommand(id);
      break;
  }
}

Generated by  Doxygen 1.6.0   Back to index