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 |
| 965 scoped_ptr<MediaStreamDevicesController> |
| 966 controller(new MediaStreamDevicesController(tab->profile(), |
| 967 request, |
| 968 callback)); |
| 969 if (!controller->DismissInfoBarAndTakeActionOnSettings()) { |
| 970 InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); |
| 971 InfoBarDelegate* old_infobar = NULL; |
| 972 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { |
| 973 old_infobar = infobar_helper->GetInfoBarDelegateAt(i)-> |
| 974 AsMediaStreamInfoBarDelegate(); |
| 975 if (old_infobar) |
| 976 break; |
| 977 } |
| 978 |
| 979 InfoBarDelegate* infobar = |
| 980 new MediaStreamInfoBarDelegate(infobar_helper, controller.release()); |
| 981 if (old_infobar) |
| 982 infobar_helper->ReplaceInfoBar(old_infobar, infobar); |
| 983 else |
| 984 infobar_helper->AddInfoBar(infobar); |
| 985 } |
| 986 } |
| 987 |
958 void Browser::UpdateUIForNavigationInTab(TabContents* contents, | 988 void Browser::UpdateUIForNavigationInTab(TabContents* contents, |
959 content::PageTransition transition, | 989 content::PageTransition transition, |
960 bool user_initiated) { | 990 bool user_initiated) { |
961 tab_strip_model_->TabNavigating(contents, transition); | 991 tab_strip_model_->TabNavigating(contents, transition); |
962 | 992 |
963 bool contents_is_selected = contents == chrome::GetActiveTabContents(this); | 993 bool contents_is_selected = contents == chrome::GetActiveTabContents(this); |
964 if (user_initiated && contents_is_selected && window()->GetLocationBar()) { | 994 if (user_initiated && contents_is_selected && window()->GetLocationBar()) { |
965 // Forcibly reset the location bar if the url is going to change in the | 995 // 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, | 996 // current tab, since otherwise it won't discard any ongoing user edits, |
967 // since it doesn't realize this is a user-initiated action. | 997 // 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 } | 1935 } |
1906 | 1936 |
1907 void Browser::LostMouseLock() { | 1937 void Browser::LostMouseLock() { |
1908 fullscreen_controller_->LostMouseLock(); | 1938 fullscreen_controller_->LostMouseLock(); |
1909 } | 1939 } |
1910 | 1940 |
1911 void Browser::RequestMediaAccessPermission( | 1941 void Browser::RequestMediaAccessPermission( |
1912 content::WebContents* web_contents, | 1942 content::WebContents* web_contents, |
1913 const content::MediaStreamRequest* request, | 1943 const content::MediaStreamRequest* request, |
1914 const content::MediaResponseCallback& callback) { | 1944 const content::MediaResponseCallback& callback) { |
1915 TabContents* tab = TabContents::FromWebContents(web_contents); | 1945 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 } | 1946 } |
1940 | 1947 |
1941 /////////////////////////////////////////////////////////////////////////////// | 1948 /////////////////////////////////////////////////////////////////////////////// |
1942 // Browser, CoreTabHelperDelegate implementation: | 1949 // Browser, CoreTabHelperDelegate implementation: |
1943 | 1950 |
1944 void Browser::SwapTabContents(TabContents* old_tab_contents, | 1951 void Browser::SwapTabContents(TabContents* old_tab_contents, |
1945 TabContents* new_tab_contents) { | 1952 TabContents* new_tab_contents) { |
1946 int index = tab_strip_model_->GetIndexOfTabContents(old_tab_contents); | 1953 int index = tab_strip_model_->GetIndexOfTabContents(old_tab_contents); |
1947 DCHECK_NE(TabStripModel::kNoTab, index); | 1954 DCHECK_NE(TabStripModel::kNoTab, index); |
1948 tab_strip_model_->ReplaceTabContentsAt(index, new_tab_contents); | 1955 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) { | 2738 if (contents && !allow_js_access) { |
2732 contents->web_contents()->GetController().LoadURL( | 2739 contents->web_contents()->GetController().LoadURL( |
2733 target_url, | 2740 target_url, |
2734 content::Referrer(), | 2741 content::Referrer(), |
2735 content::PAGE_TRANSITION_LINK, | 2742 content::PAGE_TRANSITION_LINK, |
2736 std::string()); // No extra headers. | 2743 std::string()); // No extra headers. |
2737 } | 2744 } |
2738 | 2745 |
2739 return contents != NULL; | 2746 return contents != NULL; |
2740 } | 2747 } |
OLD | NEW |