OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #endif // OS_WIN | 10 #endif // OS_WIN |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 96 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
97 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 97 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
98 #include "chrome/browser/ui/browser_command_controller.h" | 98 #include "chrome/browser/ui/browser_command_controller.h" |
99 #include "chrome/browser/ui/browser_commands.h" | 99 #include "chrome/browser/ui/browser_commands.h" |
100 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" | 100 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" |
101 #include "chrome/browser/ui/browser_dialogs.h" | 101 #include "chrome/browser/ui/browser_dialogs.h" |
102 #include "chrome/browser/ui/browser_finder.h" | 102 #include "chrome/browser/ui/browser_finder.h" |
103 #include "chrome/browser/ui/browser_list.h" | 103 #include "chrome/browser/ui/browser_list.h" |
104 #include "chrome/browser/ui/browser_navigator.h" | 104 #include "chrome/browser/ui/browser_navigator.h" |
105 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" | 105 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" |
| 106 #include "chrome/browser/ui/browser_tabstrip.h" |
106 #include "chrome/browser/ui/browser_toolbar_model_delegate.h" | 107 #include "chrome/browser/ui/browser_toolbar_model_delegate.h" |
107 #include "chrome/browser/ui/browser_ui_prefs.h" | 108 #include "chrome/browser/ui/browser_ui_prefs.h" |
108 #include "chrome/browser/ui/browser_window.h" | 109 #include "chrome/browser/ui/browser_window.h" |
109 #include "chrome/browser/ui/chrome_pages.h" | 110 #include "chrome/browser/ui/chrome_pages.h" |
110 #include "chrome/browser/ui/constrained_window_tab_helper.h" | 111 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
111 #include "chrome/browser/ui/extensions/shell_window.h" | 112 #include "chrome/browser/ui/extensions/shell_window.h" |
112 #include "chrome/browser/ui/find_bar/find_bar.h" | 113 #include "chrome/browser/ui/find_bar/find_bar.h" |
113 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 114 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
114 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 115 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
115 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 116 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 } | 498 } |
498 | 499 |
499 /////////////////////////////////////////////////////////////////////////////// | 500 /////////////////////////////////////////////////////////////////////////////// |
500 // Getters & Setters | 501 // Getters & Setters |
501 | 502 |
502 FindBarController* Browser::GetFindBarController() { | 503 FindBarController* Browser::GetFindBarController() { |
503 if (!find_bar_controller_.get()) { | 504 if (!find_bar_controller_.get()) { |
504 FindBar* find_bar = window_->CreateFindBar(); | 505 FindBar* find_bar = window_->CreateFindBar(); |
505 find_bar_controller_.reset(new FindBarController(find_bar)); | 506 find_bar_controller_.reset(new FindBarController(find_bar)); |
506 find_bar->SetFindBarController(find_bar_controller_.get()); | 507 find_bar->SetFindBarController(find_bar_controller_.get()); |
507 find_bar_controller_->ChangeTabContents(GetActiveTabContents()); | 508 find_bar_controller_->ChangeTabContents(chrome::GetActiveTabContents(this)); |
508 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true); | 509 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true); |
509 } | 510 } |
510 return find_bar_controller_.get(); | 511 return find_bar_controller_.get(); |
511 } | 512 } |
512 | 513 |
513 bool Browser::HasFindBarController() const { | 514 bool Browser::HasFindBarController() const { |
514 return find_bar_controller_.get() != NULL; | 515 return find_bar_controller_.get() != NULL; |
515 } | 516 } |
516 | 517 |
517 bool Browser::is_app() const { | 518 bool Browser::is_app() const { |
518 return !app_name_.empty(); | 519 return !app_name_.empty(); |
519 } | 520 } |
520 | 521 |
521 bool Browser::is_devtools() const { | 522 bool Browser::is_devtools() const { |
522 return app_name_ == DevToolsWindow::kDevToolsApp; | 523 return app_name_ == DevToolsWindow::kDevToolsApp; |
523 } | 524 } |
524 | 525 |
525 /////////////////////////////////////////////////////////////////////////////// | 526 /////////////////////////////////////////////////////////////////////////////// |
526 // Browser, State Storage and Retrieval for UI: | 527 // Browser, State Storage and Retrieval for UI: |
527 | 528 |
528 SkBitmap Browser::GetCurrentPageIcon() const { | 529 SkBitmap Browser::GetCurrentPageIcon() const { |
529 TabContents* contents = GetActiveTabContents(); | 530 TabContents* contents = chrome::GetActiveTabContents(this); |
530 // |contents| can be NULL since GetCurrentPageIcon() is called by the window | 531 // |contents| can be NULL since GetCurrentPageIcon() is called by the window |
531 // during the window's creation (before tabs have been added). | 532 // during the window's creation (before tabs have been added). |
532 return contents ? contents->favicon_tab_helper()->GetFavicon() : SkBitmap(); | 533 return contents ? contents->favicon_tab_helper()->GetFavicon() : SkBitmap(); |
533 } | 534 } |
534 | 535 |
535 string16 Browser::GetWindowTitleForCurrentTab() const { | 536 string16 Browser::GetWindowTitleForCurrentTab() const { |
536 WebContents* contents = GetActiveWebContents(); | 537 WebContents* contents = chrome::GetActiveWebContents(this); |
537 string16 title; | 538 string16 title; |
538 | 539 |
539 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the | 540 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the |
540 // window during the window's creation (before tabs have been added). | 541 // window during the window's creation (before tabs have been added). |
541 if (contents) { | 542 if (contents) { |
542 title = contents->GetTitle(); | 543 title = contents->GetTitle(); |
543 FormatTitleForDisplay(&title); | 544 FormatTitleForDisplay(&title); |
544 } | 545 } |
545 if (title.empty()) | 546 if (title.empty()) |
546 title = CoreTabHelper::GetDefaultTitle(); | 547 title = CoreTabHelper::GetDefaultTitle(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 | 623 |
623 if (tab_restore_service && is_type_tabbed() && tab_count()) | 624 if (tab_restore_service && is_type_tabbed() && tab_count()) |
624 tab_restore_service->BrowserClosing(tab_restore_service_delegate()); | 625 tab_restore_service->BrowserClosing(tab_restore_service_delegate()); |
625 | 626 |
626 // TODO(sky): convert session/tab restore to use notification. | 627 // TODO(sky): convert session/tab restore to use notification. |
627 content::NotificationService::current()->Notify( | 628 content::NotificationService::current()->Notify( |
628 chrome::NOTIFICATION_BROWSER_CLOSING, | 629 chrome::NOTIFICATION_BROWSER_CLOSING, |
629 content::Source<Browser>(this), | 630 content::Source<Browser>(this), |
630 content::Details<bool>(&exiting)); | 631 content::Details<bool>(&exiting)); |
631 | 632 |
632 CloseAllTabs(); | 633 chrome::CloseAllTabs(this); |
633 } | 634 } |
634 | 635 |
635 void Browser::OnWindowActivated() { | 636 void Browser::OnWindowActivated() { |
636 // On some platforms we want to automatically reload tabs that are | 637 // On some platforms we want to automatically reload tabs that are |
637 // killed when the user selects them. | 638 // killed when the user selects them. |
638 WebContents* contents = GetActiveWebContents(); | 639 WebContents* contents = chrome::GetActiveWebContents(this); |
639 if (contents && contents->GetCrashedStatus() == | 640 if (contents && contents->GetCrashedStatus() == |
640 base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { | 641 base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { |
641 if (CommandLine::ForCurrentProcess()->HasSwitch( | 642 if (CommandLine::ForCurrentProcess()->HasSwitch( |
642 switches::kReloadKilledTabs)) { | 643 switches::kReloadKilledTabs)) { |
643 chrome::Reload(this, CURRENT_TAB); | 644 chrome::Reload(this, CURRENT_TAB); |
644 } | 645 } |
645 } | 646 } |
646 } | 647 } |
647 | 648 |
648 //////////////////////////////////////////////////////////////////////////////// | 649 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 // Browser, TabStripModel pass-thrus: | 727 // Browser, TabStripModel pass-thrus: |
727 | 728 |
728 int Browser::tab_count() const { | 729 int Browser::tab_count() const { |
729 return tab_strip_model_->count(); | 730 return tab_strip_model_->count(); |
730 } | 731 } |
731 | 732 |
732 int Browser::active_index() const { | 733 int Browser::active_index() const { |
733 return tab_strip_model_->active_index(); | 734 return tab_strip_model_->active_index(); |
734 } | 735 } |
735 | 736 |
736 int Browser::GetIndexOfController( | |
737 const NavigationController* controller) const { | |
738 return tab_strip_model_->GetIndexOfController(controller); | |
739 } | |
740 | |
741 TabContents* Browser::GetActiveTabContents() const { | |
742 return tab_strip_model_->GetActiveTabContents(); | |
743 } | |
744 | |
745 WebContents* Browser::GetActiveWebContents() const { | |
746 TabContents* tab_contents = GetActiveTabContents(); | |
747 return tab_contents ? tab_contents->web_contents() : NULL; | |
748 } | |
749 | |
750 TabContents* Browser::GetTabContentsAt(int index) const { | |
751 return tab_strip_model_->GetTabContentsAt(index); | |
752 } | |
753 | |
754 WebContents* Browser::GetWebContentsAt(int index) const { | |
755 TabContents* tab_contents = GetTabContentsAt(index); | |
756 if (tab_contents) | |
757 return tab_contents->web_contents(); | |
758 return NULL; | |
759 } | |
760 | |
761 void Browser::ActivateTabAt(int index, bool user_gesture) { | |
762 tab_strip_model_->ActivateTabAt(index, user_gesture); | |
763 } | |
764 | |
765 bool Browser::IsTabPinned(int index) const { | |
766 return tab_strip_model_->IsTabPinned(index); | |
767 } | |
768 | |
769 bool Browser::IsTabDiscarded(int index) const { | |
770 return tab_strip_model_->IsTabDiscarded(index); | |
771 } | |
772 | |
773 void Browser::CloseAllTabs() { | |
774 tab_strip_model_->CloseAllTabs(); | |
775 } | |
776 | |
777 //////////////////////////////////////////////////////////////////////////////// | 737 //////////////////////////////////////////////////////////////////////////////// |
778 // Browser, Tab adding/showing functions: | 738 // Browser, Tab adding/showing functions: |
779 | 739 |
780 bool Browser::IsTabStripEditable() const { | |
781 return window()->IsTabStripEditable(); | |
782 } | |
783 | |
784 int Browser::GetIndexForInsertionDuringRestore(int relative_index) { | |
785 return (tab_strip_model_->insertion_policy() == TabStripModel::INSERT_AFTER) ? | |
786 tab_count() : relative_index; | |
787 } | |
788 | |
789 TabContents* Browser::AddSelectedTabWithURL( | |
790 const GURL& url, | |
791 content::PageTransition transition) { | |
792 browser::NavigateParams params(this, url, transition); | |
793 params.disposition = NEW_FOREGROUND_TAB; | |
794 browser::Navigate(¶ms); | |
795 return params.target_contents; | |
796 } | |
797 | |
798 WebContents* Browser::AddTab(TabContents* tab_contents, | |
799 content::PageTransition type) { | |
800 tab_strip_model_->AddTabContents(tab_contents, -1, type, | |
801 TabStripModel::ADD_ACTIVE); | |
802 return tab_contents->web_contents(); | |
803 } | |
804 | |
805 WebContents* Browser::AddRestoredTab( | |
806 const std::vector<TabNavigation>& navigations, | |
807 int tab_index, | |
808 int selected_navigation, | |
809 const std::string& extension_app_id, | |
810 bool select, | |
811 bool pin, | |
812 bool from_last_session, | |
813 content::SessionStorageNamespace* session_storage_namespace) { | |
814 GURL restore_url = navigations.at(selected_navigation).virtual_url(); | |
815 TabContents* tab_contents = TabContentsFactory( | |
816 profile(), | |
817 tab_util::GetSiteInstanceForNewTab(profile_, restore_url), | |
818 MSG_ROUTING_NONE, | |
819 GetActiveWebContents(), | |
820 session_storage_namespace); | |
821 WebContents* new_tab = tab_contents->web_contents(); | |
822 tab_contents->extension_tab_helper()->SetExtensionAppById(extension_app_id); | |
823 std::vector<NavigationEntry*> entries; | |
824 TabNavigation::CreateNavigationEntriesFromTabNavigations( | |
825 profile_, navigations, &entries); | |
826 new_tab->GetController().Restore( | |
827 selected_navigation, from_last_session, &entries); | |
828 DCHECK_EQ(0u, entries.size()); | |
829 | |
830 int add_types = select ? TabStripModel::ADD_ACTIVE : | |
831 TabStripModel::ADD_NONE; | |
832 if (pin) { | |
833 int first_mini_tab_idx = tab_strip_model_->IndexOfFirstNonMiniTab(); | |
834 tab_index = std::min(tab_index, first_mini_tab_idx); | |
835 add_types |= TabStripModel::ADD_PINNED; | |
836 } | |
837 tab_strip_model_->InsertTabContentsAt(tab_index, tab_contents, add_types); | |
838 if (select) { | |
839 window_->Activate(); | |
840 } else { | |
841 // We set the size of the view here, before WebKit does its initial | |
842 // layout. If we don't, the initial layout of background tabs will be | |
843 // performed with a view width of 0, which may cause script outputs and | |
844 // anchor link location calculations to be incorrect even after a new | |
845 // layout with proper view dimensions. TabStripModel::AddTabContents() | |
846 // contains similar logic. | |
847 new_tab->GetView()->SizeContents(window_->GetRestoredBounds().size()); | |
848 new_tab->WasHidden(); | |
849 } | |
850 SessionService* session_service = | |
851 SessionServiceFactory::GetForProfileIfExisting(profile_); | |
852 if (session_service) | |
853 session_service->TabRestored(tab_contents, pin); | |
854 return new_tab; | |
855 } | |
856 | |
857 void Browser::AddWebContents(WebContents* new_contents, | |
858 WindowOpenDisposition disposition, | |
859 const gfx::Rect& initial_pos, | |
860 bool user_gesture) { | |
861 AddNewContents(NULL, new_contents, disposition, initial_pos, user_gesture); | |
862 } | |
863 | |
864 void Browser::CloseTabContents(WebContents* contents) { | |
865 CloseContents(contents); | |
866 } | |
867 | |
868 void Browser::ReplaceRestoredTab( | |
869 const std::vector<TabNavigation>& navigations, | |
870 int selected_navigation, | |
871 bool from_last_session, | |
872 const std::string& extension_app_id, | |
873 content::SessionStorageNamespace* session_storage_namespace) { | |
874 GURL restore_url = navigations.at(selected_navigation).virtual_url(); | |
875 TabContents* tab_contents = TabContentsFactory( | |
876 profile(), | |
877 tab_util::GetSiteInstanceForNewTab(profile_, restore_url), | |
878 MSG_ROUTING_NONE, | |
879 GetActiveWebContents(), | |
880 session_storage_namespace); | |
881 tab_contents->extension_tab_helper()->SetExtensionAppById(extension_app_id); | |
882 WebContents* replacement = tab_contents->web_contents(); | |
883 std::vector<NavigationEntry*> entries; | |
884 TabNavigation::CreateNavigationEntriesFromTabNavigations( | |
885 profile_, navigations, &entries); | |
886 replacement->GetController().Restore( | |
887 selected_navigation, from_last_session, &entries); | |
888 DCHECK_EQ(0u, entries.size()); | |
889 | |
890 tab_strip_model_->ReplaceNavigationControllerAt(active_index(), tab_contents); | |
891 } | |
892 | |
893 void Browser::WindowFullscreenStateChanged() { | 740 void Browser::WindowFullscreenStateChanged() { |
894 fullscreen_controller_->WindowFullscreenStateChanged(); | 741 fullscreen_controller_->WindowFullscreenStateChanged(); |
895 command_controller_->FullscreenStateChanged(); | 742 command_controller_->FullscreenStateChanged(); |
896 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN); | 743 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN); |
897 } | 744 } |
898 | 745 |
899 /////////////////////////////////////////////////////////////////////////////// | 746 /////////////////////////////////////////////////////////////////////////////// |
900 // Browser, Assorted browser commands: | 747 // Browser, Assorted browser commands: |
901 | 748 |
902 void Browser::ToggleFullscreenMode() { | 749 void Browser::ToggleFullscreenMode() { |
(...skipping 19 matching lines...) Expand all Loading... |
922 } | 769 } |
923 | 770 |
924 void Browser::ToggleEncodingAutoDetect() { | 771 void Browser::ToggleEncodingAutoDetect() { |
925 content::RecordAction(UserMetricsAction("AutoDetectChange")); | 772 content::RecordAction(UserMetricsAction("AutoDetectChange")); |
926 encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue()); | 773 encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue()); |
927 // If "auto detect" is turned on, then any current override encoding | 774 // If "auto detect" is turned on, then any current override encoding |
928 // is cleared. This also implicitly performs a reload. | 775 // is cleared. This also implicitly performs a reload. |
929 // OTOH, if "auto detect" is turned off, we don't change the currently | 776 // OTOH, if "auto detect" is turned off, we don't change the currently |
930 // active encoding. | 777 // active encoding. |
931 if (encoding_auto_detect_.GetValue()) { | 778 if (encoding_auto_detect_.GetValue()) { |
932 WebContents* contents = GetActiveWebContents(); | 779 WebContents* contents = chrome::GetActiveWebContents(this); |
933 if (contents) | 780 if (contents) |
934 contents->ResetOverrideEncoding(); | 781 contents->ResetOverrideEncoding(); |
935 } | 782 } |
936 } | 783 } |
937 | 784 |
938 void Browser::OverrideEncoding(int encoding_id) { | 785 void Browser::OverrideEncoding(int encoding_id) { |
939 content::RecordAction(UserMetricsAction("OverrideEncoding")); | 786 content::RecordAction(UserMetricsAction("OverrideEncoding")); |
940 const std::string selected_encoding = | 787 const std::string selected_encoding = |
941 CharacterEncoding::GetCanonicalEncodingNameByCommandId(encoding_id); | 788 CharacterEncoding::GetCanonicalEncodingNameByCommandId(encoding_id); |
942 WebContents* contents = GetActiveWebContents(); | 789 WebContents* contents = chrome::GetActiveWebContents(this); |
943 if (!selected_encoding.empty() && contents) | 790 if (!selected_encoding.empty() && contents) |
944 contents->SetOverrideEncoding(selected_encoding); | 791 contents->SetOverrideEncoding(selected_encoding); |
945 // Update the list of recently selected encodings. | 792 // Update the list of recently selected encodings. |
946 std::string new_selected_encoding_list; | 793 std::string new_selected_encoding_list; |
947 if (CharacterEncoding::UpdateRecentlySelectedEncoding( | 794 if (CharacterEncoding::UpdateRecentlySelectedEncoding( |
948 profile_->GetPrefs()->GetString(prefs::kRecentlySelectedEncoding), | 795 profile_->GetPrefs()->GetString(prefs::kRecentlySelectedEncoding), |
949 encoding_id, | 796 encoding_id, |
950 &new_selected_encoding_list)) { | 797 &new_selected_encoding_list)) { |
951 profile_->GetPrefs()->SetString(prefs::kRecentlySelectedEncoding, | 798 profile_->GetPrefs()->SetString(prefs::kRecentlySelectedEncoding, |
952 new_selected_encoding_list); | 799 new_selected_encoding_list); |
953 } | 800 } |
954 } | 801 } |
955 | 802 |
956 void Browser::OpenFile() { | 803 void Browser::OpenFile() { |
957 content::RecordAction(UserMetricsAction("OpenFile")); | 804 content::RecordAction(UserMetricsAction("OpenFile")); |
958 if (!select_file_dialog_.get()) | 805 if (!select_file_dialog_.get()) |
959 select_file_dialog_ = SelectFileDialog::Create(this); | 806 select_file_dialog_ = SelectFileDialog::Create(this); |
960 | 807 |
961 const FilePath directory = profile_->last_selected_directory(); | 808 const FilePath directory = profile_->last_selected_directory(); |
962 | 809 |
963 // TODO(beng): figure out how to juggle this. | 810 // TODO(beng): figure out how to juggle this. |
964 gfx::NativeWindow parent_window = window_->GetNativeWindow(); | 811 gfx::NativeWindow parent_window = window_->GetNativeWindow(); |
965 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_OPEN_FILE, | 812 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_OPEN_FILE, |
966 string16(), directory, | 813 string16(), directory, |
967 NULL, 0, FILE_PATH_LITERAL(""), | 814 NULL, 0, FILE_PATH_LITERAL(""), |
968 GetActiveWebContents(), | 815 chrome::GetActiveWebContents(this), |
969 parent_window, NULL); | 816 parent_window, NULL); |
970 } | 817 } |
971 | 818 |
972 void Browser::OpenCreateShortcutsDialog() { | 819 void Browser::OpenCreateShortcutsDialog() { |
973 content::RecordAction(UserMetricsAction("CreateShortcut")); | 820 content::RecordAction(UserMetricsAction("CreateShortcut")); |
974 #if !defined(OS_MACOSX) | 821 #if !defined(OS_MACOSX) |
975 TabContents* current_tab = GetActiveTabContents(); | 822 TabContents* current_tab = chrome::GetActiveTabContents(this); |
976 DCHECK(current_tab && | 823 DCHECK(current_tab && |
977 web_app::IsValidUrl(current_tab->web_contents()->GetURL())) << | 824 web_app::IsValidUrl(current_tab->web_contents()->GetURL())) << |
978 "Menu item should be disabled."; | 825 "Menu item should be disabled."; |
979 | 826 |
980 NavigationEntry* entry = | 827 NavigationEntry* entry = |
981 current_tab->web_contents()->GetController().GetLastCommittedEntry(); | 828 current_tab->web_contents()->GetController().GetLastCommittedEntry(); |
982 if (!entry) | 829 if (!entry) |
983 return; | 830 return; |
984 | 831 |
985 // RVH's GetApplicationInfo should not be called before it returns. | 832 // RVH's GetApplicationInfo should not be called before it returns. |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 selection_rect, | 979 selection_rect, |
1133 active_match_ordinal, | 980 active_match_ordinal, |
1134 final_update); | 981 final_update); |
1135 } | 982 } |
1136 | 983 |
1137 void Browser::UpdateUIForNavigationInTab(TabContents* contents, | 984 void Browser::UpdateUIForNavigationInTab(TabContents* contents, |
1138 content::PageTransition transition, | 985 content::PageTransition transition, |
1139 bool user_initiated) { | 986 bool user_initiated) { |
1140 tab_strip_model_->TabNavigating(contents, transition); | 987 tab_strip_model_->TabNavigating(contents, transition); |
1141 | 988 |
1142 bool contents_is_selected = contents == GetActiveTabContents(); | 989 bool contents_is_selected = contents == chrome::GetActiveTabContents(this); |
1143 if (user_initiated && contents_is_selected && window()->GetLocationBar()) { | 990 if (user_initiated && contents_is_selected && window()->GetLocationBar()) { |
1144 // Forcibly reset the location bar if the url is going to change in the | 991 // Forcibly reset the location bar if the url is going to change in the |
1145 // current tab, since otherwise it won't discard any ongoing user edits, | 992 // current tab, since otherwise it won't discard any ongoing user edits, |
1146 // since it doesn't realize this is a user-initiated action. | 993 // since it doesn't realize this is a user-initiated action. |
1147 window()->GetLocationBar()->Revert(); | 994 window()->GetLocationBar()->Revert(); |
1148 } | 995 } |
1149 | 996 |
1150 if (GetStatusBubble()) | 997 if (GetStatusBubble()) |
1151 GetStatusBubble()->Hide(); | 998 GetStatusBubble()->Hide(); |
1152 | 999 |
1153 // Update the location bar. This is synchronous. We specifically don't | 1000 // Update the location bar. This is synchronous. We specifically don't |
1154 // update the load state since the load hasn't started yet and updating it | 1001 // update the load state since the load hasn't started yet and updating it |
1155 // will put it out of sync with the actual state like whether we're | 1002 // will put it out of sync with the actual state like whether we're |
1156 // displaying a favicon, which controls the throbber. If we updated it here, | 1003 // displaying a favicon, which controls the throbber. If we updated it here, |
1157 // the throbber will show the default favicon for a split second when | 1004 // the throbber will show the default favicon for a split second when |
1158 // navigating away from the new tab page. | 1005 // navigating away from the new tab page. |
1159 ScheduleUIUpdate(contents->web_contents(), content::INVALIDATE_TYPE_URL); | 1006 ScheduleUIUpdate(contents->web_contents(), content::INVALIDATE_TYPE_URL); |
1160 | 1007 |
1161 if (contents_is_selected) | 1008 if (contents_is_selected) |
1162 contents->web_contents()->Focus(); | 1009 contents->web_contents()->Focus(); |
1163 } | 1010 } |
1164 | 1011 |
1165 /////////////////////////////////////////////////////////////////////////////// | 1012 /////////////////////////////////////////////////////////////////////////////// |
1166 // Browser, PageNavigator implementation: | 1013 // Browser, PageNavigator implementation: |
1167 | 1014 |
1168 WebContents* Browser::OpenURL(const OpenURLParams& params) { | 1015 WebContents* Browser::OpenURL(const OpenURLParams& params) { |
1169 return OpenURLFromTab(NULL, params); | 1016 return OpenURLFromTab(NULL, params); |
1170 } | 1017 } |
1171 | 1018 |
1172 // Centralized method for creating a TabContents, configuring and | |
1173 // installing all its supporting objects and observers. | |
1174 TabContents* Browser::TabContentsFactory( | |
1175 Profile* profile, | |
1176 SiteInstance* site_instance, | |
1177 int routing_id, | |
1178 const WebContents* base_web_contents, | |
1179 content::SessionStorageNamespace* session_storage_namespace) { | |
1180 WebContents* new_contents = WebContents::Create( | |
1181 profile, site_instance, routing_id, base_web_contents, | |
1182 session_storage_namespace); | |
1183 TabContents* tab_contents = new TabContents(new_contents); | |
1184 return tab_contents; | |
1185 } | |
1186 | |
1187 /////////////////////////////////////////////////////////////////////////////// | 1019 /////////////////////////////////////////////////////////////////////////////// |
1188 // Browser, TabStripModelDelegate implementation: | 1020 // Browser, TabStripModelDelegate implementation: |
1189 | 1021 |
1190 TabContents* Browser::AddBlankTab(bool foreground) { | 1022 TabContents* Browser::AddBlankTab(bool foreground) { |
1191 return AddBlankTabAt(-1, foreground); | 1023 return AddBlankTabAt(-1, foreground); |
1192 } | 1024 } |
1193 | 1025 |
1194 TabContents* Browser::AddBlankTabAt(int index, bool foreground) { | 1026 TabContents* Browser::AddBlankTabAt(int index, bool foreground) { |
1195 // Time new tab page creation time. We keep track of the timing data in | 1027 // Time new tab page creation time. We keep track of the timing data in |
1196 // WebContents, but we want to include the time it takes to create the | 1028 // WebContents, but we want to include the time it takes to create the |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 | 1064 |
1233 int Browser::GetDragActions() const { | 1065 int Browser::GetDragActions() const { |
1234 return TabStripModelDelegate::TAB_TEAROFF_ACTION | (tab_count() > 1 ? | 1066 return TabStripModelDelegate::TAB_TEAROFF_ACTION | (tab_count() > 1 ? |
1235 TabStripModelDelegate::TAB_MOVE_ACTION : 0); | 1067 TabStripModelDelegate::TAB_MOVE_ACTION : 0); |
1236 } | 1068 } |
1237 | 1069 |
1238 TabContents* Browser::CreateTabContentsForURL( | 1070 TabContents* Browser::CreateTabContentsForURL( |
1239 const GURL& url, const content::Referrer& referrer, Profile* profile, | 1071 const GURL& url, const content::Referrer& referrer, Profile* profile, |
1240 content::PageTransition transition, bool defer_load, | 1072 content::PageTransition transition, bool defer_load, |
1241 SiteInstance* instance) const { | 1073 SiteInstance* instance) const { |
1242 TabContents* contents = TabContentsFactory(profile, instance, | 1074 TabContents* contents = chrome::TabContentsFactory(profile, instance, |
1243 MSG_ROUTING_NONE, GetActiveWebContents(), NULL); | 1075 MSG_ROUTING_NONE, chrome::GetActiveWebContents(this), NULL); |
1244 if (!defer_load) { | 1076 if (!defer_load) { |
1245 // Load the initial URL before adding the new tab contents to the tab strip | 1077 // Load the initial URL before adding the new tab contents to the tab strip |
1246 // so that the tab contents has navigation state. | 1078 // so that the tab contents has navigation state. |
1247 contents->web_contents()->GetController().LoadURL( | 1079 contents->web_contents()->GetController().LoadURL( |
1248 url, referrer, transition, std::string()); | 1080 url, referrer, transition, std::string()); |
1249 } | 1081 } |
1250 | 1082 |
1251 return contents; | 1083 return contents; |
1252 } | 1084 } |
1253 | 1085 |
1254 bool Browser::CanDuplicateContentsAt(int index) { | 1086 bool Browser::CanDuplicateContentsAt(int index) { |
1255 NavigationController& nc = GetWebContentsAt(index)->GetController(); | 1087 NavigationController& nc = |
| 1088 chrome::GetWebContentsAt(this, index)->GetController(); |
1256 return nc.GetWebContents() && nc.GetLastCommittedEntry(); | 1089 return nc.GetWebContents() && nc.GetLastCommittedEntry(); |
1257 } | 1090 } |
1258 | 1091 |
1259 void Browser::DuplicateContentsAt(int index) { | 1092 void Browser::DuplicateContentsAt(int index) { |
1260 TabContents* contents = GetTabContentsAt(index); | 1093 TabContents* contents = chrome::GetTabContentsAt(this, index); |
1261 CHECK(contents); | 1094 CHECK(contents); |
1262 TabContents* contents_dupe = contents->Clone(); | 1095 TabContents* contents_dupe = contents->Clone(); |
1263 | 1096 |
1264 bool pinned = false; | 1097 bool pinned = false; |
1265 if (CanSupportWindowFeature(FEATURE_TABSTRIP)) { | 1098 if (CanSupportWindowFeature(FEATURE_TABSTRIP)) { |
1266 // If this is a tabbed browser, just create a duplicate tab inside the same | 1099 // If this is a tabbed browser, just create a duplicate tab inside the same |
1267 // window next to the tab being duplicated. | 1100 // window next to the tab being duplicated. |
1268 int index = tab_strip_model_->GetIndexOfTabContents(contents); | 1101 int index = tab_strip_model_->GetIndexOfTabContents(contents); |
1269 pinned = IsTabPinned(index); | 1102 pinned = tab_strip_model_->IsTabPinned(index); |
1270 int add_types = TabStripModel::ADD_ACTIVE | | 1103 int add_types = TabStripModel::ADD_ACTIVE | |
1271 TabStripModel::ADD_INHERIT_GROUP | | 1104 TabStripModel::ADD_INHERIT_GROUP | |
1272 (pinned ? TabStripModel::ADD_PINNED : 0); | 1105 (pinned ? TabStripModel::ADD_PINNED : 0); |
1273 tab_strip_model_->InsertTabContentsAt(index + 1, contents_dupe, add_types); | 1106 tab_strip_model_->InsertTabContentsAt(index + 1, contents_dupe, add_types); |
1274 } else { | 1107 } else { |
1275 Browser* browser = NULL; | 1108 Browser* browser = NULL; |
1276 if (is_app()) { | 1109 if (is_app()) { |
1277 CHECK(!is_type_popup()); | 1110 CHECK(!is_type_popup()); |
1278 CHECK(!is_type_panel()); | 1111 CHECK(!is_type_panel()); |
1279 browser = Browser::CreateWithParams( | 1112 browser = Browser::CreateWithParams( |
1280 Browser::CreateParams::CreateForApp( | 1113 Browser::CreateParams::CreateForApp( |
1281 TYPE_POPUP, app_name_, gfx::Rect(),profile_)); | 1114 TYPE_POPUP, app_name_, gfx::Rect(),profile_)); |
1282 } else if (is_type_popup()) { | 1115 } else if (is_type_popup()) { |
1283 browser = Browser::CreateWithParams( | 1116 browser = Browser::CreateWithParams( |
1284 Browser::CreateParams(TYPE_POPUP, profile_)); | 1117 Browser::CreateParams(TYPE_POPUP, profile_)); |
1285 } | 1118 } |
1286 | 1119 |
1287 // Preserve the size of the original window. The new window has already | 1120 // Preserve the size of the original window. The new window has already |
1288 // been given an offset by the OS, so we shouldn't copy the old bounds. | 1121 // been given an offset by the OS, so we shouldn't copy the old bounds. |
1289 BrowserWindow* new_window = browser->window(); | 1122 BrowserWindow* new_window = browser->window(); |
1290 new_window->SetBounds(gfx::Rect(new_window->GetRestoredBounds().origin(), | 1123 new_window->SetBounds(gfx::Rect(new_window->GetRestoredBounds().origin(), |
1291 window()->GetRestoredBounds().size())); | 1124 window()->GetRestoredBounds().size())); |
1292 | 1125 |
1293 // We need to show the browser now. Otherwise ContainerWin assumes the | 1126 // We need to show the browser now. Otherwise ContainerWin assumes the |
1294 // WebContents is invisible and won't size it. | 1127 // WebContents is invisible and won't size it. |
1295 browser->window()->Show(); | 1128 browser->window()->Show(); |
1296 | 1129 |
1297 // The page transition below is only for the purpose of inserting the tab. | 1130 // The page transition below is only for the purpose of inserting the tab. |
1298 browser->AddTab(contents_dupe, content::PAGE_TRANSITION_LINK); | 1131 chrome::AddTab(browser, contents_dupe, content::PAGE_TRANSITION_LINK); |
1299 } | 1132 } |
1300 | 1133 |
1301 SessionService* session_service = | 1134 SessionService* session_service = |
1302 SessionServiceFactory::GetForProfileIfExisting(profile_); | 1135 SessionServiceFactory::GetForProfileIfExisting(profile_); |
1303 if (session_service) | 1136 if (session_service) |
1304 session_service->TabRestored(contents_dupe, pinned); | 1137 session_service->TabRestored(contents_dupe, pinned); |
1305 } | 1138 } |
1306 | 1139 |
1307 void Browser::CloseFrameAfterDragSession() { | 1140 void Browser::CloseFrameAfterDragSession() { |
1308 #if !defined(OS_MACOSX) | 1141 #if !defined(OS_MACOSX) |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 LOG(WARNING) << "Reloading killed tab at " << index; | 1259 LOG(WARNING) << "Reloading killed tab at " << index; |
1427 static int reload_count = 0; | 1260 static int reload_count = 0; |
1428 UMA_HISTOGRAM_CUSTOM_COUNTS( | 1261 UMA_HISTOGRAM_CUSTOM_COUNTS( |
1429 "Tabs.SadTab.ReloadCount", ++reload_count, 1, 1000, 50); | 1262 "Tabs.SadTab.ReloadCount", ++reload_count, 1, 1000, 50); |
1430 chrome::Reload(this, CURRENT_TAB); | 1263 chrome::Reload(this, CURRENT_TAB); |
1431 did_reload = true; | 1264 did_reload = true; |
1432 } | 1265 } |
1433 } | 1266 } |
1434 | 1267 |
1435 // Discarded tabs always get reloaded. | 1268 // Discarded tabs always get reloaded. |
1436 if (!did_reload && IsTabDiscarded(index)) { | 1269 if (!did_reload && tab_strip_model_->IsTabDiscarded(index)) { |
1437 LOG(WARNING) << "Reloading discarded tab at " << index; | 1270 LOG(WARNING) << "Reloading discarded tab at " << index; |
1438 static int reload_count = 0; | 1271 static int reload_count = 0; |
1439 UMA_HISTOGRAM_CUSTOM_COUNTS( | 1272 UMA_HISTOGRAM_CUSTOM_COUNTS( |
1440 "Tabs.Discard.ReloadCount", ++reload_count, 1, 1000, 50); | 1273 "Tabs.Discard.ReloadCount", ++reload_count, 1, 1000, 50); |
1441 chrome::Reload(this, CURRENT_TAB); | 1274 chrome::Reload(this, CURRENT_TAB); |
1442 } | 1275 } |
1443 | 1276 |
1444 // If we have any update pending, do it now. | 1277 // If we have any update pending, do it now. |
1445 if (chrome_updater_factory_.HasWeakPtrs() && old_contents) | 1278 if (chrome_updater_factory_.HasWeakPtrs() && old_contents) |
1446 ProcessPendingUIUpdates(); | 1279 ProcessPendingUIUpdates(); |
(...skipping 11 matching lines...) Expand all Loading... |
1458 // Update commands to reflect current state. | 1291 // Update commands to reflect current state. |
1459 command_controller_->TabStateChanged(); | 1292 command_controller_->TabStateChanged(); |
1460 | 1293 |
1461 // Reset the status bubble. | 1294 // Reset the status bubble. |
1462 StatusBubble* status_bubble = GetStatusBubble(); | 1295 StatusBubble* status_bubble = GetStatusBubble(); |
1463 if (status_bubble) { | 1296 if (status_bubble) { |
1464 status_bubble->Hide(); | 1297 status_bubble->Hide(); |
1465 | 1298 |
1466 // Show the loading state (if any). | 1299 // Show the loading state (if any). |
1467 status_bubble->SetStatus( | 1300 status_bubble->SetStatus( |
1468 GetActiveTabContents()->core_tab_helper()->GetStatusText()); | 1301 chrome::GetActiveTabContents(this)->core_tab_helper()->GetStatusText()); |
1469 } | 1302 } |
1470 | 1303 |
1471 if (HasFindBarController()) { | 1304 if (HasFindBarController()) { |
1472 find_bar_controller_->ChangeTabContents(new_contents); | 1305 find_bar_controller_->ChangeTabContents(new_contents); |
1473 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true); | 1306 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true); |
1474 } | 1307 } |
1475 | 1308 |
1476 // Update sessions. Don't force creation of sessions. If sessions doesn't | 1309 // Update sessions. Don't force creation of sessions. If sessions doesn't |
1477 // exist, the change will be picked up by sessions when created. | 1310 // exist, the change will be picked up by sessions when created. |
1478 SessionService* session_service = | 1311 SessionService* session_service = |
(...skipping 28 matching lines...) Expand all Loading... |
1507 new_contents->web_contents()->GetController().GetEntryAtIndex( | 1340 new_contents->web_contents()->GetController().GetEntryAtIndex( |
1508 entry_count - 1), | 1341 entry_count - 1), |
1509 entry_count - 1); | 1342 entry_count - 1); |
1510 } | 1343 } |
1511 | 1344 |
1512 SessionService* session_service = | 1345 SessionService* session_service = |
1513 SessionServiceFactory::GetForProfile(profile()); | 1346 SessionServiceFactory::GetForProfile(profile()); |
1514 if (session_service) { | 1347 if (session_service) { |
1515 // The new_contents may end up with a different navigation stack. Force | 1348 // The new_contents may end up with a different navigation stack. Force |
1516 // the session service to update itself. | 1349 // the session service to update itself. |
1517 session_service->TabRestored(new_contents, IsTabPinned(index)); | 1350 session_service->TabRestored(new_contents, |
| 1351 tab_strip_model_->IsTabPinned(index)); |
1518 } | 1352 } |
1519 | 1353 |
1520 content::DevToolsManager::GetInstance()->ContentsReplaced( | 1354 content::DevToolsManager::GetInstance()->ContentsReplaced( |
1521 old_contents->web_contents(), new_contents->web_contents()); | 1355 old_contents->web_contents(), new_contents->web_contents()); |
1522 } | 1356 } |
1523 | 1357 |
1524 void Browser::TabPinnedStateChanged(TabContents* contents, int index) { | 1358 void Browser::TabPinnedStateChanged(TabContents* contents, int index) { |
1525 SessionService* session_service = | 1359 SessionService* session_service = |
1526 SessionServiceFactory::GetForProfileIfExisting(profile()); | 1360 SessionServiceFactory::GetForProfileIfExisting(profile()); |
1527 if (session_service) { | 1361 if (session_service) { |
1528 session_service->SetPinnedState( | 1362 session_service->SetPinnedState( |
1529 session_id(), | 1363 session_id(), |
1530 GetTabContentsAt(index)->restore_tab_helper()->session_id(), | 1364 chrome::GetTabContentsAt(this, index)->restore_tab_helper()-> |
1531 IsTabPinned(index)); | 1365 session_id(), |
| 1366 tab_strip_model_->IsTabPinned(index)); |
1532 } | 1367 } |
1533 } | 1368 } |
1534 | 1369 |
1535 void Browser::TabStripEmpty() { | 1370 void Browser::TabStripEmpty() { |
1536 // Close the frame after we return to the message loop (not immediately, | 1371 // Close the frame after we return to the message loop (not immediately, |
1537 // otherwise it will destroy this object before the stack has a chance to | 1372 // otherwise it will destroy this object before the stack has a chance to |
1538 // cleanly unwind.) | 1373 // cleanly unwind.) |
1539 // Note: This will be called several times if TabStripEmpty is called several | 1374 // Note: This will be called several times if TabStripEmpty is called several |
1540 // times. This is because it does not close the window if tabs are | 1375 // times. This is because it does not close the window if tabs are |
1541 // still present. | 1376 // still present. |
(...skipping 25 matching lines...) Expand all Loading... |
1567 fullscreen_controller_->OnAcceptFullscreenPermission(url, bubble_type); | 1402 fullscreen_controller_->OnAcceptFullscreenPermission(url, bubble_type); |
1568 } | 1403 } |
1569 | 1404 |
1570 void Browser::OnDenyFullscreenPermission(FullscreenExitBubbleType bubble_type) { | 1405 void Browser::OnDenyFullscreenPermission(FullscreenExitBubbleType bubble_type) { |
1571 fullscreen_controller_->OnDenyFullscreenPermission(bubble_type); | 1406 fullscreen_controller_->OnDenyFullscreenPermission(bubble_type); |
1572 } | 1407 } |
1573 | 1408 |
1574 bool Browser::TabsNeedBeforeUnloadFired() { | 1409 bool Browser::TabsNeedBeforeUnloadFired() { |
1575 if (tabs_needing_before_unload_fired_.empty()) { | 1410 if (tabs_needing_before_unload_fired_.empty()) { |
1576 for (int i = 0; i < tab_count(); ++i) { | 1411 for (int i = 0; i < tab_count(); ++i) { |
1577 WebContents* contents = GetTabContentsAt(i)->web_contents(); | 1412 WebContents* contents = chrome::GetTabContentsAt(this, i)->web_contents(); |
1578 if (contents->NeedToFireBeforeUnload()) | 1413 if (contents->NeedToFireBeforeUnload()) |
1579 tabs_needing_before_unload_fired_.insert(contents); | 1414 tabs_needing_before_unload_fired_.insert(contents); |
1580 } | 1415 } |
1581 } | 1416 } |
1582 return !tabs_needing_before_unload_fired_.empty(); | 1417 return !tabs_needing_before_unload_fired_.empty(); |
1583 } | 1418 } |
1584 | 1419 |
1585 bool Browser::IsFullscreenForTabOrPending() const { | 1420 bool Browser::IsFullscreenForTabOrPending() const { |
1586 return fullscreen_controller_->IsFullscreenForTabOrPending(); | 1421 return fullscreen_controller_->IsFullscreenForTabOrPending(); |
1587 } | 1422 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 | 1463 |
1629 return BrowserWindow::CreateBrowserWindow(this); | 1464 return BrowserWindow::CreateBrowserWindow(this); |
1630 } | 1465 } |
1631 | 1466 |
1632 /////////////////////////////////////////////////////////////////////////////// | 1467 /////////////////////////////////////////////////////////////////////////////// |
1633 // Browser, content::WebContentsDelegate implementation: | 1468 // Browser, content::WebContentsDelegate implementation: |
1634 | 1469 |
1635 WebContents* Browser::OpenURLFromTab(WebContents* source, | 1470 WebContents* Browser::OpenURLFromTab(WebContents* source, |
1636 const OpenURLParams& params) { | 1471 const OpenURLParams& params) { |
1637 browser::NavigateParams nav_params(this, params.url, params.transition); | 1472 browser::NavigateParams nav_params(this, params.url, params.transition); |
1638 nav_params.source_contents = GetTabContentsAt( | 1473 nav_params.source_contents = chrome::GetTabContentsAt(this, |
1639 tab_strip_model_->GetIndexOfWebContents(source)); | 1474 tab_strip_model_->GetIndexOfWebContents(source)); |
1640 nav_params.referrer = params.referrer; | 1475 nav_params.referrer = params.referrer; |
1641 nav_params.disposition = params.disposition; | 1476 nav_params.disposition = params.disposition; |
1642 nav_params.tabstrip_add_types = TabStripModel::ADD_NONE; | 1477 nav_params.tabstrip_add_types = TabStripModel::ADD_NONE; |
1643 nav_params.window_action = browser::NavigateParams::SHOW_WINDOW; | 1478 nav_params.window_action = browser::NavigateParams::SHOW_WINDOW; |
1644 nav_params.user_gesture = true; | 1479 nav_params.user_gesture = true; |
1645 nav_params.override_encoding = params.override_encoding; | 1480 nav_params.override_encoding = params.override_encoding; |
1646 nav_params.is_renderer_initiated = params.is_renderer_initiated; | 1481 nav_params.is_renderer_initiated = params.is_renderer_initiated; |
1647 nav_params.transferred_global_request_id = | 1482 nav_params.transferred_global_request_id = |
1648 params.transferred_global_request_id; | 1483 params.transferred_global_request_id; |
(...skipping 16 matching lines...) Expand all Loading... |
1665 if (changed_flags & (content::INVALIDATE_TYPE_URL | | 1500 if (changed_flags & (content::INVALIDATE_TYPE_URL | |
1666 content::INVALIDATE_TYPE_LOAD)) | 1501 content::INVALIDATE_TYPE_LOAD)) |
1667 command_controller_->TabStateChanged(); | 1502 command_controller_->TabStateChanged(); |
1668 } | 1503 } |
1669 | 1504 |
1670 void Browser::AddNewContents(WebContents* source, | 1505 void Browser::AddNewContents(WebContents* source, |
1671 WebContents* new_contents, | 1506 WebContents* new_contents, |
1672 WindowOpenDisposition disposition, | 1507 WindowOpenDisposition disposition, |
1673 const gfx::Rect& initial_pos, | 1508 const gfx::Rect& initial_pos, |
1674 bool user_gesture) { | 1509 bool user_gesture) { |
1675 // No code for this yet. | 1510 chrome::AddWebContents(this, source, new_contents, disposition, initial_pos, |
1676 DCHECK(disposition != SAVE_TO_DISK); | 1511 user_gesture); |
1677 // Can't create a new contents for the current tab - invalid case. | |
1678 DCHECK(disposition != CURRENT_TAB); | |
1679 | |
1680 TabContents* source_tab_contents = NULL; | |
1681 BlockedContentTabHelper* source_blocked_content = NULL; | |
1682 TabContents* new_tab_contents = TabContents::FromWebContents(new_contents); | |
1683 if (!new_tab_contents) { | |
1684 new_tab_contents = new TabContents(new_contents); | |
1685 } | |
1686 if (source) { | |
1687 source_tab_contents = TabContents::FromWebContents(source); | |
1688 source_blocked_content = source_tab_contents->blocked_content_tab_helper(); | |
1689 } | |
1690 | |
1691 if (source_tab_contents) { | |
1692 // Handle blocking of all contents. | |
1693 if (source_blocked_content->all_contents_blocked()) { | |
1694 source_blocked_content->AddTabContents(new_tab_contents, | |
1695 disposition, | |
1696 initial_pos, | |
1697 user_gesture); | |
1698 return; | |
1699 } | |
1700 | |
1701 // Handle blocking of popups. | |
1702 if ((disposition == NEW_POPUP) && !user_gesture && | |
1703 !CommandLine::ForCurrentProcess()->HasSwitch( | |
1704 switches::kDisablePopupBlocking)) { | |
1705 // Unrequested popups from normal pages are constrained unless they're in | |
1706 // the whitelist. The popup owner will handle checking this. | |
1707 GetConstrainingTabContents(source_tab_contents)-> | |
1708 blocked_content_tab_helper()-> | |
1709 AddPopup(new_tab_contents, initial_pos, user_gesture); | |
1710 return; | |
1711 } | |
1712 | |
1713 new_contents->GetRenderViewHost()->DisassociateFromPopupCount(); | |
1714 } | |
1715 | |
1716 browser::NavigateParams params(this, new_tab_contents); | |
1717 params.source_contents = source ? | |
1718 GetTabContentsAt(tab_strip_model_->GetIndexOfWebContents(source)): NULL; | |
1719 params.disposition = disposition; | |
1720 params.window_bounds = initial_pos; | |
1721 params.window_action = browser::NavigateParams::SHOW_WINDOW; | |
1722 params.user_gesture = user_gesture; | |
1723 browser::Navigate(¶ms); | |
1724 } | 1512 } |
1725 | 1513 |
1726 void Browser::ActivateContents(WebContents* contents) { | 1514 void Browser::ActivateContents(WebContents* contents) { |
1727 ActivateTabAt(tab_strip_model_->GetIndexOfWebContents(contents), false); | 1515 chrome::ActivateTabAt(this, tab_strip_model_->GetIndexOfWebContents(contents), |
| 1516 false); |
1728 window_->Activate(); | 1517 window_->Activate(); |
1729 } | 1518 } |
1730 | 1519 |
1731 void Browser::DeactivateContents(WebContents* contents) { | 1520 void Browser::DeactivateContents(WebContents* contents) { |
1732 window_->Deactivate(); | 1521 window_->Deactivate(); |
1733 } | 1522 } |
1734 | 1523 |
1735 void Browser::LoadingStateChanged(WebContents* source) { | 1524 void Browser::LoadingStateChanged(WebContents* source) { |
1736 window_->UpdateLoadingAnimations(tab_strip_model_->TabsAreLoading()); | 1525 window_->UpdateLoadingAnimations(tab_strip_model_->TabsAreLoading()); |
1737 window_->UpdateTitleBar(); | 1526 window_->UpdateTitleBar(); |
1738 | 1527 |
1739 WebContents* selected_contents = GetActiveWebContents(); | 1528 WebContents* selected_contents = chrome::GetActiveWebContents(this); |
1740 if (source == selected_contents) { | 1529 if (source == selected_contents) { |
1741 bool is_loading = source->IsLoading(); | 1530 bool is_loading = source->IsLoading(); |
1742 command_controller_->LoadingStateChanged(is_loading, false); | 1531 command_controller_->LoadingStateChanged(is_loading, false); |
1743 if (GetStatusBubble()) { | 1532 if (GetStatusBubble()) { |
1744 GetStatusBubble()->SetStatus( | 1533 GetStatusBubble()->SetStatus( |
1745 GetActiveTabContents()->core_tab_helper()->GetStatusText()); | 1534 chrome::GetActiveTabContents(this)->core_tab_helper()-> |
| 1535 GetStatusText()); |
1746 } | 1536 } |
1747 | 1537 |
1748 if (!is_loading && pending_web_app_action_ == UPDATE_SHORTCUT) { | 1538 if (!is_loading && pending_web_app_action_ == UPDATE_SHORTCUT) { |
1749 // Schedule a shortcut update when web application info is available if | 1539 // Schedule a shortcut update when web application info is available if |
1750 // last committed entry is not NULL. Last committed entry could be NULL | 1540 // last committed entry is not NULL. Last committed entry could be NULL |
1751 // when an interstitial page is injected (e.g. bad https certificate, | 1541 // when an interstitial page is injected (e.g. bad https certificate, |
1752 // malware site etc). When this happens, we abort the shortcut update. | 1542 // malware site etc). When this happens, we abort the shortcut update. |
1753 NavigationEntry* entry = source->GetController().GetLastCommittedEntry(); | 1543 NavigationEntry* entry = source->GetController().GetLastCommittedEntry(); |
1754 if (entry) { | 1544 if (entry) { |
1755 TabContents::FromWebContents(source)-> | 1545 TabContents::FromWebContents(source)-> |
1756 extension_tab_helper()->GetApplicationInfo(entry->GetPageID()); | 1546 extension_tab_helper()->GetApplicationInfo(entry->GetPageID()); |
1757 } else { | 1547 } else { |
1758 pending_web_app_action_ = NONE; | 1548 pending_web_app_action_ = NONE; |
1759 } | 1549 } |
1760 } | 1550 } |
1761 } | 1551 } |
1762 } | 1552 } |
1763 | 1553 |
1764 void Browser::CloseContents(WebContents* source) { | 1554 void Browser::CloseContents(WebContents* source) { |
1765 if (is_attempting_to_close_browser_) { | 1555 if (is_attempting_to_close_browser_) { |
1766 // If we're trying to close the browser, just clear the state related to | 1556 // If we're trying to close the browser, just clear the state related to |
1767 // waiting for unload to fire. Don't actually try to close the tab as it | 1557 // waiting for unload to fire. Don't actually try to close the tab as it |
1768 // will go down the slow shutdown path instead of the fast path of killing | 1558 // will go down the slow shutdown path instead of the fast path of killing |
1769 // all the renderer processes. | 1559 // all the renderer processes. |
1770 ClearUnloadState(source, true); | 1560 ClearUnloadState(source, true); |
1771 return; | 1561 return; |
1772 } | 1562 } |
1773 | 1563 |
1774 int index = tab_strip_model_->GetIndexOfWebContents(source); | 1564 chrome::CloseWebContents(this, source); |
1775 if (index == TabStripModel::kNoTab) { | |
1776 NOTREACHED() << "CloseContents called for tab not in our strip"; | |
1777 return; | |
1778 } | |
1779 tab_strip_model_->CloseTabContentsAt(index, | |
1780 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); | |
1781 } | 1565 } |
1782 | 1566 |
1783 void Browser::MoveContents(WebContents* source, const gfx::Rect& pos) { | 1567 void Browser::MoveContents(WebContents* source, const gfx::Rect& pos) { |
1784 if (!IsPopupOrPanel(source)) { | 1568 if (!IsPopupOrPanel(source)) { |
1785 NOTREACHED() << "moving invalid browser type"; | 1569 NOTREACHED() << "moving invalid browser type"; |
1786 return; | 1570 return; |
1787 } | 1571 } |
1788 window_->SetBounds(pos); | 1572 window_->SetBounds(pos); |
1789 } | 1573 } |
1790 | 1574 |
1791 bool Browser::IsPopupOrPanel(const WebContents* source) const { | 1575 bool Browser::IsPopupOrPanel(const WebContents* source) const { |
1792 // A non-tabbed BROWSER is an unconstrained popup. | 1576 // A non-tabbed BROWSER is an unconstrained popup. |
1793 return is_type_popup() || is_type_panel(); | 1577 return is_type_popup() || is_type_panel(); |
1794 } | 1578 } |
1795 | 1579 |
1796 void Browser::UpdateTargetURL(WebContents* source, int32 page_id, | 1580 void Browser::UpdateTargetURL(WebContents* source, int32 page_id, |
1797 const GURL& url) { | 1581 const GURL& url) { |
1798 if (!GetStatusBubble()) | 1582 if (!GetStatusBubble()) |
1799 return; | 1583 return; |
1800 | 1584 |
1801 if (source == GetActiveWebContents()) { | 1585 if (source == chrome::GetActiveWebContents(this)) { |
1802 PrefService* prefs = profile_->GetPrefs(); | 1586 PrefService* prefs = profile_->GetPrefs(); |
1803 GetStatusBubble()->SetURL(url, prefs->GetString(prefs::kAcceptLanguages)); | 1587 GetStatusBubble()->SetURL(url, prefs->GetString(prefs::kAcceptLanguages)); |
1804 } | 1588 } |
1805 } | 1589 } |
1806 | 1590 |
1807 void Browser::ContentsMouseEvent( | 1591 void Browser::ContentsMouseEvent( |
1808 WebContents* source, const gfx::Point& location, bool motion) { | 1592 WebContents* source, const gfx::Point& location, bool motion) { |
1809 if (!GetStatusBubble()) | 1593 if (!GetStatusBubble()) |
1810 return; | 1594 return; |
1811 | 1595 |
1812 if (source == GetActiveWebContents()) { | 1596 if (source == chrome::GetActiveWebContents(this)) { |
1813 GetStatusBubble()->MouseMoved(location, !motion); | 1597 GetStatusBubble()->MouseMoved(location, !motion); |
1814 if (!motion) | 1598 if (!motion) |
1815 GetStatusBubble()->SetURL(GURL(), std::string()); | 1599 GetStatusBubble()->SetURL(GURL(), std::string()); |
1816 } | 1600 } |
1817 } | 1601 } |
1818 | 1602 |
1819 void Browser::ContentsZoomChange(bool zoom_in) { | 1603 void Browser::ContentsZoomChange(bool zoom_in) { |
1820 chrome::ExecuteCommand(this, zoom_in ? IDC_ZOOM_PLUS : IDC_ZOOM_MINUS); | 1604 chrome::ExecuteCommand(this, zoom_in ? IDC_ZOOM_PLUS : IDC_ZOOM_MINUS); |
1821 } | 1605 } |
1822 | 1606 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1908 // GetDownloadShelf creates the download shelf if it was not yet created. | 1692 // GetDownloadShelf creates the download shelf if it was not yet created. |
1909 DownloadShelf* shelf = window()->GetDownloadShelf(); | 1693 DownloadShelf* shelf = window()->GetDownloadShelf(); |
1910 shelf->AddDownload(new DownloadItemModel(download)); | 1694 shelf->AddDownload(new DownloadItemModel(download)); |
1911 // Don't show the animation for "Save file" downloads. | 1695 // Don't show the animation for "Save file" downloads. |
1912 // For non-theme extensions, we don't show the download animation. | 1696 // For non-theme extensions, we don't show the download animation. |
1913 // Show animation in same window as the download shelf. Download shelf | 1697 // Show animation in same window as the download shelf. Download shelf |
1914 // may not be in the same window that initiated the download, e.g. | 1698 // may not be in the same window that initiated the download, e.g. |
1915 // Panels. | 1699 // Panels. |
1916 // Don't show the animation if the selected tab is not visible (i.e. the | 1700 // Don't show the animation if the selected tab is not visible (i.e. the |
1917 // window is minimized, we're in a unit test, etc.). | 1701 // window is minimized, we're in a unit test, etc.). |
1918 WebContents* shelf_tab = shelf->browser()->GetActiveWebContents(); | 1702 WebContents* shelf_tab = chrome::GetActiveWebContents(shelf->browser()); |
1919 if ((download->GetTotalBytes() > 0) && | 1703 if ((download->GetTotalBytes() > 0) && |
1920 !download_crx_util::IsExtensionDownload(*download) && | 1704 !download_crx_util::IsExtensionDownload(*download) && |
1921 platform_util::IsVisible(shelf_tab->GetNativeView()) && | 1705 platform_util::IsVisible(shelf_tab->GetNativeView()) && |
1922 ui::Animation::ShouldRenderRichAnimation()) { | 1706 ui::Animation::ShouldRenderRichAnimation()) { |
1923 DownloadStartedAnimation::Show(shelf_tab); | 1707 DownloadStartedAnimation::Show(shelf_tab); |
1924 } | 1708 } |
1925 | 1709 |
1926 // If the download occurs in a new tab, close it. | 1710 // If the download occurs in a new tab, close it. |
1927 if (source->GetController().IsInitialNavigation() && tab_count() > 1) | 1711 if (source->GetController().IsInitialNavigation() && tab_count() > 1) |
1928 CloseContents(source); | 1712 CloseContents(source); |
1929 } | 1713 } |
1930 | 1714 |
1931 void Browser::ViewSourceForTab(WebContents* source, const GURL& page_url) { | 1715 void Browser::ViewSourceForTab(WebContents* source, const GURL& page_url) { |
1932 DCHECK(source); | 1716 DCHECK(source); |
1933 TabContents* tab_contents = GetTabContentsAt( | 1717 TabContents* tab_contents = chrome::GetTabContentsAt(this, |
1934 tab_strip_model_->GetIndexOfWebContents(source)); | 1718 tab_strip_model_->GetIndexOfWebContents(source)); |
1935 chrome::ViewSource(this, tab_contents); | 1719 chrome::ViewSource(this, tab_contents); |
1936 } | 1720 } |
1937 | 1721 |
1938 void Browser::ViewSourceForFrame(WebContents* source, | 1722 void Browser::ViewSourceForFrame(WebContents* source, |
1939 const GURL& frame_url, | 1723 const GURL& frame_url, |
1940 const std::string& frame_content_state) { | 1724 const std::string& frame_content_state) { |
1941 DCHECK(source); | 1725 DCHECK(source); |
1942 TabContents* tab_contents = GetTabContentsAt( | 1726 TabContents* tab_contents = chrome::GetTabContentsAt(this, |
1943 tab_strip_model_->GetIndexOfWebContents(source)); | 1727 tab_strip_model_->GetIndexOfWebContents(source)); |
1944 chrome::ViewSource(this, tab_contents, frame_url, frame_content_state); | 1728 chrome::ViewSource(this, tab_contents, frame_url, frame_content_state); |
1945 } | 1729 } |
1946 | 1730 |
1947 void Browser::ShowRepostFormWarningDialog(WebContents* source) { | 1731 void Browser::ShowRepostFormWarningDialog(WebContents* source) { |
1948 browser::ShowTabModalConfirmDialog( | 1732 browser::ShowTabModalConfirmDialog( |
1949 new RepostFormWarningController(source), | 1733 new RepostFormWarningController(source), |
1950 TabContents::FromWebContents(source)); | 1734 TabContents::FromWebContents(source)); |
1951 } | 1735 } |
1952 | 1736 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2026 TabContents* tab_contents = TabContents::FromWebContents(source); | 1810 TabContents* tab_contents = TabContents::FromWebContents(source); |
2027 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); | 1811 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); |
2028 infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( | 1812 infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( |
2029 infobar_helper, | 1813 infobar_helper, |
2030 NULL, | 1814 NULL, |
2031 l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT), | 1815 l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT), |
2032 true)); | 1816 true)); |
2033 } | 1817 } |
2034 | 1818 |
2035 void Browser::DidNavigateMainFramePostCommit(WebContents* web_contents) { | 1819 void Browser::DidNavigateMainFramePostCommit(WebContents* web_contents) { |
2036 if (web_contents == GetActiveWebContents()) | 1820 if (web_contents == chrome::GetActiveWebContents(this)) |
2037 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 1821 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
2038 } | 1822 } |
2039 | 1823 |
2040 void Browser::DidNavigateToPendingEntry(WebContents* web_contents) { | 1824 void Browser::DidNavigateToPendingEntry(WebContents* web_contents) { |
2041 if (web_contents == GetActiveWebContents()) | 1825 if (web_contents == chrome::GetActiveWebContents(this)) |
2042 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 1826 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
2043 } | 1827 } |
2044 | 1828 |
2045 content::JavaScriptDialogCreator* Browser::GetJavaScriptDialogCreator() { | 1829 content::JavaScriptDialogCreator* Browser::GetJavaScriptDialogCreator() { |
2046 return GetJavaScriptDialogCreatorInstance(); | 1830 return GetJavaScriptDialogCreatorInstance(); |
2047 } | 1831 } |
2048 | 1832 |
2049 content::ColorChooser* Browser::OpenColorChooser(WebContents* web_contents, | 1833 content::ColorChooser* Browser::OpenColorChooser(WebContents* web_contents, |
2050 int color_chooser_id, | 1834 int color_chooser_id, |
2051 SkColor color) { | 1835 SkColor color) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2116 WebContents* web_contents, | 1900 WebContents* web_contents, |
2117 content::WebIntentsDispatcher* intents_dispatcher) { | 1901 content::WebIntentsDispatcher* intents_dispatcher) { |
2118 if (!web_intents::IsWebIntentsEnabledForProfile(profile_)) | 1902 if (!web_intents::IsWebIntentsEnabledForProfile(profile_)) |
2119 return; | 1903 return; |
2120 | 1904 |
2121 UMA_HISTOGRAM_COUNTS("WebIntents.Dispatch", 1); | 1905 UMA_HISTOGRAM_COUNTS("WebIntents.Dispatch", 1); |
2122 | 1906 |
2123 if (!web_contents) { | 1907 if (!web_contents) { |
2124 // Intent is system-caused and the picker will show over the currently | 1908 // Intent is system-caused and the picker will show over the currently |
2125 // active web contents. | 1909 // active web contents. |
2126 web_contents = GetActiveWebContents(); | 1910 web_contents = chrome::GetActiveWebContents(this); |
2127 } | 1911 } |
2128 TabContents* tab_contents = TabContents::FromWebContents(web_contents); | 1912 TabContents* tab_contents = TabContents::FromWebContents(web_contents); |
2129 tab_contents->web_intent_picker_controller()->SetIntentsDispatcher( | 1913 tab_contents->web_intent_picker_controller()->SetIntentsDispatcher( |
2130 intents_dispatcher); | 1914 intents_dispatcher); |
2131 tab_contents->web_intent_picker_controller()->ShowDialog( | 1915 tab_contents->web_intent_picker_controller()->ShowDialog( |
2132 intents_dispatcher->GetIntent().action, | 1916 intents_dispatcher->GetIntent().action, |
2133 intents_dispatcher->GetIntent().type); | 1917 intents_dispatcher->GetIntent().type); |
2134 } | 1918 } |
2135 | 1919 |
2136 void Browser::UpdatePreferredSize(WebContents* source, | 1920 void Browser::UpdatePreferredSize(WebContents* source, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2225 // Browser, ConstrainedWindowTabHelperDelegate implementation: | 2009 // Browser, ConstrainedWindowTabHelperDelegate implementation: |
2226 | 2010 |
2227 void Browser::SetTabContentBlocked(TabContents* tab_contents, bool blocked) { | 2011 void Browser::SetTabContentBlocked(TabContents* tab_contents, bool blocked) { |
2228 int index = tab_strip_model_->GetIndexOfTabContents(tab_contents); | 2012 int index = tab_strip_model_->GetIndexOfTabContents(tab_contents); |
2229 if (index == TabStripModel::kNoTab) { | 2013 if (index == TabStripModel::kNoTab) { |
2230 NOTREACHED(); | 2014 NOTREACHED(); |
2231 return; | 2015 return; |
2232 } | 2016 } |
2233 tab_strip_model_->SetTabBlocked(index, blocked); | 2017 tab_strip_model_->SetTabBlocked(index, blocked); |
2234 command_controller_->PrintingStateChanged(); | 2018 command_controller_->PrintingStateChanged(); |
2235 if (!blocked && GetActiveTabContents() == tab_contents) | 2019 if (!blocked && chrome::GetActiveTabContents(this) == tab_contents) |
2236 tab_contents->web_contents()->Focus(); | 2020 tab_contents->web_contents()->Focus(); |
2237 } | 2021 } |
2238 | 2022 |
2239 /////////////////////////////////////////////////////////////////////////////// | 2023 /////////////////////////////////////////////////////////////////////////////// |
2240 // Browser, BlockedContentTabHelperDelegate implementation: | 2024 // Browser, BlockedContentTabHelperDelegate implementation: |
2241 | 2025 |
2242 TabContents* Browser::GetConstrainingTabContents(TabContents* source) { | 2026 TabContents* Browser::GetConstrainingTabContents(TabContents* source) { |
2243 return source; | 2027 return source; |
2244 } | 2028 } |
2245 | 2029 |
2246 /////////////////////////////////////////////////////////////////////////////// | 2030 /////////////////////////////////////////////////////////////////////////////// |
2247 // Browser, BookmarkTabHelperDelegate implementation: | 2031 // Browser, BookmarkTabHelperDelegate implementation: |
2248 | 2032 |
2249 void Browser::URLStarredChanged(TabContents* source, bool starred) { | 2033 void Browser::URLStarredChanged(TabContents* source, bool starred) { |
2250 if (source == GetActiveTabContents()) | 2034 if (source == chrome::GetActiveTabContents(this)) |
2251 window_->SetStarredState(starred); | 2035 window_->SetStarredState(starred); |
2252 } | 2036 } |
2253 | 2037 |
2254 /////////////////////////////////////////////////////////////////////////////// | 2038 /////////////////////////////////////////////////////////////////////////////// |
2255 // Browser, ZoomObserver implementation: | 2039 // Browser, ZoomObserver implementation: |
2256 | 2040 |
2257 void Browser::OnZoomIconChanged(TabContents* source, | 2041 void Browser::OnZoomIconChanged(TabContents* source, |
2258 ZoomController::ZoomIconState state) { | 2042 ZoomController::ZoomIconState state) { |
2259 if (source == GetActiveTabContents()) | 2043 if (source == chrome::GetActiveTabContents(this)) |
2260 window_->SetZoomIconState(state); | 2044 window_->SetZoomIconState(state); |
2261 } | 2045 } |
2262 | 2046 |
2263 void Browser::OnZoomChanged(TabContents* source, | 2047 void Browser::OnZoomChanged(TabContents* source, |
2264 int zoom_percent, | 2048 int zoom_percent, |
2265 bool can_show_bubble) { | 2049 bool can_show_bubble) { |
2266 if (source == GetActiveTabContents()) { | 2050 if (source == chrome::GetActiveTabContents(this)) { |
2267 window_->SetZoomIconTooltipPercent(zoom_percent); | 2051 window_->SetZoomIconTooltipPercent(zoom_percent); |
2268 | 2052 |
2269 // Only show the zoom bubble for zoom changes in the active window. | 2053 // Only show the zoom bubble for zoom changes in the active window. |
2270 if (can_show_bubble && window_->IsActive()) | 2054 if (can_show_bubble && window_->IsActive()) |
2271 window_->ShowZoomBubble(zoom_percent); | 2055 window_->ShowZoomBubble(zoom_percent); |
2272 } | 2056 } |
2273 } | 2057 } |
2274 | 2058 |
2275 /////////////////////////////////////////////////////////////////////////////// | 2059 /////////////////////////////////////////////////////////////////////////////// |
2276 // Browser, ExtensionTabHelperDelegate implementation: | 2060 // Browser, ExtensionTabHelperDelegate implementation: |
2277 | 2061 |
2278 void Browser::OnDidGetApplicationInfo(TabContents* source, | 2062 void Browser::OnDidGetApplicationInfo(TabContents* source, |
2279 int32 page_id) { | 2063 int32 page_id) { |
2280 if (GetActiveTabContents() != source) | 2064 if (chrome::GetActiveTabContents(this) != source) |
2281 return; | 2065 return; |
2282 | 2066 |
2283 NavigationEntry* entry = | 2067 NavigationEntry* entry = |
2284 source->web_contents()->GetController().GetLastCommittedEntry(); | 2068 source->web_contents()->GetController().GetLastCommittedEntry(); |
2285 if (!entry || (entry->GetPageID() != page_id)) | 2069 if (!entry || (entry->GetPageID() != page_id)) |
2286 return; | 2070 return; |
2287 | 2071 |
2288 switch (pending_web_app_action_) { | 2072 switch (pending_web_app_action_) { |
2289 case CREATE_SHORTCUT: { | 2073 case CREATE_SHORTCUT: { |
2290 window()->ShowCreateWebAppShortcutsDialog(source); | 2074 window()->ShowCreateWebAppShortcutsDialog(source); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2350 } | 2134 } |
2351 break; | 2135 break; |
2352 | 2136 |
2353 case content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED: | 2137 case content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED: |
2354 // When the current tab's SSL state changes, we need to update the URL | 2138 // When the current tab's SSL state changes, we need to update the URL |
2355 // bar to reflect the new state. Note that it's possible for the selected | 2139 // bar to reflect the new state. Note that it's possible for the selected |
2356 // tab contents to be NULL. This is because we listen for all sources | 2140 // tab contents to be NULL. This is because we listen for all sources |
2357 // (NavigationControllers) for convenience, so the notification could | 2141 // (NavigationControllers) for convenience, so the notification could |
2358 // actually be for a different window while we're doing asynchronous | 2142 // actually be for a different window while we're doing asynchronous |
2359 // closing of this one. | 2143 // closing of this one. |
2360 if (GetActiveWebContents() && | 2144 if (chrome::GetActiveWebContents(this) && |
2361 &GetActiveWebContents()->GetController() == | 2145 &chrome::GetActiveWebContents(this)->GetController() == |
2362 content::Source<NavigationController>(source).ptr()) | 2146 content::Source<NavigationController>(source).ptr()) |
2363 UpdateToolbar(false); | 2147 UpdateToolbar(false); |
2364 break; | 2148 break; |
2365 | 2149 |
2366 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { | 2150 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { |
2367 if (window()->GetLocationBar()) | 2151 if (window()->GetLocationBar()) |
2368 window()->GetLocationBar()->UpdatePageActions(); | 2152 window()->GetLocationBar()->UpdatePageActions(); |
2369 | 2153 |
2370 // Close any tabs from the unloaded extension, unless it's terminated, | 2154 // Close any tabs from the unloaded extension, unless it's terminated, |
2371 // in which case let the sad tabs remain. | 2155 // in which case let the sad tabs remain. |
2372 if (content::Details<extensions::UnloadedExtensionInfo>( | 2156 if (content::Details<extensions::UnloadedExtensionInfo>( |
2373 details)->reason != extension_misc::UNLOAD_REASON_TERMINATE) { | 2157 details)->reason != extension_misc::UNLOAD_REASON_TERMINATE) { |
2374 const Extension* extension = | 2158 const Extension* extension = |
2375 content::Details<extensions::UnloadedExtensionInfo>( | 2159 content::Details<extensions::UnloadedExtensionInfo>( |
2376 details)->extension; | 2160 details)->extension; |
2377 for (int i = tab_strip_model_->count() - 1; i >= 0; --i) { | 2161 for (int i = tab_strip_model_->count() - 1; i >= 0; --i) { |
2378 WebContents* tc = | 2162 WebContents* tc = chrome::GetTabContentsAt(this, i)->web_contents(); |
2379 tab_strip_model_->GetTabContentsAt(i)->web_contents(); | |
2380 bool close_tab_contents = | 2163 bool close_tab_contents = |
2381 tc->GetURL().SchemeIs(chrome::kExtensionScheme) && | 2164 tc->GetURL().SchemeIs(chrome::kExtensionScheme) && |
2382 tc->GetURL().host() == extension->id(); | 2165 tc->GetURL().host() == extension->id(); |
2383 // We want to close all panels originated by the unloaded extension. | 2166 // We want to close all panels originated by the unloaded extension. |
2384 close_tab_contents = close_tab_contents || | 2167 close_tab_contents = close_tab_contents || |
2385 (type_ == TYPE_PANEL && | 2168 (type_ == TYPE_PANEL && |
2386 (web_app::GetExtensionIdFromApplicationName(app_name_) == | 2169 (web_app::GetExtensionIdFromApplicationName(app_name_) == |
2387 extension->id())); | 2170 extension->id())); |
2388 if (close_tab_contents) { | 2171 if (close_tab_contents) |
2389 CloseTabContents(tc); | 2172 chrome::CloseWebContents(this, tc); |
2390 } | |
2391 } | 2173 } |
2392 } | 2174 } |
2393 break; | 2175 break; |
2394 } | 2176 } |
2395 | 2177 |
2396 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: { | 2178 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: { |
2397 Profile* profile = content::Source<Profile>(source).ptr(); | 2179 Profile* profile = content::Source<Profile>(source).ptr(); |
2398 if (profile_->IsSameProfile(profile) && window()->GetLocationBar()) | 2180 if (profile_->IsSameProfile(profile) && window()->GetLocationBar()) |
2399 window()->GetLocationBar()->InvalidatePageActions(); | 2181 window()->GetLocationBar()->InvalidatePageActions(); |
2400 break; | 2182 break; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2439 PrefService* pref_service = content::Source<PrefService>(source).ptr(); | 2221 PrefService* pref_service = content::Source<PrefService>(source).ptr(); |
2440 MarkHomePageAsChanged(pref_service); | 2222 MarkHomePageAsChanged(pref_service); |
2441 } else { | 2223 } else { |
2442 NOTREACHED(); | 2224 NOTREACHED(); |
2443 } | 2225 } |
2444 break; | 2226 break; |
2445 } | 2227 } |
2446 | 2228 |
2447 case chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED: { | 2229 case chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED: { |
2448 WebContents* web_contents = content::Source<WebContents>(source).ptr(); | 2230 WebContents* web_contents = content::Source<WebContents>(source).ptr(); |
2449 if (web_contents == GetActiveWebContents()) { | 2231 if (web_contents == chrome::GetActiveWebContents(this)) { |
2450 LocationBar* location_bar = window()->GetLocationBar(); | 2232 LocationBar* location_bar = window()->GetLocationBar(); |
2451 if (location_bar) | 2233 if (location_bar) |
2452 location_bar->UpdateContentSettingsIcons(); | 2234 location_bar->UpdateContentSettingsIcons(); |
2453 } | 2235 } |
2454 break; | 2236 break; |
2455 } | 2237 } |
2456 | 2238 |
2457 case content::NOTIFICATION_INTERSTITIAL_ATTACHED: | 2239 case content::NOTIFICATION_INTERSTITIAL_ATTACHED: |
2458 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 2240 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
2459 break; | 2241 break; |
2460 | 2242 |
2461 case content::NOTIFICATION_INTERSTITIAL_DETACHED: | 2243 case content::NOTIFICATION_INTERSTITIAL_DETACHED: |
2462 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 2244 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
2463 break; | 2245 break; |
2464 | 2246 |
2465 default: | 2247 default: |
2466 NOTREACHED() << "Got a notification we didn't register for."; | 2248 NOTREACHED() << "Got a notification we didn't register for."; |
2467 } | 2249 } |
2468 } | 2250 } |
2469 | 2251 |
2470 /////////////////////////////////////////////////////////////////////////////// | 2252 /////////////////////////////////////////////////////////////////////////////// |
2471 // Browser, InstantControllerDelegate implementation: | 2253 // Browser, InstantControllerDelegate implementation: |
2472 | 2254 |
2473 void Browser::ShowInstant(TabContents* preview_contents) { | 2255 void Browser::ShowInstant(TabContents* preview_contents) { |
2474 window_->ShowInstant(preview_contents); | 2256 window_->ShowInstant(preview_contents); |
2475 | 2257 |
2476 // TODO(beng): investigate if we can avoid this and instead rely on the | 2258 // TODO(beng): investigate if we can avoid this and instead rely on the |
2477 // visibility of the WebContentsView | 2259 // visibility of the WebContentsView |
2478 GetActiveWebContents()->WasHidden(); | 2260 chrome::GetActiveWebContents(this)->WasHidden(); |
2479 preview_contents->web_contents()->WasRestored(); | 2261 preview_contents->web_contents()->WasRestored(); |
2480 } | 2262 } |
2481 | 2263 |
2482 void Browser::HideInstant() { | 2264 void Browser::HideInstant() { |
2483 window_->HideInstant(); | 2265 window_->HideInstant(); |
2484 if (GetActiveWebContents()) | 2266 if (chrome::GetActiveWebContents(this)) |
2485 GetActiveWebContents()->WasRestored(); | 2267 chrome::GetActiveWebContents(this)->WasRestored(); |
2486 if (instant_->GetPreviewContents()) | 2268 if (instant_->GetPreviewContents()) |
2487 instant_->GetPreviewContents()->web_contents()->WasHidden(); | 2269 instant_->GetPreviewContents()->web_contents()->WasHidden(); |
2488 } | 2270 } |
2489 | 2271 |
2490 void Browser::CommitInstant(TabContents* preview_contents) { | 2272 void Browser::CommitInstant(TabContents* preview_contents) { |
2491 TabContents* tab_contents = GetActiveTabContents(); | 2273 TabContents* tab_contents = chrome::GetActiveTabContents(this); |
2492 int index = tab_strip_model_->GetIndexOfTabContents(tab_contents); | 2274 int index = tab_strip_model_->GetIndexOfTabContents(tab_contents); |
2493 DCHECK_NE(TabStripModel::kNoTab, index); | 2275 DCHECK_NE(TabStripModel::kNoTab, index); |
2494 // TabStripModel takes ownership of preview_contents. | 2276 // TabStripModel takes ownership of preview_contents. |
2495 tab_strip_model_->ReplaceTabContentsAt(index, preview_contents); | 2277 tab_strip_model_->ReplaceTabContentsAt(index, preview_contents); |
2496 // InstantUnloadHandler takes ownership of tab_contents. | 2278 // InstantUnloadHandler takes ownership of tab_contents. |
2497 instant_unload_handler_->RunUnloadListenersOrDestroy(tab_contents, index); | 2279 instant_unload_handler_->RunUnloadListenersOrDestroy(tab_contents, index); |
2498 | 2280 |
2499 GURL url = preview_contents->web_contents()->GetURL(); | 2281 GURL url = preview_contents->web_contents()->GetURL(); |
2500 DCHECK(profile_->GetExtensionService()); | 2282 DCHECK(profile_->GetExtensionService()); |
2501 if (profile_->GetExtensionService()->IsInstalledApp(url)) { | 2283 if (profile_->GetExtensionService()->IsInstalledApp(url)) { |
(...skipping 11 matching lines...) Expand all Loading... |
2513 gfx::Rect Browser::GetInstantBounds() { | 2295 gfx::Rect Browser::GetInstantBounds() { |
2514 return window()->GetInstantBounds(); | 2296 return window()->GetInstantBounds(); |
2515 } | 2297 } |
2516 | 2298 |
2517 void Browser::InstantPreviewFocused() { | 2299 void Browser::InstantPreviewFocused() { |
2518 // NOTE: This is only invoked on aura. | 2300 // NOTE: This is only invoked on aura. |
2519 window_->WebContentsFocused(instant_->GetPreviewContents()->web_contents()); | 2301 window_->WebContentsFocused(instant_->GetPreviewContents()->web_contents()); |
2520 } | 2302 } |
2521 | 2303 |
2522 TabContents* Browser::GetInstantHostTabContents() const { | 2304 TabContents* Browser::GetInstantHostTabContents() const { |
2523 return GetActiveTabContents(); | 2305 return chrome::GetActiveTabContents(this); |
2524 } | 2306 } |
2525 | 2307 |
2526 /////////////////////////////////////////////////////////////////////////////// | 2308 /////////////////////////////////////////////////////////////////////////////// |
2527 // Browser, Command and state updating (private): | 2309 // Browser, Command and state updating (private): |
2528 | 2310 |
2529 void Browser::MarkHomePageAsChanged(PrefService* pref_service) { | 2311 void Browser::MarkHomePageAsChanged(PrefService* pref_service) { |
2530 pref_service->SetBoolean(prefs::kHomePageChanged, true); | 2312 pref_service->SetBoolean(prefs::kHomePageChanged, true); |
2531 } | 2313 } |
2532 | 2314 |
2533 /////////////////////////////////////////////////////////////////////////////// | 2315 /////////////////////////////////////////////////////////////////////////////// |
2534 // Browser, UI update coalescing and handling (private): | 2316 // Browser, UI update coalescing and handling (private): |
2535 | 2317 |
2536 void Browser::UpdateToolbar(bool should_restore_state) { | 2318 void Browser::UpdateToolbar(bool should_restore_state) { |
2537 window_->UpdateToolbar(GetActiveTabContents(), should_restore_state); | 2319 window_->UpdateToolbar(chrome::GetActiveTabContents(this), |
| 2320 should_restore_state); |
2538 } | 2321 } |
2539 | 2322 |
2540 void Browser::UpdateSearchState(TabContents* contents) { | 2323 void Browser::UpdateSearchState(TabContents* contents) { |
2541 if (chrome::search::IsInstantExtendedAPIEnabled(profile_)) | 2324 if (chrome::search::IsInstantExtendedAPIEnabled(profile_)) |
2542 search_delegate_->OnTabActivated(contents); | 2325 search_delegate_->OnTabActivated(contents); |
2543 } | 2326 } |
2544 | 2327 |
2545 void Browser::ScheduleUIUpdate(const WebContents* source, | 2328 void Browser::ScheduleUIUpdate(const WebContents* source, |
2546 unsigned changed_flags) { | 2329 unsigned changed_flags) { |
2547 if (!source) | 2330 if (!source) |
2548 return; | 2331 return; |
2549 | 2332 |
2550 // Do some synchronous updates. | 2333 // Do some synchronous updates. |
2551 if (changed_flags & content::INVALIDATE_TYPE_URL && | 2334 if (changed_flags & content::INVALIDATE_TYPE_URL && |
2552 source == GetActiveWebContents()) { | 2335 source == chrome::GetActiveWebContents(this)) { |
2553 // Only update the URL for the current tab. Note that we do not update | 2336 // Only update the URL for the current tab. Note that we do not update |
2554 // the navigation commands since those would have already been updated | 2337 // the navigation commands since those would have already been updated |
2555 // synchronously by NavigationStateChanged. | 2338 // synchronously by NavigationStateChanged. |
2556 UpdateToolbar(false); | 2339 UpdateToolbar(false); |
2557 changed_flags &= ~content::INVALIDATE_TYPE_URL; | 2340 changed_flags &= ~content::INVALIDATE_TYPE_URL; |
2558 } | 2341 } |
2559 if (changed_flags & content::INVALIDATE_TYPE_LOAD) { | 2342 if (changed_flags & content::INVALIDATE_TYPE_LOAD) { |
2560 // Update the loading state synchronously. This is so the throbber will | 2343 // Update the loading state synchronously. This is so the throbber will |
2561 // immediately start/stop, which gives a more snappy feel. We want to do | 2344 // immediately start/stop, which gives a more snappy feel. We want to do |
2562 // this for any tab so they start & stop quickly. | 2345 // this for any tab so they start & stop quickly. |
2563 tab_strip_model_->UpdateTabContentsStateAt( | 2346 tab_strip_model_->UpdateTabContentsStateAt( |
2564 GetIndexOfController(&source->GetController()), | 2347 chrome::GetIndexOfTab(this, source), |
2565 TabStripModelObserver::LOADING_ONLY); | 2348 TabStripModelObserver::LOADING_ONLY); |
2566 // The status bubble needs to be updated during INVALIDATE_TYPE_LOAD too, | 2349 // The status bubble needs to be updated during INVALIDATE_TYPE_LOAD too, |
2567 // but we do that asynchronously by not stripping INVALIDATE_TYPE_LOAD from | 2350 // but we do that asynchronously by not stripping INVALIDATE_TYPE_LOAD from |
2568 // changed_flags. | 2351 // changed_flags. |
2569 } | 2352 } |
2570 | 2353 |
2571 if (changed_flags & content::INVALIDATE_TYPE_TITLE && !source->IsLoading()) { | 2354 if (changed_flags & content::INVALIDATE_TYPE_TITLE && !source->IsLoading()) { |
2572 // To correctly calculate whether the title changed while not loading | 2355 // To correctly calculate whether the title changed while not loading |
2573 // we need to process the update synchronously. This state only matters for | 2356 // we need to process the update synchronously. This state only matters for |
2574 // the TabStripModel, so we notify the TabStripModel now and notify others | 2357 // the TabStripModel, so we notify the TabStripModel now and notify others |
2575 // asynchronously. | 2358 // asynchronously. |
2576 tab_strip_model_->UpdateTabContentsStateAt( | 2359 tab_strip_model_->UpdateTabContentsStateAt( |
2577 GetIndexOfController(&source->GetController()), | 2360 chrome::GetIndexOfTab(this, source), |
2578 TabStripModelObserver::TITLE_NOT_LOADING); | 2361 TabStripModelObserver::TITLE_NOT_LOADING); |
2579 } | 2362 } |
2580 | 2363 |
2581 // If the only updates were synchronously handled above, we're done. | 2364 // If the only updates were synchronously handled above, we're done. |
2582 if (changed_flags == 0) | 2365 if (changed_flags == 0) |
2583 return; | 2366 return; |
2584 | 2367 |
2585 // Save the dirty bits. | 2368 // Save the dirty bits. |
2586 scheduled_updates_[source] |= changed_flags; | 2369 scheduled_updates_[source] |= changed_flags; |
2587 | 2370 |
2588 if (!chrome_updater_factory_.HasWeakPtrs()) { | 2371 if (!chrome_updater_factory_.HasWeakPtrs()) { |
2589 // No task currently scheduled, start another. | 2372 // No task currently scheduled, start another. |
2590 MessageLoop::current()->PostDelayedTask( | 2373 MessageLoop::current()->PostDelayedTask( |
2591 FROM_HERE, | 2374 FROM_HERE, |
2592 base::Bind(&Browser::ProcessPendingUIUpdates, | 2375 base::Bind(&Browser::ProcessPendingUIUpdates, |
2593 chrome_updater_factory_.GetWeakPtr()), | 2376 chrome_updater_factory_.GetWeakPtr()), |
2594 base::TimeDelta::FromMilliseconds(kUIUpdateCoalescingTimeMS)); | 2377 base::TimeDelta::FromMilliseconds(kUIUpdateCoalescingTimeMS)); |
2595 } | 2378 } |
2596 } | 2379 } |
2597 | 2380 |
2598 void Browser::ProcessPendingUIUpdates() { | 2381 void Browser::ProcessPendingUIUpdates() { |
2599 #ifndef NDEBUG | 2382 #ifndef NDEBUG |
2600 // Validate that all tabs we have pending updates for exist. This is scary | 2383 // Validate that all tabs we have pending updates for exist. This is scary |
2601 // because the pending list must be kept in sync with any detached or | 2384 // because the pending list must be kept in sync with any detached or |
2602 // deleted tabs. | 2385 // deleted tabs. |
2603 for (UpdateMap::const_iterator i = scheduled_updates_.begin(); | 2386 for (UpdateMap::const_iterator i = scheduled_updates_.begin(); |
2604 i != scheduled_updates_.end(); ++i) { | 2387 i != scheduled_updates_.end(); ++i) { |
2605 bool found = false; | 2388 bool found = false; |
2606 for (int tab = 0; tab < tab_count(); tab++) { | 2389 for (int tab = 0; tab < tab_count(); tab++) { |
2607 if (GetWebContentsAt(tab) == i->first) { | 2390 if (chrome::GetWebContentsAt(this, tab) == i->first) { |
2608 found = true; | 2391 found = true; |
2609 break; | 2392 break; |
2610 } | 2393 } |
2611 } | 2394 } |
2612 DCHECK(found); | 2395 DCHECK(found); |
2613 } | 2396 } |
2614 #endif | 2397 #endif |
2615 | 2398 |
2616 chrome_updater_factory_.InvalidateWeakPtrs(); | 2399 chrome_updater_factory_.InvalidateWeakPtrs(); |
2617 | 2400 |
2618 for (UpdateMap::const_iterator i = scheduled_updates_.begin(); | 2401 for (UpdateMap::const_iterator i = scheduled_updates_.begin(); |
2619 i != scheduled_updates_.end(); ++i) { | 2402 i != scheduled_updates_.end(); ++i) { |
2620 // Do not dereference |contents|, it may be out-of-date! | 2403 // Do not dereference |contents|, it may be out-of-date! |
2621 const WebContents* contents = i->first; | 2404 const WebContents* contents = i->first; |
2622 unsigned flags = i->second; | 2405 unsigned flags = i->second; |
2623 | 2406 |
2624 if (contents == GetActiveWebContents()) { | 2407 if (contents == chrome::GetActiveWebContents(this)) { |
2625 // Updates that only matter when the tab is selected go here. | 2408 // Updates that only matter when the tab is selected go here. |
2626 | 2409 |
2627 if (flags & content::INVALIDATE_TYPE_PAGE_ACTIONS) { | 2410 if (flags & content::INVALIDATE_TYPE_PAGE_ACTIONS) { |
2628 LocationBar* location_bar = window()->GetLocationBar(); | 2411 LocationBar* location_bar = window()->GetLocationBar(); |
2629 if (location_bar) | 2412 if (location_bar) |
2630 location_bar->UpdatePageActions(); | 2413 location_bar->UpdatePageActions(); |
2631 } | 2414 } |
2632 // Updating the URL happens synchronously in ScheduleUIUpdate. | 2415 // Updating the URL happens synchronously in ScheduleUIUpdate. |
2633 if (flags & content::INVALIDATE_TYPE_LOAD && GetStatusBubble()) { | 2416 if (flags & content::INVALIDATE_TYPE_LOAD && GetStatusBubble()) { |
2634 GetStatusBubble()->SetStatus( | 2417 GetStatusBubble()->SetStatus(chrome::GetActiveTabContents(this)-> |
2635 GetActiveTabContents()-> | 2418 core_tab_helper()->GetStatusText()); |
2636 core_tab_helper()->GetStatusText()); | |
2637 } | 2419 } |
2638 | 2420 |
2639 if (flags & (content::INVALIDATE_TYPE_TAB | | 2421 if (flags & (content::INVALIDATE_TYPE_TAB | |
2640 content::INVALIDATE_TYPE_TITLE)) { | 2422 content::INVALIDATE_TYPE_TITLE)) { |
2641 window_->UpdateTitleBar(); | 2423 window_->UpdateTitleBar(); |
2642 } | 2424 } |
2643 } | 2425 } |
2644 | 2426 |
2645 // Updates that don't depend upon the selected state go here. | 2427 // Updates that don't depend upon the selected state go here. |
2646 if (flags & | 2428 if (flags & |
(...skipping 30 matching lines...) Expand all Loading... |
2677 } | 2459 } |
2678 | 2460 |
2679 /////////////////////////////////////////////////////////////////////////////// | 2461 /////////////////////////////////////////////////////////////////////////////// |
2680 // Browser, Session restore functions (private): | 2462 // Browser, Session restore functions (private): |
2681 | 2463 |
2682 void Browser::SyncHistoryWithTabs(int index) { | 2464 void Browser::SyncHistoryWithTabs(int index) { |
2683 SessionService* session_service = | 2465 SessionService* session_service = |
2684 SessionServiceFactory::GetForProfileIfExisting(profile()); | 2466 SessionServiceFactory::GetForProfileIfExisting(profile()); |
2685 if (session_service) { | 2467 if (session_service) { |
2686 for (int i = index; i < tab_count(); ++i) { | 2468 for (int i = index; i < tab_count(); ++i) { |
2687 TabContents* tab = GetTabContentsAt(i); | 2469 TabContents* tab = chrome::GetTabContentsAt(this, i); |
2688 if (tab) { | 2470 if (tab) { |
2689 session_service->SetTabIndexInWindow( | 2471 session_service->SetTabIndexInWindow( |
2690 session_id(), tab->restore_tab_helper()->session_id(), i); | 2472 session_id(), tab->restore_tab_helper()->session_id(), i); |
2691 session_service->SetPinnedState( | 2473 session_service->SetPinnedState( |
2692 session_id(), | 2474 session_id(), |
2693 tab->restore_tab_helper()->session_id(), | 2475 tab->restore_tab_helper()->session_id(), |
2694 IsTabPinned(i)); | 2476 tab_strip_model_->IsTabPinned(i)); |
2695 } | 2477 } |
2696 } | 2478 } |
2697 } | 2479 } |
2698 } | 2480 } |
2699 | 2481 |
2700 /////////////////////////////////////////////////////////////////////////////// | 2482 /////////////////////////////////////////////////////////////////////////////// |
2701 // Browser, OnBeforeUnload handling (private): | 2483 // Browser, OnBeforeUnload handling (private): |
2702 | 2484 |
2703 void Browser::ProcessPendingTabs() { | 2485 void Browser::ProcessPendingTabs() { |
2704 if (!is_attempting_to_close_browser_) { | 2486 if (!is_attempting_to_close_browser_) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2838 window_->Close(); | 2620 window_->Close(); |
2839 } | 2621 } |
2840 | 2622 |
2841 void Browser::TabDetachedAtImpl(TabContents* contents, int index, | 2623 void Browser::TabDetachedAtImpl(TabContents* contents, int index, |
2842 DetachType type) { | 2624 DetachType type) { |
2843 if (type == DETACH_TYPE_DETACH) { | 2625 if (type == DETACH_TYPE_DETACH) { |
2844 // Save the current location bar state, but only if the tab being detached | 2626 // Save the current location bar state, but only if the tab being detached |
2845 // is the selected tab. Because saving state can conditionally revert the | 2627 // is the selected tab. Because saving state can conditionally revert the |
2846 // location bar, saving the current tab's location bar state to a | 2628 // location bar, saving the current tab's location bar state to a |
2847 // non-selected tab can corrupt both tabs. | 2629 // non-selected tab can corrupt both tabs. |
2848 if (contents == GetActiveTabContents()) { | 2630 if (contents == chrome::GetActiveTabContents(this)) { |
2849 LocationBar* location_bar = window()->GetLocationBar(); | 2631 LocationBar* location_bar = window()->GetLocationBar(); |
2850 if (location_bar) | 2632 if (location_bar) |
2851 location_bar->SaveStateToContents(contents->web_contents()); | 2633 location_bar->SaveStateToContents(contents->web_contents()); |
2852 } | 2634 } |
2853 | 2635 |
2854 if (!tab_strip_model_->closing_all()) | 2636 if (!tab_strip_model_->closing_all()) |
2855 SyncHistoryWithTabs(0); | 2637 SyncHistoryWithTabs(0); |
2856 } | 2638 } |
2857 | 2639 |
2858 SetAsDelegate(contents, NULL); | 2640 SetAsDelegate(contents, NULL); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2921 } | 2703 } |
2922 | 2704 |
2923 void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) { | 2705 void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) { |
2924 BookmarkBar::State state; | 2706 BookmarkBar::State state; |
2925 // The bookmark bar is hidden in fullscreen mode, unless on the new tab page. | 2707 // The bookmark bar is hidden in fullscreen mode, unless on the new tab page. |
2926 if (browser_defaults::bookmarks_enabled && | 2708 if (browser_defaults::bookmarks_enabled && |
2927 profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) && | 2709 profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) && |
2928 (!window_ || !window_->IsFullscreen())) { | 2710 (!window_ || !window_->IsFullscreen())) { |
2929 state = BookmarkBar::SHOW; | 2711 state = BookmarkBar::SHOW; |
2930 } else { | 2712 } else { |
2931 TabContents* tab = GetActiveTabContents(); | 2713 TabContents* tab = chrome::GetActiveTabContents(this); |
2932 if (tab && tab->bookmark_tab_helper()->ShouldShowBookmarkBar()) | 2714 if (tab && tab->bookmark_tab_helper()->ShouldShowBookmarkBar()) |
2933 state = BookmarkBar::DETACHED; | 2715 state = BookmarkBar::DETACHED; |
2934 else | 2716 else |
2935 state = BookmarkBar::HIDDEN; | 2717 state = BookmarkBar::HIDDEN; |
2936 } | 2718 } |
2937 | 2719 |
2938 // Only allow the bookmark bar to be shown in default mode. | 2720 // Only allow the bookmark bar to be shown in default mode. |
2939 if (!search_model_->mode().is_default()) | 2721 if (!search_model_->mode().is_default()) |
2940 state = BookmarkBar::HIDDEN; | 2722 state = BookmarkBar::HIDDEN; |
2941 | 2723 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3034 if (contents && !allow_js_access) { | 2816 if (contents && !allow_js_access) { |
3035 contents->web_contents()->GetController().LoadURL( | 2817 contents->web_contents()->GetController().LoadURL( |
3036 target_url, | 2818 target_url, |
3037 content::Referrer(), | 2819 content::Referrer(), |
3038 content::PAGE_TRANSITION_LINK, | 2820 content::PAGE_TRANSITION_LINK, |
3039 std::string()); // No extra headers. | 2821 std::string()); // No extra headers. |
3040 } | 2822 } |
3041 | 2823 |
3042 return contents != NULL; | 2824 return contents != NULL; |
3043 } | 2825 } |
OLD | NEW |