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

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

Issue 6368011: Clean up WebNavigationObserver by taking out password specific callbacks, and... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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) 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/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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 441
442 // Listen for Google URL changes 442 // Listen for Google URL changes
443 registrar_.Add(this, NotificationType::GOOGLE_URL_UPDATED, 443 registrar_.Add(this, NotificationType::GOOGLE_URL_UPDATED,
444 NotificationService::AllSources()); 444 NotificationService::AllSources());
445 445
446 // Set-up the showing of the omnibox search infobar if applicable. 446 // Set-up the showing of the omnibox search infobar if applicable.
447 if (OmniboxSearchHint::IsEnabled(profile)) 447 if (OmniboxSearchHint::IsEnabled(profile))
448 omnibox_search_hint_.reset(new OmniboxSearchHint(this)); 448 omnibox_search_hint_.reset(new OmniboxSearchHint(this));
449 449
450 autofill_manager_.reset(new AutoFillManager(this)); 450 autofill_manager_.reset(new AutoFillManager(this));
451 message_filters_.push_back(autofill_manager_.get()); 451 AddNavigationObserver(autofill_manager_.get());
452 autocomplete_history_manager_.reset(new AutocompleteHistoryManager(this)); 452 autocomplete_history_manager_.reset(new AutocompleteHistoryManager(this));
453 message_filters_.push_back(autocomplete_history_manager_.get()); 453 AddNavigationObserver(autocomplete_history_manager_.get());
454 } 454 }
455 455
456 TabContents::~TabContents() { 456 TabContents::~TabContents() {
457 is_being_destroyed_ = true; 457 is_being_destroyed_ = true;
458 458
459 // We don't want any notifications while we're running our destructor. 459 // We don't want any notifications while we're running our destructor.
460 registrar_.RemoveAll(); 460 registrar_.RemoveAll();
461 pref_change_registrar_.RemoveAll(); 461 pref_change_registrar_.RemoveAll();
462 462
463 NotifyDisconnected(); 463 NotifyDisconnected();
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 IDS_MINIMUM_FONT_SIZE); 563 IDS_MINIMUM_FONT_SIZE);
564 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumLogicalFontSize, 564 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumLogicalFontSize,
565 IDS_MINIMUM_LOGICAL_FONT_SIZE); 565 IDS_MINIMUM_LOGICAL_FONT_SIZE);
566 prefs->RegisterLocalizedBooleanPref(prefs::kWebKitUsesUniversalDetector, 566 prefs->RegisterLocalizedBooleanPref(prefs::kWebKitUsesUniversalDetector,
567 IDS_USES_UNIVERSAL_DETECTOR); 567 IDS_USES_UNIVERSAL_DETECTOR);
568 prefs->RegisterLocalizedStringPref(prefs::kStaticEncodings, 568 prefs->RegisterLocalizedStringPref(prefs::kStaticEncodings,
569 IDS_STATIC_ENCODING_LIST); 569 IDS_STATIC_ENCODING_LIST);
570 } 570 }
571 571
572 bool TabContents::OnMessageReceived(const IPC::Message& message) { 572 bool TabContents::OnMessageReceived(const IPC::Message& message) {
573 for (size_t i = 0; i < message_filters_.size(); ++i) { 573 ObserverListBase<WebNavigationObserver>::Iterator it(
574 if (message_filters_[i]->OnMessageReceived(message)) 574 web_navigation_observers_);
575 WebNavigationObserver* observer;
576 while ((observer = it.GetNext()) != NULL)
577 if (observer->OnMessageReceived(message))
575 return true; 578 return true;
576 }
577 579
578 bool handled = true; 580 bool handled = true;
579 bool message_is_ok = true; 581 bool message_is_ok = true;
580 IPC_BEGIN_MESSAGE_MAP_EX(TabContents, message, message_is_ok) 582 IPC_BEGIN_MESSAGE_MAP_EX(TabContents, message, message_is_ok)
581 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartProvisionalLoadForFrame, 583 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartProvisionalLoadForFrame,
582 OnDidStartProvisionalLoadForFrame) 584 OnDidStartProvisionalLoadForFrame)
583 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRedirectProvisionalLoad, 585 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRedirectProvisionalLoad,
584 OnDidRedirectProvisionalLoad) 586 OnDidRedirectProvisionalLoad)
585 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFailProvisionalLoadWithError, 587 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFailProvisionalLoadWithError,
586 OnDidFailProvisionalLoadWithError) 588 OnDidFailProvisionalLoadWithError)
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 if (!delegate_) 1607 if (!delegate_)
1606 return; 1608 return;
1607 1609
1608 NavigationEntry* active_entry = controller().GetActiveEntry(); 1610 NavigationEntry* active_entry = controller().GetActiveEntry();
1609 if (!active_entry) 1611 if (!active_entry)
1610 return; 1612 return;
1611 1613
1612 delegate_->ViewSourceForTab(this, active_entry->url()); 1614 delegate_->ViewSourceForTab(this, active_entry->url());
1613 } 1615 }
1614 1616
1617 void TabContents::TranslateStarted() {
1618 FOR_EACH_OBSERVER(WebNavigationObserver, web_navigation_observers_,
1619 TranslateStarted());
1620 }
1621
1615 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, 1622 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id,
1616 bool is_main_frame, 1623 bool is_main_frame,
1617 const GURL& url) { 1624 const GURL& url) {
1618 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); 1625 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL);
1619 GURL validated_url(url); 1626 GURL validated_url(url);
1620 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), 1627 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(),
1621 GetRenderProcessHost()->id(), &validated_url); 1628 GetRenderProcessHost()->id(), &validated_url);
1622 1629
1623 ProvisionalLoadDetails details( 1630 ProvisionalLoadDetails details(
1624 is_main_frame, 1631 is_main_frame,
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 if (!net::RegistryControlledDomainService::SameDomainOrHost( 1985 if (!net::RegistryControlledDomainService::SameDomainOrHost(
1979 details.previous_url, details.entry->url())) 1986 details.previous_url, details.entry->url()))
1980 CloseConstrainedWindows(); 1987 CloseConstrainedWindows();
1981 1988
1982 // Update the starred state. 1989 // Update the starred state.
1983 UpdateStarredStateForCurrentURL(); 1990 UpdateStarredStateForCurrentURL();
1984 1991
1985 // Notify observers about navigation. 1992 // Notify observers about navigation.
1986 FOR_EACH_OBSERVER(WebNavigationObserver, web_navigation_observers_, 1993 FOR_EACH_OBSERVER(WebNavigationObserver, web_navigation_observers_,
1987 DidNavigateMainFramePostCommit(details, params)); 1994 DidNavigateMainFramePostCommit(details, params));
1988
1989 // Clear the cache of forms in AutoFill.
1990 autofill_manager_->Reset();
1991 } 1995 }
1992 1996
1993 void TabContents::DidNavigateAnyFramePostCommit( 1997 void TabContents::DidNavigateAnyFramePostCommit(
1994 RenderViewHost* render_view_host, 1998 RenderViewHost* render_view_host,
1995 const NavigationController::LoadCommittedDetails& details, 1999 const NavigationController::LoadCommittedDetails& details,
1996 const ViewHostMsg_FrameNavigate_Params& params) { 2000 const ViewHostMsg_FrameNavigate_Params& params) {
1997 // If we navigate, start showing messages again. This does nothing to prevent 2001 // If we navigate, start showing messages again. This does nothing to prevent
1998 // a malicious script from spamming messages, since the script could just 2002 // a malicious script from spamming messages, since the script could just
1999 // reload the page to stop blocking. 2003 // reload the page to stop blocking.
2000 suppress_javascript_messages_ = false; 2004 suppress_javascript_messages_ = false;
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
2919 const std::string& json_arguments, 2923 const std::string& json_arguments,
2920 IPC::Message* reply_msg) { 2924 IPC::Message* reply_msg) {
2921 if (delegate()) { 2925 if (delegate()) {
2922 HtmlDialogUIDelegate* dialog_delegate = 2926 HtmlDialogUIDelegate* dialog_delegate =
2923 new ModalHtmlDialogDelegate(url, width, height, json_arguments, 2927 new ModalHtmlDialogDelegate(url, width, height, json_arguments,
2924 reply_msg, this); 2928 reply_msg, this);
2925 delegate()->ShowHtmlDialog(dialog_delegate, NULL); 2929 delegate()->ShowHtmlDialog(dialog_delegate, NULL);
2926 } 2930 }
2927 } 2931 }
2928 2932
2929 void TabContents::PasswordFormsFound(
2930 const std::vector<webkit_glue::PasswordForm>& forms) {
2931 FOR_EACH_OBSERVER(WebNavigationObserver, web_navigation_observers_,
2932 PasswordFormsFound(forms));
2933 }
2934
2935 void TabContents::PasswordFormsVisible(
2936 const std::vector<webkit_glue::PasswordForm>& visible_forms) {
2937 FOR_EACH_OBSERVER(WebNavigationObserver, web_navigation_observers_,
2938 PasswordFormsVisible(visible_forms));
2939 }
2940
2941 // Checks to see if we should generate a keyword based on the OSDD, and if 2933 // Checks to see if we should generate a keyword based on the OSDD, and if
2942 // necessary uses TemplateURLFetcher to download the OSDD and create a keyword. 2934 // necessary uses TemplateURLFetcher to download the OSDD and create a keyword.
2943 void TabContents::PageHasOSDD( 2935 void TabContents::PageHasOSDD(
2944 RenderViewHost* render_view_host, 2936 RenderViewHost* render_view_host,
2945 int32 page_id, 2937 int32 page_id,
2946 const GURL& url, 2938 const GURL& url,
2947 const ViewHostMsg_PageHasOSDD_Type& msg_provider_type) { 2939 const ViewHostMsg_PageHasOSDD_Type& msg_provider_type) {
2948 // Make sure page_id is the current page and other basic checks. 2940 // Make sure page_id is the current page and other basic checks.
2949 DCHECK(url.is_valid()); 2941 DCHECK(url.is_valid());
2950 if (!IsActiveEntry(page_id)) 2942 if (!IsActiveEntry(page_id))
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
3386 if (pm != NULL) { 3378 if (pm != NULL) {
3387 if (pm->MaybeUsePreloadedPage(this, url)) { 3379 if (pm->MaybeUsePreloadedPage(this, url)) {
3388 // TODO(tburkard): If the preloaded page has not finished preloading 3380 // TODO(tburkard): If the preloaded page has not finished preloading
3389 // yet, we should not do this. 3381 // yet, we should not do this.
3390 DidStopLoading(); 3382 DidStopLoading();
3391 return true; 3383 return true;
3392 } 3384 }
3393 } 3385 }
3394 return false; 3386 return false;
3395 } 3387 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698