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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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/ui/tab_contents/tab_contents_wrapper.h" 5 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "chrome/browser/autocomplete_history_manager.h" 9 #include "chrome/browser/autocomplete_history_manager.h"
10 #include "chrome/browser/autofill/autofill_manager.h" 10 #include "chrome/browser/autofill/autofill_manager.h"
(...skipping 29 matching lines...) Expand all
40 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" 40 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h"
41 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" 41 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h"
42 #include "chrome/browser/tab_contents/thumbnail_generator.h" 42 #include "chrome/browser/tab_contents/thumbnail_generator.h"
43 #include "chrome/browser/translate/translate_tab_helper.h" 43 #include "chrome/browser/translate/translate_tab_helper.h"
44 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" 44 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
45 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" 45 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
46 #include "chrome/browser/ui/download/download_tab_helper.h" 46 #include "chrome/browser/ui/download/download_tab_helper.h"
47 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 47 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
48 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" 48 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h"
49 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" 49 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h"
50 #include "chrome/common/chrome_notification_types.h"
50 #include "chrome/common/chrome_switches.h" 51 #include "chrome/common/chrome_switches.h"
51 #include "chrome/common/pref_names.h" 52 #include "chrome/common/pref_names.h"
52 #include "chrome/common/render_messages.h" 53 #include "chrome/common/render_messages.h"
53 #include "content/browser/child_process_security_policy.h" 54 #include "content/browser/child_process_security_policy.h"
54 #include "content/browser/renderer_host/render_view_host.h" 55 #include "content/browser/renderer_host/render_view_host.h"
55 #include "content/browser/tab_contents/navigation_details.h" 56 #include "content/browser/tab_contents/navigation_details.h"
56 #include "content/browser/tab_contents/tab_contents.h" 57 #include "content/browser/tab_contents/tab_contents.h"
57 #include "content/browser/tab_contents/tab_contents_view.h" 58 #include "content/browser/tab_contents/tab_contents_view.h"
58 #include "content/common/notification_service.h" 59 #include "content/common/notification_service.h"
59 #include "content/common/view_messages.h" 60 #include "content/common/view_messages.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // Start the in-browser thumbnailing if the feature is enabled. 146 // Start the in-browser thumbnailing if the feature is enabled.
146 if (switches::IsInBrowserThumbnailingEnabled()) { 147 if (switches::IsInBrowserThumbnailingEnabled()) {
147 thumbnail_generation_observer_.reset(new ThumbnailGenerator); 148 thumbnail_generation_observer_.reset(new ThumbnailGenerator);
148 thumbnail_generation_observer_->StartThumbnailing(tab_contents_.get()); 149 thumbnail_generation_observer_->StartThumbnailing(tab_contents_.get());
149 } 150 }
150 151
151 // Set-up the showing of the omnibox search infobar if applicable. 152 // Set-up the showing of the omnibox search infobar if applicable.
152 if (OmniboxSearchHint::IsEnabled(contents->profile())) 153 if (OmniboxSearchHint::IsEnabled(contents->profile()))
153 omnibox_search_hint_.reset(new OmniboxSearchHint(this)); 154 omnibox_search_hint_.reset(new OmniboxSearchHint(this));
154 155
155 registrar_.Add(this, NotificationType::GOOGLE_URL_UPDATED, 156 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_URL_UPDATED,
156 NotificationService::AllSources()); 157 NotificationService::AllSources());
157 registrar_.Add(this, NotificationType::USER_STYLE_SHEET_UPDATED, 158 registrar_.Add(this, chrome::NOTIFICATION_USER_STYLE_SHEET_UPDATED,
158 NotificationService::AllSources()); 159 NotificationService::AllSources());
159 #if defined(OS_POSIX) && !defined(OS_MACOSX) 160 #if defined(OS_POSIX) && !defined(OS_MACOSX)
160 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, 161 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
161 NotificationService::AllSources()); 162 NotificationService::AllSources());
162 #endif 163 #endif
163 164
164 // Register for notifications about all interested prefs change. 165 // Register for notifications about all interested prefs change.
165 PrefService* prefs = profile()->GetPrefs(); 166 PrefService* prefs = profile()->GetPrefs();
166 pref_change_registrar_.Init(prefs); 167 pref_change_registrar_.Init(prefs);
167 if (prefs) { 168 if (prefs) {
168 for (int i = 0; i < kPrefsToObserveLength; ++i) 169 for (int i = 0; i < kPrefsToObserveLength; ++i)
169 pref_change_registrar_.Add(kPrefsToObserve[i], this); 170 pref_change_registrar_.Add(kPrefsToObserve[i], this);
170 } 171 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 return handled; 402 return handled;
402 } 403 }
403 404
404 void TabContentsWrapper::TabContentsDestroyed(TabContents* tab) { 405 void TabContentsWrapper::TabContentsDestroyed(TabContents* tab) {
405 // Destruction of the TabContents should only be done by us from our 406 // Destruction of the TabContents should only be done by us from our
406 // destructor. Otherwise it's very likely we (or one of the helpers we own) 407 // destructor. Otherwise it's very likely we (or one of the helpers we own)
407 // will attempt to access the TabContents and we'll crash. 408 // will attempt to access the TabContents and we'll crash.
408 DCHECK(in_destructor_); 409 DCHECK(in_destructor_);
409 } 410 }
410 411
411 void TabContentsWrapper::Observe(NotificationType type, 412 void TabContentsWrapper::Observe(int type,
412 const NotificationSource& source, 413 const NotificationSource& source,
413 const NotificationDetails& details) { 414 const NotificationDetails& details) {
414 switch (type.value) { 415 switch (type) {
415 case NotificationType::NAV_ENTRY_COMMITTED: { 416 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: {
416 DCHECK(&tab_contents_->controller() == 417 DCHECK(&tab_contents_->controller() ==
417 Source<NavigationController>(source).ptr()); 418 Source<NavigationController>(source).ptr());
418 419
419 content::LoadCommittedDetails& committed_details = 420 content::LoadCommittedDetails& committed_details =
420 *(Details<content::LoadCommittedDetails>(details).ptr()); 421 *(Details<content::LoadCommittedDetails>(details).ptr());
421 422
422 // NOTE: It is not safe to change the following code to count upwards or 423 // NOTE: It is not safe to change the following code to count upwards or
423 // use iterators, as the RemoveInfoBar() call synchronously modifies our 424 // use iterators, as the RemoveInfoBar() call synchronously modifies our
424 // delegate list. 425 // delegate list.
425 for (size_t i = infobars_.size(); i > 0; --i) { 426 for (size_t i = infobars_.size(); i > 0; --i) {
426 InfoBarDelegate* delegate = GetInfoBarDelegateAt(i - 1); 427 InfoBarDelegate* delegate = GetInfoBarDelegateAt(i - 1);
427 if (delegate->ShouldExpire(committed_details)) 428 if (delegate->ShouldExpire(committed_details))
428 RemoveInfoBar(delegate); 429 RemoveInfoBar(delegate);
429 } 430 }
430 431
431 break; 432 break;
432 } 433 }
433 case NotificationType::GOOGLE_URL_UPDATED: 434 case chrome::NOTIFICATION_GOOGLE_URL_UPDATED:
434 UpdateAlternateErrorPageURL(render_view_host()); 435 UpdateAlternateErrorPageURL(render_view_host());
435 break; 436 break;
436 case NotificationType::USER_STYLE_SHEET_UPDATED: 437 case chrome::NOTIFICATION_USER_STYLE_SHEET_UPDATED:
437 UpdateWebPreferences(); 438 UpdateWebPreferences();
438 break; 439 break;
439 #if defined(OS_POSIX) && !defined(OS_MACOSX) 440 #if defined(OS_POSIX) && !defined(OS_MACOSX)
440 case NotificationType::BROWSER_THEME_CHANGED: { 441 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: {
441 UpdateRendererPreferences(); 442 UpdateRendererPreferences();
442 break; 443 break;
443 } 444 }
444 #endif 445 #endif
445 case NotificationType::PREF_CHANGED: { 446 case chrome::NOTIFICATION_PREF_CHANGED: {
446 std::string* pref_name_in = Details<std::string>(details).ptr(); 447 std::string* pref_name_in = Details<std::string>(details).ptr();
447 DCHECK(Source<PrefService>(source).ptr() == profile()->GetPrefs()); 448 DCHECK(Source<PrefService>(source).ptr() == profile()->GetPrefs());
448 if (*pref_name_in == prefs::kAlternateErrorPagesEnabled) { 449 if (*pref_name_in == prefs::kAlternateErrorPagesEnabled) {
449 UpdateAlternateErrorPageURL(render_view_host()); 450 UpdateAlternateErrorPageURL(render_view_host());
450 } else if ((*pref_name_in == prefs::kDefaultCharset) || 451 } else if ((*pref_name_in == prefs::kDefaultCharset) ||
451 StartsWithASCII(*pref_name_in, "webkit.webprefs.", true)) { 452 StartsWithASCII(*pref_name_in, "webkit.webprefs.", true)) {
452 UpdateWebPreferences(); 453 UpdateWebPreferences();
453 } else if (*pref_name_in == prefs::kDefaultZoomLevel) { 454 } else if (*pref_name_in == prefs::kDefaultZoomLevel) {
454 Send(new ViewMsg_SetZoomLevel( 455 Send(new ViewMsg_SetZoomLevel(
455 routing_id(), tab_contents()->GetZoomLevel())); 456 routing_id(), tab_contents()->GetZoomLevel()));
(...skipping 17 matching lines...) Expand all
473 474
474 for (size_t i = 0; i < infobars_.size(); ++i) { 475 for (size_t i = 0; i < infobars_.size(); ++i) {
475 if (GetInfoBarDelegateAt(i)->EqualsDelegate(delegate)) { 476 if (GetInfoBarDelegateAt(i)->EqualsDelegate(delegate)) {
476 delegate->InfoBarClosed(); 477 delegate->InfoBarClosed();
477 return; 478 return;
478 } 479 }
479 } 480 }
480 481
481 infobars_.push_back(delegate); 482 infobars_.push_back(delegate);
482 NotificationService::current()->Notify( 483 NotificationService::current()->Notify(
483 NotificationType::TAB_CONTENTS_INFOBAR_ADDED, 484 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
484 Source<TabContentsWrapper>(this), Details<InfoBarAddedDetails>(delegate)); 485 Source<TabContentsWrapper>(this), Details<InfoBarAddedDetails>(delegate));
485 486
486 // Add ourselves as an observer for navigations the first time a delegate is 487 // Add ourselves as an observer for navigations the first time a delegate is
487 // added. We use this notification to expire InfoBars that need to expire on 488 // added. We use this notification to expire InfoBars that need to expire on
488 // page transitions. 489 // page transitions.
489 if (infobars_.size() == 1) { 490 if (infobars_.size() == 1) {
490 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, 491 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
491 Source<NavigationController>(&tab_contents_->controller())); 492 Source<NavigationController>(&tab_contents_->controller()));
492 } 493 }
493 } 494 }
494 495
495 void TabContentsWrapper::RemoveInfoBar(InfoBarDelegate* delegate) { 496 void TabContentsWrapper::RemoveInfoBar(InfoBarDelegate* delegate) {
496 RemoveInfoBarInternal(delegate, true); 497 RemoveInfoBarInternal(delegate, true);
497 } 498 }
498 499
499 void TabContentsWrapper::ReplaceInfoBar(InfoBarDelegate* old_delegate, 500 void TabContentsWrapper::ReplaceInfoBar(InfoBarDelegate* old_delegate,
500 InfoBarDelegate* new_delegate) { 501 InfoBarDelegate* new_delegate) {
501 if (!infobars_enabled_) { 502 if (!infobars_enabled_) {
502 AddInfoBar(new_delegate); // Deletes the delegate. 503 AddInfoBar(new_delegate); // Deletes the delegate.
503 return; 504 return;
504 } 505 }
505 506
506 size_t i; 507 size_t i;
507 for (i = 0; i < infobars_.size(); ++i) { 508 for (i = 0; i < infobars_.size(); ++i) {
508 if (GetInfoBarDelegateAt(i) == old_delegate) 509 if (GetInfoBarDelegateAt(i) == old_delegate)
509 break; 510 break;
510 } 511 }
511 DCHECK_LT(i, infobars_.size()); 512 DCHECK_LT(i, infobars_.size());
512 513
513 infobars_.insert(infobars_.begin() + i, new_delegate); 514 infobars_.insert(infobars_.begin() + i, new_delegate);
514 515
515 InfoBarReplacedDetails replaced_details(old_delegate, new_delegate); 516 InfoBarReplacedDetails replaced_details(old_delegate, new_delegate);
516 NotificationService::current()->Notify( 517 NotificationService::current()->Notify(
517 NotificationType::TAB_CONTENTS_INFOBAR_REPLACED, 518 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED,
518 Source<TabContentsWrapper>(this), 519 Source<TabContentsWrapper>(this),
519 Details<InfoBarReplacedDetails>(&replaced_details)); 520 Details<InfoBarReplacedDetails>(&replaced_details));
520 521
521 infobars_.erase(infobars_.begin() + i + 1); 522 infobars_.erase(infobars_.begin() + i + 1);
522 } 523 }
523 524
524 InfoBarDelegate* TabContentsWrapper::GetInfoBarDelegateAt(size_t index) { 525 InfoBarDelegate* TabContentsWrapper::GetInfoBarDelegateAt(size_t index) {
525 return infobars_[index]; 526 return infobars_[index];
526 } 527 }
527 528
(...skipping 26 matching lines...) Expand all
554 if (!handler.IsEmpty() && 555 if (!handler.IsEmpty() &&
555 registry->CanSchemeBeOverridden(handler.protocol())) { 556 registry->CanSchemeBeOverridden(handler.protocol())) {
556 AddInfoBar(new RegisterProtocolHandlerInfoBarDelegate(tab_contents(), 557 AddInfoBar(new RegisterProtocolHandlerInfoBarDelegate(tab_contents(),
557 registry, 558 registry,
558 handler)); 559 handler));
559 } 560 }
560 } 561 }
561 562
562 void TabContentsWrapper::OnSnapshot(const SkBitmap& bitmap) { 563 void TabContentsWrapper::OnSnapshot(const SkBitmap& bitmap) {
563 NotificationService::current()->Notify( 564 NotificationService::current()->Notify(
564 NotificationType::TAB_SNAPSHOT_TAKEN, 565 chrome::NOTIFICATION_TAB_SNAPSHOT_TAKEN,
565 Source<TabContentsWrapper>(this), 566 Source<TabContentsWrapper>(this),
566 Details<const SkBitmap>(&bitmap)); 567 Details<const SkBitmap>(&bitmap));
567 } 568 }
568 569
569 void TabContentsWrapper::OnPDFHasUnsupportedFeature() { 570 void TabContentsWrapper::OnPDFHasUnsupportedFeature() {
570 PDFHasUnsupportedFeature(this); 571 PDFHasUnsupportedFeature(this);
571 } 572 }
572 573
573 void TabContentsWrapper::OnDidBlockDisplayingInsecureContent() { 574 void TabContentsWrapper::OnDidBlockDisplayingInsecureContent() {
574 // At most one infobar and do not supersede the stronger running content bar. 575 // At most one infobar and do not supersede the stronger running content bar.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 size_t i; 639 size_t i;
639 for (i = 0; i < infobars_.size(); ++i) { 640 for (i = 0; i < infobars_.size(); ++i) {
640 if (GetInfoBarDelegateAt(i) == delegate) 641 if (GetInfoBarDelegateAt(i) == delegate)
641 break; 642 break;
642 } 643 }
643 DCHECK_LT(i, infobars_.size()); 644 DCHECK_LT(i, infobars_.size());
644 InfoBarDelegate* infobar = infobars_[i]; 645 InfoBarDelegate* infobar = infobars_[i];
645 646
646 InfoBarRemovedDetails removed_details(infobar, animate); 647 InfoBarRemovedDetails removed_details(infobar, animate);
647 NotificationService::current()->Notify( 648 NotificationService::current()->Notify(
648 NotificationType::TAB_CONTENTS_INFOBAR_REMOVED, 649 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
649 Source<TabContentsWrapper>(this), 650 Source<TabContentsWrapper>(this),
650 Details<InfoBarRemovedDetails>(&removed_details)); 651 Details<InfoBarRemovedDetails>(&removed_details));
651 652
652 infobars_.erase(infobars_.begin() + i); 653 infobars_.erase(infobars_.begin() + i);
653 // Remove ourselves as an observer if we are tracking no more InfoBars. 654 // Remove ourselves as an observer if we are tracking no more InfoBars.
654 if (infobars_.empty()) { 655 if (infobars_.empty()) {
655 registrar_.Remove(this, NotificationType::NAV_ENTRY_COMMITTED, 656 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
656 Source<NavigationController>(&tab_contents_->controller())); 657 Source<NavigationController>(&tab_contents_->controller()));
657 } 658 }
658 } 659 }
659 660
660 void TabContentsWrapper::RemoveAllInfoBars(bool animate) { 661 void TabContentsWrapper::RemoveAllInfoBars(bool animate) {
661 while (!infobars_.empty()) 662 while (!infobars_.empty())
662 RemoveInfoBarInternal(GetInfoBarDelegateAt(infobar_count() - 1), animate); 663 RemoveInfoBarInternal(GetInfoBarDelegateAt(infobar_count() - 1), animate);
663 } 664 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tab_contents/tab_contents_wrapper.h ('k') | chrome/browser/ui/toolbar/wrench_menu_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698