OLD | NEW |
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 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 SendResponse(true); | 900 SendResponse(true); |
901 } | 901 } |
902 | 902 |
903 FileBrowserFunction::FileBrowserFunction() { | 903 FileBrowserFunction::FileBrowserFunction() { |
904 } | 904 } |
905 | 905 |
906 FileBrowserFunction::~FileBrowserFunction() { | 906 FileBrowserFunction::~FileBrowserFunction() { |
907 } | 907 } |
908 | 908 |
909 int32 FileBrowserFunction::GetTabId() const { | 909 int32 FileBrowserFunction::GetTabId() const { |
910 int32 tab_id = 0; | |
911 if (!dispatcher()) { | 910 if (!dispatcher()) { |
912 NOTREACHED(); | 911 LOG(WARNING) << "No dispatcher"; |
913 return tab_id; | 912 return 0; |
914 } | 913 } |
915 | 914 if (!dispatcher()->delegate()) { |
916 // TODO(jamescook): This is going to fail when we switch to tab-modal | 915 LOG(WARNING) << "No delegate"; |
917 // dialogs. Figure out a way to find which SelectFileDialog::Listener | 916 return 0; |
918 // to call from inside these extension FileBrowserFunctions. | |
919 Browser* browser = | |
920 const_cast<FileBrowserFunction*>(this)->GetCurrentBrowser(); | |
921 if (browser) { | |
922 TabContents* contents = browser->GetSelectedTabContents(); | |
923 if (contents) | |
924 tab_id = ExtensionTabUtil::GetTabId(contents); | |
925 } | 917 } |
926 return tab_id; | 918 TabContents* tab_contents = |
| 919 dispatcher()->delegate()->GetAssociatedTabContents(); |
| 920 if (!tab_contents) { |
| 921 LOG(WARNING) << "No associated tab contents"; |
| 922 return 0; |
| 923 } |
| 924 return ExtensionTabUtil::GetTabId(tab_contents); |
927 } | 925 } |
928 | 926 |
929 // GetFileSystemRootPathOnFileThread can only be called from the file thread, | 927 // GetFileSystemRootPathOnFileThread can only be called from the file thread, |
930 // so here we are. This function takes a vector of virtual paths, converts | 928 // so here we are. This function takes a vector of virtual paths, converts |
931 // them to local paths and calls GetLocalPathsResponseOnUIThread with the | 929 // them to local paths and calls GetLocalPathsResponseOnUIThread with the |
932 // result vector, on the UI thread. | 930 // result vector, on the UI thread. |
933 void FileBrowserFunction::GetLocalPathsOnFileThread(const UrlList& file_urls, | 931 void FileBrowserFunction::GetLocalPathsOnFileThread(const UrlList& file_urls, |
934 void* context) { | 932 void* context) { |
935 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 933 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
936 FilePathList selected_files; | 934 FilePathList selected_files; |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1534 // TODO(serya): Create a new string in .grd file for this one in M13. | 1532 // TODO(serya): Create a new string in .grd file for this one in M13. |
1535 dict->SetString("PREVIEW_IMAGE", | 1533 dict->SetString("PREVIEW_IMAGE", |
1536 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); | 1534 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); |
1537 dict->SetString("PLAY_MEDIA", | 1535 dict->SetString("PLAY_MEDIA", |
1538 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); | 1536 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); |
1539 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableArchives)) | 1537 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableArchives)) |
1540 dict->SetString("ENABLE_ARCHIVES", "true"); | 1538 dict->SetString("ENABLE_ARCHIVES", "true"); |
1541 | 1539 |
1542 return true; | 1540 return true; |
1543 } | 1541 } |
OLD | NEW |