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

Side by Side Diff: chrome/browser/extensions/extension_file_browser_private_api.cc

Issue 7003150: Merge 88759 - CrOS - Fix crash when pressing Enter in file browser dialog (Closed) Base URL: svn://svn.chromium.org/chrome/branches/782/src/
Patch Set: '' Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extensions/extension_file_browser_private_api.h" 5 #include "chrome/browser/extensions/extension_file_browser_private_api.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 if (contents) 809 if (contents)
810 tab_id = ExtensionTabUtil::GetTabId(contents); 810 tab_id = ExtensionTabUtil::GetTabId(contents);
811 } 811 }
812 return tab_id; 812 return tab_id;
813 } 813 }
814 814
815 const FileDialogFunction::Callback& FileDialogFunction::GetCallback() const { 815 const FileDialogFunction::Callback& FileDialogFunction::GetCallback() const {
816 return Callback::Find(GetTabId()); 816 return Callback::Find(GetTabId());
817 } 817 }
818 818
819 void FileDialogFunction::RemoveCallback() {
820 // Listeners expect to be invoked exactly once, so we need to remove our
821 // callback objects afterwards.
822 Callback::Remove(GetTabId());
823 }
824
819 // GetFileSystemRootPathOnFileThread can only be called from the file thread, 825 // GetFileSystemRootPathOnFileThread can only be called from the file thread,
820 // so here we are. This function takes a vector of virtual paths, converts 826 // so here we are. This function takes a vector of virtual paths, converts
821 // them to local paths and calls GetLocalPathsResponseOnUIThread with the 827 // them to local paths and calls GetLocalPathsResponseOnUIThread with the
822 // result vector, on the UI thread. 828 // result vector, on the UI thread.
823 void FileDialogFunction::GetLocalPathsOnFileThread(const UrlList& file_urls, 829 void FileDialogFunction::GetLocalPathsOnFileThread(const UrlList& file_urls,
824 const std::string& task_id) { 830 const std::string& task_id) {
825 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 831 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
826 FilePathList selected_files; 832 FilePathList selected_files;
827 833
828 // FilePath(virtual_path) doesn't work on win, so limit this to ChromeOS. 834 // FilePath(virtual_path) doesn't work on win, so limit this to ChromeOS.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 return; 901 return;
896 } 902 }
897 int index; 903 int index;
898 args_->GetInteger(1, &index); 904 args_->GetInteger(1, &index);
899 const Callback& callback = GetCallback(); 905 const Callback& callback = GetCallback();
900 DCHECK(!callback.IsNull()); 906 DCHECK(!callback.IsNull());
901 if (!callback.IsNull()) { 907 if (!callback.IsNull()) {
902 callback.listener()->FileSelected(files[0], 908 callback.listener()->FileSelected(files[0],
903 index, 909 index,
904 callback.params()); 910 callback.params());
911 RemoveCallback(); // Listeners expect to be invoked exactly once.
905 } 912 }
906 SendResponse(true); 913 SendResponse(true);
907 } 914 }
908 915
909 916
910 ViewFilesFunction::ViewFilesFunction() { 917 ViewFilesFunction::ViewFilesFunction() {
911 } 918 }
912 919
913 ViewFilesFunction::~ViewFilesFunction() { 920 ViewFilesFunction::~ViewFilesFunction() {
914 } 921 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 } 996 }
990 997
991 void SelectFilesFunction::GetLocalPathsResponseOnUIThread( 998 void SelectFilesFunction::GetLocalPathsResponseOnUIThread(
992 const FilePathList& files, const std::string& internal_task_id) { 999 const FilePathList& files, const std::string& internal_task_id) {
993 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1000 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
994 1001
995 const Callback& callback = GetCallback(); 1002 const Callback& callback = GetCallback();
996 DCHECK(!callback.IsNull()); 1003 DCHECK(!callback.IsNull());
997 if (!callback.IsNull()) { 1004 if (!callback.IsNull()) {
998 callback.listener()->MultiFilesSelected(files, callback.params()); 1005 callback.listener()->MultiFilesSelected(files, callback.params());
1006 RemoveCallback(); // Listeners expect to be invoked exactly once.
999 } 1007 }
1000 SendResponse(true); 1008 SendResponse(true);
1001 } 1009 }
1002 1010
1003 bool CancelFileDialogFunction::RunImpl() { 1011 bool CancelFileDialogFunction::RunImpl() {
1004 const Callback& callback = GetCallback(); 1012 const Callback& callback = GetCallback();
1005 DCHECK(!callback.IsNull()); 1013 DCHECK(!callback.IsNull());
1006 if (!callback.IsNull()) { 1014 if (!callback.IsNull()) {
1007 callback.listener()->FileSelectionCanceled(callback.params()); 1015 callback.listener()->FileSelectionCanceled(callback.params());
1016 RemoveCallback(); // Listeners expect to be invoked exactly once.
1008 } 1017 }
1009 SendResponse(true); 1018 SendResponse(true);
1010 return true; 1019 return true;
1011 } 1020 }
1012 1021
1013 bool FileDialogStringsFunction::RunImpl() { 1022 bool FileDialogStringsFunction::RunImpl() {
1014 result_.reset(new DictionaryValue()); 1023 result_.reset(new DictionaryValue());
1015 DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get()); 1024 DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get());
1016 1025
1017 #define SET_STRING(ns, id) \ 1026 #define SET_STRING(ns, id) \
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 #undef SET_STRING 1098 #undef SET_STRING
1090 1099
1091 // TODO(serya): Create a new string in .grd file for this one in M13. 1100 // TODO(serya): Create a new string in .grd file for this one in M13.
1092 dict->SetString("PREVIEW_IMAGE", 1101 dict->SetString("PREVIEW_IMAGE",
1093 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); 1102 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON));
1094 dict->SetString("PLAY_MEDIA", 1103 dict->SetString("PLAY_MEDIA",
1095 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); 1104 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY));
1096 1105
1097 return true; 1106 return true;
1098 } 1107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698