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 "content/browser/tab_contents/tab_contents.h" | 5 #include "content/browser/tab_contents/tab_contents.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 UMA_HISTOGRAM_TIMES("Tab.Close", | 263 UMA_HISTOGRAM_TIMES("Tab.Close", |
264 base::TimeTicks::Now() - tab_close_start_time_); | 264 base::TimeTicks::Now() - tab_close_start_time_); |
265 } | 265 } |
266 | 266 |
267 FOR_EACH_OBSERVER(TabContentsObserver, observers_, TabContentsDestroyed()); | 267 FOR_EACH_OBSERVER(TabContentsObserver, observers_, TabContentsDestroyed()); |
268 | 268 |
269 SetDelegate(NULL); | 269 SetDelegate(NULL); |
270 } | 270 } |
271 | 271 |
272 bool TabContents::OnMessageReceived(const IPC::Message& message) { | 272 bool TabContents::OnMessageReceived(const IPC::Message& message) { |
273 if (web_ui() && web_ui()->OnMessageReceived(message)) | 273 if (GetWebUI() && GetWebUI()->OnMessageReceived(message)) |
274 return true; | 274 return true; |
275 | 275 |
276 ObserverListBase<TabContentsObserver>::Iterator it(observers_); | 276 ObserverListBase<TabContentsObserver>::Iterator it(observers_); |
277 TabContentsObserver* observer; | 277 TabContentsObserver* observer; |
278 while ((observer = it.GetNext()) != NULL) | 278 while ((observer = it.GetNext()) != NULL) |
279 if (observer->OnMessageReceived(message)) | 279 if (observer->OnMessageReceived(message)) |
280 return true; | 280 return true; |
281 | 281 |
282 bool handled = true; | 282 bool handled = true; |
283 bool message_is_ok = true; | 283 bool message_is_ok = true; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 } | 339 } |
340 | 340 |
341 content::BrowserContext* TabContents::GetBrowserContext() const { | 341 content::BrowserContext* TabContents::GetBrowserContext() const { |
342 return controller_.browser_context(); | 342 return controller_.browser_context(); |
343 } | 343 } |
344 | 344 |
345 void TabContents::SetViewType(content::ViewType type) { | 345 void TabContents::SetViewType(content::ViewType type) { |
346 view_type_ = type; | 346 view_type_ = type; |
347 } | 347 } |
348 | 348 |
| 349 const GURL& TabContents::GetURL() const { |
| 350 // We may not have a navigation entry yet |
| 351 NavigationEntry* entry = controller_.GetActiveEntry(); |
| 352 return entry ? entry->virtual_url() : GURL::EmptyGURL(); |
| 353 } |
| 354 |
| 355 |
| 356 const base::PropertyBag* TabContents::GetPropertyBag() const { |
| 357 return &property_bag_; |
| 358 } |
| 359 |
| 360 base::PropertyBag* TabContents::GetPropertyBag() { |
| 361 return &property_bag_; |
| 362 } |
| 363 |
| 364 content::WebContentsDelegate* TabContents::GetDelegate() { |
| 365 return delegate_; |
| 366 } |
| 367 |
| 368 void TabContents::SetDelegate(content::WebContentsDelegate* delegate) { |
| 369 // TODO(cbentzel): remove this debugging code? |
| 370 if (delegate == delegate_) |
| 371 return; |
| 372 if (delegate_) |
| 373 delegate_->Detach(this); |
| 374 delegate_ = delegate; |
| 375 if (delegate_) |
| 376 delegate_->Attach(this); |
| 377 } |
| 378 |
349 content::RenderProcessHost* TabContents::GetRenderProcessHost() const { | 379 content::RenderProcessHost* TabContents::GetRenderProcessHost() const { |
350 if (render_manager_.current_host()) | 380 if (render_manager_.current_host()) |
351 return render_manager_.current_host()->process(); | 381 return render_manager_.current_host()->process(); |
352 else | 382 else |
353 return NULL; | 383 return NULL; |
354 } | 384 } |
355 | 385 |
356 const GURL& TabContents::GetURL() const { | 386 RenderViewHost* TabContents::GetRenderViewHost() const { |
357 // We may not have a navigation entry yet | 387 return render_manager_.current_host(); |
358 NavigationEntry* entry = controller_.GetActiveEntry(); | 388 } |
359 return entry ? entry->virtual_url() : GURL::EmptyGURL(); | 389 |
| 390 RenderWidgetHostView* TabContents::GetRenderWidgetHostView() const { |
| 391 return render_manager_.GetRenderWidgetHostView(); |
| 392 } |
| 393 |
| 394 TabContentsView* TabContents::GetView() const { |
| 395 return view_.get(); |
| 396 } |
| 397 |
| 398 WebUI* TabContents::GetWebUI() const { |
| 399 return render_manager_.web_ui() ? render_manager_.web_ui() |
| 400 : render_manager_.pending_web_ui(); |
| 401 } |
| 402 |
| 403 WebUI* TabContents::GetCommittedWebUI() const { |
| 404 return render_manager_.web_ui(); |
360 } | 405 } |
361 | 406 |
362 const string16& TabContents::GetTitle() const { | 407 const string16& TabContents::GetTitle() const { |
363 // Transient entries take precedence. They are used for interstitial pages | 408 // Transient entries take precedence. They are used for interstitial pages |
364 // that are shown on top of existing pages. | 409 // that are shown on top of existing pages. |
365 NavigationEntry* entry = controller_.GetTransientEntry(); | 410 NavigationEntry* entry = controller_.GetTransientEntry(); |
366 std::string accept_languages = | 411 std::string accept_languages = |
367 content::GetContentClient()->browser()->GetAcceptLangs( | 412 content::GetContentClient()->browser()->GetAcceptLangs( |
368 GetBrowserContext()); | 413 GetBrowserContext()); |
369 if (entry) { | 414 if (entry) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 return render_manager_.current_host()->site_instance(); | 466 return render_manager_.current_host()->site_instance(); |
422 } | 467 } |
423 | 468 |
424 SiteInstance* TabContents::GetPendingSiteInstance() const { | 469 SiteInstance* TabContents::GetPendingSiteInstance() const { |
425 RenderViewHost* dest_rvh = render_manager_.pending_render_view_host() ? | 470 RenderViewHost* dest_rvh = render_manager_.pending_render_view_host() ? |
426 render_manager_.pending_render_view_host() : | 471 render_manager_.pending_render_view_host() : |
427 render_manager_.current_host(); | 472 render_manager_.current_host(); |
428 return dest_rvh->site_instance(); | 473 return dest_rvh->site_instance(); |
429 } | 474 } |
430 | 475 |
431 void TabContents::AddObserver(TabContentsObserver* observer) { | 476 bool TabContents::IsLoading() const { |
432 observers_.AddObserver(observer); | 477 return is_loading_; |
433 } | 478 } |
434 | 479 |
435 void TabContents::RemoveObserver(TabContentsObserver* observer) { | 480 bool TabContents::IsWaitingForResponse() const { |
436 observers_.RemoveObserver(observer); | 481 return waiting_for_response_; |
| 482 } |
| 483 |
| 484 const net::LoadStateWithParam& TabContents::GetLoadState() const { |
| 485 return load_state_; |
| 486 } |
| 487 |
| 488 const string16& TabContents::GetLoadStateHost() const { |
| 489 return load_state_host_; |
| 490 } |
| 491 |
| 492 uint64 TabContents::GetUploadSize() const { |
| 493 return upload_size_; |
| 494 } |
| 495 |
| 496 uint64 TabContents::GetUploadPosition() const { |
| 497 return upload_position_; |
| 498 } |
| 499 |
| 500 const std::string& TabContents::GetEncoding() const { |
| 501 return encoding_; |
| 502 } |
| 503 |
| 504 bool TabContents::DisplayedInsecureContent() const { |
| 505 return displayed_insecure_content_; |
| 506 } |
| 507 |
| 508 void TabContents::SetCapturingContents(bool cap) { |
| 509 capturing_contents_ = cap; |
| 510 } |
| 511 |
| 512 bool TabContents::IsCrashed() const { |
| 513 return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED || |
| 514 crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION || |
| 515 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED); |
437 } | 516 } |
438 | 517 |
439 void TabContents::SetIsCrashed(base::TerminationStatus status, int error_code) { | 518 void TabContents::SetIsCrashed(base::TerminationStatus status, int error_code) { |
440 if (status == crashed_status_) | 519 if (status == crashed_status_) |
441 return; | 520 return; |
442 | 521 |
443 crashed_status_ = status; | 522 crashed_status_ = status; |
444 crashed_error_code_ = error_code; | 523 crashed_error_code_ = error_code; |
445 NotifyNavigationStateChanged(INVALIDATE_TAB); | 524 NotifyNavigationStateChanged(INVALIDATE_TAB); |
446 } | 525 } |
447 | 526 |
| 527 base::TerminationStatus TabContents::GetCrashedStatus() const { |
| 528 return crashed_status_; |
| 529 } |
| 530 |
| 531 bool TabContents::IsBeingDestroyed() const { |
| 532 return is_being_destroyed_; |
| 533 } |
| 534 |
448 void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) { | 535 void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) { |
449 if (delegate_) | 536 if (delegate_) |
450 delegate_->NavigationStateChanged(this, changed_flags); | 537 delegate_->NavigationStateChanged(this, changed_flags); |
451 } | 538 } |
452 | 539 |
453 void TabContents::DidBecomeSelected() { | 540 void TabContents::DidBecomeSelected() { |
454 controller_.SetActive(true); | 541 controller_.SetActive(true); |
455 RenderWidgetHostView* rwhv = GetRenderWidgetHostView(); | 542 RenderWidgetHostView* rwhv = GetRenderWidgetHostView(); |
456 if (rwhv) { | 543 if (rwhv) { |
457 rwhv->DidBecomeSelected(); | 544 rwhv->DidBecomeSelected(); |
458 #if defined(OS_MACOSX) | 545 #if defined(OS_MACOSX) |
459 rwhv->SetActive(true); | 546 rwhv->SetActive(true); |
460 #endif | 547 #endif |
461 } | 548 } |
462 | 549 |
463 last_selected_time_ = base::TimeTicks::Now(); | 550 last_selected_time_ = base::TimeTicks::Now(); |
464 | 551 |
465 FOR_EACH_OBSERVER(TabContentsObserver, observers_, DidBecomeSelected()); | 552 FOR_EACH_OBSERVER(TabContentsObserver, observers_, DidBecomeSelected()); |
466 } | 553 } |
467 | 554 |
| 555 |
| 556 base::TimeTicks TabContents::GetLastSelectedTime() const { |
| 557 return last_selected_time_; |
| 558 } |
| 559 |
468 void TabContents::WasHidden() { | 560 void TabContents::WasHidden() { |
469 if (!capturing_contents()) { | 561 if (!capturing_contents_) { |
470 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to | 562 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to |
471 // open a tab in then background, then closes the tab before selecting it. | 563 // open a tab in then background, then closes the tab before selecting it. |
472 // This is because closing the tab calls TabContents::Destroy(), which | 564 // This is because closing the tab calls TabContents::Destroy(), which |
473 // removes the |GetRenderViewHost()|; then when we actually destroy the | 565 // removes the |GetRenderViewHost()|; then when we actually destroy the |
474 // window, OnWindowPosChanged() notices and calls HideContents() (which | 566 // window, OnWindowPosChanged() notices and calls HideContents() (which |
475 // calls us). | 567 // calls us). |
476 RenderWidgetHostView* rwhv = GetRenderWidgetHostView(); | 568 RenderWidgetHostView* rwhv = GetRenderWidgetHostView(); |
477 if (rwhv) | 569 if (rwhv) |
478 rwhv->WasHidden(); | 570 rwhv->WasHidden(); |
479 } | 571 } |
480 | 572 |
481 content::NotificationService::current()->Notify( | 573 content::NotificationService::current()->Notify( |
482 content::NOTIFICATION_TAB_CONTENTS_HIDDEN, | 574 content::NOTIFICATION_TAB_CONTENTS_HIDDEN, |
483 content::Source<TabContents>(this), | 575 content::Source<TabContents>(this), |
484 content::NotificationService::NoDetails()); | 576 content::NotificationService::NoDetails()); |
485 } | 577 } |
486 | 578 |
| 579 void TabContents::ShowContents() { |
| 580 RenderWidgetHostView* rwhv = GetRenderWidgetHostView(); |
| 581 if (rwhv) |
| 582 rwhv->DidBecomeSelected(); |
| 583 } |
| 584 |
| 585 void TabContents::HideContents() { |
| 586 // TODO(pkasting): http://b/1239839 Right now we purposefully don't call |
| 587 // our superclass HideContents(), because some callers want to be very picky |
| 588 // about the order in which these get called. In addition to making the code |
| 589 // here practically impossible to understand, this also means we end up |
| 590 // calling TabContents::WasHidden() twice if callers call both versions of |
| 591 // HideContents() on a TabContents. |
| 592 WasHidden(); |
| 593 } |
| 594 |
| 595 bool TabContents::NeedToFireBeforeUnload() { |
| 596 // TODO(creis): Should we fire even for interstitial pages? |
| 597 return notify_disconnection() && |
| 598 !showing_interstitial_page() && |
| 599 !GetRenderViewHost()->SuddenTerminationAllowed(); |
| 600 } |
| 601 |
| 602 RenderViewHostManager* TabContents::GetRenderManagerForTesting() { |
| 603 return &render_manager_; |
| 604 } |
| 605 |
| 606 void TabContents::AddObserver(TabContentsObserver* observer) { |
| 607 observers_.AddObserver(observer); |
| 608 } |
| 609 |
| 610 void TabContents::RemoveObserver(TabContentsObserver* observer) { |
| 611 observers_.RemoveObserver(observer); |
| 612 } |
| 613 |
487 void TabContents::Activate() { | 614 void TabContents::Activate() { |
488 if (delegate_) | 615 if (delegate_) |
489 delegate_->ActivateContents(this); | 616 delegate_->ActivateContents(this); |
490 } | 617 } |
491 | 618 |
492 void TabContents::Deactivate() { | 619 void TabContents::Deactivate() { |
493 if (delegate_) | 620 if (delegate_) |
494 delegate_->DeactivateContents(this); | 621 delegate_->DeactivateContents(this); |
495 } | 622 } |
496 | 623 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 } | 680 } |
554 | 681 |
555 void TabContents::WebUISend(RenderViewHost* render_view_host, | 682 void TabContents::WebUISend(RenderViewHost* render_view_host, |
556 const GURL& source_url, | 683 const GURL& source_url, |
557 const std::string& name, | 684 const std::string& name, |
558 const base::ListValue& args) { | 685 const base::ListValue& args) { |
559 if (delegate_) | 686 if (delegate_) |
560 delegate_->WebUISend(this, source_url, name, args); | 687 delegate_->WebUISend(this, source_url, name, args); |
561 } | 688 } |
562 | 689 |
563 void TabContents::ShowContents() { | |
564 RenderWidgetHostView* rwhv = GetRenderWidgetHostView(); | |
565 if (rwhv) | |
566 rwhv->DidBecomeSelected(); | |
567 } | |
568 | |
569 void TabContents::HideContents() { | |
570 // TODO(pkasting): http://b/1239839 Right now we purposefully don't call | |
571 // our superclass HideContents(), because some callers want to be very picky | |
572 // about the order in which these get called. In addition to making the code | |
573 // here practically impossible to understand, this also means we end up | |
574 // calling TabContents::WasHidden() twice if callers call both versions of | |
575 // HideContents() on a TabContents. | |
576 WasHidden(); | |
577 } | |
578 | |
579 bool TabContents::NeedToFireBeforeUnload() { | |
580 // TODO(creis): Should we fire even for interstitial pages? | |
581 return notify_disconnection() && | |
582 !showing_interstitial_page() && | |
583 !GetRenderViewHost()->SuddenTerminationAllowed(); | |
584 } | |
585 | |
586 // TODO(adriansc): Remove this method once refactoring changed all call sites. | 690 // TODO(adriansc): Remove this method once refactoring changed all call sites. |
587 TabContents* TabContents::OpenURL(const GURL& url, | 691 TabContents* TabContents::OpenURL(const GURL& url, |
588 const GURL& referrer, | 692 const GURL& referrer, |
589 WindowOpenDisposition disposition, | 693 WindowOpenDisposition disposition, |
590 content::PageTransition transition) { | 694 content::PageTransition transition) { |
591 // For specifying a referrer, use the version of OpenURL taking OpenURLParams. | 695 // For specifying a referrer, use the version of OpenURL taking OpenURLParams. |
592 DCHECK(referrer.is_empty()); | 696 DCHECK(referrer.is_empty()); |
593 return OpenURL(OpenURLParams(url, content::Referrer(), disposition, | 697 return OpenURL(OpenURLParams(url, content::Referrer(), disposition, |
594 transition, false)); | 698 transition, false)); |
595 } | 699 } |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 } | 925 } |
822 | 926 |
823 bool TabContents::IsActiveEntry(int32 page_id) { | 927 bool TabContents::IsActiveEntry(int32 page_id) { |
824 NavigationEntry* active_entry = controller_.GetActiveEntry(); | 928 NavigationEntry* active_entry = controller_.GetActiveEntry(); |
825 return (active_entry != NULL && | 929 return (active_entry != NULL && |
826 active_entry->site_instance() == GetSiteInstance() && | 930 active_entry->site_instance() == GetSiteInstance() && |
827 active_entry->page_id() == page_id); | 931 active_entry->page_id() == page_id); |
828 } | 932 } |
829 | 933 |
830 void TabContents::SetOverrideEncoding(const std::string& encoding) { | 934 void TabContents::SetOverrideEncoding(const std::string& encoding) { |
831 set_encoding(encoding); | 935 SetEncoding(encoding); |
832 GetRenderViewHost()->Send(new ViewMsg_SetPageEncoding( | 936 GetRenderViewHost()->Send(new ViewMsg_SetPageEncoding( |
833 GetRenderViewHost()->routing_id(), encoding)); | 937 GetRenderViewHost()->routing_id(), encoding)); |
834 } | 938 } |
835 | 939 |
836 void TabContents::ResetOverrideEncoding() { | 940 void TabContents::ResetOverrideEncoding() { |
837 reset_encoding(); | 941 encoding_.clear(); |
838 GetRenderViewHost()->Send(new ViewMsg_ResetPageEncodingToDefault( | 942 GetRenderViewHost()->Send(new ViewMsg_ResetPageEncodingToDefault( |
839 GetRenderViewHost()->routing_id())); | 943 GetRenderViewHost()->routing_id())); |
840 } | 944 } |
841 | 945 |
842 void TabContents::OnCloseStarted() { | 946 void TabContents::OnCloseStarted() { |
843 if (tab_close_start_time_.is_null()) | 947 if (tab_close_start_time_.is_null()) |
844 tab_close_start_time_ = base::TimeTicks::Now(); | 948 tab_close_start_time_ = base::TimeTicks::Now(); |
845 } | 949 } |
846 | 950 |
847 bool TabContents::ShouldAcceptDragAndDrop() const { | 951 bool TabContents::ShouldAcceptDragAndDrop() const { |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 if (!notify_disconnection_) | 1521 if (!notify_disconnection_) |
1418 return; | 1522 return; |
1419 | 1523 |
1420 notify_disconnection_ = false; | 1524 notify_disconnection_ = false; |
1421 content::NotificationService::current()->Notify( | 1525 content::NotificationService::current()->Notify( |
1422 content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED, | 1526 content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED, |
1423 content::Source<TabContents>(this), | 1527 content::Source<TabContents>(this), |
1424 content::NotificationService::NoDetails()); | 1528 content::NotificationService::NoDetails()); |
1425 } | 1529 } |
1426 | 1530 |
1427 const base::PropertyBag* TabContents::GetPropertyBag() const { | |
1428 return &property_bag_; | |
1429 } | |
1430 | |
1431 base::PropertyBag* TabContents::GetPropertyBag() { | |
1432 return &property_bag_; | |
1433 } | |
1434 | |
1435 content::WebContentsDelegate* TabContents::GetDelegate() { | |
1436 return delegate_; | |
1437 } | |
1438 | |
1439 void TabContents::SetDelegate(content::WebContentsDelegate* delegate) { | |
1440 // TODO(cbentzel): remove this debugging code? | |
1441 if (delegate == delegate_) | |
1442 return; | |
1443 if (delegate_) | |
1444 delegate_->Detach(this); | |
1445 delegate_ = delegate; | |
1446 if (delegate_) | |
1447 delegate_->Attach(this); | |
1448 } | |
1449 | |
1450 RenderViewHost* TabContents::GetRenderViewHost() const { | |
1451 return render_manager_.current_host(); | |
1452 } | |
1453 | |
1454 RenderWidgetHostView* TabContents::GetRenderWidgetHostView() const { | |
1455 return render_manager_.GetRenderWidgetHostView(); | |
1456 } | |
1457 | |
1458 TabContentsView* TabContents::GetView() const { | |
1459 return view_.get(); | |
1460 } | |
1461 | |
1462 RenderViewHostDelegate::View* TabContents::GetViewDelegate() { | 1531 RenderViewHostDelegate::View* TabContents::GetViewDelegate() { |
1463 return view_.get(); | 1532 return view_.get(); |
1464 } | 1533 } |
1465 | 1534 |
1466 RenderViewHostDelegate::RendererManagement* | 1535 RenderViewHostDelegate::RendererManagement* |
1467 TabContents::GetRendererManagementDelegate() { | 1536 TabContents::GetRendererManagementDelegate() { |
1468 return &render_manager_; | 1537 return &render_manager_; |
1469 } | 1538 } |
1470 | 1539 |
1471 content::RendererPreferences TabContents::GetRendererPrefs( | 1540 content::RendererPreferences TabContents::GetRendererPrefs( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1508 } | 1577 } |
1509 | 1578 |
1510 void TabContents::RenderViewReady(RenderViewHost* rvh) { | 1579 void TabContents::RenderViewReady(RenderViewHost* rvh) { |
1511 if (rvh != GetRenderViewHost()) { | 1580 if (rvh != GetRenderViewHost()) { |
1512 // Don't notify the world, since this came from a renderer in the | 1581 // Don't notify the world, since this came from a renderer in the |
1513 // background. | 1582 // background. |
1514 return; | 1583 return; |
1515 } | 1584 } |
1516 | 1585 |
1517 NotifyConnected(); | 1586 NotifyConnected(); |
1518 bool was_crashed = is_crashed(); | 1587 bool was_crashed = IsCrashed(); |
1519 SetIsCrashed(base::TERMINATION_STATUS_STILL_RUNNING, 0); | 1588 SetIsCrashed(base::TERMINATION_STATUS_STILL_RUNNING, 0); |
1520 | 1589 |
1521 // Restore the focus to the tab (otherwise the focus will be on the top | 1590 // Restore the focus to the tab (otherwise the focus will be on the top |
1522 // window). | 1591 // window). |
1523 if (was_crashed && !FocusLocationBarByDefault() && | 1592 if (was_crashed && !FocusLocationBarByDefault() && |
1524 (!delegate_ || delegate_->ShouldFocusPageAfterCrash())) { | 1593 (!delegate_ || delegate_->ShouldFocusPageAfterCrash())) { |
1525 Focus(); | 1594 Focus(); |
1526 } | 1595 } |
1527 | 1596 |
1528 FOR_EACH_OBSERVER(TabContentsObserver, observers_, RenderViewReady()); | 1597 FOR_EACH_OBSERVER(TabContentsObserver, observers_, RenderViewReady()); |
1529 } | 1598 } |
1530 | 1599 |
1531 void TabContents::RenderViewGone(RenderViewHost* rvh, | 1600 void TabContents::RenderViewGone(RenderViewHost* rvh, |
1532 base::TerminationStatus status, | 1601 base::TerminationStatus status, |
1533 int error_code) { | 1602 int error_code) { |
1534 if (rvh != GetRenderViewHost()) { | 1603 if (rvh != GetRenderViewHost()) { |
1535 // The pending page's RenderViewHost is gone. | 1604 // The pending page's RenderViewHost is gone. |
1536 return; | 1605 return; |
1537 } | 1606 } |
1538 | 1607 |
1539 SetIsLoading(false, NULL); | 1608 SetIsLoading(false, NULL); |
1540 NotifyDisconnected(); | 1609 NotifyDisconnected(); |
1541 SetIsCrashed(status, error_code); | 1610 SetIsCrashed(status, error_code); |
1542 GetView()->OnTabCrashed(crashed_status(), crashed_error_code()); | 1611 GetView()->OnTabCrashed(GetCrashedStatus(), crashed_error_code_); |
1543 | 1612 |
1544 FOR_EACH_OBSERVER(TabContentsObserver, | 1613 FOR_EACH_OBSERVER(TabContentsObserver, |
1545 observers_, | 1614 observers_, |
1546 RenderViewGone(crashed_status())); | 1615 RenderViewGone(GetCrashedStatus())); |
1547 } | 1616 } |
1548 | 1617 |
1549 void TabContents::RenderViewDeleted(RenderViewHost* rvh) { | 1618 void TabContents::RenderViewDeleted(RenderViewHost* rvh) { |
1550 render_manager_.RenderViewDeleted(rvh); | 1619 render_manager_.RenderViewDeleted(rvh); |
1551 FOR_EACH_OBSERVER(TabContentsObserver, observers_, RenderViewDeleted(rvh)); | 1620 FOR_EACH_OBSERVER(TabContentsObserver, observers_, RenderViewDeleted(rvh)); |
1552 } | 1621 } |
1553 | 1622 |
1554 void TabContents::DidNavigate(RenderViewHost* rvh, | 1623 void TabContents::DidNavigate(RenderViewHost* rvh, |
1555 const ViewHostMsg_FrameNavigate_Params& params) { | 1624 const ViewHostMsg_FrameNavigate_Params& params) { |
1556 if (content::PageTransitionIsMainFrame(params.transition)) | 1625 if (content::PageTransitionIsMainFrame(params.transition)) |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 if (!UpdateTitleForEntry(entry, title)) | 1727 if (!UpdateTitleForEntry(entry, title)) |
1659 return; | 1728 return; |
1660 | 1729 |
1661 // Broadcast notifications when the UI should be updated. | 1730 // Broadcast notifications when the UI should be updated. |
1662 if (entry == controller_.GetEntryAtOffset(0)) | 1731 if (entry == controller_.GetEntryAtOffset(0)) |
1663 NotifyNavigationStateChanged(INVALIDATE_TITLE); | 1732 NotifyNavigationStateChanged(INVALIDATE_TITLE); |
1664 } | 1733 } |
1665 | 1734 |
1666 void TabContents::UpdateEncoding(RenderViewHost* render_view_host, | 1735 void TabContents::UpdateEncoding(RenderViewHost* render_view_host, |
1667 const std::string& encoding) { | 1736 const std::string& encoding) { |
1668 set_encoding(encoding); | 1737 SetEncoding(encoding); |
1669 } | 1738 } |
1670 | 1739 |
1671 void TabContents::UpdateTargetURL(int32 page_id, const GURL& url) { | 1740 void TabContents::UpdateTargetURL(int32 page_id, const GURL& url) { |
1672 if (delegate_) | 1741 if (delegate_) |
1673 delegate_->UpdateTargetURL(this, page_id, url); | 1742 delegate_->UpdateTargetURL(this, page_id, url); |
1674 } | 1743 } |
1675 | 1744 |
1676 void TabContents::Close(RenderViewHost* rvh) { | 1745 void TabContents::Close(RenderViewHost* rvh) { |
1677 // The UI may be in an event-tracking loop, such as between the | 1746 // The UI may be in an event-tracking loop, such as between the |
1678 // mouse-down and mouse-up in text selection or a button click. | 1747 // mouse-down and mouse-up in text selection or a button click. |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2085 } | 2154 } |
2086 | 2155 |
2087 gfx::NativeWindow TabContents::GetDialogRootWindow() const { | 2156 gfx::NativeWindow TabContents::GetDialogRootWindow() const { |
2088 return view_->GetTopLevelNativeWindow(); | 2157 return view_->GetTopLevelNativeWindow(); |
2089 } | 2158 } |
2090 | 2159 |
2091 void TabContents::OnDialogShown() { | 2160 void TabContents::OnDialogShown() { |
2092 Activate(); | 2161 Activate(); |
2093 } | 2162 } |
2094 | 2163 |
2095 void TabContents::set_encoding(const std::string& encoding) { | 2164 void TabContents::SetEncoding(const std::string& encoding) { |
2096 encoding_ = content::GetContentClient()->browser()-> | 2165 encoding_ = content::GetContentClient()->browser()-> |
2097 GetCanonicalEncodingNameByAliasName(encoding); | 2166 GetCanonicalEncodingNameByAliasName(encoding); |
2098 } | 2167 } |
2099 | 2168 |
2100 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2169 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2101 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); | 2170 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); |
2102 // Can be NULL during tests. | 2171 // Can be NULL during tests. |
2103 if (rwh_view) | 2172 if (rwh_view) |
2104 rwh_view->SetSize(GetView()->GetContainerSize()); | 2173 rwh_view->SetSize(GetView()->GetContainerSize()); |
2105 } | 2174 } |
2106 | 2175 |
2107 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { | 2176 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { |
2108 return GetRenderViewHost() ? | 2177 return GetRenderViewHost() ? |
2109 GetRenderViewHost()->GotResponseToLockMouseRequest(allowed) : false; | 2178 GetRenderViewHost()->GotResponseToLockMouseRequest(allowed) : false; |
2110 } | 2179 } |
OLD | NEW |