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

Side by Side Diff: chrome/browser/tab_contents/render_view_context_menu.cc

Issue 6893046: added CTRL+Click and SHIFT+Click handler for context menu, Back and Forward. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: fixed pointed problems. Created 9 years, 7 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 <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
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 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 LookUpInDictionary(); 1527 LookUpInDictionary();
1526 break; 1528 break;
1527 #endif // OS_MACOSX 1529 #endif // OS_MACOSX
1528 1530
1529 default: 1531 default:
1530 NOTREACHED(); 1532 NOTREACHED();
1531 break; 1533 break;
1532 } 1534 }
1533 } 1535 }
1534 1536
1537 void RenderViewContextMenu::ExecuteCommandWithDisposition(
1538 int id, int disposition) {
1539
1540 switch (id) {
1541 case IDC_BACK: {
1542 TabContentsWrapper* wrapper =
1543 TabContentsWrapper::GetCurrentWrapperForContents(
1544 source_tab_contents_);
1545 wrapper->delegate()->GoBack(
1546 static_cast<WindowOpenDisposition>(disposition));
1547 return;
1548 }
1549 case IDC_FORWARD: {
1550 TabContentsWrapper* wrapper =
1551 TabContentsWrapper::GetCurrentWrapperForContents(
1552 source_tab_contents_);
1553 wrapper->delegate()->GoForward(
1554 static_cast<WindowOpenDisposition>(disposition));
1555 return;
1556 }
1557 }
1558
1559 // If not processed, call ExecuteCommand instead.
1560 ExecuteCommand(id);
1561 }
1562
1535 void RenderViewContextMenu::MenuWillShow() { 1563 void RenderViewContextMenu::MenuWillShow() {
1536 RenderWidgetHostView* view = source_tab_contents_->GetRenderWidgetHostView(); 1564 RenderWidgetHostView* view = source_tab_contents_->GetRenderWidgetHostView();
1537 if (view) 1565 if (view)
1538 view->ShowingContextMenu(true); 1566 view->ShowingContextMenu(true);
1539 } 1567 }
1540 1568
1541 void RenderViewContextMenu::MenuClosed() { 1569 void RenderViewContextMenu::MenuClosed() {
1542 RenderWidgetHostView* view = source_tab_contents_->GetRenderWidgetHostView(); 1570 RenderWidgetHostView* view = source_tab_contents_->GetRenderWidgetHostView();
1543 if (view) 1571 if (view)
1544 view->ShowingContextMenu(false); 1572 view->ShowingContextMenu(false);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), 1641 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages),
1614 g_browser_process->clipboard()); 1642 g_browser_process->clipboard());
1615 } 1643 }
1616 1644
1617 void RenderViewContextMenu::MediaPlayerActionAt( 1645 void RenderViewContextMenu::MediaPlayerActionAt(
1618 const gfx::Point& location, 1646 const gfx::Point& location,
1619 const WebMediaPlayerAction& action) { 1647 const WebMediaPlayerAction& action) {
1620 source_tab_contents_->render_view_host()->MediaPlayerActionAt( 1648 source_tab_contents_->render_view_host()->MediaPlayerActionAt(
1621 location, action); 1649 location, action);
1622 } 1650 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698