OLD | NEW |
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 <algorithm> | 5 #include <algorithm> |
6 #include <set> | 6 #include <set> |
7 | 7 |
8 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 8 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 #include "content/browser/download/download_manager.h" | 55 #include "content/browser/download/download_manager.h" |
56 #include "content/browser/download/download_stats.h" | 56 #include "content/browser/download/download_stats.h" |
57 #include "content/browser/download/save_package.h" | 57 #include "content/browser/download/save_package.h" |
58 #include "content/browser/renderer_host/render_view_host.h" | 58 #include "content/browser/renderer_host/render_view_host.h" |
59 #include "content/browser/renderer_host/render_widget_host_view.h" | 59 #include "content/browser/renderer_host/render_widget_host_view.h" |
60 #include "content/browser/tab_contents/navigation_details.h" | 60 #include "content/browser/tab_contents/navigation_details.h" |
61 #include "content/browser/tab_contents/navigation_entry.h" | 61 #include "content/browser/tab_contents/navigation_entry.h" |
62 #include "content/browser/tab_contents/tab_contents.h" | 62 #include "content/browser/tab_contents/tab_contents.h" |
63 #include "content/browser/user_metrics.h" | 63 #include "content/browser/user_metrics.h" |
64 #include "content/common/content_restriction.h" | 64 #include "content/common/content_restriction.h" |
65 #include "content/common/view_messages.h" | |
66 #include "grit/generated_resources.h" | 65 #include "grit/generated_resources.h" |
67 #include "net/base/escape.h" | 66 #include "net/base/escape.h" |
68 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" | 67 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" |
69 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction.
h" | 68 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction.
h" |
70 #include "ui/base/l10n/l10n_util.h" | 69 #include "ui/base/l10n/l10n_util.h" |
71 #include "ui/base/text/text_elider.h" | 70 #include "ui/base/text/text_elider.h" |
72 #include "ui/gfx/favicon_size.h" | 71 #include "ui/gfx/favicon_size.h" |
73 #include "webkit/glue/webmenuitem.h" | 72 #include "webkit/glue/webmenuitem.h" |
74 | 73 |
75 #ifdef FILE_MANAGER_EXTENSION | 74 #ifdef FILE_MANAGER_EXTENSION |
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 } | 1419 } |
1421 return; | 1420 return; |
1422 } | 1421 } |
1423 | 1422 |
1424 RenderViewHost* rvh = source_tab_contents_->render_view_host(); | 1423 RenderViewHost* rvh = source_tab_contents_->render_view_host(); |
1425 | 1424 |
1426 // Process custom actions range. | 1425 // Process custom actions range. |
1427 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && | 1426 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && |
1428 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { | 1427 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { |
1429 unsigned action = id - IDC_CONTENT_CONTEXT_CUSTOM_FIRST; | 1428 unsigned action = id - IDC_CONTENT_CONTEXT_CUSTOM_FIRST; |
1430 rvh->Send(new ViewMsg_CustomContextMenuAction( | 1429 rvh->ExecuteCustomContextMenuCommand(action, params_.custom_context); |
1431 rvh->routing_id(), params_.custom_context, action)); | |
1432 return; | 1430 return; |
1433 } | 1431 } |
1434 | 1432 |
1435 // Process extension menu items. | 1433 // Process extension menu items. |
1436 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && | 1434 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && |
1437 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { | 1435 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { |
1438 ExtensionMenuManager* manager = | 1436 ExtensionMenuManager* manager = |
1439 profile_->GetExtensionService()->menu_manager(); | 1437 profile_->GetExtensionService()->menu_manager(); |
1440 std::map<int, ExtensionMenuItem::Id>::const_iterator i = | 1438 std::map<int, ExtensionMenuItem::Id>::const_iterator i = |
1441 extension_item_map_.find(id); | 1439 extension_item_map_.find(id); |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1866 void RenderViewContextMenu::MenuClosed(ui::SimpleMenuModel* source) { | 1864 void RenderViewContextMenu::MenuClosed(ui::SimpleMenuModel* source) { |
1867 // Ignore notifications from submenus. | 1865 // Ignore notifications from submenus. |
1868 if (source != &menu_model_) | 1866 if (source != &menu_model_) |
1869 return; | 1867 return; |
1870 | 1868 |
1871 RenderWidgetHostView* view = source_tab_contents_->GetRenderWidgetHostView(); | 1869 RenderWidgetHostView* view = source_tab_contents_->GetRenderWidgetHostView(); |
1872 if (view) | 1870 if (view) |
1873 view->ShowingContextMenu(false); | 1871 view->ShowingContextMenu(false); |
1874 RenderViewHost* rvh = source_tab_contents_->render_view_host(); | 1872 RenderViewHost* rvh = source_tab_contents_->render_view_host(); |
1875 if (rvh) { | 1873 if (rvh) { |
1876 rvh->Send(new ViewMsg_ContextMenuClosed( | 1874 rvh->NotifyContextMenuClosed(params_.custom_context); |
1877 rvh->routing_id(), params_.custom_context)); | |
1878 } | 1875 } |
1879 } | 1876 } |
1880 | 1877 |
1881 bool RenderViewContextMenu::IsDevCommandEnabled(int id) const { | 1878 bool RenderViewContextMenu::IsDevCommandEnabled(int id) const { |
1882 if (id == IDC_CONTENT_CONTEXT_INSPECTELEMENT) { | 1879 if (id == IDC_CONTENT_CONTEXT_INSPECTELEMENT) { |
1883 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 1880 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
1884 // Don't enable the web inspector if JavaScript is disabled. | 1881 // Don't enable the web inspector if JavaScript is disabled. |
1885 if (!profile_->GetPrefs()->GetBoolean(prefs::kWebKitJavascriptEnabled) || | 1882 if (!profile_->GetPrefs()->GetBoolean(prefs::kWebKitJavascriptEnabled) || |
1886 command_line.HasSwitch(switches::kDisableJavaScript)) | 1883 command_line.HasSwitch(switches::kDisableJavaScript)) |
1887 return false; | 1884 return false; |
(...skipping 28 matching lines...) Expand all Loading... |
1916 details.target_tab_contents = new_contents; | 1913 details.target_tab_contents = new_contents; |
1917 NotificationService::current()->Notify( | 1914 NotificationService::current()->Notify( |
1918 content::NOTIFICATION_RETARGETING, | 1915 content::NOTIFICATION_RETARGETING, |
1919 Source<content::BrowserContext>( | 1916 Source<content::BrowserContext>( |
1920 source_tab_contents_->browser_context()), | 1917 source_tab_contents_->browser_context()), |
1921 Details<content::RetargetingDetails>(&details)); | 1918 Details<content::RetargetingDetails>(&details)); |
1922 } | 1919 } |
1923 } | 1920 } |
1924 | 1921 |
1925 void RenderViewContextMenu::CopyImageAt(int x, int y) { | 1922 void RenderViewContextMenu::CopyImageAt(int x, int y) { |
1926 RenderViewHost* rvh = source_tab_contents_->render_view_host(); | 1923 source_tab_contents_->render_view_host()->CopyImageAt(x, y); |
1927 rvh->Send(new ViewMsg_CopyImageAt(rvh->routing_id(), x, y)); | |
1928 } | 1924 } |
1929 | 1925 |
1930 void RenderViewContextMenu::Inspect(int x, int y) { | 1926 void RenderViewContextMenu::Inspect(int x, int y) { |
1931 UserMetrics::RecordAction(UserMetricsAction("DevTools_InspectElement")); | 1927 UserMetrics::RecordAction(UserMetricsAction("DevTools_InspectElement")); |
1932 DevToolsWindow::InspectElement( | 1928 DevToolsWindow::InspectElement( |
1933 source_tab_contents_->render_view_host(), x, y); | 1929 source_tab_contents_->render_view_host(), x, y); |
1934 } | 1930 } |
1935 | 1931 |
1936 void RenderViewContextMenu::WriteURLToClipboard(const GURL& url) { | 1932 void RenderViewContextMenu::WriteURLToClipboard(const GURL& url) { |
1937 chrome_browser_net::WriteURLToClipboard( | 1933 chrome_browser_net::WriteURLToClipboard( |
1938 url, | 1934 url, |
1939 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), | 1935 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), |
1940 g_browser_process->clipboard()); | 1936 g_browser_process->clipboard()); |
1941 } | 1937 } |
1942 | 1938 |
1943 void RenderViewContextMenu::MediaPlayerActionAt( | 1939 void RenderViewContextMenu::MediaPlayerActionAt( |
1944 const gfx::Point& location, | 1940 const gfx::Point& location, |
1945 const WebMediaPlayerAction& action) { | 1941 const WebMediaPlayerAction& action) { |
1946 RenderViewHost* rvh = source_tab_contents_->render_view_host(); | 1942 source_tab_contents_->render_view_host()-> |
1947 rvh->Send(new ViewMsg_MediaPlayerActionAt( | 1943 ExecuteMediaPlayerActionAtLocation(location, action); |
1948 rvh->routing_id(), location, action)); | |
1949 } | 1944 } |
OLD | NEW |