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