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

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: cleaning 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 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 case IDC_CONTENT_CONTEXT_SAVELINKAS: { 1508 case IDC_CONTENT_CONTEXT_SAVELINKAS: {
1507 download_util::RecordDownloadSource( 1509 download_util::RecordDownloadSource(
1508 download_util::INITIATED_BY_CONTEXT_MENU); 1510 download_util::INITIATED_BY_CONTEXT_MENU);
1509 const GURL& referrer = 1511 const GURL& referrer =
1510 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; 1512 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url;
1511 const GURL& url = params_.link_url; 1513 const GURL& url = params_.link_url;
1512 content::DownloadSaveInfo save_info; 1514 content::DownloadSaveInfo save_info;
1513 save_info.prompt_for_save_location = true; 1515 save_info.prompt_for_save_location = true;
1514 DownloadManager* dlm = 1516 DownloadManager* dlm =
1515 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager(); 1517 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager();
1516 dlm->DownloadUrl(url, 1518 scoped_ptr<DownloadUrlParameters> dl_params(
1517 referrer, 1519 DownloadUrlParameters::FromWebContents(
1518 params_.frame_charset, 1520 source_web_contents_, url, save_info));
1519 false, // Don't prefer_cache 1521 dl_params->set_referrer(referrer);
1520 -1, // No POST id 1522 dl_params->set_referrer_encoding(params_.frame_charset);
1521 save_info, 1523 dlm->DownloadUrl(dl_params.Pass());
1522 source_web_contents_,
1523 DownloadManager::OnStartedCallback());
1524 break; 1524 break;
1525 } 1525 }
1526 1526
1527 case IDC_CONTENT_CONTEXT_SAVEAVAS: 1527 case IDC_CONTENT_CONTEXT_SAVEAVAS:
1528 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: { 1528 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: {
1529 download_util::RecordDownloadSource( 1529 download_util::RecordDownloadSource(
1530 download_util::INITIATED_BY_CONTEXT_MENU); 1530 download_util::INITIATED_BY_CONTEXT_MENU);
1531 const GURL& referrer = 1531 const GURL& referrer =
1532 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; 1532 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url;
1533 const GURL& url = params_.src_url; 1533 const GURL& url = params_.src_url;
1534 content::DownloadSaveInfo save_info; 1534 content::DownloadSaveInfo save_info;
1535 save_info.prompt_for_save_location = true; 1535 save_info.prompt_for_save_location = true;
1536 int64 post_id = -1; 1536 int64 post_id = -1;
1537 if (url == source_web_contents_->GetURL()) { 1537 if (url == source_web_contents_->GetURL()) {
1538 const NavigationEntry* entry = 1538 const NavigationEntry* entry =
1539 source_web_contents_->GetController().GetActiveEntry(); 1539 source_web_contents_->GetController().GetActiveEntry();
1540 if (entry) 1540 if (entry)
1541 post_id = entry->GetPostID(); 1541 post_id = entry->GetPostID();
1542 } 1542 }
1543 DownloadManager* dlm = 1543 DownloadManager* dlm =
1544 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager(); 1544 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager();
1545 dlm->DownloadUrl(url, 1545 scoped_ptr<DownloadUrlParameters> dl_params(
1546 referrer, 1546 DownloadUrlParameters::FromWebContents(
1547 "", 1547 source_web_contents_, url, save_info));
1548 true, // prefer_cache 1548 dl_params->set_referrer(referrer);
1549 post_id, 1549 dl_params->set_post_id(post_id);
1550 save_info, 1550 dl_params->set_prefer_cache(true);
1551 source_web_contents_, 1551 if (post_id >= 0)
1552 DownloadManager::OnStartedCallback()); 1552 dl_params->set_method("POST");
1553 dlm->DownloadUrl(dl_params.Pass());
1553 break; 1554 break;
1554 } 1555 }
1555 1556
1556 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: 1557 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION:
1557 WriteURLToClipboard(params_.unfiltered_link_url); 1558 WriteURLToClipboard(params_.unfiltered_link_url);
1558 break; 1559 break;
1559 1560
1560 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION: 1561 case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION:
1561 case IDC_CONTENT_CONTEXT_COPYAVLOCATION: 1562 case IDC_CONTENT_CONTEXT_COPYAVLOCATION:
1562 WriteURLToClipboard(params_.src_url); 1563 WriteURLToClipboard(params_.src_url);
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 source_web_contents_->GetRenderViewHost()-> 1970 source_web_contents_->GetRenderViewHost()->
1970 ExecuteMediaPlayerActionAtLocation(location, action); 1971 ExecuteMediaPlayerActionAtLocation(location, action);
1971 } 1972 }
1972 1973
1973 void RenderViewContextMenu::PluginActionAt( 1974 void RenderViewContextMenu::PluginActionAt(
1974 const gfx::Point& location, 1975 const gfx::Point& location,
1975 const WebPluginAction& action) { 1976 const WebPluginAction& action) {
1976 source_web_contents_->GetRenderViewHost()-> 1977 source_web_contents_->GetRenderViewHost()->
1977 ExecutePluginActionAtLocation(location, action); 1978 ExecutePluginActionAtLocation(location, action);
1978 } 1979 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698