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

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: fixes Created 8 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) 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #include "chrome/common/chrome_switches.h" 55 #include "chrome/common/chrome_switches.h"
56 #include "chrome/common/chrome_view_type.h" 56 #include "chrome/common/chrome_view_type.h"
57 #include "chrome/common/extensions/extension.h" 57 #include "chrome/common/extensions/extension.h"
58 #include "chrome/common/pref_names.h" 58 #include "chrome/common/pref_names.h"
59 #include "chrome/common/print_messages.h" 59 #include "chrome/common/print_messages.h"
60 #include "chrome/common/spellcheck_messages.h" 60 #include "chrome/common/spellcheck_messages.h"
61 #include "chrome/common/url_constants.h" 61 #include "chrome/common/url_constants.h"
62 #include "content/public/browser/child_process_security_policy.h" 62 #include "content/public/browser/child_process_security_policy.h"
63 #include "content/public/browser/download_manager.h" 63 #include "content/public/browser/download_manager.h"
64 #include "content/public/browser/download_save_info.h" 64 #include "content/public/browser/download_save_info.h"
65 #include "content/public/browser/download_url_parameters.h"
65 #include "content/public/browser/navigation_details.h" 66 #include "content/public/browser/navigation_details.h"
66 #include "content/public/browser/navigation_entry.h" 67 #include "content/public/browser/navigation_entry.h"
67 #include "content/public/browser/notification_service.h" 68 #include "content/public/browser/notification_service.h"
68 #include "content/public/browser/render_view_host.h" 69 #include "content/public/browser/render_view_host.h"
69 #include "content/public/browser/render_widget_host_view.h" 70 #include "content/public/browser/render_widget_host_view.h"
70 #include "content/public/browser/speech_recognition_preferences.h" 71 #include "content/public/browser/speech_recognition_preferences.h"
71 #include "content/public/browser/user_metrics.h" 72 #include "content/public/browser/user_metrics.h"
72 #include "content/public/browser/web_contents.h" 73 #include "content/public/browser/web_contents.h"
73 #include "content/public/common/content_restriction.h" 74 #include "content/public/common/content_restriction.h"
74 #include "content/public/common/ssl_status.h" 75 #include "content/public/common/ssl_status.h"
75 #include "grit/generated_resources.h" 76 #include "grit/generated_resources.h"
76 #include "net/base/escape.h" 77 #include "net/base/escape.h"
77 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" 78 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
78 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h" 79 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h"
79 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginAction.h" 80 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginAction.h"
80 #include "ui/base/l10n/l10n_util.h" 81 #include "ui/base/l10n/l10n_util.h"
81 #include "ui/base/text/text_elider.h" 82 #include "ui/base/text/text_elider.h"
82 #include "ui/gfx/favicon_size.h" 83 #include "ui/gfx/favicon_size.h"
83 #include "webkit/glue/webmenuitem.h" 84 #include "webkit/glue/webmenuitem.h"
84 85
85 #ifdef FILE_MANAGER_EXTENSION 86 #ifdef FILE_MANAGER_EXTENSION
86 #include "chrome/browser/chromeos/extensions/file_manager_util.h" 87 #include "chrome/browser/chromeos/extensions/file_manager_util.h"
87 #endif 88 #endif
88 89
90 using WebKit::WebContextMenuData;
91 using WebKit::WebMediaPlayerAction;
92 using WebKit::WebPluginAction;
93 using WebKit::WebString;
94 using WebKit::WebURL;
89 using content::ChildProcessSecurityPolicy; 95 using content::ChildProcessSecurityPolicy;
90 using content::DownloadManager; 96 using content::DownloadManager;
97 using content::DownloadUrlParameters;
91 using content::NavigationController; 98 using content::NavigationController;
92 using content::NavigationEntry; 99 using content::NavigationEntry;
93 using content::OpenURLParams; 100 using content::OpenURLParams;
94 using content::RenderViewHost; 101 using content::RenderViewHost;
95 using content::SSLStatus; 102 using content::SSLStatus;
96 using content::UserMetricsAction; 103 using content::UserMetricsAction;
97 using content::WebContents; 104 using content::WebContents;
98 using WebKit::WebContextMenuData;
99 using WebKit::WebMediaPlayerAction;
100 using WebKit::WebPluginAction;
101 using WebKit::WebURL;
102 using WebKit::WebString;
103 105
104 namespace { 106 namespace {
105 107
106 // Usually a new tab is expected where this function is used, 108 // Usually a new tab is expected where this function is used,
107 // however users should be able to open a tab in background 109 // however users should be able to open a tab in background
108 // or in a new window. 110 // or in a new window.
109 WindowOpenDisposition ForceNewTabDispositionFromEventFlags( 111 WindowOpenDisposition ForceNewTabDispositionFromEventFlags(
110 int event_flags) { 112 int event_flags) {
111 WindowOpenDisposition disposition = 113 WindowOpenDisposition disposition =
112 browser::DispositionFromEventFlags(event_flags); 114 browser::DispositionFromEventFlags(event_flags);
(...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 case IDC_CONTENT_CONTEXT_SAVELINKAS: { 1512 case IDC_CONTENT_CONTEXT_SAVELINKAS: {
1511 download_util::RecordDownloadSource( 1513 download_util::RecordDownloadSource(
1512 download_util::INITIATED_BY_CONTEXT_MENU); 1514 download_util::INITIATED_BY_CONTEXT_MENU);
1513 const GURL& referrer = 1515 const GURL& referrer =
1514 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; 1516 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url;
1515 const GURL& url = params_.link_url; 1517 const GURL& url = params_.link_url;
1516 content::DownloadSaveInfo save_info; 1518 content::DownloadSaveInfo save_info;
1517 save_info.prompt_for_save_location = true; 1519 save_info.prompt_for_save_location = true;
1518 DownloadManager* dlm = 1520 DownloadManager* dlm =
1519 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager(); 1521 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager();
1520 dlm->DownloadUrl(url, 1522 scoped_ptr<DownloadUrlParameters> dl_params(
1521 referrer, 1523 DownloadUrlParameters::FromWebContents(
1522 params_.frame_charset, 1524 source_web_contents_, url, save_info));
1523 false, // Don't prefer_cache 1525 dl_params->set_referrer(referrer);
1524 -1, // No POST id 1526 dl_params->set_referrer_encoding(params_.frame_charset);
1525 save_info, 1527 dlm->DownloadUrl(dl_params.Pass());
1526 source_web_contents_,
1527 DownloadManager::OnStartedCallback());
1528 break; 1528 break;
1529 } 1529 }
1530 1530
1531 case IDC_CONTENT_CONTEXT_SAVEAVAS: 1531 case IDC_CONTENT_CONTEXT_SAVEAVAS:
1532 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: { 1532 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: {
1533 download_util::RecordDownloadSource( 1533 download_util::RecordDownloadSource(
1534 download_util::INITIATED_BY_CONTEXT_MENU); 1534 download_util::INITIATED_BY_CONTEXT_MENU);
1535 const GURL& referrer = 1535 const GURL& referrer =
1536 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; 1536 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url;
1537 const GURL& url = params_.src_url; 1537 const GURL& url = params_.src_url;
1538 content::DownloadSaveInfo save_info; 1538 content::DownloadSaveInfo save_info;
1539 save_info.prompt_for_save_location = true; 1539 save_info.prompt_for_save_location = true;
1540 int64 post_id = -1; 1540 int64 post_id = -1;
1541 if (url == source_web_contents_->GetURL()) { 1541 if (url == source_web_contents_->GetURL()) {
1542 const NavigationEntry* entry = 1542 const NavigationEntry* entry =
1543 source_web_contents_->GetController().GetActiveEntry(); 1543 source_web_contents_->GetController().GetActiveEntry();
1544 if (entry) 1544 if (entry)
1545 post_id = entry->GetPostID(); 1545 post_id = entry->GetPostID();
1546 } 1546 }
1547 DownloadManager* dlm = 1547 DownloadManager* dlm =
1548 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager(); 1548 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager();
1549 dlm->DownloadUrl(url, 1549 scoped_ptr<DownloadUrlParameters> dl_params(
1550 referrer, 1550 DownloadUrlParameters::FromWebContents(
1551 "", 1551 source_web_contents_, url, save_info));
1552 true, // prefer_cache 1552 dl_params->set_referrer(referrer);
1553 post_id, 1553 dl_params->set_post_id(post_id);
1554 save_info, 1554 dl_params->set_prefer_cache(true);
1555 source_web_contents_, 1555 if (post_id >= 0)
1556 DownloadManager::OnStartedCallback()); 1556 dl_params->set_method("POST");
1557 dlm->DownloadUrl(dl_params.Pass());
1557 break; 1558 break;
1558 } 1559 }
1559 1560
1560 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: 1561 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION:
1561 WriteURLToClipboard(params_.unfiltered_link_url); 1562 WriteURLToClipboard(params_.unfiltered_link_url);
1562 break; 1563 break;
1563 1564
1564 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION: 1565 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION:
1565 case IDC_CONTENT_CONTEXT_COPYAVLOCATION: 1566 case IDC_CONTENT_CONTEXT_COPYAVLOCATION:
1566 WriteURLToClipboard(params_.src_url); 1567 WriteURLToClipboard(params_.src_url);
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 source_web_contents_->GetRenderViewHost()-> 1979 source_web_contents_->GetRenderViewHost()->
1979 ExecuteMediaPlayerActionAtLocation(location, action); 1980 ExecuteMediaPlayerActionAtLocation(location, action);
1980 } 1981 }
1981 1982
1982 void RenderViewContextMenu::PluginActionAt( 1983 void RenderViewContextMenu::PluginActionAt(
1983 const gfx::Point& location, 1984 const gfx::Point& location,
1984 const WebPluginAction& action) { 1985 const WebPluginAction& action) {
1985 source_web_contents_->GetRenderViewHost()-> 1986 source_web_contents_->GetRenderViewHost()->
1986 ExecutePluginActionAtLocation(location, action); 1987 ExecutePluginActionAtLocation(location, action);
1987 } 1988 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/webstore_installer.cc ('k') | content/browser/download/download_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698