OLD | NEW |
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 <string> | 7 #include <string> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/file_util.h" | 11 #include "base/file_util.h" |
11 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
12 #include "base/string_util.h" | 13 #include "base/string_util.h" |
13 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
14 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/platform_util.h" | 16 #include "chrome/browser/platform_util.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/browser/ui/browser_list.h" | 19 #include "chrome/browser/ui/browser_list.h" |
19 #include "chrome/browser/ui/chrome_select_file_policy.h" | 20 #include "chrome/browser/ui/chrome_select_file_policy.h" |
20 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/browser/notification_details.h" | 22 #include "content/public/browser/notification_details.h" |
22 #include "content/public/browser/notification_source.h" | 23 #include "content/public/browser/notification_source.h" |
23 #include "content/public/browser/notification_types.h" | 24 #include "content/public/browser/notification_types.h" |
24 #include "content/public/browser/render_view_host.h" | 25 #include "content/public/browser/render_view_host.h" |
25 #include "content/public/browser/render_widget_host_view.h" | 26 #include "content/public/browser/render_widget_host_view.h" |
26 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
27 #include "content/public/common/file_chooser_params.h" | 28 #include "content/public/common/file_chooser_params.h" |
28 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
29 #include "net/base/mime_util.h" | 30 #include "net/base/mime_util.h" |
| 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.
h" |
30 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
31 #include "ui/shell_dialogs/selected_file_info.h" | 33 #include "ui/shell_dialogs/selected_file_info.h" |
32 | 34 |
33 using content::BrowserThread; | 35 using content::BrowserThread; |
34 using content::FileChooserParams; | 36 using content::FileChooserParams; |
35 using content::RenderViewHost; | 37 using content::RenderViewHost; |
36 using content::RenderWidgetHost; | 38 using content::RenderWidgetHost; |
37 using content::WebContents; | 39 using content::WebContents; |
38 | 40 |
39 namespace { | 41 namespace { |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 | 409 |
408 base::FilePath default_file_name = params.default_file_name.IsAbsolute() ? | 410 base::FilePath default_file_name = params.default_file_name.IsAbsolute() ? |
409 params.default_file_name : | 411 params.default_file_name : |
410 profile_->last_selected_directory().Append(params.default_file_name); | 412 profile_->last_selected_directory().Append(params.default_file_name); |
411 | 413 |
412 gfx::NativeWindow owning_window = | 414 gfx::NativeWindow owning_window = |
413 platform_util::GetTopLevel(render_view_host_->GetView()->GetNativeView()); | 415 platform_util::GetTopLevel(render_view_host_->GetView()->GetNativeView()); |
414 | 416 |
415 #if defined(OS_ANDROID) | 417 #if defined(OS_ANDROID) |
416 // Android needs the original MIME types and an additional capture value. | 418 // Android needs the original MIME types and an additional capture value. |
417 std::vector<string16> accept_types(params.accept_types); | 419 #if defined(NEW_MEDIA_CAPTURE_IMPLEMENTATION) |
418 accept_types.push_back(params.capture); | 420 std::pair<std::vector<string16>, bool> accept_types = |
| 421 #else |
| 422 std::pair<std::vector<string16>, string16> accept_types = |
| 423 #endif |
| 424 std::make_pair(params.accept_types, params.capture); |
419 #endif | 425 #endif |
420 | 426 |
421 select_file_dialog_->SelectFile( | 427 select_file_dialog_->SelectFile( |
422 dialog_type_, | 428 dialog_type_, |
423 params.title, | 429 params.title, |
424 default_file_name, | 430 default_file_name, |
425 select_file_types_.get(), | 431 select_file_types_.get(), |
426 select_file_types_.get() && !select_file_types_->extensions.empty() | 432 select_file_types_.get() && !select_file_types_->extensions.empty() |
427 ? 1 | 433 ? 1 |
428 : 0, // 1-based index of default extension to show. | 434 : 0, // 1-based index of default extension to show. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 // A 1 character accept type will always be invalid (either a "." in the case | 500 // A 1 character accept type will always be invalid (either a "." in the case |
495 // of an extension or a "/" in the case of a MIME type). | 501 // of an extension or a "/" in the case of a MIME type). |
496 std::string unused; | 502 std::string unused; |
497 if (accept_type.length() <= 1 || | 503 if (accept_type.length() <= 1 || |
498 StringToLowerASCII(accept_type) != accept_type || | 504 StringToLowerASCII(accept_type) != accept_type || |
499 TrimWhitespaceASCII(accept_type, TRIM_ALL, &unused) != TRIM_NONE) { | 505 TrimWhitespaceASCII(accept_type, TRIM_ALL, &unused) != TRIM_NONE) { |
500 return false; | 506 return false; |
501 } | 507 } |
502 return true; | 508 return true; |
503 } | 509 } |
OLD | NEW |