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 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1477 break; | 1477 break; |
1478 | 1478 |
1479 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: | 1479 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: |
1480 OpenURL(params_.link_url, | 1480 OpenURL(params_.link_url, |
1481 GURL(), | 1481 GURL(), |
1482 params_.frame_id, | 1482 params_.frame_id, |
1483 OFF_THE_RECORD, | 1483 OFF_THE_RECORD, |
1484 content::PAGE_TRANSITION_LINK); | 1484 content::PAGE_TRANSITION_LINK); |
1485 break; | 1485 break; |
1486 | 1486 |
1487 case IDC_CONTENT_CONTEXT_SAVEAVAS: | |
1488 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: | |
1489 case IDC_CONTENT_CONTEXT_SAVELINKAS: { | 1487 case IDC_CONTENT_CONTEXT_SAVELINKAS: { |
1490 download_util::RecordDownloadCount( | 1488 download_util::RecordDownloadCount( |
1491 download_util::INITIATED_BY_CONTEXT_MENU_COUNT); | 1489 download_util::INITIATED_BY_CONTEXT_MENU_COUNT); |
1492 const GURL& referrer = | 1490 const GURL& referrer = |
1493 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; | 1491 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; |
1494 const GURL& url = | 1492 const GURL& url = params_.link_url; |
1495 (id == IDC_CONTENT_CONTEXT_SAVELINKAS ? params_.link_url : | 1493 DownloadSaveInfo save_info; |
1496 params_.src_url); | 1494 save_info.prompt_for_save_location = true; |
1497 DownloadManager* dlm = | 1495 DownloadManager* dlm = |
1498 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager(); | 1496 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager(); |
1499 // For images and AV "Save As" context menu commands, save the cached | 1497 dlm->DownloadUrl(url, |
1500 // data even if it is no longer valid. This helps ensure that the content | 1498 referrer, |
1501 // that is visible on the page is what is saved. For links, this behavior | 1499 params_.frame_charset, |
1502 // is not desired since the content being linked to is not visible. | 1500 false, // Don't prefer_cache |
1503 bool prefer_cache = (id != IDC_CONTENT_CONTEXT_SAVELINKAS); | 1501 -1, // No POST id |
1504 DownloadSaveInfo save_info; | 1502 save_info, |
1505 save_info.prompt_for_save_location = true; | 1503 source_web_contents_); |
1506 dlm->DownloadUrl(url, referrer, params_.frame_charset, | |
1507 prefer_cache, save_info, source_web_contents_); | |
1508 break; | 1504 break; |
1509 } | 1505 } |
1510 | 1506 |
| 1507 case IDC_CONTENT_CONTEXT_SAVEAVAS: |
| 1508 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: { |
| 1509 download_util::RecordDownloadCount( |
| 1510 download_util::INITIATED_BY_CONTEXT_MENU_COUNT); |
| 1511 const GURL& referrer = |
| 1512 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; |
| 1513 const GURL& url = params_.src_url; |
| 1514 DownloadSaveInfo save_info; |
| 1515 save_info.prompt_for_save_location = true; |
| 1516 int64 post_id = -1; |
| 1517 if (url == source_web_contents_->GetURL()) { |
| 1518 const NavigationEntry* entry = |
| 1519 source_web_contents_->GetController().GetActiveEntry(); |
| 1520 if (entry) |
| 1521 post_id = entry->GetPostID(); |
| 1522 } |
| 1523 DownloadManager* dlm = |
| 1524 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager(); |
| 1525 dlm->DownloadUrl(url, |
| 1526 referrer, |
| 1527 "", |
| 1528 true, // prefer_cache |
| 1529 post_id, |
| 1530 save_info, |
| 1531 source_web_contents_); |
| 1532 break; |
| 1533 } |
| 1534 |
1511 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: | 1535 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: |
1512 WriteURLToClipboard(params_.unfiltered_link_url); | 1536 WriteURLToClipboard(params_.unfiltered_link_url); |
1513 break; | 1537 break; |
1514 | 1538 |
1515 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION: | 1539 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION: |
1516 case IDC_CONTENT_CONTEXT_COPYAVLOCATION: | 1540 case IDC_CONTENT_CONTEXT_COPYAVLOCATION: |
1517 WriteURLToClipboard(params_.src_url); | 1541 WriteURLToClipboard(params_.src_url); |
1518 break; | 1542 break; |
1519 | 1543 |
1520 case IDC_CONTENT_CONTEXT_COPYIMAGE: | 1544 case IDC_CONTENT_CONTEXT_COPYIMAGE: |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1945 source_web_contents_->GetRenderViewHost()-> | 1969 source_web_contents_->GetRenderViewHost()-> |
1946 ExecuteMediaPlayerActionAtLocation(location, action); | 1970 ExecuteMediaPlayerActionAtLocation(location, action); |
1947 } | 1971 } |
1948 | 1972 |
1949 void RenderViewContextMenu::PluginActionAt( | 1973 void RenderViewContextMenu::PluginActionAt( |
1950 const gfx::Point& location, | 1974 const gfx::Point& location, |
1951 const WebPluginAction& action) { | 1975 const WebPluginAction& action) { |
1952 source_web_contents_->GetRenderViewHost()-> | 1976 source_web_contents_->GetRenderViewHost()-> |
1953 ExecutePluginActionAtLocation(location, action); | 1977 ExecutePluginActionAtLocation(location, action); |
1954 } | 1978 } |
OLD | NEW |