Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / renderer_context_menu / render_view_context_menu_test_util.cc
blob0465a7144f8816943a7bde6ada1c5231257968ad
1 // Copyright 2014 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.
5 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_util.h"
6 #include "content/public/browser/web_contents.h"
7 #include "ui/base/models/menu_model.h"
9 using ui::MenuModel;
11 TestRenderViewContextMenu::TestRenderViewContextMenu(
12 content::RenderFrameHost* render_frame_host,
13 content::ContextMenuParams params)
14 : RenderViewContextMenu(render_frame_host, params) {}
16 TestRenderViewContextMenu::~TestRenderViewContextMenu() {}
18 // static
19 TestRenderViewContextMenu* TestRenderViewContextMenu::Create(
20 content::WebContents* web_contents,
21 const GURL& page_url,
22 const GURL& link_url,
23 const GURL& frame_url) {
24 content::ContextMenuParams params;
25 params.page_url = page_url;
26 params.link_url = link_url;
27 params.frame_url = frame_url;
28 TestRenderViewContextMenu* menu =
29 new TestRenderViewContextMenu(web_contents->GetMainFrame(), params);
30 menu->Init();
31 return menu;
34 bool TestRenderViewContextMenu::GetAcceleratorForCommandId(
35 int command_id,
36 ui::Accelerator* accelerator) {
37 // None of our commands have accelerators, so always return false.
38 return false;
41 bool TestRenderViewContextMenu::IsItemPresent(int command_id) {
42 return menu_model_.GetIndexOfCommandId(command_id) != -1;
45 bool TestRenderViewContextMenu::GetMenuModelAndItemIndex(
46 int command_id,
47 MenuModel** found_model,
48 int* found_index) {
49 std::vector<MenuModel*> models_to_search;
50 models_to_search.push_back(&menu_model_);
52 while (!models_to_search.empty()) {
53 MenuModel* model = models_to_search.back();
54 models_to_search.pop_back();
55 for (int i = 0; i < model->GetItemCount(); i++) {
56 if (model->GetCommandIdAt(i) == command_id) {
57 *found_model = model;
58 *found_index = i;
59 return true;
60 } else if (model->GetTypeAt(i) == MenuModel::TYPE_SUBMENU) {
61 models_to_search.push_back(model->GetSubmenuModelAt(i));
66 return false;
69 void TestRenderViewContextMenu::Show() {