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

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

Issue 10535026: Move creation and ownership of DownloadManager from the embedder to content. This matches all the o… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros compile Created 8 years, 6 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 #ifdef FILE_MANAGER_EXTENSION 87 #ifdef FILE_MANAGER_EXTENSION
88 #include "chrome/browser/chromeos/extensions/file_manager_util.h" 88 #include "chrome/browser/chromeos/extensions/file_manager_util.h"
89 #endif 89 #endif
90 90
91 using WebKit::WebContextMenuData; 91 using WebKit::WebContextMenuData;
92 using WebKit::WebMediaPlayerAction; 92 using WebKit::WebMediaPlayerAction;
93 using WebKit::WebPluginAction; 93 using WebKit::WebPluginAction;
94 using WebKit::WebString; 94 using WebKit::WebString;
95 using WebKit::WebURL; 95 using WebKit::WebURL;
96 using content::BrowserContext;
96 using content::ChildProcessSecurityPolicy; 97 using content::ChildProcessSecurityPolicy;
97 using content::DownloadManager; 98 using content::DownloadManager;
98 using content::DownloadUrlParameters; 99 using content::DownloadUrlParameters;
99 using content::NavigationController; 100 using content::NavigationController;
100 using content::NavigationEntry; 101 using content::NavigationEntry;
101 using content::OpenURLParams; 102 using content::OpenURLParams;
102 using content::RenderViewHost; 103 using content::RenderViewHost;
103 using content::SSLStatus; 104 using content::SSLStatus;
104 using content::UserMetricsAction; 105 using content::UserMetricsAction;
105 using content::WebContents; 106 using content::WebContents;
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 break; 1514 break;
1514 1515
1515 case IDC_CONTENT_CONTEXT_SAVELINKAS: { 1516 case IDC_CONTENT_CONTEXT_SAVELINKAS: {
1516 download_util::RecordDownloadSource( 1517 download_util::RecordDownloadSource(
1517 download_util::INITIATED_BY_CONTEXT_MENU); 1518 download_util::INITIATED_BY_CONTEXT_MENU);
1518 const GURL& referrer = 1519 const GURL& referrer =
1519 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; 1520 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url;
1520 const GURL& url = params_.link_url; 1521 const GURL& url = params_.link_url;
1521 content::DownloadSaveInfo save_info; 1522 content::DownloadSaveInfo save_info;
1522 save_info.prompt_for_save_location = true; 1523 save_info.prompt_for_save_location = true;
1523 DownloadManager* dlm = 1524 DownloadManager* dlm = BrowserContext::GetDownloadManager(profile_);
1524 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager();
1525 scoped_ptr<DownloadUrlParameters> dl_params( 1525 scoped_ptr<DownloadUrlParameters> dl_params(
1526 DownloadUrlParameters::FromWebContents( 1526 DownloadUrlParameters::FromWebContents(
1527 source_web_contents_, url, save_info)); 1527 source_web_contents_, url, save_info));
1528 dl_params->set_referrer( 1528 dl_params->set_referrer(
1529 content::Referrer(referrer, params_.referrer_policy)); 1529 content::Referrer(referrer, params_.referrer_policy));
1530 dl_params->set_referrer_encoding(params_.frame_charset); 1530 dl_params->set_referrer_encoding(params_.frame_charset);
1531 dlm->DownloadUrl(dl_params.Pass()); 1531 dlm->DownloadUrl(dl_params.Pass());
1532 break; 1532 break;
1533 } 1533 }
1534 1534
1535 case IDC_CONTENT_CONTEXT_SAVEAVAS: 1535 case IDC_CONTENT_CONTEXT_SAVEAVAS:
1536 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: { 1536 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: {
1537 download_util::RecordDownloadSource( 1537 download_util::RecordDownloadSource(
1538 download_util::INITIATED_BY_CONTEXT_MENU); 1538 download_util::INITIATED_BY_CONTEXT_MENU);
1539 const GURL& referrer = 1539 const GURL& referrer =
1540 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; 1540 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url;
1541 const GURL& url = params_.src_url; 1541 const GURL& url = params_.src_url;
1542 content::DownloadSaveInfo save_info; 1542 content::DownloadSaveInfo save_info;
1543 save_info.prompt_for_save_location = true; 1543 save_info.prompt_for_save_location = true;
1544 int64 post_id = -1; 1544 int64 post_id = -1;
1545 if (url == source_web_contents_->GetURL()) { 1545 if (url == source_web_contents_->GetURL()) {
1546 const NavigationEntry* entry = 1546 const NavigationEntry* entry =
1547 source_web_contents_->GetController().GetActiveEntry(); 1547 source_web_contents_->GetController().GetActiveEntry();
1548 if (entry) 1548 if (entry)
1549 post_id = entry->GetPostID(); 1549 post_id = entry->GetPostID();
1550 } 1550 }
1551 DownloadManager* dlm = 1551 DownloadManager* dlm = BrowserContext::GetDownloadManager(profile_);
1552 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager();
1553 scoped_ptr<DownloadUrlParameters> dl_params( 1552 scoped_ptr<DownloadUrlParameters> dl_params(
1554 DownloadUrlParameters::FromWebContents( 1553 DownloadUrlParameters::FromWebContents(
1555 source_web_contents_, url, save_info)); 1554 source_web_contents_, url, save_info));
1556 dl_params->set_referrer( 1555 dl_params->set_referrer(
1557 content::Referrer(referrer, params_.referrer_policy)); 1556 content::Referrer(referrer, params_.referrer_policy));
1558 dl_params->set_post_id(post_id); 1557 dl_params->set_post_id(post_id);
1559 dl_params->set_prefer_cache(true); 1558 dl_params->set_prefer_cache(true);
1560 if (post_id >= 0) 1559 if (post_id >= 0)
1561 dl_params->set_method("POST"); 1560 dl_params->set_method("POST");
1562 dlm->DownloadUrl(dl_params.Pass()); 1561 dlm->DownloadUrl(dl_params.Pass());
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 source_web_contents_->GetRenderViewHost()-> 1986 source_web_contents_->GetRenderViewHost()->
1988 ExecuteMediaPlayerActionAtLocation(location, action); 1987 ExecuteMediaPlayerActionAtLocation(location, action);
1989 } 1988 }
1990 1989
1991 void RenderViewContextMenu::PluginActionAt( 1990 void RenderViewContextMenu::PluginActionAt(
1992 const gfx::Point& location, 1991 const gfx::Point& location,
1993 const WebPluginAction& action) { 1992 const WebPluginAction& action) {
1994 source_web_contents_->GetRenderViewHost()-> 1993 source_web_contents_->GetRenderViewHost()->
1995 ExecutePluginActionAtLocation(location, action); 1994 ExecutePluginActionAtLocation(location, action);
1996 } 1995 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698