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 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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* session_tab_helper = |
966 SessionTabHelper::FromWebContents(contents); | 966 SessionTabHelper::FromWebContents(contents); |
967 session_tab_helper->SetWindowID(session_id()); | 967 session_tab_helper->SetWindowID(session_id()); |
968 | 968 |
969 SearchTabHelper* search_tab_helper = | |
970 SearchTabHelper::FromWebContents(contents); | |
Peter Kasting
2017/03/10 10:19:57
Nit: Or could inline into next line
Marc Treib
2017/03/10 11:30:03
Sure, done.
(I was copying the style from SessionT
| |
971 search_tab_helper->SetOmniboxView( | |
972 window_->GetLocationBar()->GetOmniboxView()); | |
973 | |
969 content::NotificationService::current()->Notify( | 974 content::NotificationService::current()->Notify( |
970 chrome::NOTIFICATION_TAB_PARENTED, | 975 chrome::NOTIFICATION_TAB_PARENTED, |
971 content::Source<content::WebContents>(contents), | 976 content::Source<content::WebContents>(contents), |
972 content::NotificationService::NoDetails()); | 977 content::NotificationService::NoDetails()); |
973 | 978 |
974 SyncHistoryWithTabs(index); | 979 SyncHistoryWithTabs(index); |
975 | 980 |
976 // Make sure the loading state is updated correctly, otherwise the throbber | 981 // Make sure the loading state is updated correctly, otherwise the throbber |
977 // won't start if the page is loading. | 982 // won't start if the page is loading. |
978 LoadingStateChanged(contents, true); | 983 LoadingStateChanged(contents, true); |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1976 | 1981 |
1977 bool Browser::CanReloadContents(content::WebContents* web_contents) const { | 1982 bool Browser::CanReloadContents(content::WebContents* web_contents) const { |
1978 return chrome::CanReload(this); | 1983 return chrome::CanReload(this); |
1979 } | 1984 } |
1980 | 1985 |
1981 bool Browser::CanSaveContents(content::WebContents* web_contents) const { | 1986 bool Browser::CanSaveContents(content::WebContents* web_contents) const { |
1982 return chrome::CanSavePage(this); | 1987 return chrome::CanSavePage(this); |
1983 } | 1988 } |
1984 | 1989 |
1985 /////////////////////////////////////////////////////////////////////////////// | 1990 /////////////////////////////////////////////////////////////////////////////// |
1986 // Browser, SearchTabHelperDelegate implementation: | |
1987 | |
1988 OmniboxView* Browser::GetOmniboxView() { | |
1989 return window_->GetLocationBar()->GetOmniboxView(); | |
1990 } | |
1991 | |
1992 /////////////////////////////////////////////////////////////////////////////// | |
1993 // Browser, web_modal::WebContentsModalDialogManagerDelegate implementation: | 1991 // Browser, web_modal::WebContentsModalDialogManagerDelegate implementation: |
1994 | 1992 |
1995 void Browser::SetWebContentsBlocked(content::WebContents* web_contents, | 1993 void Browser::SetWebContentsBlocked(content::WebContents* web_contents, |
1996 bool blocked) { | 1994 bool blocked) { |
1997 int index = tab_strip_model_->GetIndexOfWebContents(web_contents); | 1995 int index = tab_strip_model_->GetIndexOfWebContents(web_contents); |
1998 if (index == TabStripModel::kNoTab) { | 1996 if (index == TabStripModel::kNoTab) { |
1999 NOTREACHED(); | 1997 NOTREACHED(); |
2000 return; | 1998 return; |
2001 } | 1999 } |
2002 tab_strip_model_->SetTabBlocked(index, blocked); | 2000 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) { | 2420 void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) { |
2423 Browser* delegate = set_delegate ? this : NULL; | 2421 Browser* delegate = set_delegate ? this : NULL; |
2424 // WebContents... | 2422 // WebContents... |
2425 web_contents->SetDelegate(delegate); | 2423 web_contents->SetDelegate(delegate); |
2426 | 2424 |
2427 // ...and all the helpers. | 2425 // ...and all the helpers. |
2428 BookmarkTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2426 BookmarkTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
2429 WebContentsModalDialogManager::FromWebContents(web_contents)-> | 2427 WebContentsModalDialogManager::FromWebContents(web_contents)-> |
2430 SetDelegate(delegate); | 2428 SetDelegate(delegate); |
2431 CoreTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2429 CoreTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
2432 SearchTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | |
2433 translate::ContentTranslateDriver& content_translate_driver = | 2430 translate::ContentTranslateDriver& content_translate_driver = |
2434 ChromeTranslateClient::FromWebContents(web_contents)->translate_driver(); | 2431 ChromeTranslateClient::FromWebContents(web_contents)->translate_driver(); |
2435 if (delegate) { | 2432 if (delegate) { |
2436 zoom::ZoomController::FromWebContents(web_contents)->AddObserver(this); | 2433 zoom::ZoomController::FromWebContents(web_contents)->AddObserver(this); |
2437 content_translate_driver.AddObserver(this); | 2434 content_translate_driver.AddObserver(this); |
2438 } else { | 2435 } else { |
2439 zoom::ZoomController::FromWebContents(web_contents)->RemoveObserver(this); | 2436 zoom::ZoomController::FromWebContents(web_contents)->RemoveObserver(this); |
2440 content_translate_driver.RemoveObserver(this); | 2437 content_translate_driver.RemoveObserver(this); |
2441 } | 2438 } |
2442 } | 2439 } |
(...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. | 2668 // new window later, thus we need to navigate the window now. |
2672 if (contents) { | 2669 if (contents) { |
2673 contents->web_contents()->GetController().LoadURL( | 2670 contents->web_contents()->GetController().LoadURL( |
2674 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, | 2671 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, |
2675 std::string()); // No extra headers. | 2672 std::string()); // No extra headers. |
2676 } | 2673 } |
2677 } | 2674 } |
2678 | 2675 |
2679 return contents != NULL; | 2676 return contents != NULL; |
2680 } | 2677 } |
OLD | NEW |