| OLD | NEW |
| 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 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "chrome/browser/google/google_util.h" | 48 #include "chrome/browser/google/google_util.h" |
| 49 #include "chrome/browser/host_content_settings_map.h" | 49 #include "chrome/browser/host_content_settings_map.h" |
| 50 #include "chrome/browser/hung_renderer_dialog.h" | 50 #include "chrome/browser/hung_renderer_dialog.h" |
| 51 #include "chrome/browser/in_process_webkit/session_storage_namespace.h" | 51 #include "chrome/browser/in_process_webkit/session_storage_namespace.h" |
| 52 #include "chrome/browser/message_box_handler.h" | 52 #include "chrome/browser/message_box_handler.h" |
| 53 #include "chrome/browser/load_from_memory_cache_details.h" | 53 #include "chrome/browser/load_from_memory_cache_details.h" |
| 54 #include "chrome/browser/load_notification_details.h" | 54 #include "chrome/browser/load_notification_details.h" |
| 55 #include "chrome/browser/metrics/metric_event_duration_details.h" | 55 #include "chrome/browser/metrics/metric_event_duration_details.h" |
| 56 #include "chrome/browser/modal_html_dialog_delegate.h" | 56 #include "chrome/browser/modal_html_dialog_delegate.h" |
| 57 #include "chrome/browser/omnibox_search_hint.h" | 57 #include "chrome/browser/omnibox_search_hint.h" |
| 58 #include "chrome/browser/password_manager/password_manager.h" | |
| 59 #include "chrome/browser/platform_util.h" | 58 #include "chrome/browser/platform_util.h" |
| 60 #include "chrome/browser/plugin_installer.h" | 59 #include "chrome/browser/plugin_installer.h" |
| 61 #include "chrome/browser/prefs/pref_service.h" | 60 #include "chrome/browser/prefs/pref_service.h" |
| 62 #include "chrome/browser/printing/print_preview_tab_controller.h" | 61 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 63 #include "chrome/browser/printing/print_view_manager.h" | 62 #include "chrome/browser/printing/print_view_manager.h" |
| 64 #include "chrome/browser/profile.h" | 63 #include "chrome/browser/profile.h" |
| 65 #include "chrome/browser/renderer_host/render_process_host.h" | 64 #include "chrome/browser/renderer_host/render_process_host.h" |
| 66 #include "chrome/browser/renderer_host/render_view_host.h" | 65 #include "chrome/browser/renderer_host/render_view_host.h" |
| 67 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 66 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
| 68 #include "chrome/browser/renderer_host/resource_request_details.h" | 67 #include "chrome/browser/renderer_host/resource_request_details.h" |
| 69 #include "chrome/browser/renderer_host/site_instance.h" | 68 #include "chrome/browser/renderer_host/site_instance.h" |
| 70 #include "chrome/browser/renderer_host/web_cache_manager.h" | 69 #include "chrome/browser/renderer_host/web_cache_manager.h" |
| 71 #include "chrome/browser/renderer_preferences_util.h" | 70 #include "chrome/browser/renderer_preferences_util.h" |
| 72 #include "chrome/browser/search_engines/template_url.h" | 71 #include "chrome/browser/search_engines/template_url.h" |
| 73 #include "chrome/browser/search_engines/template_url_fetcher.h" | 72 #include "chrome/browser/search_engines/template_url_fetcher.h" |
| 74 #include "chrome/browser/search_engines/template_url_fetcher_ui_callbacks.h" | 73 #include "chrome/browser/search_engines/template_url_fetcher_ui_callbacks.h" |
| 75 #include "chrome/browser/search_engines/template_url_model.h" | 74 #include "chrome/browser/search_engines/template_url_model.h" |
| 76 #include "chrome/browser/sessions/session_types.h" | 75 #include "chrome/browser/sessions/session_types.h" |
| 77 #include "chrome/browser/tab_contents/infobar_delegate.h" | 76 #include "chrome/browser/tab_contents/infobar_delegate.h" |
| 78 #include "chrome/browser/tab_contents/interstitial_page.h" | 77 #include "chrome/browser/tab_contents/interstitial_page.h" |
| 79 #include "chrome/browser/tab_contents/navigation_entry.h" | 78 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 80 #include "chrome/browser/tab_contents/provisional_load_details.h" | 79 #include "chrome/browser/tab_contents/provisional_load_details.h" |
| 81 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | 80 #include "chrome/browser/tab_contents/tab_contents_delegate.h" |
| 82 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" | 81 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" |
| 83 #include "chrome/browser/tab_contents/tab_contents_view.h" | 82 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 84 #include "chrome/browser/tab_contents/thumbnail_generator.h" | 83 #include "chrome/browser/tab_contents/thumbnail_generator.h" |
| 84 #include "chrome/browser/tab_contents/web_navigation_observer.h" |
| 85 #include "chrome/browser/translate/page_translated_details.h" | 85 #include "chrome/browser/translate/page_translated_details.h" |
| 86 #include "chrome/common/bindings_policy.h" | 86 #include "chrome/common/bindings_policy.h" |
| 87 #include "chrome/common/chrome_switches.h" | 87 #include "chrome/common/chrome_switches.h" |
| 88 #include "chrome/common/extensions/extension.h" | 88 #include "chrome/common/extensions/extension.h" |
| 89 #include "chrome/common/extensions/extension_action.h" | 89 #include "chrome/common/extensions/extension_action.h" |
| 90 #include "chrome/common/extensions/extension_icon_set.h" | 90 #include "chrome/common/extensions/extension_icon_set.h" |
| 91 #include "chrome/common/extensions/extension_resource.h" | 91 #include "chrome/common/extensions/extension_resource.h" |
| 92 #include "chrome/common/extensions/url_pattern.h" | 92 #include "chrome/common/extensions/url_pattern.h" |
| 93 #include "chrome/common/navigation_types.h" | 93 #include "chrome/common/navigation_types.h" |
| 94 #include "chrome/common/net/url_request_context_getter.h" | 94 #include "chrome/common/net/url_request_context_getter.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 ALLOW_THIS_IN_INITIALIZER_LIST(view_( | 323 ALLOW_THIS_IN_INITIALIZER_LIST(view_( |
| 324 TabContentsView::Create(this))), | 324 TabContentsView::Create(this))), |
| 325 ALLOW_THIS_IN_INITIALIZER_LIST(render_manager_(this, this)), | 325 ALLOW_THIS_IN_INITIALIZER_LIST(render_manager_(this, this)), |
| 326 property_bag_(), | 326 property_bag_(), |
| 327 registrar_(), | 327 registrar_(), |
| 328 ALLOW_THIS_IN_INITIALIZER_LIST(printing_( | 328 ALLOW_THIS_IN_INITIALIZER_LIST(printing_( |
| 329 new printing::PrintViewManager(*this))), | 329 new printing::PrintViewManager(*this))), |
| 330 save_package_(), | 330 save_package_(), |
| 331 autocomplete_history_manager_(), | 331 autocomplete_history_manager_(), |
| 332 autofill_manager_(), | 332 autofill_manager_(), |
| 333 password_manager_(), | |
| 334 plugin_installer_(), | 333 plugin_installer_(), |
| 335 bookmark_drag_(NULL), | 334 bookmark_drag_(NULL), |
| 336 ALLOW_THIS_IN_INITIALIZER_LIST(fav_icon_helper_(this)), | 335 ALLOW_THIS_IN_INITIALIZER_LIST(fav_icon_helper_(this)), |
| 337 is_loading_(false), | 336 is_loading_(false), |
| 338 is_crashed_(false), | 337 is_crashed_(false), |
| 339 waiting_for_response_(false), | 338 waiting_for_response_(false), |
| 340 max_page_id_(-1), | 339 max_page_id_(-1), |
| 341 current_load_start_(), | 340 current_load_start_(), |
| 342 load_state_(net::LOAD_STATE_IDLE), | 341 load_state_(net::LOAD_STATE_IDLE), |
| 343 load_state_host_(), | 342 load_state_host_(), |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 bool TabContents::HostsExtension() const { | 558 bool TabContents::HostsExtension() const { |
| 560 return GetURL().SchemeIs(chrome::kExtensionScheme); | 559 return GetURL().SchemeIs(chrome::kExtensionScheme); |
| 561 } | 560 } |
| 562 | 561 |
| 563 AutoFillManager* TabContents::GetAutoFillManager() { | 562 AutoFillManager* TabContents::GetAutoFillManager() { |
| 564 if (autofill_manager_.get() == NULL) | 563 if (autofill_manager_.get() == NULL) |
| 565 autofill_manager_.reset(new AutoFillManager(this)); | 564 autofill_manager_.reset(new AutoFillManager(this)); |
| 566 return autofill_manager_.get(); | 565 return autofill_manager_.get(); |
| 567 } | 566 } |
| 568 | 567 |
| 569 PasswordManager* TabContents::GetPasswordManager() { | |
| 570 if (password_manager_.get() == NULL) | |
| 571 password_manager_.reset(new PasswordManager(this)); | |
| 572 return password_manager_.get(); | |
| 573 } | |
| 574 | |
| 575 PluginInstaller* TabContents::GetPluginInstaller() { | 568 PluginInstaller* TabContents::GetPluginInstaller() { |
| 576 if (plugin_installer_.get() == NULL) | 569 if (plugin_installer_.get() == NULL) |
| 577 plugin_installer_.reset(new PluginInstaller(this)); | 570 plugin_installer_.reset(new PluginInstaller(this)); |
| 578 return plugin_installer_.get(); | 571 return plugin_installer_.get(); |
| 579 } | 572 } |
| 580 | 573 |
| 581 TabContentsSSLHelper* TabContents::GetSSLHelper() { | 574 TabContentsSSLHelper* TabContents::GetSSLHelper() { |
| 582 if (ssl_helper_.get() == NULL) | 575 if (ssl_helper_.get() == NULL) |
| 583 ssl_helper_.reset(new TabContentsSSLHelper(this)); | 576 ssl_helper_.reset(new TabContentsSSLHelper(this)); |
| 584 return ssl_helper_.get(); | 577 return ssl_helper_.get(); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 load_state_host_); | 753 load_state_host_); |
| 761 // Ignore net::LOAD_STATE_READING_RESPONSE and net::LOAD_STATE_IDLE | 754 // Ignore net::LOAD_STATE_READING_RESPONSE and net::LOAD_STATE_IDLE |
| 762 case net::LOAD_STATE_IDLE: | 755 case net::LOAD_STATE_IDLE: |
| 763 case net::LOAD_STATE_READING_RESPONSE: | 756 case net::LOAD_STATE_READING_RESPONSE: |
| 764 break; | 757 break; |
| 765 } | 758 } |
| 766 | 759 |
| 767 return std::wstring(); | 760 return std::wstring(); |
| 768 } | 761 } |
| 769 | 762 |
| 763 void TabContents::AddNavigationObserver(WebNavigationObserver* observer) { |
| 764 web_navigation_observers_.AddObserver(observer); |
| 765 } |
| 766 |
| 767 void TabContents::RemoveNavigationObserver(WebNavigationObserver* observer) { |
| 768 web_navigation_observers_.RemoveObserver(observer); |
| 769 } |
| 770 |
| 770 void TabContents::SetIsCrashed(bool state) { | 771 void TabContents::SetIsCrashed(bool state) { |
| 771 if (state == is_crashed_) | 772 if (state == is_crashed_) |
| 772 return; | 773 return; |
| 773 | 774 |
| 774 is_crashed_ = state; | 775 is_crashed_ = state; |
| 775 NotifyNavigationStateChanged(INVALIDATE_TAB); | 776 NotifyNavigationStateChanged(INVALIDATE_TAB); |
| 776 } | 777 } |
| 777 | 778 |
| 778 void TabContents::PageActionStateChanged() { | 779 void TabContents::PageActionStateChanged() { |
| 779 NotifyNavigationStateChanged(TabContents::INVALIDATE_PAGE_ACTIONS); | 780 NotifyNavigationStateChanged(TabContents::INVALIDATE_PAGE_ACTIONS); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 if (entry.page_id() == -1) { | 893 if (entry.page_id() == -1) { |
| 893 // HACK!! This code suppresses javascript: URLs from being added to | 894 // HACK!! This code suppresses javascript: URLs from being added to |
| 894 // session history, which is what we want to do for javascript: URLs that | 895 // session history, which is what we want to do for javascript: URLs that |
| 895 // do not generate content. What we really need is a message from the | 896 // do not generate content. What we really need is a message from the |
| 896 // renderer telling us that a new page was not created. The same message | 897 // renderer telling us that a new page was not created. The same message |
| 897 // could be used for mailto: URLs and the like. | 898 // could be used for mailto: URLs and the like. |
| 898 if (entry.url().SchemeIs(chrome::kJavaScriptScheme)) | 899 if (entry.url().SchemeIs(chrome::kJavaScriptScheme)) |
| 899 return false; | 900 return false; |
| 900 } | 901 } |
| 901 | 902 |
| 902 // Clear any provisional password saves - this stops password infobars | 903 // Notify observers about navigation. |
| 903 // showing up on pages the user navigates to while the right page is | 904 FOR_EACH_OBSERVER(WebNavigationObserver, web_navigation_observers_, |
| 904 // loading. | 905 NavigateToPendingEntry()); |
| 905 GetPasswordManager()->ClearProvisionalSave(); | |
| 906 | 906 |
| 907 if (reload_type != NavigationController::NO_RELOAD && | 907 if (reload_type != NavigationController::NO_RELOAD && |
| 908 !profile()->IsOffTheRecord()) { | 908 !profile()->IsOffTheRecord()) { |
| 909 FaviconService* favicon_service = | 909 FaviconService* favicon_service = |
| 910 profile()->GetFaviconService(Profile::IMPLICIT_ACCESS); | 910 profile()->GetFaviconService(Profile::IMPLICIT_ACCESS); |
| 911 if (favicon_service) | 911 if (favicon_service) |
| 912 favicon_service->SetFaviconOutOfDateForPage(entry.url()); | 912 favicon_service->SetFaviconOutOfDateForPage(entry.url()); |
| 913 } | 913 } |
| 914 | 914 |
| 915 return true; | 915 return true; |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1638 } | 1638 } |
| 1639 | 1639 |
| 1640 if (details.is_user_initiated_main_frame_load()) { | 1640 if (details.is_user_initiated_main_frame_load()) { |
| 1641 // Clear the status bubble. This is a workaround for a bug where WebKit | 1641 // Clear the status bubble. This is a workaround for a bug where WebKit |
| 1642 // doesn't let us know that the cursor left an element during a | 1642 // doesn't let us know that the cursor left an element during a |
| 1643 // transition (this is also why the mouse cursor remains as a hand after | 1643 // transition (this is also why the mouse cursor remains as a hand after |
| 1644 // clicking on a link); see bugs 1184641 and 980803. We don't want to | 1644 // clicking on a link); see bugs 1184641 and 980803. We don't want to |
| 1645 // clear the bubble when a user navigates to a named anchor in the same | 1645 // clear the bubble when a user navigates to a named anchor in the same |
| 1646 // page. | 1646 // page. |
| 1647 UpdateTargetURL(details.entry->page_id(), GURL()); | 1647 UpdateTargetURL(details.entry->page_id(), GURL()); |
| 1648 | |
| 1649 // UpdateHelpersForDidNavigate will handle the case where the password_form | |
| 1650 // origin is valid. | |
| 1651 // TODO(brettw) bug 1343111: Password manager stuff in here needs to be | |
| 1652 // cleaned up and covered by tests. | |
| 1653 if (!params.password_form.origin.is_valid()) | |
| 1654 GetPasswordManager()->DidNavigate(); | |
| 1655 } | 1648 } |
| 1656 | 1649 |
| 1657 // The keyword generator uses the navigation entries, so must be called after | 1650 // The keyword generator uses the navigation entries, so must be called after |
| 1658 // the commit. | 1651 // the commit. |
| 1659 GenerateKeywordIfNecessary(params); | 1652 GenerateKeywordIfNecessary(params); |
| 1660 | 1653 |
| 1661 // Allow the new page to set the title again. | 1654 // Allow the new page to set the title again. |
| 1662 received_page_title_ = false; | 1655 received_page_title_ = false; |
| 1663 | 1656 |
| 1664 // Get the favicon, either from history or request it from the net. | 1657 // Get the favicon, either from history or request it from the net. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1706 } | 1699 } |
| 1707 | 1700 |
| 1708 // Close constrained windows if necessary. | 1701 // Close constrained windows if necessary. |
| 1709 if (!net::RegistryControlledDomainService::SameDomainOrHost( | 1702 if (!net::RegistryControlledDomainService::SameDomainOrHost( |
| 1710 details.previous_url, details.entry->url())) | 1703 details.previous_url, details.entry->url())) |
| 1711 CloseConstrainedWindows(); | 1704 CloseConstrainedWindows(); |
| 1712 | 1705 |
| 1713 // Update the starred state. | 1706 // Update the starred state. |
| 1714 UpdateStarredStateForCurrentURL(); | 1707 UpdateStarredStateForCurrentURL(); |
| 1715 | 1708 |
| 1709 // Notify observers about navigation. |
| 1710 FOR_EACH_OBSERVER(WebNavigationObserver, web_navigation_observers_, |
| 1711 DidNavigateMainFramePostCommit(details, params)); |
| 1712 |
| 1716 // Clear the cache of forms in AutoFill. | 1713 // Clear the cache of forms in AutoFill. |
| 1717 if (autofill_manager_.get()) | 1714 if (autofill_manager_.get()) |
| 1718 autofill_manager_->Reset(); | 1715 autofill_manager_->Reset(); |
| 1719 } | 1716 } |
| 1720 | 1717 |
| 1721 void TabContents::DidNavigateAnyFramePostCommit( | 1718 void TabContents::DidNavigateAnyFramePostCommit( |
| 1722 RenderViewHost* render_view_host, | 1719 RenderViewHost* render_view_host, |
| 1723 const NavigationController::LoadCommittedDetails& details, | 1720 const NavigationController::LoadCommittedDetails& details, |
| 1724 const ViewHostMsg_FrameNavigate_Params& params) { | 1721 const ViewHostMsg_FrameNavigate_Params& params) { |
| 1725 // If we navigate, start showing messages again. This does nothing to prevent | 1722 // If we navigate, start showing messages again. This does nothing to prevent |
| 1726 // a malicious script from spamming messages, since the script could just | 1723 // a malicious script from spamming messages, since the script could just |
| 1727 // reload the page to stop blocking. | 1724 // reload the page to stop blocking. |
| 1728 suppress_javascript_messages_ = false; | 1725 suppress_javascript_messages_ = false; |
| 1729 | 1726 |
| 1730 // Notify the password manager of the navigation or form submit. | 1727 // Notify observers about navigation. |
| 1731 // TODO(brettw) bug 1343111: Password manager stuff in here needs to be | 1728 FOR_EACH_OBSERVER(WebNavigationObserver, web_navigation_observers_, |
| 1732 // cleaned up and covered by tests. | 1729 DidNavigateAnyFramePostCommit(details, params)); |
| 1733 if (params.password_form.origin.is_valid()) | |
| 1734 GetPasswordManager()->ProvisionallySavePassword(params.password_form); | |
| 1735 | 1730 |
| 1736 // Let the LanguageState clear its state. | 1731 // Let the LanguageState clear its state. |
| 1737 language_state_.DidNavigate(details); | 1732 language_state_.DidNavigate(details); |
| 1738 } | 1733 } |
| 1739 | 1734 |
| 1740 void TabContents::CloseConstrainedWindows() { | 1735 void TabContents::CloseConstrainedWindows() { |
| 1741 // Clear out any constrained windows since we are leaving this page entirely. | 1736 // Clear out any constrained windows since we are leaving this page entirely. |
| 1742 // We use indices instead of iterators in case CloseWindow does something | 1737 // We use indices instead of iterators in case CloseWindow does something |
| 1743 // that may invalidate an iterator. | 1738 // that may invalidate an iterator. |
| 1744 int size = static_cast<int>(child_windows_.size()); | 1739 int size = static_cast<int>(child_windows_.size()); |
| (...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2636 delegate()->CloseContents(this); | 2631 delegate()->CloseContents(this); |
| 2637 } | 2632 } |
| 2638 | 2633 |
| 2639 void TabContents::RequestMove(const gfx::Rect& new_bounds) { | 2634 void TabContents::RequestMove(const gfx::Rect& new_bounds) { |
| 2640 if (delegate() && delegate()->IsPopup(this)) | 2635 if (delegate() && delegate()->IsPopup(this)) |
| 2641 delegate()->MoveContents(this, new_bounds); | 2636 delegate()->MoveContents(this, new_bounds); |
| 2642 } | 2637 } |
| 2643 | 2638 |
| 2644 void TabContents::DidStartLoading() { | 2639 void TabContents::DidStartLoading() { |
| 2645 SetIsLoading(true, NULL); | 2640 SetIsLoading(true, NULL); |
| 2641 |
| 2646 if (content_restrictions_) { | 2642 if (content_restrictions_) { |
| 2647 content_restrictions_= 0; | 2643 content_restrictions_= 0; |
| 2648 delegate()->ContentRestrictionsChanged(this); | 2644 delegate()->ContentRestrictionsChanged(this); |
| 2649 } | 2645 } |
| 2646 |
| 2647 // Notify observers about navigation. |
| 2648 FOR_EACH_OBSERVER(WebNavigationObserver, web_navigation_observers_, |
| 2649 DidStartLoading()); |
| 2650 } | 2650 } |
| 2651 | 2651 |
| 2652 void TabContents::DidStopLoading() { | 2652 void TabContents::DidStopLoading() { |
| 2653 scoped_ptr<LoadNotificationDetails> details; | 2653 scoped_ptr<LoadNotificationDetails> details; |
| 2654 | 2654 |
| 2655 NavigationEntry* entry = controller_.GetActiveEntry(); | 2655 NavigationEntry* entry = controller_.GetActiveEntry(); |
| 2656 // An entry may not exist for a stop when loading an initial blank page or | 2656 // An entry may not exist for a stop when loading an initial blank page or |
| 2657 // if an iframe injected by script into a blank page finishes loading. | 2657 // if an iframe injected by script into a blank page finishes loading. |
| 2658 if (entry) { | 2658 if (entry) { |
| 2659 base::TimeDelta elapsed = base::TimeTicks::Now() - current_load_start_; | 2659 base::TimeDelta elapsed = base::TimeTicks::Now() - current_load_start_; |
| 2660 | 2660 |
| 2661 details.reset(new LoadNotificationDetails( | 2661 details.reset(new LoadNotificationDetails( |
| 2662 entry->virtual_url(), | 2662 entry->virtual_url(), |
| 2663 entry->transition_type(), | 2663 entry->transition_type(), |
| 2664 elapsed, | 2664 elapsed, |
| 2665 &controller_, | 2665 &controller_, |
| 2666 controller_.GetCurrentEntryIndex())); | 2666 controller_.GetCurrentEntryIndex())); |
| 2667 } | 2667 } |
| 2668 | 2668 |
| 2669 // Tell PasswordManager we've finished a page load, which serves as a | 2669 SetIsLoading(false, details.get()); |
| 2670 // green light to save pending passwords and reset itself. | |
| 2671 GetPasswordManager()->DidStopLoading(); | |
| 2672 | 2670 |
| 2673 SetIsLoading(false, details.get()); | 2671 // Notify observers about navigation. |
| 2672 FOR_EACH_OBSERVER(WebNavigationObserver, web_navigation_observers_, |
| 2673 DidStopLoading()); |
| 2674 } | 2674 } |
| 2675 | 2675 |
| 2676 void TabContents::DocumentOnLoadCompletedInMainFrame( | 2676 void TabContents::DocumentOnLoadCompletedInMainFrame( |
| 2677 RenderViewHost* render_view_host, | 2677 RenderViewHost* render_view_host, |
| 2678 int32 page_id) { | 2678 int32 page_id) { |
| 2679 NotificationService::current()->Notify( | 2679 NotificationService::current()->Notify( |
| 2680 NotificationType::LOAD_COMPLETED_MAIN_FRAME, | 2680 NotificationType::LOAD_COMPLETED_MAIN_FRAME, |
| 2681 Source<TabContents>(this), | 2681 Source<TabContents>(this), |
| 2682 Details<int>(&page_id)); | 2682 Details<int>(&page_id)); |
| 2683 } | 2683 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2785 const std::string& json_arguments, | 2785 const std::string& json_arguments, |
| 2786 IPC::Message* reply_msg) { | 2786 IPC::Message* reply_msg) { |
| 2787 if (delegate()) { | 2787 if (delegate()) { |
| 2788 HtmlDialogUIDelegate* dialog_delegate = | 2788 HtmlDialogUIDelegate* dialog_delegate = |
| 2789 new ModalHtmlDialogDelegate(url, width, height, json_arguments, | 2789 new ModalHtmlDialogDelegate(url, width, height, json_arguments, |
| 2790 reply_msg, this); | 2790 reply_msg, this); |
| 2791 delegate()->ShowHtmlDialog(dialog_delegate, NULL); | 2791 delegate()->ShowHtmlDialog(dialog_delegate, NULL); |
| 2792 } | 2792 } |
| 2793 } | 2793 } |
| 2794 | 2794 |
| 2795 void TabContents::PasswordFormsFound( | |
| 2796 const std::vector<webkit_glue::PasswordForm>& forms) { | |
| 2797 GetPasswordManager()->PasswordFormsFound(forms); | |
| 2798 } | |
| 2799 | |
| 2800 void TabContents::PasswordFormsVisible( | |
| 2801 const std::vector<webkit_glue::PasswordForm>& visible_forms) { | |
| 2802 GetPasswordManager()->PasswordFormsVisible(visible_forms); | |
| 2803 } | |
| 2804 | |
| 2805 // Checks to see if we should generate a keyword based on the OSDD, and if | 2795 // Checks to see if we should generate a keyword based on the OSDD, and if |
| 2806 // necessary uses TemplateURLFetcher to download the OSDD and create a keyword. | 2796 // necessary uses TemplateURLFetcher to download the OSDD and create a keyword. |
| 2807 void TabContents::PageHasOSDD( | 2797 void TabContents::PageHasOSDD( |
| 2808 RenderViewHost* render_view_host, | 2798 RenderViewHost* render_view_host, |
| 2809 int32 page_id, | 2799 int32 page_id, |
| 2810 const GURL& url, | 2800 const GURL& url, |
| 2811 const ViewHostMsg_PageHasOSDD_Type& msg_provider_type) { | 2801 const ViewHostMsg_PageHasOSDD_Type& msg_provider_type) { |
| 2812 // Make sure page_id is the current page and other basic checks. | 2802 // Make sure page_id is the current page and other basic checks. |
| 2813 DCHECK(url.is_valid()); | 2803 DCHECK(url.is_valid()); |
| 2814 if (!IsActiveEntry(page_id)) | 2804 if (!IsActiveEntry(page_id)) |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3229 } | 3219 } |
| 3230 | 3220 |
| 3231 void TabContents::set_encoding(const std::string& encoding) { | 3221 void TabContents::set_encoding(const std::string& encoding) { |
| 3232 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); | 3222 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); |
| 3233 } | 3223 } |
| 3234 | 3224 |
| 3235 void TabContents::SetAppIcon(const SkBitmap& app_icon) { | 3225 void TabContents::SetAppIcon(const SkBitmap& app_icon) { |
| 3236 app_icon_ = app_icon; | 3226 app_icon_ = app_icon; |
| 3237 NotifyNavigationStateChanged(INVALIDATE_TITLE); | 3227 NotifyNavigationStateChanged(INVALIDATE_TITLE); |
| 3238 } | 3228 } |
| 3239 | |
| 3240 // After a successful *new* login attempt, we take the PasswordFormManager in | |
| 3241 // provisional_save_manager_ and move it to a SavePasswordInfoBarDelegate while | |
| 3242 // the user makes up their mind with the "save password" infobar. Note if the | |
| 3243 // login is one we already know about, the end of the line is | |
| 3244 // provisional_save_manager_ because we just update it on success and so such | |
| 3245 // forms never end up in an infobar. | |
| 3246 class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate { | |
| 3247 public: | |
| 3248 SavePasswordInfoBarDelegate(TabContents* tab_contents, | |
| 3249 PasswordFormManager* form_to_save) | |
| 3250 : ConfirmInfoBarDelegate(tab_contents), | |
| 3251 form_to_save_(form_to_save), | |
| 3252 infobar_response_(NO_RESPONSE) {} | |
| 3253 | |
| 3254 virtual ~SavePasswordInfoBarDelegate() {} | |
| 3255 | |
| 3256 // Begin ConfirmInfoBarDelegate implementation. | |
| 3257 virtual void InfoBarClosed() { | |
| 3258 UMA_HISTOGRAM_ENUMERATION("PasswordManager.InfoBarResponse", | |
| 3259 infobar_response_, NUM_RESPONSE_TYPES); | |
| 3260 delete this; | |
| 3261 } | |
| 3262 | |
| 3263 virtual Type GetInfoBarType() { return PAGE_ACTION_TYPE; } | |
| 3264 | |
| 3265 virtual string16 GetMessageText() const { | |
| 3266 return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_PASSWORD_PROMPT); | |
| 3267 } | |
| 3268 | |
| 3269 virtual SkBitmap* GetIcon() const { | |
| 3270 return ResourceBundle::GetSharedInstance().GetBitmapNamed( | |
| 3271 IDR_INFOBAR_SAVE_PASSWORD); | |
| 3272 } | |
| 3273 | |
| 3274 virtual int GetButtons() const { | |
| 3275 return BUTTON_OK | BUTTON_CANCEL; | |
| 3276 } | |
| 3277 | |
| 3278 virtual string16 GetButtonLabel(InfoBarButton button) const { | |
| 3279 if (button == BUTTON_OK) | |
| 3280 return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON); | |
| 3281 if (button == BUTTON_CANCEL) | |
| 3282 return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BLACKLIST_BUTTON); | |
| 3283 NOTREACHED(); | |
| 3284 return string16(); | |
| 3285 } | |
| 3286 | |
| 3287 virtual bool Accept() { | |
| 3288 DCHECK(form_to_save_.get()); | |
| 3289 form_to_save_->Save(); | |
| 3290 infobar_response_ = REMEMBER_PASSWORD; | |
| 3291 return true; | |
| 3292 } | |
| 3293 | |
| 3294 virtual bool Cancel() { | |
| 3295 DCHECK(form_to_save_.get()); | |
| 3296 form_to_save_->PermanentlyBlacklist(); | |
| 3297 infobar_response_ = DONT_REMEMBER_PASSWORD; | |
| 3298 return true; | |
| 3299 } | |
| 3300 // End ConfirmInfoBarDelegate implementation. | |
| 3301 | |
| 3302 private: | |
| 3303 // The PasswordFormManager managing the form we're asking the user about, | |
| 3304 // and should update as per her decision. | |
| 3305 scoped_ptr<PasswordFormManager> form_to_save_; | |
| 3306 | |
| 3307 // Used to track the results we get from the info bar. | |
| 3308 enum ResponseType { | |
| 3309 NO_RESPONSE = 0, | |
| 3310 REMEMBER_PASSWORD, | |
| 3311 DONT_REMEMBER_PASSWORD, | |
| 3312 NUM_RESPONSE_TYPES, | |
| 3313 }; | |
| 3314 ResponseType infobar_response_; | |
| 3315 | |
| 3316 DISALLOW_COPY_AND_ASSIGN(SavePasswordInfoBarDelegate); | |
| 3317 }; | |
| 3318 | |
| 3319 void TabContents::FillPasswordForm( | |
| 3320 const webkit_glue::PasswordFormFillData& form_data) { | |
| 3321 render_view_host()->FillPasswordForm(form_data); | |
| 3322 } | |
| 3323 | |
| 3324 void TabContents::AddSavePasswordInfoBar(PasswordFormManager* form_to_save) { | |
| 3325 AddInfoBar(new SavePasswordInfoBarDelegate(this, form_to_save)); | |
| 3326 } | |
| 3327 | |
| 3328 Profile* TabContents::GetProfileForPasswordManager() { | |
| 3329 return profile(); | |
| 3330 } | |
| 3331 | |
| 3332 bool TabContents::DidLastPageLoadEncounterSSLErrors() { | |
| 3333 return controller().ssl_manager()->ProcessedSSLErrorFromRequest(); | |
| 3334 } | |
| OLD | NEW |