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

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 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 if (!net::RegistryControlledDomainService::SameDomainOrHost( 1980 if (!net::RegistryControlledDomainService::SameDomainOrHost(
1979 details.previous_url, details.entry->url())) 1981 details.previous_url, details.entry->url()))
1980 CloseConstrainedWindows(); 1982 CloseConstrainedWindows();
1981 1983
1982 // Update the starred state. 1984 // Update the starred state.
1983 UpdateStarredStateForCurrentURL(); 1985 UpdateStarredStateForCurrentURL();
1984 1986
1985 // Notify observers about navigation. 1987 // Notify observers about navigation.
1986 FOR_EACH_OBSERVER(WebNavigationObserver, web_navigation_observers_, 1988 FOR_EACH_OBSERVER(WebNavigationObserver, web_navigation_observers_,
1987 DidNavigateMainFramePostCommit(details, params)); 1989 DidNavigateMainFramePostCommit(details, params));
1988
1989 // Clear the cache of forms in AutoFill.
1990 autofill_manager_->Reset();
1991 } 1990 }
1992 1991
1993 void TabContents::DidNavigateAnyFramePostCommit( 1992 void TabContents::DidNavigateAnyFramePostCommit(
1994 RenderViewHost* render_view_host, 1993 RenderViewHost* render_view_host,
1995 const NavigationController::LoadCommittedDetails& details, 1994 const NavigationController::LoadCommittedDetails& details,
1996 const ViewHostMsg_FrameNavigate_Params& params) { 1995 const ViewHostMsg_FrameNavigate_Params& params) {
1997 // If we navigate, start showing messages again. This does nothing to prevent 1996 // If we navigate, start showing messages again. This does nothing to prevent
1998 // a malicious script from spamming messages, since the script could just 1997 // a malicious script from spamming messages, since the script could just
1999 // reload the page to stop blocking. 1998 // reload the page to stop blocking.
2000 suppress_javascript_messages_ = false; 1999 suppress_javascript_messages_ = false;
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
2919 const std::string& json_arguments, 2918 const std::string& json_arguments,
2920 IPC::Message* reply_msg) { 2919 IPC::Message* reply_msg) {
2921 if (delegate()) { 2920 if (delegate()) {
2922 HtmlDialogUIDelegate* dialog_delegate = 2921 HtmlDialogUIDelegate* dialog_delegate =
2923 new ModalHtmlDialogDelegate(url, width, height, json_arguments, 2922 new ModalHtmlDialogDelegate(url, width, height, json_arguments,
2924 reply_msg, this); 2923 reply_msg, this);
2925 delegate()->ShowHtmlDialog(dialog_delegate, NULL); 2924 delegate()->ShowHtmlDialog(dialog_delegate, NULL);
2926 } 2925 }
2927 } 2926 }
2928 2927
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 2928 // 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. 2929 // necessary uses TemplateURLFetcher to download the OSDD and create a keyword.
2943 void TabContents::PageHasOSDD( 2930 void TabContents::PageHasOSDD(
2944 RenderViewHost* render_view_host, 2931 RenderViewHost* render_view_host,
2945 int32 page_id, 2932 int32 page_id,
2946 const GURL& url, 2933 const GURL& url,
2947 const ViewHostMsg_PageHasOSDD_Type& msg_provider_type) { 2934 const ViewHostMsg_PageHasOSDD_Type& msg_provider_type) {
2948 // Make sure page_id is the current page and other basic checks. 2935 // Make sure page_id is the current page and other basic checks.
2949 DCHECK(url.is_valid()); 2936 DCHECK(url.is_valid());
2950 if (!IsActiveEntry(page_id)) 2937 if (!IsActiveEntry(page_id))
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
3386 if (pm != NULL) { 3373 if (pm != NULL) {
3387 if (pm->MaybeUsePreloadedPage(this, url)) { 3374 if (pm->MaybeUsePreloadedPage(this, url)) {
3388 // TODO(tburkard): If the preloaded page has not finished preloading 3375 // TODO(tburkard): If the preloaded page has not finished preloading
3389 // yet, we should not do this. 3376 // yet, we should not do this.
3390 DidStopLoading(); 3377 DidStopLoading();
3391 return true; 3378 return true;
3392 } 3379 }
3393 } 3380 }
3394 return false; 3381 return false;
3395 } 3382 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.h ('k') | chrome/browser/tab_contents/web_navigation_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698