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

Side by Side Diff: chrome/browser/file_select_helper.cc

Issue 2059533002: Change WebContentsDelegate::RunFileChooser to be frame based. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes based on reviews. Created 4 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
« no previous file with comments | « chrome/browser/file_select_helper.h ('k') | chrome/browser/ui/apps/chrome_app_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/file_select_helper.h" 5 #include "chrome/browser/file_select_helper.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 12 matching lines...) Expand all
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/profiles/profile_manager.h" 24 #include "chrome/browser/profiles/profile_manager.h"
25 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
26 #include "chrome/browser/ui/browser_list.h" 26 #include "chrome/browser/ui/browser_list.h"
27 #include "chrome/browser/ui/chrome_select_file_policy.h" 27 #include "chrome/browser/ui/chrome_select_file_policy.h"
28 #include "chrome/grit/generated_resources.h" 28 #include "chrome/grit/generated_resources.h"
29 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/notification_details.h" 30 #include "content/public/browser/notification_details.h"
31 #include "content/public/browser/notification_source.h" 31 #include "content/public/browser/notification_source.h"
32 #include "content/public/browser/notification_types.h" 32 #include "content/public/browser/notification_types.h"
33 #include "content/public/browser/render_frame_host.h"
34 #include "content/public/browser/render_process_host.h"
33 #include "content/public/browser/render_view_host.h" 35 #include "content/public/browser/render_view_host.h"
34 #include "content/public/browser/render_widget_host.h" 36 #include "content/public/browser/render_widget_host.h"
35 #include "content/public/browser/render_widget_host_view.h" 37 #include "content/public/browser/render_widget_host_view.h"
36 #include "content/public/browser/storage_partition.h" 38 #include "content/public/browser/storage_partition.h"
37 #include "content/public/browser/web_contents.h" 39 #include "content/public/browser/web_contents.h"
38 #include "content/public/common/file_chooser_file_info.h" 40 #include "content/public/common/file_chooser_file_info.h"
39 #include "content/public/common/file_chooser_params.h" 41 #include "content/public/common/file_chooser_params.h"
40 #include "net/base/filename_util.h" 42 #include "net/base/filename_util.h"
41 #include "net/base/mime_util.h" 43 #include "net/base/mime_util.h"
42 #include "ui/base/l10n/l10n_util.h" 44 #include "ui/base/l10n/l10n_util.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 ActiveDirectoryEnumeration() : rvh_(NULL) {} 125 ActiveDirectoryEnumeration() : rvh_(NULL) {}
124 126
125 std::unique_ptr<DirectoryListerDispatchDelegate> delegate_; 127 std::unique_ptr<DirectoryListerDispatchDelegate> delegate_;
126 std::unique_ptr<net::DirectoryLister> lister_; 128 std::unique_ptr<net::DirectoryLister> lister_;
127 RenderViewHost* rvh_; 129 RenderViewHost* rvh_;
128 std::vector<base::FilePath> results_; 130 std::vector<base::FilePath> results_;
129 }; 131 };
130 132
131 FileSelectHelper::FileSelectHelper(Profile* profile) 133 FileSelectHelper::FileSelectHelper(Profile* profile)
132 : profile_(profile), 134 : profile_(profile),
133 render_view_host_(NULL), 135 render_frame_host_(nullptr),
134 web_contents_(NULL), 136 web_contents_(nullptr),
135 select_file_dialog_(), 137 select_file_dialog_(),
136 select_file_types_(), 138 select_file_types_(),
137 dialog_type_(ui::SelectFileDialog::SELECT_OPEN_FILE), 139 dialog_type_(ui::SelectFileDialog::SELECT_OPEN_FILE),
138 dialog_mode_(FileChooserParams::Open) { 140 dialog_mode_(FileChooserParams::Open) {}
139 }
140 141
141 FileSelectHelper::~FileSelectHelper() { 142 FileSelectHelper::~FileSelectHelper() {
142 // There may be pending file dialogs, we need to tell them that we've gone 143 // There may be pending file dialogs, we need to tell them that we've gone
143 // away so they don't try and call back to us. 144 // away so they don't try and call back to us.
144 if (select_file_dialog_.get()) 145 if (select_file_dialog_.get())
145 select_file_dialog_->ListenerDestroyed(); 146 select_file_dialog_->ListenerDestroyed();
146 147
147 // Stop any pending directory enumeration, prevent a callback, and free 148 // Stop any pending directory enumeration, prevent a callback, and free
148 // allocated memory. 149 // allocated memory.
149 std::map<int, ActiveDirectoryEnumeration*>::iterator iter; 150 std::map<int, ActiveDirectoryEnumeration*>::iterator iter;
(...skipping 19 matching lines...) Expand all
169 FileSelectedWithExtraInfo(ui::SelectedFileInfo(path, path), index, params); 170 FileSelectedWithExtraInfo(ui::SelectedFileInfo(path, path), index, params);
170 } 171 }
171 172
172 void FileSelectHelper::FileSelectedWithExtraInfo( 173 void FileSelectHelper::FileSelectedWithExtraInfo(
173 const ui::SelectedFileInfo& file, 174 const ui::SelectedFileInfo& file,
174 int index, 175 int index,
175 void* params) { 176 void* params) {
176 if (IsValidProfile(profile_)) 177 if (IsValidProfile(profile_))
177 profile_->set_last_selected_directory(file.file_path.DirName()); 178 profile_->set_last_selected_directory(file.file_path.DirName());
178 179
179 if (!render_view_host_) { 180 if (!render_frame_host_) {
180 RunFileChooserEnd(); 181 RunFileChooserEnd();
181 return; 182 return;
182 } 183 }
183 184
184 const base::FilePath& path = file.local_path; 185 const base::FilePath& path = file.local_path;
185 if (dialog_type_ == ui::SelectFileDialog::SELECT_UPLOAD_FOLDER) { 186 if (dialog_type_ == ui::SelectFileDialog::SELECT_UPLOAD_FOLDER) {
186 StartNewEnumeration(path, kFileSelectEnumerationId, render_view_host_); 187 StartNewEnumeration(path, kFileSelectEnumerationId,
188 render_frame_host_->GetRenderViewHost());
187 return; 189 return;
188 } 190 }
189 191
190 std::vector<ui::SelectedFileInfo> files; 192 std::vector<ui::SelectedFileInfo> files;
191 files.push_back(file); 193 files.push_back(file);
192 194
193 #if defined(OS_MACOSX) 195 #if defined(OS_MACOSX)
194 content::BrowserThread::PostTask( 196 content::BrowserThread::PostTask(
195 content::BrowserThread::FILE_USER_BLOCKING, 197 content::BrowserThread::FILE_USER_BLOCKING,
196 FROM_HERE, 198 FROM_HERE,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 if (id == kFileSelectEnumerationId) { 281 if (id == kFileSelectEnumerationId) {
280 NotifyRenderViewHostAndEnd(selected_files); 282 NotifyRenderViewHostAndEnd(selected_files);
281 } else { 283 } else {
282 entry->rvh_->DirectoryEnumerationFinished(id, entry->results_); 284 entry->rvh_->DirectoryEnumerationFinished(id, entry->results_);
283 EnumerateDirectoryEnd(); 285 EnumerateDirectoryEnd();
284 } 286 }
285 } 287 }
286 288
287 void FileSelectHelper::NotifyRenderViewHostAndEnd( 289 void FileSelectHelper::NotifyRenderViewHostAndEnd(
288 const std::vector<ui::SelectedFileInfo>& files) { 290 const std::vector<ui::SelectedFileInfo>& files) {
289 if (!render_view_host_) { 291 if (!render_frame_host_) {
290 RunFileChooserEnd(); 292 RunFileChooserEnd();
291 return; 293 return;
292 } 294 }
293 295
294 #if defined(OS_CHROMEOS) 296 #if defined(OS_CHROMEOS)
295 if (!files.empty()) { 297 if (!files.empty()) {
296 if (!IsValidProfile(profile_)) { 298 if (!IsValidProfile(profile_)) {
297 RunFileChooserEnd(); 299 RunFileChooserEnd();
298 return; 300 return;
299 } 301 }
300 // Converts |files| into FileChooserFileInfo with handling of non-native 302 // Converts |files| into FileChooserFileInfo with handling of non-native
301 // files. 303 // files.
304 content::SiteInstance* site_instance =
305 render_frame_host_->GetSiteInstance();
302 storage::FileSystemContext* file_system_context = 306 storage::FileSystemContext* file_system_context =
303 content::BrowserContext::GetStoragePartition( 307 content::BrowserContext::GetStoragePartition(profile_, site_instance)
304 profile_, render_view_host_->GetSiteInstance())-> 308 ->GetFileSystemContext();
305 GetFileSystemContext();
306 file_manager::util::ConvertSelectedFileInfoListToFileChooserFileInfoList( 309 file_manager::util::ConvertSelectedFileInfoListToFileChooserFileInfoList(
307 file_system_context, 310 file_system_context, site_instance->GetSiteURL(), files,
308 web_contents_->GetSiteInstance()->GetSiteURL(), 311 base::Bind(&FileSelectHelper::NotifyRenderViewHostAndEndAfterConversion,
309 files, 312 this));
310 base::Bind(
311 &FileSelectHelper::NotifyRenderViewHostAndEndAfterConversion,
312 this));
313 return; 313 return;
314 } 314 }
315 #endif // defined(OS_CHROMEOS) 315 #endif // defined(OS_CHROMEOS)
316 316
317 std::vector<content::FileChooserFileInfo> chooser_files; 317 std::vector<content::FileChooserFileInfo> chooser_files;
318 for (const auto& file : files) { 318 for (const auto& file : files) {
319 content::FileChooserFileInfo chooser_file; 319 content::FileChooserFileInfo chooser_file;
320 chooser_file.file_path = file.local_path; 320 chooser_file.file_path = file.local_path;
321 chooser_file.display_name = file.display_name; 321 chooser_file.display_name = file.display_name;
322 chooser_files.push_back(chooser_file); 322 chooser_files.push_back(chooser_file);
323 } 323 }
324 324
325 NotifyRenderViewHostAndEndAfterConversion(chooser_files); 325 NotifyRenderViewHostAndEndAfterConversion(chooser_files);
326 } 326 }
327 327
328 void FileSelectHelper::NotifyRenderViewHostAndEndAfterConversion( 328 void FileSelectHelper::NotifyRenderViewHostAndEndAfterConversion(
329 const std::vector<content::FileChooserFileInfo>& list) { 329 const std::vector<content::FileChooserFileInfo>& list) {
330 if (render_view_host_) 330 if (render_frame_host_)
331 render_view_host_->FilesSelectedInChooser(list, dialog_mode_); 331 render_frame_host_->FilesSelectedInChooser(list, dialog_mode_);
332 332
333 // No members should be accessed from here on. 333 // No members should be accessed from here on.
334 RunFileChooserEnd(); 334 RunFileChooserEnd();
335 } 335 }
336 336
337 void FileSelectHelper::DeleteTemporaryFiles() { 337 void FileSelectHelper::DeleteTemporaryFiles() {
338 BrowserThread::PostTask(BrowserThread::FILE, 338 BrowserThread::PostTask(BrowserThread::FILE,
339 FROM_HERE, 339 FROM_HERE,
340 base::Bind(&DeleteFiles, temporary_files_)); 340 base::Bind(&DeleteFiles, temporary_files_));
341 temporary_files_.clear(); 341 temporary_files_.clear();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 413
414 if (description_id) { 414 if (description_id) {
415 file_type->extension_description_overrides.push_back( 415 file_type->extension_description_overrides.push_back(
416 l10n_util::GetStringUTF16(description_id)); 416 l10n_util::GetStringUTF16(description_id));
417 } 417 }
418 418
419 return file_type; 419 return file_type;
420 } 420 }
421 421
422 // static 422 // static
423 void FileSelectHelper::RunFileChooser(content::WebContents* tab, 423 void FileSelectHelper::RunFileChooser(
424 const FileChooserParams& params) { 424 content::RenderFrameHost* render_frame_host,
425 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); 425 const FileChooserParams& params) {
426 Profile* profile = Profile::FromBrowserContext(
427 render_frame_host->GetProcess()->GetBrowserContext());
426 // FileSelectHelper will keep itself alive until it sends the result message. 428 // FileSelectHelper will keep itself alive until it sends the result message.
427 scoped_refptr<FileSelectHelper> file_select_helper( 429 scoped_refptr<FileSelectHelper> file_select_helper(
428 new FileSelectHelper(profile)); 430 new FileSelectHelper(profile));
429 file_select_helper->RunFileChooser( 431 file_select_helper->RunFileChooser(
430 tab->GetRenderViewHost(), tab, 432 render_frame_host,
431 base::WrapUnique(new content::FileChooserParams(params))); 433 base::WrapUnique(new content::FileChooserParams(params)));
432 } 434 }
433 435
434 // static 436 // static
435 void FileSelectHelper::EnumerateDirectory(content::WebContents* tab, 437 void FileSelectHelper::EnumerateDirectory(content::WebContents* tab,
436 int request_id, 438 int request_id,
437 const base::FilePath& path) { 439 const base::FilePath& path) {
438 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); 440 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext());
439 // FileSelectHelper will keep itself alive until it sends the result message. 441 // FileSelectHelper will keep itself alive until it sends the result message.
440 scoped_refptr<FileSelectHelper> file_select_helper( 442 scoped_refptr<FileSelectHelper> file_select_helper(
441 new FileSelectHelper(profile)); 443 new FileSelectHelper(profile));
442 file_select_helper->EnumerateDirectory( 444 file_select_helper->EnumerateDirectory(
443 request_id, tab->GetRenderViewHost(), path); 445 request_id, tab->GetRenderViewHost(), path);
444 } 446 }
445 447
446 void FileSelectHelper::RunFileChooser( 448 void FileSelectHelper::RunFileChooser(
447 RenderViewHost* render_view_host, 449 content::RenderFrameHost* render_frame_host,
448 content::WebContents* web_contents,
449 std::unique_ptr<FileChooserParams> params) { 450 std::unique_ptr<FileChooserParams> params) {
450 DCHECK(!render_view_host_); 451 DCHECK(!render_frame_host_);
451 DCHECK(!web_contents_); 452 DCHECK(!web_contents_);
452 DCHECK(params->default_file_name.empty() || 453 DCHECK(params->default_file_name.empty() ||
453 params->mode == FileChooserParams::Save) 454 params->mode == FileChooserParams::Save)
454 << "The default_file_name parameter should only be specified for Save " 455 << "The default_file_name parameter should only be specified for Save "
455 "file choosers"; 456 "file choosers";
456 DCHECK(params->default_file_name == params->default_file_name.BaseName()) 457 DCHECK(params->default_file_name == params->default_file_name.BaseName())
457 << "The default_file_name parameter should not contain path separators"; 458 << "The default_file_name parameter should not contain path separators";
458 459
459 render_view_host_ = render_view_host; 460 render_frame_host_ = render_frame_host;
460 web_contents_ = web_contents; 461 web_contents_ = WebContents::FromRenderFrameHost(render_frame_host);
461 notification_registrar_.RemoveAll(); 462 notification_registrar_.RemoveAll();
462 content::WebContentsObserver::Observe(web_contents_); 463 content::WebContentsObserver::Observe(web_contents_);
463 notification_registrar_.Add( 464 notification_registrar_.Add(
464 this, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 465 this, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
465 content::Source<RenderWidgetHost>(render_view_host_->GetWidget())); 466 content::Source<RenderWidgetHost>(
467 render_frame_host_->GetRenderViewHost()->GetWidget()));
466 468
467 BrowserThread::PostTask( 469 BrowserThread::PostTask(
468 BrowserThread::FILE, FROM_HERE, 470 BrowserThread::FILE, FROM_HERE,
469 base::Bind(&FileSelectHelper::GetFileTypesOnFileThread, this, 471 base::Bind(&FileSelectHelper::GetFileTypesOnFileThread, this,
470 base::Passed(&params))); 472 base::Passed(&params)));
471 473
472 // Because this class returns notifications to the RenderViewHost, it is 474 // Because this class returns notifications to the RenderViewHost, it is
473 // difficult for callers to know how long to keep a reference to this 475 // difficult for callers to know how long to keep a reference to this
474 // instance. We AddRef() here to keep the instance alive after we return 476 // instance. We AddRef() here to keep the instance alive after we return
475 // to the caller, until the last callback is received from the file dialog. 477 // to the caller, until the last callback is received from the file dialog.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 return; 545 return;
544 } 546 }
545 RunFileChooserOnUIThread(default_file_path, std::move(params)); 547 RunFileChooserOnUIThread(default_file_path, std::move(params));
546 } 548 }
547 #endif 549 #endif
548 550
549 void FileSelectHelper::RunFileChooserOnUIThread( 551 void FileSelectHelper::RunFileChooserOnUIThread(
550 const base::FilePath& default_file_path, 552 const base::FilePath& default_file_path,
551 std::unique_ptr<FileChooserParams> params) { 553 std::unique_ptr<FileChooserParams> params) {
552 DCHECK(params); 554 DCHECK(params);
553 if (!render_view_host_ || !web_contents_ || !IsValidProfile(profile_) || 555 if (!render_frame_host_ || !web_contents_ || !IsValidProfile(profile_) ||
554 !render_view_host_->GetWidget()->GetView()) { 556 !web_contents_->GetNativeView()) {
555 // If the renderer was destroyed before we started, just cancel the 557 // If the renderer was destroyed before we started, just cancel the
556 // operation. 558 // operation.
557 RunFileChooserEnd(); 559 RunFileChooserEnd();
558 return; 560 return;
559 } 561 }
560 562
561 select_file_dialog_ = ui::SelectFileDialog::Create( 563 select_file_dialog_ = ui::SelectFileDialog::Create(
562 this, new ChromeSelectFilePolicy(web_contents_)); 564 this, new ChromeSelectFilePolicy(web_contents_));
563 if (!select_file_dialog_.get()) 565 if (!select_file_dialog_.get())
564 return; 566 return;
(...skipping 11 matching lines...) Expand all
576 break; 578 break;
577 case FileChooserParams::Save: 579 case FileChooserParams::Save:
578 dialog_type_ = ui::SelectFileDialog::SELECT_SAVEAS_FILE; 580 dialog_type_ = ui::SelectFileDialog::SELECT_SAVEAS_FILE;
579 break; 581 break;
580 default: 582 default:
581 // Prevent warning. 583 // Prevent warning.
582 dialog_type_ = ui::SelectFileDialog::SELECT_OPEN_FILE; 584 dialog_type_ = ui::SelectFileDialog::SELECT_OPEN_FILE;
583 NOTREACHED(); 585 NOTREACHED();
584 } 586 }
585 587
586 gfx::NativeWindow owning_window = platform_util::GetTopLevel( 588 gfx::NativeWindow owning_window =
587 render_view_host_->GetWidget()->GetView()->GetNativeView()); 589 platform_util::GetTopLevel(web_contents_->GetNativeView());
588 590
589 #if defined(OS_ANDROID) 591 #if defined(OS_ANDROID)
590 // Android needs the original MIME types and an additional capture value. 592 // Android needs the original MIME types and an additional capture value.
591 std::pair<std::vector<base::string16>, bool> accept_types = 593 std::pair<std::vector<base::string16>, bool> accept_types =
592 std::make_pair(params->accept_types, params->capture); 594 std::make_pair(params->accept_types, params->capture);
593 #endif 595 #endif
594 596
595 select_file_dialog_->SelectFile( 597 select_file_dialog_->SelectFile(
596 dialog_type_, params->title, default_file_path, select_file_types_.get(), 598 dialog_type_, params->title, default_file_path, select_file_types_.get(),
597 select_file_types_.get() && !select_file_types_->extensions.empty() 599 select_file_types_.get() && !select_file_types_->extensions.empty()
(...skipping 13 matching lines...) Expand all
611 // This method is called when we receive the last callback from the file 613 // This method is called when we receive the last callback from the file
612 // chooser dialog. Perform any cleanup and release the reference we added 614 // chooser dialog. Perform any cleanup and release the reference we added
613 // in RunFileChooser(). 615 // in RunFileChooser().
614 void FileSelectHelper::RunFileChooserEnd() { 616 void FileSelectHelper::RunFileChooserEnd() {
615 // If there are temporary files, then this instance needs to stick around 617 // If there are temporary files, then this instance needs to stick around
616 // until web_contents_ is destroyed, so that this instance can delete the 618 // until web_contents_ is destroyed, so that this instance can delete the
617 // temporary files. 619 // temporary files.
618 if (!temporary_files_.empty()) 620 if (!temporary_files_.empty())
619 return; 621 return;
620 622
621 render_view_host_ = NULL; 623 render_frame_host_ = nullptr;
622 web_contents_ = NULL; 624 web_contents_ = nullptr;
623 Release(); 625 Release();
624 } 626 }
625 627
626 void FileSelectHelper::EnumerateDirectory(int request_id, 628 void FileSelectHelper::EnumerateDirectory(int request_id,
627 RenderViewHost* render_view_host, 629 RenderViewHost* render_view_host,
628 const base::FilePath& path) { 630 const base::FilePath& path) {
629 631
630 // Because this class returns notifications to the RenderViewHost, it is 632 // Because this class returns notifications to the RenderViewHost, it is
631 // difficult for callers to know how long to keep a reference to this 633 // difficult for callers to know how long to keep a reference to this
632 // instance. We AddRef() here to keep the instance alive after we return 634 // instance. We AddRef() here to keep the instance alive after we return
633 // to the caller, until the last callback is received from the enumeration 635 // to the caller, until the last callback is received from the enumeration
634 // code. At that point, we must call EnumerateDirectoryEnd(). 636 // code. At that point, we must call EnumerateDirectoryEnd().
635 AddRef(); 637 AddRef();
636 StartNewEnumeration(path, request_id, render_view_host); 638 StartNewEnumeration(path, request_id, render_view_host);
637 } 639 }
638 640
639 // This method is called when we receive the last callback from the enumeration 641 // This method is called when we receive the last callback from the enumeration
640 // code. Perform any cleanup and release the reference we added in 642 // code. Perform any cleanup and release the reference we added in
641 // EnumerateDirectory(). 643 // EnumerateDirectory().
642 void FileSelectHelper::EnumerateDirectoryEnd() { 644 void FileSelectHelper::EnumerateDirectoryEnd() {
643 Release(); 645 Release();
644 } 646 }
645 647
646 void FileSelectHelper::Observe(int type, 648 void FileSelectHelper::Observe(int type,
647 const content::NotificationSource& source, 649 const content::NotificationSource& source,
648 const content::NotificationDetails& details) { 650 const content::NotificationDetails& details) {
649 switch (type) { 651 switch (type) {
650 case content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED: { 652 case content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED: {
651 DCHECK(content::Source<RenderWidgetHost>(source).ptr() == 653 DCHECK(content::Source<RenderWidgetHost>(source).ptr() ==
652 render_view_host_->GetWidget()); 654 render_frame_host_->GetRenderViewHost()->GetWidget());
653 render_view_host_ = NULL; 655 render_frame_host_ = NULL;
654 break; 656 break;
655 } 657 }
656 default: 658 default:
657 NOTREACHED(); 659 NOTREACHED();
658 } 660 }
659 } 661 }
660 662
661 void FileSelectHelper::RenderViewHostChanged(RenderViewHost* old_host, 663 void FileSelectHelper::RenderViewHostChanged(RenderViewHost* old_host,
662 RenderViewHost* new_host) { 664 RenderViewHost* new_host) {
663 CleanUpOnRenderViewHostChange(); 665 CleanUpOnRenderViewHostChange();
(...skipping 21 matching lines...) Expand all
685 687
686 // static 688 // static
687 base::FilePath FileSelectHelper::GetSanitizedFileName( 689 base::FilePath FileSelectHelper::GetSanitizedFileName(
688 const base::FilePath& suggested_filename) { 690 const base::FilePath& suggested_filename) {
689 if (suggested_filename.empty()) 691 if (suggested_filename.empty())
690 return base::FilePath(); 692 return base::FilePath();
691 return net::GenerateFileName( 693 return net::GenerateFileName(
692 GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(), 694 GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(),
693 std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); 695 std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME));
694 } 696 }
OLDNEW
« no previous file with comments | « chrome/browser/file_select_helper.h ('k') | chrome/browser/ui/apps/chrome_app_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698