| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delega
te_android.h" | 5 #include "chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delega
te_android.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/ui/android/context_menu_helper.h" | 8 #include "chrome/browser/ui/android/context_menu_helper.h" |
| 9 #include "content/public/browser/android/content_view_core.h" | 9 #include "content/public/browser/android/content_view_core.h" |
| 10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 ChromeWebContentsViewDelegateAndroid::GetDragDestDelegate() { | 23 ChromeWebContentsViewDelegateAndroid::GetDragDestDelegate() { |
| 24 // GetDragDestDelegate is a pure virtual method from WebContentsViewDelegate | 24 // GetDragDestDelegate is a pure virtual method from WebContentsViewDelegate |
| 25 // and must have an implementation although android doesn't use it. | 25 // and must have an implementation although android doesn't use it. |
| 26 NOTREACHED(); | 26 NOTREACHED(); |
| 27 return NULL; | 27 return NULL; |
| 28 } | 28 } |
| 29 | 29 |
| 30 void ChromeWebContentsViewDelegateAndroid::ShowContextMenu( | 30 void ChromeWebContentsViewDelegateAndroid::ShowContextMenu( |
| 31 content::RenderFrameHost* render_frame_host, | 31 content::RenderFrameHost* render_frame_host, |
| 32 const content::ContextMenuParams& params) { | 32 const content::ContextMenuParams& params) { |
| 33 // Display paste pop-up only when selection is empty and editable. | 33 content::ContentViewCore* content_view_core = |
| 34 if (params.is_editable && params.selection_text.empty()) { | 34 content::ContentViewCore::FromWebContents(web_contents_); |
| 35 content::ContentViewCore* content_view_core = | 35 if (content_view_core && content_view_core->ShowPastePopup(params)) |
| 36 content::ContentViewCore::FromWebContents(web_contents_); | |
| 37 if (content_view_core) { | |
| 38 content_view_core->ShowPastePopup(params.selection_start.x(), | |
| 39 params.selection_start.y()); | |
| 40 } | |
| 41 return; | 36 return; |
| 42 } | |
| 43 | 37 |
| 44 // TODO(dtrainor, kouhei): Give WebView a Populator/delegate so it can use | 38 // TODO(dtrainor, kouhei): Give WebView a Populator/delegate so it can use |
| 45 // the same context menu code. | 39 // the same context menu code. |
| 46 ContextMenuHelper* helper = | 40 ContextMenuHelper* helper = |
| 47 ContextMenuHelper::FromWebContents(web_contents_); | 41 ContextMenuHelper::FromWebContents(web_contents_); |
| 48 if (helper) | 42 if (helper) |
| 49 helper->ShowContextMenu(render_frame_host, params); | 43 helper->ShowContextMenu(render_frame_host, params); |
| 50 } | 44 } |
| 51 | 45 |
| 52 namespace chrome { | 46 namespace chrome { |
| 53 | 47 |
| 54 content::WebContentsViewDelegate* CreateWebContentsViewDelegate( | 48 content::WebContentsViewDelegate* CreateWebContentsViewDelegate( |
| 55 content::WebContents* web_contents) { | 49 content::WebContents* web_contents) { |
| 56 return new ChromeWebContentsViewDelegateAndroid(web_contents); | 50 return new ChromeWebContentsViewDelegateAndroid(web_contents); |
| 57 } | 51 } |
| 58 | 52 |
| 59 } // namespace chrome | 53 } // namespace chrome |
| OLD | NEW |