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

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

Issue 10232010: DownloadUrlParameters (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: " Created 8 years, 8 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) 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginAction.h" 78 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginAction.h"
79 #include "ui/base/l10n/l10n_util.h" 79 #include "ui/base/l10n/l10n_util.h"
80 #include "ui/base/text/text_elider.h" 80 #include "ui/base/text/text_elider.h"
81 #include "ui/gfx/favicon_size.h" 81 #include "ui/gfx/favicon_size.h"
82 #include "webkit/glue/webmenuitem.h" 82 #include "webkit/glue/webmenuitem.h"
83 83
84 #ifdef FILE_MANAGER_EXTENSION 84 #ifdef FILE_MANAGER_EXTENSION
85 #include "chrome/browser/chromeos/extensions/file_manager_util.h" 85 #include "chrome/browser/chromeos/extensions/file_manager_util.h"
86 #endif 86 #endif
87 87
88 using WebKit::WebContextMenuData;
89 using WebKit::WebMediaPlayerAction;
90 using WebKit::WebPluginAction;
91 using WebKit::WebString;
92 using WebKit::WebURL;
88 using content::ChildProcessSecurityPolicy; 93 using content::ChildProcessSecurityPolicy;
89 using content::DownloadManager; 94 using content::DownloadManager;
95 using content::DownloadUrlParameters;
90 using content::NavigationController; 96 using content::NavigationController;
91 using content::NavigationEntry; 97 using content::NavigationEntry;
92 using content::OpenURLParams; 98 using content::OpenURLParams;
93 using content::RenderViewHost; 99 using content::RenderViewHost;
94 using content::SSLStatus; 100 using content::SSLStatus;
95 using content::UserMetricsAction; 101 using content::UserMetricsAction;
96 using content::WebContents; 102 using content::WebContents;
97 using WebKit::WebContextMenuData;
98 using WebKit::WebMediaPlayerAction;
99 using WebKit::WebPluginAction;
100 using WebKit::WebURL;
101 using WebKit::WebString;
102 103
103 namespace { 104 namespace {
104 105
105 // Usually a new tab is expected where this function is used, 106 // Usually a new tab is expected where this function is used,
106 // however users should be able to open a tab in background 107 // however users should be able to open a tab in background
107 // or in a new window. 108 // or in a new window.
108 WindowOpenDisposition ForceNewTabDispositionFromEventFlags( 109 WindowOpenDisposition ForceNewTabDispositionFromEventFlags(
109 int event_flags) { 110 int event_flags) {
110 WindowOpenDisposition disposition = 111 WindowOpenDisposition disposition =
111 browser::DispositionFromEventFlags(event_flags); 112 browser::DispositionFromEventFlags(event_flags);
(...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 case IDC_CONTENT_CONTEXT_SAVELINKAS: { 1504 case IDC_CONTENT_CONTEXT_SAVELINKAS: {
1504 download_util::RecordDownloadSource( 1505 download_util::RecordDownloadSource(
1505 download_util::INITIATED_BY_CONTEXT_MENU); 1506 download_util::INITIATED_BY_CONTEXT_MENU);
1506 const GURL& referrer = 1507 const GURL& referrer =
1507 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; 1508 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url;
1508 const GURL& url = params_.link_url; 1509 const GURL& url = params_.link_url;
1509 content::DownloadSaveInfo save_info; 1510 content::DownloadSaveInfo save_info;
1510 save_info.prompt_for_save_location = true; 1511 save_info.prompt_for_save_location = true;
1511 DownloadManager* dlm = 1512 DownloadManager* dlm =
1512 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager(); 1513 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager();
1513 dlm->DownloadUrl(url, 1514 DownloadUrlParameters* dl_params = DownloadUrlParameters::FromWebContents(
1514 referrer, 1515 source_web_contents_, url, save_info);
1515 params_.frame_charset, 1516 dl_params->set_referrer(referrer);
1516 false, // Don't prefer_cache 1517 dl_params->set_referrer_encoding(params_.frame_charset);
1517 -1, // No POST id 1518 dlm->DownloadUrl(dl_params);
1518 save_info,
1519 source_web_contents_,
1520 DownloadManager::OnStartedCallback());
1521 break; 1519 break;
1522 } 1520 }
1523 1521
1524 case IDC_CONTENT_CONTEXT_SAVEAVAS: 1522 case IDC_CONTENT_CONTEXT_SAVEAVAS:
1525 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: { 1523 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: {
1526 download_util::RecordDownloadSource( 1524 download_util::RecordDownloadSource(
1527 download_util::INITIATED_BY_CONTEXT_MENU); 1525 download_util::INITIATED_BY_CONTEXT_MENU);
1528 const GURL& referrer = 1526 const GURL& referrer =
1529 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; 1527 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url;
1530 const GURL& url = params_.src_url; 1528 const GURL& url = params_.src_url;
1531 content::DownloadSaveInfo save_info; 1529 content::DownloadSaveInfo save_info;
1532 save_info.prompt_for_save_location = true; 1530 save_info.prompt_for_save_location = true;
1533 int64 post_id = -1; 1531 int64 post_id = -1;
1534 if (url == source_web_contents_->GetURL()) { 1532 if (url == source_web_contents_->GetURL()) {
1535 const NavigationEntry* entry = 1533 const NavigationEntry* entry =
1536 source_web_contents_->GetController().GetActiveEntry(); 1534 source_web_contents_->GetController().GetActiveEntry();
1537 if (entry) 1535 if (entry)
1538 post_id = entry->GetPostID(); 1536 post_id = entry->GetPostID();
1539 } 1537 }
1540 DownloadManager* dlm = 1538 DownloadManager* dlm =
1541 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager(); 1539 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager();
1542 dlm->DownloadUrl(url, 1540 DownloadUrlParameters* dl_params = DownloadUrlParameters::FromWebContents(
1543 referrer, 1541 source_web_contents_, url, save_info);
1544 "", 1542 dl_params->set_referrer(referrer);
1545 true, // prefer_cache 1543 dl_params->set_post_id(post_id);
1546 post_id, 1544 dlm->DownloadUrl(dl_params);
1547 save_info,
1548 source_web_contents_,
1549 DownloadManager::OnStartedCallback());
1550 break; 1545 break;
1551 } 1546 }
1552 1547
1553 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: 1548 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION:
1554 WriteURLToClipboard(params_.unfiltered_link_url); 1549 WriteURLToClipboard(params_.unfiltered_link_url);
1555 break; 1550 break;
1556 1551
1557 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION: 1552 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION:
1558 case IDC_CONTENT_CONTEXT_COPYAVLOCATION: 1553 case IDC_CONTENT_CONTEXT_COPYAVLOCATION:
1559 WriteURLToClipboard(params_.src_url); 1554 WriteURLToClipboard(params_.src_url);
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1973 source_web_contents_->GetRenderViewHost()-> 1968 source_web_contents_->GetRenderViewHost()->
1974 ExecuteMediaPlayerActionAtLocation(location, action); 1969 ExecuteMediaPlayerActionAtLocation(location, action);
1975 } 1970 }
1976 1971
1977 void RenderViewContextMenu::PluginActionAt( 1972 void RenderViewContextMenu::PluginActionAt(
1978 const gfx::Point& location, 1973 const gfx::Point& location,
1979 const WebPluginAction& action) { 1974 const WebPluginAction& action) {
1980 source_web_contents_->GetRenderViewHost()-> 1975 source_web_contents_->GetRenderViewHost()->
1981 ExecutePluginActionAtLocation(location, action); 1976 ExecutePluginActionAtLocation(location, action);
1982 } 1977 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698