| 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/ui/shell_dialogs.h" | 5 #include "chrome/browser/ui/shell_dialogs.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // Owner of this FileBrowseDelegate. | 72 // Owner of this FileBrowseDelegate. |
| 73 scoped_refptr<SelectFileDialogImpl> owner_; | 73 scoped_refptr<SelectFileDialogImpl> owner_; |
| 74 | 74 |
| 75 // Parent window. | 75 // Parent window. |
| 76 gfx::NativeWindow parent_; | 76 gfx::NativeWindow parent_; |
| 77 | 77 |
| 78 // The type of dialog we are showing the user. | 78 // The type of dialog we are showing the user. |
| 79 Type type_; | 79 Type type_; |
| 80 | 80 |
| 81 // The dialog title. | 81 // The dialog title. |
| 82 std::wstring title_; | 82 string16 title_; |
| 83 | 83 |
| 84 // Default path of the file dialog. | 84 // Default path of the file dialog. |
| 85 FilePath default_path_; | 85 FilePath default_path_; |
| 86 | 86 |
| 87 // The file filters. | 87 // The file filters. |
| 88 FileTypeInfo file_types_; | 88 FileTypeInfo file_types_; |
| 89 | 89 |
| 90 // The index of the default selected file filter. | 90 // The index of the default selected file filter. |
| 91 // Note: This starts from 1, not 0. | 91 // Note: This starts from 1, not 0. |
| 92 int file_type_index_; | 92 int file_type_index_; |
| 93 | 93 |
| 94 // Default extension to be added to file if user does not type one. | 94 // Default extension to be added to file if user does not type one. |
| 95 FilePath::StringType default_extension_; | 95 FilePath::StringType default_extension_; |
| 96 | 96 |
| 97 // Associated user data. | 97 // Associated user data. |
| 98 void* params_; | 98 void* params_; |
| 99 | 99 |
| 100 private: | 100 private: |
| 101 ~FileBrowseDelegate(); | 101 ~FileBrowseDelegate(); |
| 102 | 102 |
| 103 // Overridden from HtmlDialogUI::Delegate: | 103 // Overridden from HtmlDialogUI::Delegate: |
| 104 virtual bool IsDialogModal() const; | 104 virtual bool IsDialogModal() const OVERRIDE; |
| 105 virtual std::wstring GetDialogTitle() const; | 105 virtual string16 GetDialogTitle() const OVERRIDE; |
| 106 virtual GURL GetDialogContentURL() const; | 106 virtual GURL GetDialogContentURL() const OVERRIDE; |
| 107 virtual void GetWebUIMessageHandlers( | 107 virtual void GetWebUIMessageHandlers( |
| 108 std::vector<WebUIMessageHandler*>* handlers) const; | 108 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE; |
| 109 virtual void GetDialogSize(gfx::Size* size) const; | 109 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; |
| 110 virtual std::string GetDialogArgs() const; | 110 virtual std::string GetDialogArgs() const OVERRIDE; |
| 111 virtual void OnDialogClosed(const std::string& json_retval); | 111 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; |
| 112 virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) { | 112 virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) |
| 113 OVERRIDE { |
| 113 } | 114 } |
| 114 virtual bool ShouldShowDialogTitle() const { return true; } | 115 virtual bool ShouldShowDialogTitle() const OVERRIDE { return true; } |
| 115 virtual bool HandleContextMenu(const ContextMenuParams& params) { | 116 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE { |
| 116 return true; | 117 return true; |
| 117 } | 118 } |
| 118 | 119 |
| 119 DISALLOW_COPY_AND_ASSIGN(FileBrowseDelegate); | 120 DISALLOW_COPY_AND_ASSIGN(FileBrowseDelegate); |
| 120 }; | 121 }; |
| 121 | 122 |
| 122 class FileBrowseDelegateHandler : public WebUIMessageHandler { | 123 class FileBrowseDelegateHandler : public WebUIMessageHandler { |
| 123 public: | 124 public: |
| 124 explicit FileBrowseDelegateHandler(FileBrowseDelegate* delegate); | 125 explicit FileBrowseDelegateHandler(FileBrowseDelegate* delegate); |
| 125 | 126 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 const std::wstring& title, | 295 const std::wstring& title, |
| 295 const FilePath& default_path, | 296 const FilePath& default_path, |
| 296 const FileTypeInfo* file_types, | 297 const FileTypeInfo* file_types, |
| 297 int file_type_index, | 298 int file_type_index, |
| 298 const FilePath::StringType& default_extension, | 299 const FilePath::StringType& default_extension, |
| 299 gfx::NativeWindow parent, | 300 gfx::NativeWindow parent, |
| 300 void* params) | 301 void* params) |
| 301 : owner_(owner), | 302 : owner_(owner), |
| 302 parent_(parent), | 303 parent_(parent), |
| 303 type_(type), | 304 type_(type), |
| 304 title_(title), | 305 title_(WideToUTF16Hack(title)), |
| 305 default_path_(default_path), | 306 default_path_(default_path), |
| 306 file_type_index_(file_type_index), | 307 file_type_index_(file_type_index), |
| 307 default_extension_(default_extension), | 308 default_extension_(default_extension), |
| 308 params_(params) { | 309 params_(params) { |
| 309 if (file_types) | 310 if (file_types) |
| 310 file_types_ = *file_types; | 311 file_types_ = *file_types; |
| 311 else | 312 else |
| 312 file_types_.include_all_files = true; | 313 file_types_.include_all_files = true; |
| 313 } | 314 } |
| 314 | 315 |
| 315 SelectFileDialogImpl::FileBrowseDelegate::~FileBrowseDelegate() { | 316 SelectFileDialogImpl::FileBrowseDelegate::~FileBrowseDelegate() { |
| 316 } | 317 } |
| 317 | 318 |
| 318 bool SelectFileDialogImpl::FileBrowseDelegate::IsDialogModal() const { | 319 bool SelectFileDialogImpl::FileBrowseDelegate::IsDialogModal() const { |
| 319 return true; | 320 return true; |
| 320 } | 321 } |
| 321 | 322 |
| 322 std::wstring SelectFileDialogImpl::FileBrowseDelegate::GetDialogTitle() const { | 323 string16 SelectFileDialogImpl::FileBrowseDelegate::GetDialogTitle() const { |
| 323 return title_; | 324 return title_; |
| 324 } | 325 } |
| 325 | 326 |
| 326 GURL SelectFileDialogImpl::FileBrowseDelegate::GetDialogContentURL() const { | 327 GURL SelectFileDialogImpl::FileBrowseDelegate::GetDialogContentURL() const { |
| 327 std::string url_string(chrome::kChromeUIFileBrowseURL); | 328 std::string url_string(chrome::kChromeUIFileBrowseURL); |
| 328 | 329 |
| 329 return GURL(url_string); | 330 return GURL(url_string); |
| 330 } | 331 } |
| 331 | 332 |
| 332 void SelectFileDialogImpl::FileBrowseDelegate::GetWebUIMessageHandlers( | 333 void SelectFileDialogImpl::FileBrowseDelegate::GetWebUIMessageHandlers( |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 // TODO(xiyuan): Change this when the infrastructure is improved. | 457 // TODO(xiyuan): Change this when the infrastructure is improved. |
| 457 HtmlDialogUIDelegate** delegate = HtmlDialogUI::GetPropertyAccessor(). | 458 HtmlDialogUIDelegate** delegate = HtmlDialogUI::GetPropertyAccessor(). |
| 458 GetProperty(web_ui_->tab_contents()->property_bag()); | 459 GetProperty(web_ui_->tab_contents()->property_bag()); |
| 459 HtmlDialogView* containing_view = static_cast<HtmlDialogView*>(*delegate); | 460 HtmlDialogView* containing_view = static_cast<HtmlDialogView*>(*delegate); |
| 460 DCHECK(containing_view); | 461 DCHECK(containing_view); |
| 461 | 462 |
| 462 containing_view->GetWindow()->UpdateWindowTitle(); | 463 containing_view->GetWindow()->UpdateWindowTitle(); |
| 463 containing_view->GetWindow()->non_client_view()->SchedulePaint(); | 464 containing_view->GetWindow()->non_client_view()->SchedulePaint(); |
| 464 } | 465 } |
| 465 } | 466 } |
| OLD | NEW |