| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 history_forward_list_count_(0), | 223 history_forward_list_count_(0), |
| 224 has_unload_listener_(false), | 224 has_unload_listener_(false), |
| 225 decrement_shared_popup_at_destruction_(false), | 225 decrement_shared_popup_at_destruction_(false), |
| 226 form_field_autofill_request_id_(0), | 226 form_field_autofill_request_id_(0), |
| 227 form_field_autofill_node_id_(0), | 227 form_field_autofill_node_id_(0), |
| 228 popup_notification_visible_(false), | 228 popup_notification_visible_(false), |
| 229 spelling_panel_visible_(false), | 229 spelling_panel_visible_(false), |
| 230 delay_seconds_for_form_state_sync_(kDefaultDelaySecondsForFormStateSync), | 230 delay_seconds_for_form_state_sync_(kDefaultDelaySecondsForFormStateSync), |
| 231 preferred_width_(0), | 231 preferred_width_(0), |
| 232 send_preferred_width_changes_(false), | 232 send_preferred_width_changes_(false), |
| 233 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 234 notification_provider_(new NotificationProvider(this))), |
| 233 determine_page_text_after_loading_stops_(false), | 235 determine_page_text_after_loading_stops_(false), |
| 234 view_type_(ViewType::INVALID), | 236 view_type_(ViewType::INVALID), |
| 235 browser_window_id_(-1), | 237 browser_window_id_(-1), |
| 236 last_top_level_navigation_page_id_(-1), | 238 last_top_level_navigation_page_id_(-1), |
| 237 #if defined(OS_MACOSX) | 239 #if defined(OS_MACOSX) |
| 238 has_document_tag_(false), | 240 has_document_tag_(false), |
| 239 #endif | 241 #endif |
| 240 document_tag_(0), | 242 document_tag_(0), |
| 241 webkit_preferences_(webkit_preferences) { | 243 webkit_preferences_(webkit_preferences) { |
| 242 } | 244 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 255 if (file_chooser_completion_) | 257 if (file_chooser_completion_) |
| 256 file_chooser_completion_->didChooseFile(WebVector<WebString>()); | 258 file_chooser_completion_->didChooseFile(WebVector<WebString>()); |
| 257 | 259 |
| 258 #if defined(OS_MACOSX) | 260 #if defined(OS_MACOSX) |
| 259 // Tell the spellchecker that the document is closed. | 261 // Tell the spellchecker that the document is closed. |
| 260 if (has_document_tag_) | 262 if (has_document_tag_) |
| 261 Send(new ViewHostMsg_DocumentWithTagClosed(routing_id_, document_tag_)); | 263 Send(new ViewHostMsg_DocumentWithTagClosed(routing_id_, document_tag_)); |
| 262 #endif | 264 #endif |
| 263 | 265 |
| 264 render_thread_->RemoveFilter(audio_message_filter_); | 266 render_thread_->RemoveFilter(audio_message_filter_); |
| 265 render_thread_->RemoveFilter(notification_provider_.get()); | |
| 266 | 267 |
| 267 #ifndef NDEBUG | 268 #ifndef NDEBUG |
| 268 // Make sure we are no longer referenced by the ViewMap. | 269 // Make sure we are no longer referenced by the ViewMap. |
| 269 ViewMap* views = Singleton<ViewMap>::get(); | 270 ViewMap* views = Singleton<ViewMap>::get(); |
| 270 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) | 271 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) |
| 271 DCHECK_NE(this, it->second) << "Failed to call Close?"; | 272 DCHECK_NE(this, it->second) << "Failed to call Close?"; |
| 272 #endif | 273 #endif |
| 273 } | 274 } |
| 274 | 275 |
| 275 /*static*/ | 276 /*static*/ |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 shared_popup_counter_ = counter; | 340 shared_popup_counter_ = counter; |
| 340 shared_popup_counter_->data++; | 341 shared_popup_counter_->data++; |
| 341 decrement_shared_popup_at_destruction_ = true; | 342 decrement_shared_popup_at_destruction_ = true; |
| 342 } else { | 343 } else { |
| 343 shared_popup_counter_ = new SharedRenderViewCounter(0); | 344 shared_popup_counter_ = new SharedRenderViewCounter(0); |
| 344 decrement_shared_popup_at_destruction_ = false; | 345 decrement_shared_popup_at_destruction_ = false; |
| 345 } | 346 } |
| 346 | 347 |
| 347 devtools_agent_.reset(new DevToolsAgent(routing_id, this)); | 348 devtools_agent_.reset(new DevToolsAgent(routing_id, this)); |
| 348 | 349 |
| 349 notification_provider_ = new NotificationProvider(this); | |
| 350 | |
| 351 webwidget_ = WebView::Create(this); | 350 webwidget_ = WebView::Create(this); |
| 352 Singleton<ViewMap>::get()->insert(std::make_pair(webview(), this)); | 351 Singleton<ViewMap>::get()->insert(std::make_pair(webview(), this)); |
| 353 webkit_preferences_.Apply(webview()); | 352 webkit_preferences_.Apply(webview()); |
| 354 webview()->initializeMainFrame(this); | 353 webview()->initializeMainFrame(this); |
| 355 | 354 |
| 356 OnSetRendererPrefs(renderer_prefs); | 355 OnSetRendererPrefs(renderer_prefs); |
| 357 | 356 |
| 358 routing_id_ = routing_id; | 357 routing_id_ = routing_id; |
| 359 render_thread_->AddRoute(routing_id_, this); | 358 render_thread_->AddRoute(routing_id_, this); |
| 360 // Take a reference on behalf of the RenderThread. This will be balanced | 359 // Take a reference on behalf of the RenderThread. This will be balanced |
| 361 // when we receive ViewMsg_Close. | 360 // when we receive ViewMsg_Close. |
| 362 AddRef(); | 361 AddRef(); |
| 363 | 362 |
| 364 // If this is a popup, we must wait for the CreatingNew_ACK message before | 363 // If this is a popup, we must wait for the CreatingNew_ACK message before |
| 365 // completing initialization. Otherwise, we can finish it now. | 364 // completing initialization. Otherwise, we can finish it now. |
| 366 if (opener_id == MSG_ROUTING_NONE) { | 365 if (opener_id == MSG_ROUTING_NONE) { |
| 367 did_show_ = true; | 366 did_show_ = true; |
| 368 CompleteInit(parent_hwnd); | 367 CompleteInit(parent_hwnd); |
| 369 } | 368 } |
| 370 | 369 |
| 371 host_window_ = parent_hwnd; | 370 host_window_ = parent_hwnd; |
| 372 | 371 |
| 373 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 372 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 374 if (command_line.HasSwitch(switches::kDomAutomationController)) | 373 if (command_line.HasSwitch(switches::kDomAutomationController)) |
| 375 enabled_bindings_ |= BindingsPolicy::DOM_AUTOMATION; | 374 enabled_bindings_ |= BindingsPolicy::DOM_AUTOMATION; |
| 376 | 375 |
| 377 audio_message_filter_ = new AudioMessageFilter(routing_id_); | 376 audio_message_filter_ = new AudioMessageFilter(routing_id_); |
| 378 render_thread_->AddFilter(audio_message_filter_); | 377 render_thread_->AddFilter(audio_message_filter_); |
| 379 render_thread_->AddFilter(notification_provider_.get()); | |
| 380 } | 378 } |
| 381 | 379 |
| 382 void RenderView::OnMessageReceived(const IPC::Message& message) { | 380 void RenderView::OnMessageReceived(const IPC::Message& message) { |
| 383 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; | 381 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; |
| 384 child_process_logging::ScopedActiveURLSetter url_setter( | 382 child_process_logging::ScopedActiveURLSetter url_setter( |
| 385 main_frame ? main_frame->url() : WebURL()); | 383 main_frame ? main_frame->url() : WebURL()); |
| 386 | 384 |
| 387 // If this is developer tools renderer intercept tools messages first. | 385 // If this is developer tools renderer intercept tools messages first. |
| 388 if (devtools_client_.get() && devtools_client_->OnMessageReceived(message)) | 386 if (devtools_client_.get() && devtools_client_->OnMessageReceived(message)) |
| 389 return; | 387 return; |
| 390 if (devtools_agent_.get() && devtools_agent_->OnMessageReceived(message)) | 388 if (devtools_agent_.get() && devtools_agent_->OnMessageReceived(message)) |
| 391 return; | 389 return; |
| 390 if (notification_provider_->OnMessageReceived(message)) |
| 391 return; |
| 392 | 392 |
| 393 IPC_BEGIN_MESSAGE_MAP(RenderView, message) | 393 IPC_BEGIN_MESSAGE_MAP(RenderView, message) |
| 394 IPC_MESSAGE_HANDLER(ViewMsg_CaptureThumbnail, SendThumbnail) | 394 IPC_MESSAGE_HANDLER(ViewMsg_CaptureThumbnail, SendThumbnail) |
| 395 IPC_MESSAGE_HANDLER(ViewMsg_PrintPages, OnPrintPages) | 395 IPC_MESSAGE_HANDLER(ViewMsg_PrintPages, OnPrintPages) |
| 396 IPC_MESSAGE_HANDLER(ViewMsg_PrintingDone, OnPrintingDone) | 396 IPC_MESSAGE_HANDLER(ViewMsg_PrintingDone, OnPrintingDone) |
| 397 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) | 397 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) |
| 398 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) | 398 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) |
| 399 IPC_MESSAGE_HANDLER(ViewMsg_LoadAlternateHTMLText, OnLoadAlternateHTMLText) | 399 IPC_MESSAGE_HANDLER(ViewMsg_LoadAlternateHTMLText, OnLoadAlternateHTMLText) |
| 400 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) | 400 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) |
| 401 IPC_MESSAGE_HANDLER(ViewMsg_Undo, OnUndo) | 401 IPC_MESSAGE_HANDLER(ViewMsg_Undo, OnUndo) |
| (...skipping 3247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3649 new PluginMsg_SignalModalDialogEvent(host_window_)); | 3649 new PluginMsg_SignalModalDialogEvent(host_window_)); |
| 3650 | 3650 |
| 3651 message->EnableMessagePumping(); // Runs a nested message loop. | 3651 message->EnableMessagePumping(); // Runs a nested message loop. |
| 3652 bool rv = Send(message); | 3652 bool rv = Send(message); |
| 3653 | 3653 |
| 3654 PluginChannelHost::Broadcast( | 3654 PluginChannelHost::Broadcast( |
| 3655 new PluginMsg_ResetModalDialogEvent(host_window_)); | 3655 new PluginMsg_ResetModalDialogEvent(host_window_)); |
| 3656 | 3656 |
| 3657 return rv; | 3657 return rv; |
| 3658 } | 3658 } |
| OLD | NEW |