| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 | 955 |
| 956 /////////////////////////////////////////////////////////////////////////////// | 956 /////////////////////////////////////////////////////////////////////////////// |
| 957 // Browser, TabStripModelObserver implementation: | 957 // Browser, TabStripModelObserver implementation: |
| 958 | 958 |
| 959 void Browser::TabInsertedAt(TabStripModel* tab_strip_model, | 959 void Browser::TabInsertedAt(TabStripModel* tab_strip_model, |
| 960 WebContents* contents, | 960 WebContents* contents, |
| 961 int index, | 961 int index, |
| 962 bool foreground) { | 962 bool foreground) { |
| 963 SetAsDelegate(contents, true); | 963 SetAsDelegate(contents, true); |
| 964 | 964 |
| 965 SessionTabHelper* session_tab_helper = | 965 SessionTabHelper::FromWebContents(contents)->SetWindowID(session_id()); |
| 966 SessionTabHelper::FromWebContents(contents); | 966 |
| 967 session_tab_helper->SetWindowID(session_id()); | 967 SearchTabHelper::FromWebContents(contents)->OnTabAttachedToWindow(window_); |
| 968 | 968 |
| 969 content::NotificationService::current()->Notify( | 969 content::NotificationService::current()->Notify( |
| 970 chrome::NOTIFICATION_TAB_PARENTED, | 970 chrome::NOTIFICATION_TAB_PARENTED, |
| 971 content::Source<content::WebContents>(contents), | 971 content::Source<content::WebContents>(contents), |
| 972 content::NotificationService::NoDetails()); | 972 content::NotificationService::NoDetails()); |
| 973 | 973 |
| 974 SyncHistoryWithTabs(index); | 974 SyncHistoryWithTabs(index); |
| 975 | 975 |
| 976 // Make sure the loading state is updated correctly, otherwise the throbber | 976 // Make sure the loading state is updated correctly, otherwise the throbber |
| 977 // won't start if the page is loading. | 977 // won't start if the page is loading. |
| (...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1976 | 1976 |
| 1977 bool Browser::CanReloadContents(content::WebContents* web_contents) const { | 1977 bool Browser::CanReloadContents(content::WebContents* web_contents) const { |
| 1978 return chrome::CanReload(this); | 1978 return chrome::CanReload(this); |
| 1979 } | 1979 } |
| 1980 | 1980 |
| 1981 bool Browser::CanSaveContents(content::WebContents* web_contents) const { | 1981 bool Browser::CanSaveContents(content::WebContents* web_contents) const { |
| 1982 return chrome::CanSavePage(this); | 1982 return chrome::CanSavePage(this); |
| 1983 } | 1983 } |
| 1984 | 1984 |
| 1985 /////////////////////////////////////////////////////////////////////////////// | 1985 /////////////////////////////////////////////////////////////////////////////// |
| 1986 // Browser, SearchTabHelperDelegate implementation: | |
| 1987 | |
| 1988 OmniboxView* Browser::GetOmniboxView() { | |
| 1989 return window_->GetLocationBar()->GetOmniboxView(); | |
| 1990 } | |
| 1991 | |
| 1992 /////////////////////////////////////////////////////////////////////////////// | |
| 1993 // Browser, web_modal::WebContentsModalDialogManagerDelegate implementation: | 1986 // Browser, web_modal::WebContentsModalDialogManagerDelegate implementation: |
| 1994 | 1987 |
| 1995 void Browser::SetWebContentsBlocked(content::WebContents* web_contents, | 1988 void Browser::SetWebContentsBlocked(content::WebContents* web_contents, |
| 1996 bool blocked) { | 1989 bool blocked) { |
| 1997 int index = tab_strip_model_->GetIndexOfWebContents(web_contents); | 1990 int index = tab_strip_model_->GetIndexOfWebContents(web_contents); |
| 1998 if (index == TabStripModel::kNoTab) { | 1991 if (index == TabStripModel::kNoTab) { |
| 1999 NOTREACHED(); | 1992 NOTREACHED(); |
| 2000 return; | 1993 return; |
| 2001 } | 1994 } |
| 2002 tab_strip_model_->SetTabBlocked(index, blocked); | 1995 tab_strip_model_->SetTabBlocked(index, blocked); |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2422 void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) { | 2415 void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) { |
| 2423 Browser* delegate = set_delegate ? this : NULL; | 2416 Browser* delegate = set_delegate ? this : NULL; |
| 2424 // WebContents... | 2417 // WebContents... |
| 2425 web_contents->SetDelegate(delegate); | 2418 web_contents->SetDelegate(delegate); |
| 2426 | 2419 |
| 2427 // ...and all the helpers. | 2420 // ...and all the helpers. |
| 2428 BookmarkTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2421 BookmarkTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
| 2429 WebContentsModalDialogManager::FromWebContents(web_contents)-> | 2422 WebContentsModalDialogManager::FromWebContents(web_contents)-> |
| 2430 SetDelegate(delegate); | 2423 SetDelegate(delegate); |
| 2431 CoreTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2424 CoreTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
| 2432 SearchTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | |
| 2433 translate::ContentTranslateDriver& content_translate_driver = | 2425 translate::ContentTranslateDriver& content_translate_driver = |
| 2434 ChromeTranslateClient::FromWebContents(web_contents)->translate_driver(); | 2426 ChromeTranslateClient::FromWebContents(web_contents)->translate_driver(); |
| 2435 if (delegate) { | 2427 if (delegate) { |
| 2436 zoom::ZoomController::FromWebContents(web_contents)->AddObserver(this); | 2428 zoom::ZoomController::FromWebContents(web_contents)->AddObserver(this); |
| 2437 content_translate_driver.AddObserver(this); | 2429 content_translate_driver.AddObserver(this); |
| 2438 } else { | 2430 } else { |
| 2439 zoom::ZoomController::FromWebContents(web_contents)->RemoveObserver(this); | 2431 zoom::ZoomController::FromWebContents(web_contents)->RemoveObserver(this); |
| 2440 content_translate_driver.RemoveObserver(this); | 2432 content_translate_driver.RemoveObserver(this); |
| 2441 } | 2433 } |
| 2442 } | 2434 } |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2671 // new window later, thus we need to navigate the window now. | 2663 // new window later, thus we need to navigate the window now. |
| 2672 if (contents) { | 2664 if (contents) { |
| 2673 contents->web_contents()->GetController().LoadURL( | 2665 contents->web_contents()->GetController().LoadURL( |
| 2674 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, | 2666 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, |
| 2675 std::string()); // No extra headers. | 2667 std::string()); // No extra headers. |
| 2676 } | 2668 } |
| 2677 } | 2669 } |
| 2678 | 2670 |
| 2679 return contents != NULL; | 2671 return contents != NULL; |
| 2680 } | 2672 } |
| OLD | NEW |