| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/geolocation/geolocation_permission_context.h" | 5 #include "chrome/browser/geolocation/geolocation_permission_context.h" |
| 6 | 6 |
| 7 #include "base/scoped_vector.h" | 7 #include "base/scoped_vector.h" |
| 8 #include "chrome/browser/geolocation/location_arbitrator.h" | 8 #include "chrome/browser/geolocation/location_arbitrator.h" |
| 9 #include "chrome/browser/geolocation/location_provider.h" | 9 #include "chrome/browser/geolocation/location_provider.h" |
| 10 #include "chrome/browser/geolocation/mock_location_provider.h" | 10 #include "chrome/browser/geolocation/mock_location_provider.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // Request permission for two frames. | 177 // Request permission for two frames. |
| 178 geolocation_permission_context_->RequestGeolocationPermission( | 178 geolocation_permission_context_->RequestGeolocationPermission( |
| 179 process_id(), render_id(), bridge_id(), requesting_frame_0); | 179 process_id(), render_id(), bridge_id(), requesting_frame_0); |
| 180 geolocation_permission_context_->RequestGeolocationPermission( | 180 geolocation_permission_context_->RequestGeolocationPermission( |
| 181 process_id(), render_id(), bridge_id() + 1, requesting_frame_1); | 181 process_id(), render_id(), bridge_id() + 1, requesting_frame_1); |
| 182 // Ensure only one infobar is created. | 182 // Ensure only one infobar is created. |
| 183 EXPECT_EQ(1, contents()->infobar_delegate_count()); | 183 EXPECT_EQ(1, contents()->infobar_delegate_count()); |
| 184 ConfirmInfoBarDelegate* infobar_0 = | 184 ConfirmInfoBarDelegate* infobar_0 = |
| 185 contents()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); | 185 contents()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
| 186 ASSERT_TRUE(infobar_0); | 186 ASSERT_TRUE(infobar_0); |
| 187 std::wstring text_0 = infobar_0->GetMessageText(); | 187 string16 text_0 = infobar_0->GetMessageText(); |
| 188 | 188 |
| 189 // Accept the first frame. | 189 // Accept the first frame. |
| 190 infobar_0->Accept(); | 190 infobar_0->Accept(); |
| 191 CheckTabContentsState(requesting_frame_0, CONTENT_SETTING_ALLOW); | 191 CheckTabContentsState(requesting_frame_0, CONTENT_SETTING_ALLOW); |
| 192 CheckPermissionMessageSent(bridge_id(), true); | 192 CheckPermissionMessageSent(bridge_id(), true); |
| 193 | 193 |
| 194 contents()->RemoveInfoBar(infobar_0); | 194 contents()->RemoveInfoBar(infobar_0); |
| 195 EXPECT_EQ(infobar_0, | 195 EXPECT_EQ(infobar_0, |
| 196 tab_contents_with_pending_infobar_->removed_infobar_delegate_); | 196 tab_contents_with_pending_infobar_->removed_infobar_delegate_); |
| 197 infobar_0->InfoBarClosed(); | 197 infobar_0->InfoBarClosed(); |
| 198 // Now we should have a new infobar for the second frame. | 198 // Now we should have a new infobar for the second frame. |
| 199 EXPECT_EQ(1, contents()->infobar_delegate_count()); | 199 EXPECT_EQ(1, contents()->infobar_delegate_count()); |
| 200 | 200 |
| 201 ConfirmInfoBarDelegate* infobar_1 = | 201 ConfirmInfoBarDelegate* infobar_1 = |
| 202 contents()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); | 202 contents()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
| 203 ASSERT_TRUE(infobar_1); | 203 ASSERT_TRUE(infobar_1); |
| 204 std::wstring text_1 = infobar_1->GetMessageText(); | 204 string16 text_1 = infobar_1->GetMessageText(); |
| 205 EXPECT_NE(text_0, text_1); | 205 EXPECT_NE(text_0, text_1); |
| 206 | 206 |
| 207 // Cancel (block) this frame. | 207 // Cancel (block) this frame. |
| 208 infobar_1->Cancel(); | 208 infobar_1->Cancel(); |
| 209 CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_BLOCK); | 209 CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_BLOCK); |
| 210 CheckPermissionMessageSent(bridge_id() + 1, false); | 210 CheckPermissionMessageSent(bridge_id() + 1, false); |
| 211 contents()->RemoveInfoBar(infobar_1); | 211 contents()->RemoveInfoBar(infobar_1); |
| 212 EXPECT_EQ(infobar_1, | 212 EXPECT_EQ(infobar_1, |
| 213 tab_contents_with_pending_infobar_->removed_infobar_delegate_); | 213 tab_contents_with_pending_infobar_->removed_infobar_delegate_); |
| 214 infobar_1->InfoBarClosed(); | 214 infobar_1->InfoBarClosed(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 241 // Request permission for two frames. | 241 // Request permission for two frames. |
| 242 geolocation_permission_context_->RequestGeolocationPermission( | 242 geolocation_permission_context_->RequestGeolocationPermission( |
| 243 process_id(), render_id(), bridge_id(), requesting_frame_0); | 243 process_id(), render_id(), bridge_id(), requesting_frame_0); |
| 244 geolocation_permission_context_->RequestGeolocationPermission( | 244 geolocation_permission_context_->RequestGeolocationPermission( |
| 245 process_id(), render_id(), bridge_id() + 1, requesting_frame_1); | 245 process_id(), render_id(), bridge_id() + 1, requesting_frame_1); |
| 246 EXPECT_EQ(1, contents()->infobar_delegate_count()); | 246 EXPECT_EQ(1, contents()->infobar_delegate_count()); |
| 247 | 247 |
| 248 ConfirmInfoBarDelegate* infobar_0 = | 248 ConfirmInfoBarDelegate* infobar_0 = |
| 249 contents()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); | 249 contents()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
| 250 ASSERT_TRUE(infobar_0); | 250 ASSERT_TRUE(infobar_0); |
| 251 std::wstring text_0 = infobar_0->GetMessageText(); | 251 string16 text_0 = infobar_0->GetMessageText(); |
| 252 | 252 |
| 253 // Simulate the frame going away, ensure the infobar for this frame | 253 // Simulate the frame going away, ensure the infobar for this frame |
| 254 // is removed and the next pending infobar is created. | 254 // is removed and the next pending infobar is created. |
| 255 geolocation_permission_context_->CancelGeolocationPermissionRequest( | 255 geolocation_permission_context_->CancelGeolocationPermissionRequest( |
| 256 process_id(), render_id(), bridge_id(), requesting_frame_0); | 256 process_id(), render_id(), bridge_id(), requesting_frame_0); |
| 257 EXPECT_EQ(infobar_0, | 257 EXPECT_EQ(infobar_0, |
| 258 tab_contents_with_pending_infobar_->removed_infobar_delegate_); | 258 tab_contents_with_pending_infobar_->removed_infobar_delegate_); |
| 259 infobar_0->InfoBarClosed(); | 259 infobar_0->InfoBarClosed(); |
| 260 EXPECT_EQ(1, contents()->infobar_delegate_count()); | 260 EXPECT_EQ(1, contents()->infobar_delegate_count()); |
| 261 | 261 |
| 262 ConfirmInfoBarDelegate* infobar_1 = | 262 ConfirmInfoBarDelegate* infobar_1 = |
| 263 contents()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); | 263 contents()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
| 264 ASSERT_TRUE(infobar_1); | 264 ASSERT_TRUE(infobar_1); |
| 265 std::wstring text_1 = infobar_1->GetMessageText(); | 265 string16 text_1 = infobar_1->GetMessageText(); |
| 266 EXPECT_NE(text_0, text_1); | 266 EXPECT_NE(text_0, text_1); |
| 267 | 267 |
| 268 // Allow this frame. | 268 // Allow this frame. |
| 269 infobar_1->Accept(); | 269 infobar_1->Accept(); |
| 270 CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_ALLOW); | 270 CheckTabContentsState(requesting_frame_1, CONTENT_SETTING_ALLOW); |
| 271 CheckPermissionMessageSent(bridge_id() + 1, true); | 271 CheckPermissionMessageSent(bridge_id() + 1, true); |
| 272 contents()->RemoveInfoBar(infobar_1); | 272 contents()->RemoveInfoBar(infobar_1); |
| 273 EXPECT_EQ(infobar_1, | 273 EXPECT_EQ(infobar_1, |
| 274 tab_contents_with_pending_infobar_->removed_infobar_delegate_); | 274 tab_contents_with_pending_infobar_->removed_infobar_delegate_); |
| 275 infobar_1->InfoBarClosed(); | 275 infobar_1->InfoBarClosed(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 ASSERT_TRUE(infobar_1); | 410 ASSERT_TRUE(infobar_1); |
| 411 infobar_1->Accept(); | 411 infobar_1->Accept(); |
| 412 CheckPermissionMessageSentForTab(0, bridge_id() + 1, true); | 412 CheckPermissionMessageSentForTab(0, bridge_id() + 1, true); |
| 413 extra_tabs_[0]->RemoveInfoBar(infobar_1); | 413 extra_tabs_[0]->RemoveInfoBar(infobar_1); |
| 414 EXPECT_EQ(infobar_1, | 414 EXPECT_EQ(infobar_1, |
| 415 extra_tabs_[0]->removed_infobar_delegate_); | 415 extra_tabs_[0]->removed_infobar_delegate_); |
| 416 infobar_1->InfoBarClosed(); | 416 infobar_1->InfoBarClosed(); |
| 417 | 417 |
| 418 extra_tabs_.reset(); | 418 extra_tabs_.reset(); |
| 419 } | 419 } |
| OLD | NEW |