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

Side by Side Diff: chrome/browser/extensions/extension_context_menu_browsertest.cc

Issue 9382037: Move ContextMenuParams struct from webkit/glue to content/public/common. The reasons are: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 8 years, 10 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "base/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "chrome/app/chrome_command_ids.h" 6 #include "chrome/app/chrome_command_ids.h"
7 #include "chrome/browser/extensions/extension_browsertest.h" 7 #include "chrome/browser/extensions/extension_browsertest.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_test_message_listener.h" 9 #include "chrome/browser/extensions/extension_test_message_listener.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/tab_contents/render_view_context_menu.h" 11 #include "chrome/browser/tab_contents/render_view_context_menu.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_list.h" 13 #include "chrome/browser/ui/browser_list.h"
14 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/public/common/context_menu_params.h"
15 #include "net/base/mock_host_resolver.h" 16 #include "net/base/mock_host_resolver.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
17 #include "ui/base/models/menu_model.h" 18 #include "ui/base/models/menu_model.h"
18 #include "webkit/glue/context_menu.h"
19 19
20 using WebKit::WebContextMenuData; 20 using WebKit::WebContextMenuData;
21 using content::WebContents; 21 using content::WebContents;
22 using ui::MenuModel; 22 using ui::MenuModel;
23 23
24 namespace { 24 namespace {
25 // This test class helps us sidestep platform-specific issues with popping up a 25 // This test class helps us sidestep platform-specific issues with popping up a
26 // real context menu, while still running through the actual code in 26 // real context menu, while still running through the actual code in
27 // RenderViewContextMenu where extension items get added and executed. 27 // RenderViewContextMenu where extension items get added and executed.
28 class TestRenderViewContextMenu : public RenderViewContextMenu { 28 class TestRenderViewContextMenu : public RenderViewContextMenu {
29 public: 29 public:
30 TestRenderViewContextMenu(WebContents* web_contents, 30 TestRenderViewContextMenu(WebContents* web_contents,
31 const ContextMenuParams& params) 31 const content::ContextMenuParams& params)
32 : RenderViewContextMenu(web_contents, params) {} 32 : RenderViewContextMenu(web_contents, params) {}
33 33
34 virtual ~TestRenderViewContextMenu() {} 34 virtual ~TestRenderViewContextMenu() {}
35 35
36 bool HasExtensionItemWithLabel(const std::string& label) { 36 bool HasExtensionItemWithLabel(const std::string& label) {
37 string16 label16 = UTF8ToUTF16(label); 37 string16 label16 = UTF8ToUTF16(label);
38 std::map<int, ExtensionMenuItem::Id>::iterator i; 38 std::map<int, ExtensionMenuItem::Id>::iterator i;
39 for (i = extension_item_map_.begin(); i != extension_item_map_.end(); ++i) { 39 for (i = extension_item_map_.begin(); i != extension_item_map_.end(); ++i) {
40 const ExtensionMenuItem::Id& id = i->second; 40 const ExtensionMenuItem::Id& id = i->second;
41 string16 tmp_label; 41 string16 tmp_label;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 test_data_dir_.AppendASCII("context_menus").AppendASCII(subdirectory); 131 test_data_dir_.AppendASCII("context_menus").AppendASCII(subdirectory);
132 return LoadExtensionIncognito(extension_dir); 132 return LoadExtensionIncognito(extension_dir);
133 } 133 }
134 134
135 TestRenderViewContextMenu* CreateMenu(Browser* browser, 135 TestRenderViewContextMenu* CreateMenu(Browser* browser,
136 const GURL& page_url, 136 const GURL& page_url,
137 const GURL& link_url, 137 const GURL& link_url,
138 const GURL& frame_url) { 138 const GURL& frame_url) {
139 WebContents* web_contents = browser->GetSelectedWebContents(); 139 WebContents* web_contents = browser->GetSelectedWebContents();
140 WebContextMenuData data; 140 WebContextMenuData data;
141 ContextMenuParams params(data); 141 content::ContextMenuParams params(data);
142 params.page_url = page_url; 142 params.page_url = page_url;
143 params.link_url = link_url; 143 params.link_url = link_url;
144 params.frame_url = frame_url; 144 params.frame_url = frame_url;
145 TestRenderViewContextMenu* menu = 145 TestRenderViewContextMenu* menu =
146 new TestRenderViewContextMenu(web_contents, params); 146 new TestRenderViewContextMenu(web_contents, params);
147 menu->Init(); 147 menu->Init();
148 return menu; 148 return menu;
149 } 149 }
150 150
151 // Shortcut to return the current ExtensionMenuManager. 151 // Shortcut to return the current ExtensionMenuManager.
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 ASSERT_TRUE(MenuHasItemWithLabel( 460 ASSERT_TRUE(MenuHasItemWithLabel(
461 page_url, GURL(), no_frame_url, std::string("Page item"))); 461 page_url, GURL(), no_frame_url, std::string("Page item")));
462 ASSERT_FALSE(MenuHasItemWithLabel( 462 ASSERT_FALSE(MenuHasItemWithLabel(
463 page_url, GURL(), no_frame_url, std::string("Frame item"))); 463 page_url, GURL(), no_frame_url, std::string("Frame item")));
464 464
465 ASSERT_TRUE(MenuHasItemWithLabel( 465 ASSERT_TRUE(MenuHasItemWithLabel(
466 page_url, GURL(), frame_url, std::string("Page item"))); 466 page_url, GURL(), frame_url, std::string("Page item")));
467 ASSERT_TRUE(MenuHasItemWithLabel( 467 ASSERT_TRUE(MenuHasItemWithLabel(
468 page_url, GURL(), frame_url, std::string("Frame item"))); 468 page_url, GURL(), frame_url, std::string("Frame item")));
469 } 469 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698