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 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
948 if (!tab_contents || !tab_contents->find_tab_helper()) | 948 if (!tab_contents || !tab_contents->find_tab_helper()) |
949 return; | 949 return; |
950 | 950 |
951 tab_contents->find_tab_helper()->HandleFindReply(request_id, | 951 tab_contents->find_tab_helper()->HandleFindReply(request_id, |
952 number_of_matches, | 952 number_of_matches, |
953 selection_rect, | 953 selection_rect, |
954 active_match_ordinal, | 954 active_match_ordinal, |
955 final_update); | 955 final_update); |
956 } | 956 } |
957 | 957 |
958 // static | |
959 void Browser::RequestMediaAccessPermissionHelper( | |
960 content::WebContents* web_contents, | |
961 const content::MediaStreamRequest* request, | |
962 const content::MediaResponseCallback& callback) { | |
963 TabContents* tab = TabContents::FromWebContents(web_contents); | |
964 DCHECK(tab); | |
tommi (sloooow) - chröme
2012/07/06 22:17:09
nit: dcheck not needed since tab is dereferenced a
grt (UTC plus 2)
2012/07/06 23:07:25
Done.
| |
965 | |
966 scoped_ptr<MediaStreamDevicesController> | |
967 controller(new MediaStreamDevicesController(tab->profile(), | |
968 request, | |
969 callback)); | |
970 if (!controller->DismissInfoBarAndTakeActionOnSettings()) { | |
971 InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); | |
972 InfoBarDelegate* old_infobar = NULL; | |
973 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { | |
974 old_infobar = infobar_helper->GetInfoBarDelegateAt(i)-> | |
975 AsMediaStreamInfoBarDelegate(); | |
976 if (old_infobar) | |
977 break; | |
978 } | |
979 | |
980 InfoBarDelegate* infobar = | |
981 new MediaStreamInfoBarDelegate(infobar_helper, controller.release()); | |
982 if (old_infobar) | |
983 infobar_helper->ReplaceInfoBar(old_infobar, infobar); | |
984 else | |
985 infobar_helper->AddInfoBar(infobar); | |
986 } | |
987 } | |
988 | |
958 void Browser::UpdateUIForNavigationInTab(TabContents* contents, | 989 void Browser::UpdateUIForNavigationInTab(TabContents* contents, |
959 content::PageTransition transition, | 990 content::PageTransition transition, |
960 bool user_initiated) { | 991 bool user_initiated) { |
961 tab_strip_model_->TabNavigating(contents, transition); | 992 tab_strip_model_->TabNavigating(contents, transition); |
962 | 993 |
963 bool contents_is_selected = contents == chrome::GetActiveTabContents(this); | 994 bool contents_is_selected = contents == chrome::GetActiveTabContents(this); |
964 if (user_initiated && contents_is_selected && window()->GetLocationBar()) { | 995 if (user_initiated && contents_is_selected && window()->GetLocationBar()) { |
965 // Forcibly reset the location bar if the url is going to change in the | 996 // Forcibly reset the location bar if the url is going to change in the |
966 // current tab, since otherwise it won't discard any ongoing user edits, | 997 // current tab, since otherwise it won't discard any ongoing user edits, |
967 // since it doesn't realize this is a user-initiated action. | 998 // since it doesn't realize this is a user-initiated action. |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1905 } | 1936 } |
1906 | 1937 |
1907 void Browser::LostMouseLock() { | 1938 void Browser::LostMouseLock() { |
1908 fullscreen_controller_->LostMouseLock(); | 1939 fullscreen_controller_->LostMouseLock(); |
1909 } | 1940 } |
1910 | 1941 |
1911 void Browser::RequestMediaAccessPermission( | 1942 void Browser::RequestMediaAccessPermission( |
1912 content::WebContents* web_contents, | 1943 content::WebContents* web_contents, |
1913 const content::MediaStreamRequest* request, | 1944 const content::MediaStreamRequest* request, |
1914 const content::MediaResponseCallback& callback) { | 1945 const content::MediaResponseCallback& callback) { |
1915 TabContents* tab = TabContents::FromWebContents(web_contents); | 1946 RequestMediaAccessPermissionHelper(web_contents, request, callback); |
1916 DCHECK(tab); | |
1917 | |
1918 scoped_ptr<MediaStreamDevicesController> | |
1919 controller(new MediaStreamDevicesController(tab->profile(), | |
1920 request, | |
1921 callback)); | |
1922 if (!controller->DismissInfoBarAndTakeActionOnSettings()) { | |
1923 InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); | |
1924 InfoBarDelegate* old_infobar = NULL; | |
1925 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { | |
1926 old_infobar = infobar_helper->GetInfoBarDelegateAt(i)-> | |
1927 AsMediaStreamInfoBarDelegate(); | |
1928 if (old_infobar) | |
1929 break; | |
1930 } | |
1931 | |
1932 InfoBarDelegate* infobar = | |
1933 new MediaStreamInfoBarDelegate(infobar_helper, controller.release()); | |
1934 if (old_infobar) | |
1935 infobar_helper->ReplaceInfoBar(old_infobar, infobar); | |
1936 else | |
1937 infobar_helper->AddInfoBar(infobar); | |
1938 } | |
1939 } | 1947 } |
1940 | 1948 |
1941 /////////////////////////////////////////////////////////////////////////////// | 1949 /////////////////////////////////////////////////////////////////////////////// |
1942 // Browser, CoreTabHelperDelegate implementation: | 1950 // Browser, CoreTabHelperDelegate implementation: |
1943 | 1951 |
1944 void Browser::SwapTabContents(TabContents* old_tab_contents, | 1952 void Browser::SwapTabContents(TabContents* old_tab_contents, |
1945 TabContents* new_tab_contents) { | 1953 TabContents* new_tab_contents) { |
1946 int index = tab_strip_model_->GetIndexOfTabContents(old_tab_contents); | 1954 int index = tab_strip_model_->GetIndexOfTabContents(old_tab_contents); |
1947 DCHECK_NE(TabStripModel::kNoTab, index); | 1955 DCHECK_NE(TabStripModel::kNoTab, index); |
1948 tab_strip_model_->ReplaceTabContentsAt(index, new_tab_contents); | 1956 tab_strip_model_->ReplaceTabContentsAt(index, new_tab_contents); |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2731 if (contents && !allow_js_access) { | 2739 if (contents && !allow_js_access) { |
2732 contents->web_contents()->GetController().LoadURL( | 2740 contents->web_contents()->GetController().LoadURL( |
2733 target_url, | 2741 target_url, |
2734 content::Referrer(), | 2742 content::Referrer(), |
2735 content::PAGE_TRANSITION_LINK, | 2743 content::PAGE_TRANSITION_LINK, |
2736 std::string()); // No extra headers. | 2744 std::string()); // No extra headers. |
2737 } | 2745 } |
2738 | 2746 |
2739 return contents != NULL; | 2747 return contents != NULL; |
2740 } | 2748 } |
OLD | NEW |