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

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

Issue 2825051: Add support for a directory file chooser command, which creates a file list b... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/tab_contents/tab_contents.h" 5 #include "chrome/browser/tab_contents/tab_contents.h"
6 6
7 #if defined(OS_CHROMEOS) 7 #if defined(OS_CHROMEOS)
8 // For GdkScreen 8 // For GdkScreen
9 #include <gdk/gdk.h> 9 #include <gdk/gdk.h>
10 #endif // defined(OS_CHROMEOS) 10 #endif // defined(OS_CHROMEOS)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #include "chrome/browser/renderer_preferences_util.h" 65 #include "chrome/browser/renderer_preferences_util.h"
66 #include "chrome/browser/search_engines/template_url_fetcher.h" 66 #include "chrome/browser/search_engines/template_url_fetcher.h"
67 #include "chrome/browser/search_engines/template_url_model.h" 67 #include "chrome/browser/search_engines/template_url_model.h"
68 #include "chrome/browser/sessions/session_types.h" 68 #include "chrome/browser/sessions/session_types.h"
69 #include "chrome/browser/tab_contents/infobar_delegate.h" 69 #include "chrome/browser/tab_contents/infobar_delegate.h"
70 #include "chrome/browser/tab_contents/interstitial_page.h" 70 #include "chrome/browser/tab_contents/interstitial_page.h"
71 #include "chrome/browser/tab_contents/match_preview.h" 71 #include "chrome/browser/tab_contents/match_preview.h"
72 #include "chrome/browser/tab_contents/navigation_entry.h" 72 #include "chrome/browser/tab_contents/navigation_entry.h"
73 #include "chrome/browser/tab_contents/provisional_load_details.h" 73 #include "chrome/browser/tab_contents/provisional_load_details.h"
74 #include "chrome/browser/tab_contents/tab_contents_delegate.h" 74 #include "chrome/browser/tab_contents/tab_contents_delegate.h"
75 #include "chrome/browser/tab_contents/tab_contents_file_select_helper.h"
75 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" 76 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h"
76 #include "chrome/browser/tab_contents/tab_contents_view.h" 77 #include "chrome/browser/tab_contents/tab_contents_view.h"
77 #include "chrome/browser/tab_contents/thumbnail_generator.h" 78 #include "chrome/browser/tab_contents/thumbnail_generator.h"
78 #include "chrome/browser/translate/page_translated_details.h" 79 #include "chrome/browser/translate/page_translated_details.h"
79 #include "chrome/common/bindings_policy.h" 80 #include "chrome/common/bindings_policy.h"
80 #include "chrome/common/chrome_switches.h" 81 #include "chrome/common/chrome_switches.h"
81 #include "chrome/common/extensions/extension.h" 82 #include "chrome/common/extensions/extension.h"
82 #include "chrome/common/extensions/extension_action.h" 83 #include "chrome/common/extensions/extension_action.h"
83 #include "chrome/common/extensions/extension_resource.h" 84 #include "chrome/common/extensions/extension_resource.h"
84 #include "chrome/common/extensions/url_pattern.h" 85 #include "chrome/common/extensions/url_pattern.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 registrar_(), 319 registrar_(),
319 ALLOW_THIS_IN_INITIALIZER_LIST(printing_( 320 ALLOW_THIS_IN_INITIALIZER_LIST(printing_(
320 new printing::PrintViewManager(*this))), 321 new printing::PrintViewManager(*this))),
321 save_package_(), 322 save_package_(),
322 autocomplete_history_manager_(), 323 autocomplete_history_manager_(),
323 autofill_manager_(), 324 autofill_manager_(),
324 password_manager_(), 325 password_manager_(),
325 plugin_installer_(), 326 plugin_installer_(),
326 bookmark_drag_(NULL), 327 bookmark_drag_(NULL),
327 ALLOW_THIS_IN_INITIALIZER_LIST(fav_icon_helper_(this)), 328 ALLOW_THIS_IN_INITIALIZER_LIST(fav_icon_helper_(this)),
328 select_file_dialog_(),
329 is_loading_(false), 329 is_loading_(false),
330 is_crashed_(false), 330 is_crashed_(false),
331 waiting_for_response_(false), 331 waiting_for_response_(false),
332 max_page_id_(-1), 332 max_page_id_(-1),
333 current_load_start_(), 333 current_load_start_(),
334 load_state_(net::LOAD_STATE_IDLE), 334 load_state_(net::LOAD_STATE_IDLE),
335 load_state_host_(), 335 load_state_host_(),
336 upload_size_(0), 336 upload_size_(0),
337 upload_position_(0), 337 upload_position_(0),
338 received_page_title_(false), 338 received_page_title_(false),
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 // First cleanly close all child windows. 447 // First cleanly close all child windows.
448 // TODO(mpcomplete): handle case if MaybeCloseChildWindows() already asked 448 // TODO(mpcomplete): handle case if MaybeCloseChildWindows() already asked
449 // some of these to close. CloseWindows is async, so it might get called 449 // some of these to close. CloseWindows is async, so it might get called
450 // twice before it runs. 450 // twice before it runs.
451 CloseConstrainedWindows(); 451 CloseConstrainedWindows();
452 452
453 // Close all blocked popups. 453 // Close all blocked popups.
454 if (blocked_popups_) 454 if (blocked_popups_)
455 blocked_popups_->Destroy(); 455 blocked_popups_->Destroy();
456 456
457 // There may be pending file dialogs, we need to tell them that we've gone
458 // away so they don't try and call back to us.
459 if (select_file_dialog_.get())
460 select_file_dialog_->ListenerDestroyed();
461
462 // Notify any observer that have a reference on this tab contents. 457 // Notify any observer that have a reference on this tab contents.
463 NotificationService::current()->Notify( 458 NotificationService::current()->Notify(
464 NotificationType::TAB_CONTENTS_DESTROYED, 459 NotificationType::TAB_CONTENTS_DESTROYED,
465 Source<TabContents>(this), 460 Source<TabContents>(this),
466 NotificationService::NoDetails()); 461 NotificationService::NoDetails());
467 462
468 // Notify any lasting InfobarDelegates that have not yet been removed that 463 // Notify any lasting InfobarDelegates that have not yet been removed that
469 // whatever infobar they were handling in this TabContents has closed, 464 // whatever infobar they were handling in this TabContents has closed,
470 // because the TabContents is going away entirely. 465 // because the TabContents is going away entirely.
471 // This must happen after the TAB_CONTENTS_DESTROYED notification as the 466 // This must happen after the TAB_CONTENTS_DESTROYED notification as the
(...skipping 1783 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 RenderViewHostDelegate::BlockedPlugin* TabContents::GetBlockedPluginDelegate() { 2250 RenderViewHostDelegate::BlockedPlugin* TabContents::GetBlockedPluginDelegate() {
2256 if (blocked_plugin_manager_.get() == NULL) 2251 if (blocked_plugin_manager_.get() == NULL)
2257 blocked_plugin_manager_.reset(new BlockedPluginManager(this)); 2252 blocked_plugin_manager_.reset(new BlockedPluginManager(this));
2258 return blocked_plugin_manager_.get(); 2253 return blocked_plugin_manager_.get();
2259 } 2254 }
2260 2255
2261 RenderViewHostDelegate::SSL* TabContents::GetSSLDelegate() { 2256 RenderViewHostDelegate::SSL* TabContents::GetSSLDelegate() {
2262 return GetSSLHelper(); 2257 return GetSSLHelper();
2263 } 2258 }
2264 2259
2260 RenderViewHostDelegate::FileSelect* TabContents::GetFileSelectDelegate() {
2261 if (file_select_helper_.get() == NULL)
2262 file_select_helper_.reset(new TabContentsFileSelectHelper(this));
2263 return file_select_helper_.get();
2264 }
2265
2265 AutomationResourceRoutingDelegate* 2266 AutomationResourceRoutingDelegate*
2266 TabContents::GetAutomationResourceRoutingDelegate() { 2267 TabContents::GetAutomationResourceRoutingDelegate() {
2267 return delegate(); 2268 return delegate();
2268 } 2269 }
2269 2270
2270 RenderViewHostDelegate::BookmarkDrag* TabContents::GetBookmarkDragDelegate() { 2271 RenderViewHostDelegate::BookmarkDrag* TabContents::GetBookmarkDragDelegate() {
2271 return bookmark_drag_; 2272 return bookmark_drag_;
2272 } 2273 }
2273 2274
2274 void TabContents::SetBookmarkDragDelegate( 2275 void TabContents::SetBookmarkDragDelegate(
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
2622 render_manager_.dom_ui()->ProcessDOMUIMessage(params); 2623 render_manager_.dom_ui()->ProcessDOMUIMessage(params);
2623 } 2624 }
2624 2625
2625 void TabContents::ProcessExternalHostMessage(const std::string& message, 2626 void TabContents::ProcessExternalHostMessage(const std::string& message,
2626 const std::string& origin, 2627 const std::string& origin,
2627 const std::string& target) { 2628 const std::string& target) {
2628 if (delegate()) 2629 if (delegate())
2629 delegate()->ForwardMessageToExternalHost(message, origin, target); 2630 delegate()->ForwardMessageToExternalHost(message, origin, target);
2630 } 2631 }
2631 2632
2632 void TabContents::RunFileChooser(
2633 const ViewHostMsg_RunFileChooser_Params &params) {
2634 if (!select_file_dialog_.get())
2635 select_file_dialog_ = SelectFileDialog::Create(this);
2636
2637 SelectFileDialog::Type dialog_type;
2638 switch (params.mode) {
2639 case ViewHostMsg_RunFileChooser_Params::Open:
2640 dialog_type = SelectFileDialog::SELECT_OPEN_FILE;
2641 break;
2642 case ViewHostMsg_RunFileChooser_Params::OpenMultiple:
2643 dialog_type = SelectFileDialog::SELECT_OPEN_MULTI_FILE;
2644 break;
2645 case ViewHostMsg_RunFileChooser_Params::Save:
2646 dialog_type = SelectFileDialog::SELECT_SAVEAS_FILE;
2647 break;
2648 default:
2649 dialog_type = SelectFileDialog::SELECT_OPEN_FILE; // Prevent warning.
2650 NOTREACHED();
2651 }
2652 FilePath default_file_name = params.default_file_name;
2653 if (default_file_name.empty())
2654 default_file_name = profile()->last_selected_directory();
2655 select_file_dialog_->SelectFile(dialog_type, params.title,
2656 default_file_name,
2657 NULL, 0, FILE_PATH_LITERAL(""),
2658 view_->GetTopLevelNativeWindow(), NULL);
2659 }
2660
2661 void TabContents::RunJavaScriptMessage( 2633 void TabContents::RunJavaScriptMessage(
2662 const std::wstring& message, 2634 const std::wstring& message,
2663 const std::wstring& default_prompt, 2635 const std::wstring& default_prompt,
2664 const GURL& frame_url, 2636 const GURL& frame_url,
2665 const int flags, 2637 const int flags,
2666 IPC::Message* reply_msg, 2638 IPC::Message* reply_msg,
2667 bool* did_suppress_message) { 2639 bool* did_suppress_message) {
2668 // Suppress javascript messages when requested and when inside a constrained 2640 // Suppress javascript messages when requested and when inside a constrained
2669 // popup window (because that activates them and breaks them out of the 2641 // popup window (because that activates them and breaks them out of the
2670 // constrained window jail). 2642 // constrained window jail).
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
2908 Source<RenderViewHost>(render_view_host()), 2880 Source<RenderViewHost>(render_view_host()),
2909 NotificationService::NoDetails()); 2881 NotificationService::NoDetails());
2910 } 2882 }
2911 2883
2912 void TabContents::SetDisplayingPDFContent() { 2884 void TabContents::SetDisplayingPDFContent() {
2913 displaying_pdf_content_ = true; 2885 displaying_pdf_content_ = true;
2914 if (delegate()) 2886 if (delegate())
2915 delegate()->ContentTypeChanged(this); 2887 delegate()->ContentTypeChanged(this);
2916 } 2888 }
2917 2889
2918 void TabContents::FileSelected(const FilePath& path,
2919 int index, void* params) {
2920 profile()->set_last_selected_directory(path.DirName());
2921 std::vector<FilePath> files;
2922 files.push_back(path);
2923 render_view_host()->FilesSelectedInChooser(files);
2924 }
2925
2926 void TabContents::MultiFilesSelected(const std::vector<FilePath>& files,
2927 void* params) {
2928 if (!files.empty())
2929 profile()->set_last_selected_directory(files[0].DirName());
2930 render_view_host()->FilesSelectedInChooser(files);
2931 }
2932
2933 void TabContents::FileSelectionCanceled(void* params) {
2934 // If the user cancels choosing a file to upload we pass back an
2935 // empty vector.
2936 render_view_host()->FilesSelectedInChooser(std::vector<FilePath>());
2937 }
2938
2939 void TabContents::BeforeUnloadFiredFromRenderManager( 2890 void TabContents::BeforeUnloadFiredFromRenderManager(
2940 bool proceed, 2891 bool proceed,
2941 bool* proceed_to_fire_unload) { 2892 bool* proceed_to_fire_unload) {
2942 if (delegate()) 2893 if (delegate())
2943 delegate()->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); 2894 delegate()->BeforeUnloadFired(this, proceed, proceed_to_fire_unload);
2944 } 2895 }
2945 2896
2946 void TabContents::DidStartLoadingFromRenderManager( 2897 void TabContents::DidStartLoadingFromRenderManager(
2947 RenderViewHost* render_view_host) { 2898 RenderViewHost* render_view_host) {
2948 DidStartLoading(); 2899 DidStartLoading();
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
3270 AddInfoBar(new SavePasswordInfoBarDelegate(this, form_to_save)); 3221 AddInfoBar(new SavePasswordInfoBarDelegate(this, form_to_save));
3271 } 3222 }
3272 3223
3273 Profile* TabContents::GetProfileForPasswordManager() { 3224 Profile* TabContents::GetProfileForPasswordManager() {
3274 return profile(); 3225 return profile();
3275 } 3226 }
3276 3227
3277 bool TabContents::DidLastPageLoadEncounterSSLErrors() { 3228 bool TabContents::DidLastPageLoadEncounterSSLErrors() {
3278 return controller().ssl_manager()->ProcessedSSLErrorFromRequest(); 3229 return controller().ssl_manager()->ProcessedSSLErrorFromRequest();
3279 } 3230 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.h ('k') | chrome/browser/tab_contents/tab_contents_file_select_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698