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 24 matching lines...) Expand all Loading... |
35 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
36 #include "chrome/browser/search_engines/template_url.h" | 36 #include "chrome/browser/search_engines/template_url.h" |
37 #include "chrome/browser/search_engines/template_url_model.h" | 37 #include "chrome/browser/search_engines/template_url_model.h" |
38 #include "chrome/browser/spellcheck_host.h" | 38 #include "chrome/browser/spellcheck_host.h" |
39 #include "chrome/browser/spellchecker_platform_engine.h" | 39 #include "chrome/browser/spellchecker_platform_engine.h" |
40 #include "chrome/browser/translate/translate_manager.h" | 40 #include "chrome/browser/translate/translate_manager.h" |
41 #include "chrome/browser/translate/translate_prefs.h" | 41 #include "chrome/browser/translate/translate_prefs.h" |
42 #include "chrome/browser/translate/translate_tab_helper.h" | 42 #include "chrome/browser/translate/translate_tab_helper.h" |
43 #include "chrome/browser/ui/download/download_tab_helper.h" | 43 #include "chrome/browser/ui/download/download_tab_helper.h" |
44 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 44 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 45 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" |
45 #include "chrome/common/chrome_constants.h" | 46 #include "chrome/common/chrome_constants.h" |
46 #include "chrome/common/chrome_switches.h" | 47 #include "chrome/common/chrome_switches.h" |
47 #include "chrome/common/pref_names.h" | 48 #include "chrome/common/pref_names.h" |
48 #include "chrome/common/print_messages.h" | 49 #include "chrome/common/print_messages.h" |
49 #include "chrome/common/spellcheck_messages.h" | 50 #include "chrome/common/spellcheck_messages.h" |
50 #include "chrome/common/url_constants.h" | 51 #include "chrome/common/url_constants.h" |
51 #include "content/browser/child_process_security_policy.h" | 52 #include "content/browser/child_process_security_policy.h" |
52 #include "content/browser/renderer_host/render_view_host.h" | 53 #include "content/browser/renderer_host/render_view_host.h" |
53 #include "content/browser/renderer_host/render_widget_host_view.h" | 54 #include "content/browser/renderer_host/render_widget_host_view.h" |
54 #include "content/browser/tab_contents/navigation_entry.h" | 55 #include "content/browser/tab_contents/navigation_entry.h" |
55 #include "content/browser/tab_contents/tab_contents.h" | 56 #include "content/browser/tab_contents/tab_contents.h" |
56 #include "content/browser/user_metrics.h" | 57 #include "content/browser/user_metrics.h" |
57 #include "content/common/content_restriction.h" | 58 #include "content/common/content_restriction.h" |
58 #include "grit/generated_resources.h" | 59 #include "grit/generated_resources.h" |
59 #include "net/base/escape.h" | 60 #include "net/base/escape.h" |
60 #include "net/url_request/url_request.h" | 61 #include "net/url_request/url_request.h" |
61 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" | 62 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" |
62 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction.
h" | 63 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction.
h" |
63 #include "ui/base/l10n/l10n_util.h" | 64 #include "ui/base/l10n/l10n_util.h" |
64 #include "ui/gfx/favicon_size.h" | 65 #include "ui/gfx/favicon_size.h" |
65 #include "webkit/glue/webmenuitem.h" | 66 #include "webkit/glue/webmenuitem.h" |
| 67 #include "webkit/glue/window_open_disposition.h" |
66 | 68 |
67 using WebKit::WebContextMenuData; | 69 using WebKit::WebContextMenuData; |
68 using WebKit::WebMediaPlayerAction; | 70 using WebKit::WebMediaPlayerAction; |
69 using WebKit::WebURL; | 71 using WebKit::WebURL; |
70 using WebKit::WebString; | 72 using WebKit::WebString; |
71 | 73 |
72 namespace { | 74 namespace { |
73 | 75 |
74 bool IsCustomItemEnabled(const std::vector<WebMenuItem>& items, int id) { | 76 bool IsCustomItemEnabled(const std::vector<WebMenuItem>& items, int id) { |
75 DCHECK(id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && | 77 DCHECK(id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && |
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1500 LookUpInDictionary(); | 1502 LookUpInDictionary(); |
1501 break; | 1503 break; |
1502 #endif // OS_MACOSX | 1504 #endif // OS_MACOSX |
1503 | 1505 |
1504 default: | 1506 default: |
1505 NOTREACHED(); | 1507 NOTREACHED(); |
1506 break; | 1508 break; |
1507 } | 1509 } |
1508 } | 1510 } |
1509 | 1511 |
| 1512 void RenderViewContextMenu::ExecuteCommandWithDisposition( |
| 1513 int id, int disposition) { |
| 1514 |
| 1515 switch (id) { |
| 1516 case IDC_BACK: { |
| 1517 TabContentsWrapper* wrapper = |
| 1518 TabContentsWrapper::GetCurrentWrapperForContents( |
| 1519 source_tab_contents_); |
| 1520 wrapper->delegate()->GoBack( |
| 1521 static_cast<WindowOpenDisposition>(disposition)); |
| 1522 return; |
| 1523 } |
| 1524 case IDC_FORWARD: { |
| 1525 TabContentsWrapper* wrapper = |
| 1526 TabContentsWrapper::GetCurrentWrapperForContents( |
| 1527 source_tab_contents_); |
| 1528 wrapper->delegate()->GoForward( |
| 1529 static_cast<WindowOpenDisposition>(disposition)); |
| 1530 return; |
| 1531 } |
| 1532 } |
| 1533 |
| 1534 // If not processed, call ExecuteCommand instead. |
| 1535 ExecuteCommand(id); |
| 1536 } |
| 1537 |
1510 void RenderViewContextMenu::MenuWillShow() { | 1538 void RenderViewContextMenu::MenuWillShow() { |
1511 RenderWidgetHostView* view = source_tab_contents_->GetRenderWidgetHostView(); | 1539 RenderWidgetHostView* view = source_tab_contents_->GetRenderWidgetHostView(); |
1512 if (view) | 1540 if (view) |
1513 view->ShowingContextMenu(true); | 1541 view->ShowingContextMenu(true); |
1514 } | 1542 } |
1515 | 1543 |
1516 void RenderViewContextMenu::MenuClosed() { | 1544 void RenderViewContextMenu::MenuClosed() { |
1517 RenderWidgetHostView* view = source_tab_contents_->GetRenderWidgetHostView(); | 1545 RenderWidgetHostView* view = source_tab_contents_->GetRenderWidgetHostView(); |
1518 if (view) | 1546 if (view) |
1519 view->ShowingContextMenu(false); | 1547 view->ShowingContextMenu(false); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1588 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), | 1616 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), |
1589 g_browser_process->clipboard()); | 1617 g_browser_process->clipboard()); |
1590 } | 1618 } |
1591 | 1619 |
1592 void RenderViewContextMenu::MediaPlayerActionAt( | 1620 void RenderViewContextMenu::MediaPlayerActionAt( |
1593 const gfx::Point& location, | 1621 const gfx::Point& location, |
1594 const WebMediaPlayerAction& action) { | 1622 const WebMediaPlayerAction& action) { |
1595 source_tab_contents_->render_view_host()->MediaPlayerActionAt( | 1623 source_tab_contents_->render_view_host()->MediaPlayerActionAt( |
1596 location, action); | 1624 location, action); |
1597 } | 1625 } |
OLD | NEW |