Chromium Code Reviews| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 9 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 #include "chrome/common/chrome_notification_types.h" | 54 #include "chrome/common/chrome_notification_types.h" |
| 55 #include "chrome/common/chrome_switches.h" | 55 #include "chrome/common/chrome_switches.h" |
| 56 #include "chrome/common/extensions/extension.h" | 56 #include "chrome/common/extensions/extension.h" |
| 57 #include "chrome/common/pref_names.h" | 57 #include "chrome/common/pref_names.h" |
| 58 #include "chrome/common/print_messages.h" | 58 #include "chrome/common/print_messages.h" |
| 59 #include "chrome/common/spellcheck_messages.h" | 59 #include "chrome/common/spellcheck_messages.h" |
| 60 #include "chrome/common/url_constants.h" | 60 #include "chrome/common/url_constants.h" |
| 61 #include "content/public/browser/child_process_security_policy.h" | 61 #include "content/public/browser/child_process_security_policy.h" |
| 62 #include "content/public/browser/download_manager.h" | 62 #include "content/public/browser/download_manager.h" |
| 63 #include "content/public/browser/download_save_info.h" | 63 #include "content/public/browser/download_save_info.h" |
| 64 #include "content/public/browser/download_url_parameters.h" | |
| 64 #include "content/public/browser/navigation_details.h" | 65 #include "content/public/browser/navigation_details.h" |
| 65 #include "content/public/browser/navigation_entry.h" | 66 #include "content/public/browser/navigation_entry.h" |
| 66 #include "content/public/browser/notification_service.h" | 67 #include "content/public/browser/notification_service.h" |
| 67 #include "content/public/browser/render_view_host.h" | 68 #include "content/public/browser/render_view_host.h" |
| 68 #include "content/public/browser/render_widget_host_view.h" | 69 #include "content/public/browser/render_widget_host_view.h" |
| 69 #include "content/public/browser/speech_recognition_preferences.h" | 70 #include "content/public/browser/speech_recognition_preferences.h" |
| 70 #include "content/public/browser/user_metrics.h" | 71 #include "content/public/browser/user_metrics.h" |
| 71 #include "content/public/browser/web_contents.h" | 72 #include "content/public/browser/web_contents.h" |
| 72 #include "content/public/common/content_restriction.h" | 73 #include "content/public/common/content_restriction.h" |
| 73 #include "content/public/common/ssl_status.h" | 74 #include "content/public/common/ssl_status.h" |
| 74 #include "grit/generated_resources.h" | 75 #include "grit/generated_resources.h" |
| 75 #include "net/base/escape.h" | 76 #include "net/base/escape.h" |
| 76 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" | 77 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" |
| 77 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h" | 78 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h" |
| 78 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginAction.h" | 79 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginAction.h" |
| 79 #include "ui/base/l10n/l10n_util.h" | 80 #include "ui/base/l10n/l10n_util.h" |
| 80 #include "ui/base/text/text_elider.h" | 81 #include "ui/base/text/text_elider.h" |
| 81 #include "ui/gfx/favicon_size.h" | 82 #include "ui/gfx/favicon_size.h" |
| 82 #include "webkit/glue/webmenuitem.h" | 83 #include "webkit/glue/webmenuitem.h" |
| 83 | 84 |
| 84 #ifdef FILE_MANAGER_EXTENSION | 85 #ifdef FILE_MANAGER_EXTENSION |
| 85 #include "chrome/browser/chromeos/extensions/file_manager_util.h" | 86 #include "chrome/browser/chromeos/extensions/file_manager_util.h" |
| 86 #endif | 87 #endif |
| 87 | 88 |
| 89 using WebKit::WebContextMenuData; | |
| 90 using WebKit::WebMediaPlayerAction; | |
| 91 using WebKit::WebPluginAction; | |
| 92 using WebKit::WebString; | |
| 93 using WebKit::WebURL; | |
|
Randy Smith (Not in Mondays)
2012/04/30 19:44:48
nit: Why does WebKit go first? It's not alphabeti
benjhayden
2012/05/02 15:11:54
'W'=87
'c'=99
Randy Smith (Not in Mondays)
2012/05/02 18:36:22
Very true :-}. Ok.
| |
| 88 using content::ChildProcessSecurityPolicy; | 94 using content::ChildProcessSecurityPolicy; |
| 89 using content::DownloadManager; | 95 using content::DownloadManager; |
| 96 using content::DownloadUrlParameters; | |
| 90 using content::NavigationController; | 97 using content::NavigationController; |
| 91 using content::NavigationEntry; | 98 using content::NavigationEntry; |
| 92 using content::OpenURLParams; | 99 using content::OpenURLParams; |
| 93 using content::RenderViewHost; | 100 using content::RenderViewHost; |
| 94 using content::SSLStatus; | 101 using content::SSLStatus; |
| 95 using content::UserMetricsAction; | 102 using content::UserMetricsAction; |
| 96 using content::WebContents; | 103 using content::WebContents; |
| 97 using WebKit::WebContextMenuData; | |
| 98 using WebKit::WebMediaPlayerAction; | |
| 99 using WebKit::WebPluginAction; | |
| 100 using WebKit::WebURL; | |
| 101 using WebKit::WebString; | |
| 102 | 104 |
| 103 namespace { | 105 namespace { |
| 104 | 106 |
| 105 // Usually a new tab is expected where this function is used, | 107 // Usually a new tab is expected where this function is used, |
| 106 // however users should be able to open a tab in background | 108 // however users should be able to open a tab in background |
| 107 // or in a new window. | 109 // or in a new window. |
| 108 WindowOpenDisposition ForceNewTabDispositionFromEventFlags( | 110 WindowOpenDisposition ForceNewTabDispositionFromEventFlags( |
| 109 int event_flags) { | 111 int event_flags) { |
| 110 WindowOpenDisposition disposition = | 112 WindowOpenDisposition disposition = |
| 111 browser::DispositionFromEventFlags(event_flags); | 113 browser::DispositionFromEventFlags(event_flags); |
| (...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1503 case IDC_CONTENT_CONTEXT_SAVELINKAS: { | 1505 case IDC_CONTENT_CONTEXT_SAVELINKAS: { |
| 1504 download_util::RecordDownloadSource( | 1506 download_util::RecordDownloadSource( |
| 1505 download_util::INITIATED_BY_CONTEXT_MENU); | 1507 download_util::INITIATED_BY_CONTEXT_MENU); |
| 1506 const GURL& referrer = | 1508 const GURL& referrer = |
| 1507 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; | 1509 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; |
| 1508 const GURL& url = params_.link_url; | 1510 const GURL& url = params_.link_url; |
| 1509 content::DownloadSaveInfo save_info; | 1511 content::DownloadSaveInfo save_info; |
| 1510 save_info.prompt_for_save_location = true; | 1512 save_info.prompt_for_save_location = true; |
| 1511 DownloadManager* dlm = | 1513 DownloadManager* dlm = |
| 1512 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager(); | 1514 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager(); |
| 1513 dlm->DownloadUrl(url, | 1515 DownloadUrlParameters* dl_params = DownloadUrlParameters::FromWebContents( |
| 1514 referrer, | 1516 source_web_contents_, url, save_info); |
| 1515 params_.frame_charset, | 1517 dl_params->set_referrer(referrer); |
| 1516 false, // Don't prefer_cache | 1518 dl_params->set_referrer_encoding(params_.frame_charset); |
| 1517 -1, // No POST id | 1519 dlm->DownloadUrl(dl_params); |
| 1518 save_info, | |
| 1519 source_web_contents_, | |
| 1520 DownloadManager::OnStartedCallback()); | |
| 1521 break; | 1520 break; |
| 1522 } | 1521 } |
| 1523 | 1522 |
| 1524 case IDC_CONTENT_CONTEXT_SAVEAVAS: | 1523 case IDC_CONTENT_CONTEXT_SAVEAVAS: |
| 1525 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: { | 1524 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: { |
| 1526 download_util::RecordDownloadSource( | 1525 download_util::RecordDownloadSource( |
| 1527 download_util::INITIATED_BY_CONTEXT_MENU); | 1526 download_util::INITIATED_BY_CONTEXT_MENU); |
| 1528 const GURL& referrer = | 1527 const GURL& referrer = |
| 1529 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; | 1528 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; |
| 1530 const GURL& url = params_.src_url; | 1529 const GURL& url = params_.src_url; |
| 1531 content::DownloadSaveInfo save_info; | 1530 content::DownloadSaveInfo save_info; |
| 1532 save_info.prompt_for_save_location = true; | 1531 save_info.prompt_for_save_location = true; |
| 1533 int64 post_id = -1; | 1532 int64 post_id = -1; |
| 1534 if (url == source_web_contents_->GetURL()) { | 1533 if (url == source_web_contents_->GetURL()) { |
| 1535 const NavigationEntry* entry = | 1534 const NavigationEntry* entry = |
| 1536 source_web_contents_->GetController().GetActiveEntry(); | 1535 source_web_contents_->GetController().GetActiveEntry(); |
| 1537 if (entry) | 1536 if (entry) |
| 1538 post_id = entry->GetPostID(); | 1537 post_id = entry->GetPostID(); |
| 1539 } | 1538 } |
| 1540 DownloadManager* dlm = | 1539 DownloadManager* dlm = |
| 1541 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager(); | 1540 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager(); |
| 1542 dlm->DownloadUrl(url, | 1541 DownloadUrlParameters* dl_params = DownloadUrlParameters::FromWebContents( |
| 1543 referrer, | 1542 source_web_contents_, url, save_info); |
| 1544 "", | 1543 dl_params->set_referrer(referrer); |
| 1545 true, // prefer_cache | 1544 dl_params->set_post_id(post_id); |
| 1546 post_id, | 1545 dl_params->set_prefer_cache(true); |
| 1547 save_info, | 1546 dlm->DownloadUrl(dl_params); |
| 1548 source_web_contents_, | |
| 1549 DownloadManager::OnStartedCallback()); | |
| 1550 break; | 1547 break; |
| 1551 } | 1548 } |
| 1552 | 1549 |
| 1553 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: | 1550 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: |
| 1554 WriteURLToClipboard(params_.unfiltered_link_url); | 1551 WriteURLToClipboard(params_.unfiltered_link_url); |
| 1555 break; | 1552 break; |
| 1556 | 1553 |
| 1557 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION: | 1554 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION: |
| 1558 case IDC_CONTENT_CONTEXT_COPYAVLOCATION: | 1555 case IDC_CONTENT_CONTEXT_COPYAVLOCATION: |
| 1559 WriteURLToClipboard(params_.src_url); | 1556 WriteURLToClipboard(params_.src_url); |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1973 source_web_contents_->GetRenderViewHost()-> | 1970 source_web_contents_->GetRenderViewHost()-> |
| 1974 ExecuteMediaPlayerActionAtLocation(location, action); | 1971 ExecuteMediaPlayerActionAtLocation(location, action); |
| 1975 } | 1972 } |
| 1976 | 1973 |
| 1977 void RenderViewContextMenu::PluginActionAt( | 1974 void RenderViewContextMenu::PluginActionAt( |
| 1978 const gfx::Point& location, | 1975 const gfx::Point& location, |
| 1979 const WebPluginAction& action) { | 1976 const WebPluginAction& action) { |
| 1980 source_web_contents_->GetRenderViewHost()-> | 1977 source_web_contents_->GetRenderViewHost()-> |
| 1981 ExecutePluginActionAtLocation(location, action); | 1978 ExecutePluginActionAtLocation(location, action); |
| 1982 } | 1979 } |
| OLD | NEW |