diff options
40 files changed, 190 insertions, 153 deletions
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index f60a766..ee6ebed 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2013 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. @@ -79,6 +79,7 @@ #include "content/public/browser/user_metrics.h" #include "content/public/browser/web_contents.h" #include "content/public/common/content_restriction.h" +#include "content/public/common/menu_item.h" #include "content/public/common/ssl_status.h" #include "content/public/common/url_utils.h" #include "extensions/browser/view_type_utils.h" @@ -91,7 +92,6 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/text/text_elider.h" #include "ui/gfx/favicon_size.h" -#include "webkit/common/webmenuitem.h" using WebKit::WebContextMenuData; using WebKit::WebMediaPlayerAction; @@ -258,14 +258,14 @@ WindowOpenDisposition ForceNewTabDispositionFromEventFlags( return disposition == CURRENT_TAB ? NEW_FOREGROUND_TAB : disposition; } -bool IsCustomItemEnabled(const std::vector<WebMenuItem>& items, int id) { +bool IsCustomItemEnabled(const std::vector<content::MenuItem>& items, int id) { DCHECK(id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST); for (size_t i = 0; i < items.size(); ++i) { int action_id = IDC_CONTENT_CONTEXT_CUSTOM_FIRST + items[i].action; if (action_id == id) return items[i].enabled; - if (items[i].type == WebMenuItem::SUBMENU) { + if (items[i].type == content::MenuItem::SUBMENU) { if (IsCustomItemEnabled(items[i].submenu, id)) return true; } @@ -273,14 +273,14 @@ bool IsCustomItemEnabled(const std::vector<WebMenuItem>& items, int id) { return false; } -bool IsCustomItemChecked(const std::vector<WebMenuItem>& items, int id) { +bool IsCustomItemChecked(const std::vector<content::MenuItem>& items, int id) { DCHECK(id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST); for (size_t i = 0; i < items.size(); ++i) { int action_id = IDC_CONTENT_CONTEXT_CUSTOM_FIRST + items[i].action; if (action_id == id) return items[i].checked; - if (items[i].type == WebMenuItem::SUBMENU) { + if (items[i].type == content::MenuItem::SUBMENU) { if (IsCustomItemChecked(items[i].submenu, id)) return true; } @@ -291,7 +291,7 @@ bool IsCustomItemChecked(const std::vector<WebMenuItem>& items, int id) { const size_t kMaxCustomMenuDepth = 5; const size_t kMaxCustomMenuTotalItems = 1000; -void AddCustomItemsToMenu(const std::vector<WebMenuItem>& items, +void AddCustomItemsToMenu(const std::vector<content::MenuItem>& items, size_t depth, size_t* total_items, ui::SimpleMenuModel::Delegate* delegate, @@ -312,24 +312,24 @@ void AddCustomItemsToMenu(const std::vector<WebMenuItem>& items, } (*total_items)++; switch (items[i].type) { - case WebMenuItem::OPTION: + case content::MenuItem::OPTION: menu_model->AddItem( items[i].action + IDC_CONTENT_CONTEXT_CUSTOM_FIRST, items[i].label); break; - case WebMenuItem::CHECKABLE_OPTION: + case content::MenuItem::CHECKABLE_OPTION: menu_model->AddCheckItem( items[i].action + IDC_CONTENT_CONTEXT_CUSTOM_FIRST, items[i].label); break; - case WebMenuItem::GROUP: + case content::MenuItem::GROUP: // TODO(viettrungluu): I don't know what this is supposed to do. NOTREACHED(); break; - case WebMenuItem::SEPARATOR: + case content::MenuItem::SEPARATOR: menu_model->AddSeparator(ui::NORMAL_SEPARATOR); break; - case WebMenuItem::SUBMENU: { + case content::MenuItem::SUBMENU: { ui::SimpleMenuModel* submenu = new ui::SimpleMenuModel(delegate); AddCustomItemsToMenu(items[i].submenu, depth + 1, total_items, delegate, submenu); diff --git a/chrome/browser/ui/webui/ntp/android/context_menu_handler.cc b/chrome/browser/ui/webui/ntp/android/context_menu_handler.cc index d323da0..75a0d81 100644 --- a/chrome/browser/ui/webui/ntp/android/context_menu_handler.cc +++ b/chrome/browser/ui/webui/ntp/android/context_menu_handler.cc @@ -70,7 +70,7 @@ void ContextMenuHandler::HandleShowContextMenu( return; } - WebMenuItem menu_item; + content::MenuItem menu_item; menu_item.action = id; if (!item_list_value->GetString(1, &(menu_item.label))) { Value* value = NULL; diff --git a/chrome/renderer/pepper/pepper_flash_menu_host.cc b/chrome/renderer/pepper/pepper_flash_menu_host.cc index 9924c21..d8799d2 100644 --- a/chrome/renderer/pepper/pepper_flash_menu_host.cc +++ b/chrome/renderer/pepper/pepper_flash_menu_host.cc @@ -14,7 +14,6 @@ #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/serialized_flash_menu.h" #include "ui/gfx/point.h" -#include "webkit/common/webmenuitem.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" namespace chrome { @@ -35,11 +34,11 @@ const size_t kMaxMenuIdMapEntries = 501; // Converts menu data from one form to another. // - |depth| is the current nested depth (call it starting with 0). // - |menu_id_map| is such that |menu_id_map[output_item.action] == -// input_item.id| (where |action| is what a |WebMenuItem| has, |id| is what a +// input_item.id| (where |action| is what a |MenuItem| has, |id| is what a // |PP_Flash_MenuItem| has). bool ConvertMenuData(const PP_Flash_Menu* in_menu, size_t depth, - std::vector<WebMenuItem>* out_menu, + std::vector<content::MenuItem>* out_menu, std::vector<int32_t>* menu_id_map) { if (depth > kMaxMenuDepth || !in_menu) return false; @@ -53,21 +52,21 @@ bool ConvertMenuData(const PP_Flash_Menu* in_menu, if (!in_menu->items || in_menu->count > kMaxMenuEntries) return false; for (uint32_t i = 0; i < in_menu->count; i++) { - WebMenuItem item; + content::MenuItem item; PP_Flash_MenuItem_Type type = in_menu->items[i].type; switch (type) { case PP_FLASH_MENUITEM_TYPE_NORMAL: - item.type = WebMenuItem::OPTION; + item.type = content::MenuItem::OPTION; break; case PP_FLASH_MENUITEM_TYPE_CHECKBOX: - item.type = WebMenuItem::CHECKABLE_OPTION; + item.type = content::MenuItem::CHECKABLE_OPTION; break; case PP_FLASH_MENUITEM_TYPE_SEPARATOR: - item.type = WebMenuItem::SEPARATOR; + item.type = content::MenuItem::SEPARATOR; break; case PP_FLASH_MENUITEM_TYPE_SUBMENU: - item.type = WebMenuItem::SUBMENU; + item.type = content::MenuItem::SUBMENU; break; default: return false; diff --git a/chrome/renderer/pepper/pepper_flash_menu_host.h b/chrome/renderer/pepper/pepper_flash_menu_host.h index 858ab4c..51cc42c 100644 --- a/chrome/renderer/pepper/pepper_flash_menu_host.h +++ b/chrome/renderer/pepper/pepper_flash_menu_host.h @@ -13,10 +13,9 @@ #include "ppapi/host/host_message_context.h" #include "ppapi/host/resource_host.h" -struct WebMenuItem; - namespace content { class RendererPpapiHost; +struct MenuItem; } namespace ppapi { @@ -55,9 +54,9 @@ class PepperFlashMenuHost : public ppapi::host::ResourceHost, bool showing_context_menu_; int context_menu_request_id_; - std::vector<WebMenuItem> menu_data_; + std::vector<content::MenuItem> menu_data_; - // We send |WebMenuItem|s, which have an |unsigned| "action" field instead of + // We send |MenuItem|s, which have an |unsigned| "action" field instead of // an |int32_t| ID. (CONTENT also limits the range of valid values for // actions.) This maps actions to IDs. std::vector<int32_t> menu_id_map_; diff --git a/chrome/renderer/plugins/plugin_placeholder.cc b/chrome/renderer/plugins/plugin_placeholder.cc index a750e6b..126f5ce 100644 --- a/chrome/renderer/plugins/plugin_placeholder.cc +++ b/chrome/renderer/plugins/plugin_placeholder.cc @@ -31,7 +31,6 @@ #include "third_party/WebKit/public/web/WebElement.h" #include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebInputEvent.h" -#include "third_party/WebKit/public/web/WebMenuItemInfo.h" #include "third_party/WebKit/public/web/WebPluginContainer.h" #include "third_party/WebKit/public/web/WebScriptSource.h" #include "third_party/WebKit/public/web/WebView.h" @@ -50,7 +49,6 @@ using WebKit::WebContextMenuData; using WebKit::WebDocument; using WebKit::WebElement; using WebKit::WebFrame; -using WebKit::WebMenuItemInfo; using WebKit::WebMouseEvent; using WebKit::WebNode; using WebKit::WebPlugin; @@ -91,7 +89,7 @@ std::string GetYoutubeVideoId(const WebPluginParams& params) { return video_id; } #endif -} +} // namespace // static PluginPlaceholder* PluginPlaceholder::CreateMissingPlugin( @@ -494,36 +492,28 @@ void PluginPlaceholder::ShowContextMenu(const WebMouseEvent& event) { content::ContextMenuParams params; - WebMenuItemInfo name_item; + content::MenuItem name_item; name_item.label = title_; - name_item.hasTextDirectionOverride = false; - name_item.textDirection = WebKit::WebTextDirectionDefault; - params.custom_items.push_back(WebMenuItem(name_item)); + params.custom_items.push_back(name_item); - WebMenuItemInfo separator_item; - separator_item.type = WebMenuItemInfo::Separator; - params.custom_items.push_back(WebMenuItem(separator_item)); + content::MenuItem separator_item; + separator_item.type = content::MenuItem::SEPARATOR; + params.custom_items.push_back(separator_item); if (!plugin_info_.path.value().empty()) { - WebMenuItemInfo run_item; + content::MenuItem run_item; run_item.action = chrome::MENU_COMMAND_PLUGIN_RUN; // Disable this menu item if the plugin is blocked by policy. run_item.enabled = allow_loading_; - run_item.label = WebString::fromUTF8( - l10n_util::GetStringUTF8(IDS_CONTENT_CONTEXT_PLUGIN_RUN).c_str()); - run_item.hasTextDirectionOverride = false; - run_item.textDirection = WebKit::WebTextDirectionDefault; - params.custom_items.push_back(WebMenuItem(run_item)); + run_item.label = l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLUGIN_RUN); + params.custom_items.push_back(run_item); } - WebMenuItemInfo hide_item; + content::MenuItem hide_item; hide_item.action = chrome::MENU_COMMAND_PLUGIN_HIDE; hide_item.enabled = true; - hide_item.label = WebString::fromUTF8( - l10n_util::GetStringUTF8(IDS_CONTENT_CONTEXT_PLUGIN_HIDE).c_str()); - hide_item.hasTextDirectionOverride = false; - hide_item.textDirection = WebKit::WebTextDirectionDefault; - params.custom_items.push_back(WebMenuItem(hide_item)); + hide_item.label = l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLUGIN_HIDE); + params.custom_items.push_back(hide_item); params.x = event.windowX; params.y = event.windowY; diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc index ef94c7f..9ee3838 100644 --- a/content/browser/android/content_view_core_impl.cc +++ b/content/browser/android/content_view_core_impl.cc @@ -42,6 +42,7 @@ #include "content/public/browser/web_contents.h" #include "content/public/common/content_client.h" #include "content/public/common/content_switches.h" +#include "content/public/common/menu_item.h" #include "content/public/common/page_transition_types.h" #include "jni/ContentViewCore_jni.h" #include "third_party/WebKit/public/web/WebBindings.h" @@ -54,7 +55,6 @@ #include "ui/gfx/size_conversions.h" #include "ui/gfx/size_f.h" #include "webkit/common/user_agent/user_agent_util.h" -#include "webkit/common/webmenuitem.h" using base::android::AttachCurrentThread; using base::android::ConvertJavaStringToUTF16; @@ -430,7 +430,7 @@ void ContentViewCoreImpl::OnBackgroundColorChanged(SkColor color) { } void ContentViewCoreImpl::ShowSelectPopupMenu( - const std::vector<WebMenuItem>& items, int selected_item, bool multiple) { + const std::vector<MenuItem>& items, int selected_item, bool multiple) { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); if (j_obj.is_null()) @@ -465,7 +465,7 @@ void ContentViewCoreImpl::ShowSelectPopupMenu( for (size_t i = 0; i < items.size(); ++i) { labels.push_back(items[i].label); jint enabled = - (items[i].type == WebMenuItem::GROUP ? POPUP_ITEM_TYPE_GROUP : + (items[i].type == MenuItem::GROUP ? POPUP_ITEM_TYPE_GROUP : (items[i].enabled ? POPUP_ITEM_TYPE_ENABLED : POPUP_ITEM_TYPE_DISABLED)); env->SetIntArrayRegion(enabled_array.obj(), i, 1, &enabled); diff --git a/content/browser/android/content_view_core_impl.h b/content/browser/android/content_view_core_impl.h index 2464706..967f2af 100644 --- a/content/browser/android/content_view_core_impl.h +++ b/content/browser/android/content_view_core_impl.h @@ -24,8 +24,6 @@ #include "ui/gfx/rect_f.h" #include "url/gurl.h" -struct WebMenuItem; - namespace ui { class ViewAndroid; class WindowAndroid; @@ -33,6 +31,7 @@ class WindowAndroid; namespace content { class RenderWidgetHostViewAndroid; +struct MenuItem; // TODO(jrg): this is a shell. Upstream the rest. class ContentViewCoreImpl : public ContentViewCore, @@ -231,7 +230,7 @@ class ContentViewCoreImpl : public ContentViewCore, // |multiple| defines if it should support multi-select. // If not |multiple|, |selected_item| sets the initially selected item. // Otherwise, item's "checked" flag selects it. - void ShowSelectPopupMenu(const std::vector<WebMenuItem>& items, + void ShowSelectPopupMenu(const std::vector<MenuItem>& items, int selected_item, bool multiple); diff --git a/content/browser/renderer_host/popup_menu_helper_mac.h b/content/browser/renderer_host/popup_menu_helper_mac.h index fa143cb..332fecd 100644 --- a/content/browser/renderer_host/popup_menu_helper_mac.h +++ b/content/browser/renderer_host/popup_menu_helper_mac.h @@ -13,12 +13,11 @@ #include "content/public/browser/notification_registrar.h" #include "ui/gfx/rect.h" -struct WebMenuItem; - namespace content { class RenderViewHost; class RenderViewHostImpl; class RenderWidgetHostViewMac; +struct MenuItem; class PopupMenuHelper : public NotificationObserver { public: @@ -33,7 +32,7 @@ class PopupMenuHelper : public NotificationObserver { int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection); diff --git a/content/browser/renderer_host/popup_menu_helper_mac.mm b/content/browser/renderer_host/popup_menu_helper_mac.mm index d3f7063..65340ae 100644 --- a/content/browser/renderer_host/popup_menu_helper_mac.mm +++ b/content/browser/renderer_host/popup_menu_helper_mac.mm @@ -36,7 +36,7 @@ void PopupMenuHelper::ShowPopupMenu( int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection) { // Only single selection list boxes show a popup on Mac. diff --git a/content/browser/renderer_host/render_view_host_unittest.cc b/content/browser/renderer_host/render_view_host_unittest.cc index 5661316..810439d 100644 --- a/content/browser/renderer_host/render_view_host_unittest.cc +++ b/content/browser/renderer_host/render_view_host_unittest.cc @@ -122,7 +122,7 @@ class MockDraggingRenderViewHostDelegateView int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection) OVERRIDE {} virtual void StartDragging(const DropData& drop_data, diff --git a/content/browser/renderer_host/webmenurunner_mac.h b/content/browser/renderer_host/webmenurunner_mac.h index 28afb19..e1ce91a 100644 --- a/content/browser/renderer_host/webmenurunner_mac.h +++ b/content/browser/renderer_host/webmenurunner_mac.h @@ -10,7 +10,7 @@ #include <vector> #include "base/mac/scoped_nsobject.h" -#include "webkit/common/webmenuitem.h" +#include "content/public/common/menu_item.h" // WebMenuRunner --------------------------------------------------------------- @@ -39,7 +39,7 @@ } // Initializes the MenuDelegate with a list of items sent from WebKit. -- (id)initWithItems:(const std::vector<WebMenuItem>&)items +- (id)initWithItems:(const std::vector<content::MenuItem>&)items fontSize:(CGFloat)fontSize rightAligned:(BOOL)rightAligned; diff --git a/content/browser/renderer_host/webmenurunner_mac.mm b/content/browser/renderer_host/webmenurunner_mac.mm index 2ff5137..a81d2c9 100644 --- a/content/browser/renderer_host/webmenurunner_mac.mm +++ b/content/browser/renderer_host/webmenurunner_mac.mm @@ -9,7 +9,7 @@ @interface WebMenuRunner (PrivateAPI) // Worker function used during initialization. -- (void)addItem:(const WebMenuItem&)item; +- (void)addItem:(const content::MenuItem&)item; // A callback for the menu controller object to call when an item is selected // from the menu. This is not called if the menu is dismissed without a @@ -20,7 +20,7 @@ @implementation WebMenuRunner -- (id)initWithItems:(const std::vector<WebMenuItem>&)items +- (id)initWithItems:(const std::vector<content::MenuItem>&)items fontSize:(CGFloat)fontSize rightAligned:(BOOL)rightAligned { if ((self = [super init])) { @@ -35,8 +35,8 @@ return self; } -- (void)addItem:(const WebMenuItem&)item { - if (item.type == WebMenuItem::SEPARATOR) { +- (void)addItem:(const content::MenuItem&)item { + if (item.type == content::MenuItem::SEPARATOR) { [menu_ addItem:[NSMenuItem separatorItem]]; return; } @@ -45,11 +45,11 @@ NSMenuItem* menuItem = [menu_ addItemWithTitle:title action:@selector(menuItemSelected:) keyEquivalent:@""]; - if (!item.toolTip.empty()) { - NSString* toolTip = base::SysUTF16ToNSString(item.toolTip); + if (!item.tool_tip.empty()) { + NSString* toolTip = base::SysUTF16ToNSString(item.tool_tip); [menuItem setToolTip:toolTip]; } - [menuItem setEnabled:(item.enabled && item.type != WebMenuItem::GROUP)]; + [menuItem setEnabled:(item.enabled && item.type != content::MenuItem::GROUP)]; [menuItem setTarget:self]; // Set various alignment/language attributes. Note that many (if not most) of diff --git a/content/browser/web_contents/interstitial_page_impl.cc b/content/browser/web_contents/interstitial_page_impl.cc index 3aaaba8..5ab2134 100644 --- a/content/browser/web_contents/interstitial_page_impl.cc +++ b/content/browser/web_contents/interstitial_page_impl.cc @@ -77,7 +77,7 @@ class InterstitialPageImpl::InterstitialPageRVHDelegateView int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection) OVERRIDE; virtual void StartDragging(const DropData& drop_data, @@ -769,7 +769,7 @@ void InterstitialPageImpl::InterstitialPageRVHDelegateView::ShowPopupMenu( int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection) { NOTREACHED() << "InterstitialPage does not support showing popup menus."; diff --git a/content/browser/web_contents/web_contents_view_android.cc b/content/browser/web_contents/web_contents_view_android.cc index 016858c..1f7b247 100644 --- a/content/browser/web_contents/web_contents_view_android.cc +++ b/content/browser/web_contents/web_contents_view_android.cc @@ -188,7 +188,7 @@ void WebContentsViewAndroid::ShowPopupMenu( int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection) { if (content_view_core_) { diff --git a/content/browser/web_contents/web_contents_view_android.h b/content/browser/web_contents/web_contents_view_android.h index c72c512..594bc5c 100644 --- a/content/browser/web_contents/web_contents_view_android.h +++ b/content/browser/web_contents/web_contents_view_android.h @@ -68,7 +68,7 @@ class WebContentsViewAndroid : public WebContentsViewPort, int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection) OVERRIDE; virtual void StartDragging(const DropData& drop_data, diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc index c59757c..185d483 100644 --- a/content/browser/web_contents/web_contents_view_aura.cc +++ b/content/browser/web_contents/web_contents_view_aura.cc @@ -1229,7 +1229,7 @@ void WebContentsViewAura::ShowPopupMenu(const gfx::Rect& bounds, int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection) { // External popup menus are only used on Mac and Android. diff --git a/content/browser/web_contents/web_contents_view_aura.h b/content/browser/web_contents/web_contents_view_aura.h index 0ed09ef..e2336dd 100644 --- a/content/browser/web_contents/web_contents_view_aura.h +++ b/content/browser/web_contents/web_contents_view_aura.h @@ -130,7 +130,7 @@ class CONTENT_EXPORT WebContentsViewAura int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection) OVERRIDE; virtual void StartDragging(const DropData& drop_data, diff --git a/content/browser/web_contents/web_contents_view_gtk.cc b/content/browser/web_contents/web_contents_view_gtk.cc index e60a011..cdc36c8 100644 --- a/content/browser/web_contents/web_contents_view_gtk.cc +++ b/content/browser/web_contents/web_contents_view_gtk.cc @@ -360,7 +360,7 @@ void WebContentsViewGtk::ShowPopupMenu(const gfx::Rect& bounds, int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection) { // External popup menus are only used on Mac and Android. diff --git a/content/browser/web_contents/web_contents_view_gtk.h b/content/browser/web_contents/web_contents_view_gtk.h index 7a603d7..4a456fc 100644 --- a/content/browser/web_contents/web_contents_view_gtk.h +++ b/content/browser/web_contents/web_contents_view_gtk.h @@ -77,7 +77,7 @@ class CONTENT_EXPORT WebContentsViewGtk int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection) OVERRIDE; virtual void StartDragging(const DropData& drop_data, diff --git a/content/browser/web_contents/web_contents_view_guest.cc b/content/browser/web_contents/web_contents_view_guest.cc index c675063..2143e8a 100644 --- a/content/browser/web_contents/web_contents_view_guest.cc +++ b/content/browser/web_contents/web_contents_view_guest.cc @@ -196,7 +196,7 @@ void WebContentsViewGuest::ShowPopupMenu(const gfx::Rect& bounds, int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection) { // External popup menus are only used on Mac and Android. diff --git a/content/browser/web_contents/web_contents_view_guest.h b/content/browser/web_contents/web_contents_view_guest.h index 436295a..8d968f4 100644 --- a/content/browser/web_contents/web_contents_view_guest.h +++ b/content/browser/web_contents/web_contents_view_guest.h @@ -78,7 +78,7 @@ class CONTENT_EXPORT WebContentsViewGuest int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection) OVERRIDE; virtual void StartDragging(const DropData& drop_data, diff --git a/content/browser/web_contents/web_contents_view_mac.h b/content/browser/web_contents/web_contents_view_mac.h index 8e0894f..a8e7bb3 100644 --- a/content/browser/web_contents/web_contents_view_mac.h +++ b/content/browser/web_contents/web_contents_view_mac.h @@ -101,7 +101,7 @@ class WebContentsViewMac : public WebContentsViewPort, int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection) OVERRIDE; virtual void StartDragging(const DropData& drop_data, diff --git a/content/browser/web_contents/web_contents_view_mac.mm b/content/browser/web_contents/web_contents_view_mac.mm index cb9f274..6a9459d 100644 --- a/content/browser/web_contents/web_contents_view_mac.mm +++ b/content/browser/web_contents/web_contents_view_mac.mm @@ -247,7 +247,7 @@ void WebContentsViewMac::ShowPopupMenu( int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection) { PopupMenuHelper popup_menu_helper(web_contents_->GetRenderViewHost()); diff --git a/content/browser/web_contents/web_contents_view_win.cc b/content/browser/web_contents/web_contents_view_win.cc index 59415ea..6a75e71 100644 --- a/content/browser/web_contents/web_contents_view_win.cc +++ b/content/browser/web_contents/web_contents_view_win.cc @@ -252,7 +252,7 @@ void WebContentsViewWin::ShowPopupMenu(const gfx::Rect& bounds, int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection) { // External popup menus are only used on Mac and Android. diff --git a/content/browser/web_contents/web_contents_view_win.h b/content/browser/web_contents/web_contents_view_win.h index cfb4ecd..3ca6b48 100644 --- a/content/browser/web_contents/web_contents_view_win.h +++ b/content/browser/web_contents/web_contents_view_win.h @@ -84,7 +84,7 @@ class CONTENT_EXPORT WebContentsViewWin int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection) OVERRIDE; virtual void StartDragging(const DropData& drop_data, diff --git a/content/common/view_messages.h b/content/common/view_messages.h index 034bfb1..9d7b328 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -25,6 +25,7 @@ #include "content/public/common/file_chooser_params.h" #include "content/public/common/frame_navigate_params.h" #include "content/public/common/javascript_message_type.h" +#include "content/public/common/menu_item.h" #include "content/public/common/page_state.h" #include "content/public/common/page_zoom.h" #include "content/public/common/referrer.h" @@ -58,7 +59,6 @@ #include "ui/gfx/vector2d.h" #include "ui/gfx/vector2d_f.h" #include "ui/shell_dialogs/selected_file_info.h" -#include "webkit/common/webmenuitem.h" #include "webkit/plugins/npapi/webplugin.h" #if defined(OS_MACOSX) @@ -77,11 +77,11 @@ IPC_ENUM_TRAITS(WebKit::WebMediaPlayerAction::Type) IPC_ENUM_TRAITS(WebKit::WebPluginAction::Type) IPC_ENUM_TRAITS(WebKit::WebPopupType) IPC_ENUM_TRAITS(WebKit::WebTextDirection) -IPC_ENUM_TRAITS(WebMenuItem::Type) IPC_ENUM_TRAITS(WindowContainerType) IPC_ENUM_TRAITS(content::FaviconURL::IconType) IPC_ENUM_TRAITS(content::FileChooserParams::Mode) IPC_ENUM_TRAITS(content::JavaScriptMessageType) +IPC_ENUM_TRAITS(content::MenuItem::Type) IPC_ENUM_TRAITS(content::NavigationGesture) IPC_ENUM_TRAITS(content::PageZoom) IPC_ENUM_TRAITS(content::RendererPreferencesHintingEnum) @@ -145,9 +145,9 @@ IPC_STRUCT_TRAITS_BEGIN(WebKit::WebScreenInfo) IPC_STRUCT_TRAITS_MEMBER(availableRect) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(WebMenuItem) +IPC_STRUCT_TRAITS_BEGIN(content::MenuItem) IPC_STRUCT_TRAITS_MEMBER(label) - IPC_STRUCT_TRAITS_MEMBER(toolTip) + IPC_STRUCT_TRAITS_MEMBER(tool_tip) IPC_STRUCT_TRAITS_MEMBER(type) IPC_STRUCT_TRAITS_MEMBER(action) IPC_STRUCT_TRAITS_MEMBER(rtl) @@ -485,7 +485,7 @@ IPC_STRUCT_BEGIN(ViewHostMsg_ShowPopup_Params) IPC_STRUCT_MEMBER(int, selected_item) // The entire list of items in the popup menu. - IPC_STRUCT_MEMBER(std::vector<WebMenuItem>, popup_items) + IPC_STRUCT_MEMBER(std::vector<content::MenuItem>, popup_items) // Whether items should be right-aligned. IPC_STRUCT_MEMBER(bool, right_aligned) diff --git a/content/content_common.gypi b/content/content_common.gypi index 7e72a48..f55381c 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -56,6 +56,8 @@ 'public/common/main_function_params.h', 'public/common/media_stream_request.cc', 'public/common/media_stream_request.h', + 'public/common/menu_item.cc', + 'public/common/menu_item.h', 'public/common/page_state.cc', 'public/common/page_state.h', 'public/common/page_transition_types.cc', diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi index a2e634e..e3aa05f 100644 --- a/content/content_renderer.gypi +++ b/content/content_renderer.gypi @@ -247,6 +247,8 @@ 'renderer/media/websourcebuffer_impl.h', 'renderer/memory_benchmarking_extension.cc', 'renderer/memory_benchmarking_extension.h', + 'renderer/menu_item_builder.cc', + 'renderer/menu_item_builder.h', 'renderer/mhtml_generator.cc', 'renderer/mhtml_generator.h', 'renderer/mouse_lock_dispatcher.cc', diff --git a/content/port/browser/render_view_host_delegate_view.h b/content/port/browser/render_view_host_delegate_view.h index 375b867..5e5d9b4 100644 --- a/content/port/browser/render_view_host_delegate_view.h +++ b/content/port/browser/render_view_host_delegate_view.h @@ -13,7 +13,6 @@ #include "third_party/WebKit/public/web/WebDragOperation.h" class SkBitmap; -struct WebMenuItem; namespace gfx { class ImageSkia; @@ -22,9 +21,9 @@ class Vector2d; } namespace content { - struct ContextMenuParams; struct DropData; +struct MenuItem; // This class provides a way for the RenderViewHost to reach out to its // delegate's view. It only needs to be implemented by embedders if they don't @@ -42,7 +41,7 @@ class CONTENT_EXPORT RenderViewHostDelegateView { int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection) = 0; diff --git a/content/public/common/context_menu_params.h b/content/public/common/context_menu_params.h index e962530..f58e9de 100644 --- a/content/public/common/context_menu_params.h +++ b/content/public/common/context_menu_params.h @@ -10,13 +10,13 @@ #include "base/basictypes.h" #include "base/strings/string16.h" #include "content/common/content_export.h" +#include "content/public/common/menu_item.h" #include "content/public/common/page_state.h" #include "content/public/common/ssl_status.h" #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" #include "third_party/WebKit/public/web/WebContextMenuData.h" #include "ui/base/ui_base_types.h" #include "url/gurl.h" -#include "webkit/common/webmenuitem.h" #if defined(OS_ANDROID) #include "ui/gfx/point.h" @@ -144,7 +144,7 @@ struct CONTENT_EXPORT ContextMenuParams { WebKit::WebReferrerPolicy referrer_policy; CustomContextMenuContext custom_context; - std::vector<WebMenuItem> custom_items; + std::vector<MenuItem> custom_items; ui::MenuSourceType source_type; diff --git a/content/public/common/menu_item.cc b/content/public/common/menu_item.cc new file mode 100644 index 0000000..4ea06cf --- /dev/null +++ b/content/public/common/menu_item.cc @@ -0,0 +1,33 @@ +// Copyright 2013 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 "content/public/common/menu_item.h" + +namespace content { + +MenuItem::MenuItem() + : type(OPTION), + action(0), + rtl(false), + has_directional_override(false), + enabled(false), + checked(false) { +} + +MenuItem::MenuItem(const MenuItem& item) + : label(item.label), + tool_tip(item.tool_tip), + type(item.type), + action(item.action), + rtl(item.rtl), + has_directional_override(item.has_directional_override), + enabled(item.enabled), + checked(item.checked), + submenu(item.submenu) { +} + +MenuItem::~MenuItem() { +} + +} // namespace content diff --git a/webkit/common/webmenuitem.h b/content/public/common/menu_item.h index 99d0498..c6c20bc 100644 --- a/webkit/common/webmenuitem.h +++ b/content/public/common/menu_item.h @@ -2,40 +2,43 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef WEBKIT_COMMON_WEBMENUITEM_H_ -#define WEBKIT_COMMON_WEBMENUITEM_H_ +#ifndef CONTENT_PUBLIC_COMMON_MENU_ITEM_H_ +#define CONTENT_PUBLIC_COMMON_MENU_ITEM_H_ #include <vector> #include "base/strings/string16.h" +#include "content/common/content_export.h" #include "third_party/WebKit/public/web/WebMenuItemInfo.h" -#include "webkit/common/webkit_common_export.h" + +namespace content { // Container for information about entries in an HTML select popup menu and // custom entries of the context menu. -struct WEBKIT_COMMON_EXPORT WebMenuItem { +struct CONTENT_EXPORT MenuItem { enum Type { - OPTION = WebKit::WebMenuItemInfo::Option, + OPTION = WebKit::WebMenuItemInfo::Option, CHECKABLE_OPTION = WebKit::WebMenuItemInfo::CheckableOption, - GROUP = WebKit::WebMenuItemInfo::Group, - SEPARATOR = WebKit::WebMenuItemInfo::Separator, + GROUP = WebKit::WebMenuItemInfo::Group, + SEPARATOR = WebKit::WebMenuItemInfo::Separator, SUBMENU // This is currently only used by Pepper, not by WebKit. }; - WebMenuItem(); - WebMenuItem(const WebKit::WebMenuItemInfo& item); - WebMenuItem(const WebMenuItem& item); - ~WebMenuItem(); + MenuItem(); + MenuItem(const MenuItem& item); + ~MenuItem(); base::string16 label; - base::string16 toolTip; + base::string16 tool_tip; Type type; unsigned action; bool rtl; bool has_directional_override; bool enabled; bool checked; - std::vector<WebMenuItem> submenu; + std::vector<MenuItem> submenu; }; -#endif // WEBKIT_COMMON_WEBMENUITEM_H_ +} // namespace content + +#endif // CONTENT_PUBLIC_COMMON_MENU_ITEM_H_ diff --git a/content/renderer/context_menu_params_builder.cc b/content/renderer/context_menu_params_builder.cc index d4aa912..8459fa2 100644 --- a/content/renderer/context_menu_params_builder.cc +++ b/content/renderer/context_menu_params_builder.cc @@ -8,6 +8,7 @@ #include "content/common/ssl_status_serialization.h" #include "content/public/common/context_menu_params.h" #include "content/public/renderer/history_item_serialization.h" +#include "content/renderer/menu_item_builder.h" #include "third_party/WebKit/public/web/WebElement.h" #include "third_party/WebKit/public/web/WebNode.h" @@ -48,7 +49,7 @@ ContextMenuParams ContextMenuParamsBuilder::Build( params.custom_context.is_pepper_menu = false; for (size_t i = 0; i < data.customItems.size(); ++i) - params.custom_items.push_back(WebMenuItem(data.customItems[i])); + params.custom_items.push_back(MenuItemBuilder::Build(data.customItems[i])); if (!data.frameHistoryItem.isNull()) params.frame_page_state = HistoryItemToPageState(data.frameHistoryItem); diff --git a/content/renderer/external_popup_menu.cc b/content/renderer/external_popup_menu.cc index 06f8345..08d71e9 100644 --- a/content/renderer/external_popup_menu.cc +++ b/content/renderer/external_popup_menu.cc @@ -5,6 +5,7 @@ #include "content/renderer/external_popup_menu.h" #include "content/common/view_messages.h" +#include "content/renderer/menu_item_builder.h" #include "content/renderer/render_view_impl.h" #include "third_party/WebKit/public/platform/WebRect.h" #include "third_party/WebKit/public/web/WebExternalPopupMenuClient.h" @@ -26,8 +27,10 @@ void ExternalPopupMenu::show(const WebKit::WebRect& bounds) { popup_params.item_height = popup_menu_info_.itemHeight; popup_params.item_font_size = popup_menu_info_.itemFontSize; popup_params.selected_item = popup_menu_info_.selectedIndex; - for (size_t i = 0; i < popup_menu_info_.items.size(); ++i) - popup_params.popup_items.push_back(WebMenuItem(popup_menu_info_.items[i])); + for (size_t i = 0; i < popup_menu_info_.items.size(); ++i) { + popup_params.popup_items.push_back( + MenuItemBuilder::Build(popup_menu_info_.items[i])); + } popup_params.right_aligned = popup_menu_info_.rightAligned; popup_params.allow_multiple_selection = popup_menu_info_.allowMultipleSelection; diff --git a/content/renderer/menu_item_builder.cc b/content/renderer/menu_item_builder.cc new file mode 100644 index 0000000..5946c41 --- /dev/null +++ b/content/renderer/menu_item_builder.cc @@ -0,0 +1,28 @@ +// Copyright 2013 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 "content/renderer/menu_item_builder.h" + +#include "content/public/common/menu_item.h" + +namespace content { + +MenuItem MenuItemBuilder::Build(const WebKit::WebMenuItemInfo& item) { + MenuItem result; + + result.label = item.label; + result.tool_tip = item.toolTip; + result.type = static_cast<MenuItem::Type>(item.type); + result.action = item.action; + result.rtl = (item.textDirection == WebKit::WebTextDirectionRightToLeft); + result.has_directional_override = item.hasTextDirectionOverride; + result.enabled = item.enabled; + result.checked = item.checked; + for (size_t i = 0; i < item.subMenuItems.size(); ++i) + result.submenu.push_back(MenuItemBuilder::Build(item.subMenuItems[i])); + + return result; +} + +} // namespace content diff --git a/content/renderer/menu_item_builder.h b/content/renderer/menu_item_builder.h new file mode 100644 index 0000000..8f007bd --- /dev/null +++ b/content/renderer/menu_item_builder.h @@ -0,0 +1,23 @@ +// Copyright 2013 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. + +#ifndef CONTENT_RENDERER_MENU_ITEM_BUILDER_H_ +#define CONTENT_RENDERER_MENU_ITEM_BUILDER_H_ + +namespace WebKit { +struct WebMenuItemInfo; +} + +namespace content { +struct MenuItem; + +class MenuItemBuilder { + public: + static MenuItem Build(const WebKit::WebMenuItemInfo& item); +}; + +} // namespace content + +#endif // CONTENT_RENDERER_MENU_ITEM_BUILDER_H_ + diff --git a/content/test/test_web_contents_view.cc b/content/test/test_web_contents_view.cc index 1d6f7db..b732a01 100644 --- a/content/test/test_web_contents_view.cc +++ b/content/test/test_web_contents_view.cc @@ -16,7 +16,7 @@ void TestWebContentsView::ShowPopupMenu(const gfx::Rect& bounds, int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection) { } diff --git a/content/test/test_web_contents_view.h b/content/test/test_web_contents_view.h index 149e300..a087f78 100644 --- a/content/test/test_web_contents_view.h +++ b/content/test/test_web_contents_view.h @@ -22,7 +22,7 @@ class TestWebContentsView : public WebContentsViewPort, int item_height, double item_font_size, int selected_item, - const std::vector<WebMenuItem>& items, + const std::vector<MenuItem>& items, bool right_aligned, bool allow_multiple_selection) OVERRIDE; virtual void StartDragging(const DropData& drop_data, diff --git a/webkit/common/webmenuitem.cc b/webkit/common/webmenuitem.cc deleted file mode 100644 index 68c9a9e..0000000 --- a/webkit/common/webmenuitem.cc +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2013 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 "webkit/common/webmenuitem.h" - -WebMenuItem::WebMenuItem() - : type(OPTION), - action(0), - rtl(false), - has_directional_override(false), - enabled(false), - checked(false) { -} - -WebMenuItem::WebMenuItem(const WebKit::WebMenuItemInfo& item) - : label(item.label), - toolTip(item.toolTip), - type(static_cast<Type>(item.type)), - action(item.action), - rtl(item.textDirection == WebKit::WebTextDirectionRightToLeft), - has_directional_override(item.hasTextDirectionOverride), - enabled(item.enabled), - checked(item.checked) { - for (size_t i = 0; i < item.subMenuItems.size(); ++i) - submenu.push_back(WebMenuItem(item.subMenuItems[i])); -} - -WebMenuItem::WebMenuItem(const WebMenuItem& item) - : label(item.label), - toolTip(item.toolTip), - type(item.type), - action(item.action), - rtl(item.rtl), - has_directional_override(item.has_directional_override), - enabled(item.enabled), - checked(item.checked), - submenu(item.submenu) { -} - -WebMenuItem::~WebMenuItem() {} diff --git a/webkit/glue/webkit_glue_common.gyp b/webkit/glue/webkit_glue_common.gyp index c3db7cd..ff845ef 100644 --- a/webkit/glue/webkit_glue_common.gyp +++ b/webkit/glue/webkit_glue_common.gyp @@ -24,8 +24,6 @@ ], 'sources': [ '../common/webkit_common_export.h', - '../common/webmenuitem.cc', - '../common/webmenuitem.h', '../common/webpreferences.cc', '../common/webpreferences.h', 'multipart_response_delegate.cc', |