OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
10 #include "chrome/browser/dom_operation_notification_details.h" | 10 #include "chrome/browser/dom_operation_notification_details.h" |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 void SetInfobarResponse(const GURL& requesting_url, bool allowed) { | 310 void SetInfobarResponse(const GURL& requesting_url, bool allowed) { |
311 TabContentsWrapper* tab_contents_wrapper = | 311 TabContentsWrapper* tab_contents_wrapper = |
312 current_browser_->GetSelectedTabContentsWrapper(); | 312 current_browser_->GetSelectedTabContentsWrapper(); |
313 TabSpecificContentSettings* content_settings = | 313 TabSpecificContentSettings* content_settings = |
314 tab_contents_wrapper->content_settings(); | 314 tab_contents_wrapper->content_settings(); |
315 const GeolocationSettingsState& settings_state = | 315 const GeolocationSettingsState& settings_state = |
316 content_settings->geolocation_settings_state(); | 316 content_settings->geolocation_settings_state(); |
317 size_t state_map_size = settings_state.state_map().size(); | 317 size_t state_map_size = settings_state.state_map().size(); |
318 ASSERT_TRUE(infobar_); | 318 ASSERT_TRUE(infobar_); |
319 LOG(WARNING) << "will set infobar response"; | 319 LOG(WARNING) << "will set infobar response"; |
320 { | 320 if (allowed) |
321 ui_test_utils::WindowedNotificationObserver observer( | 321 infobar_->AsConfirmInfoBarDelegate()->Accept(); |
322 content::NOTIFICATION_LOAD_STOP, | 322 else |
323 Source<NavigationController>(&tab_contents_wrapper->controller())); | 323 infobar_->AsConfirmInfoBarDelegate()->Cancel(); |
324 if (allowed) | 324 WaitForNavigation(); |
325 infobar_->AsConfirmInfoBarDelegate()->Accept(); | |
326 else | |
327 infobar_->AsConfirmInfoBarDelegate()->Cancel(); | |
328 observer.Wait(); | |
329 } | |
330 | |
331 tab_contents_wrapper->RemoveInfoBar(infobar_); | 325 tab_contents_wrapper->RemoveInfoBar(infobar_); |
332 LOG(WARNING) << "infobar response set"; | 326 LOG(WARNING) << "infobar response set"; |
333 infobar_ = NULL; | 327 infobar_ = NULL; |
334 EXPECT_GT(settings_state.state_map().size(), state_map_size); | 328 EXPECT_GT(settings_state.state_map().size(), state_map_size); |
335 GURL requesting_origin = requesting_url.GetOrigin(); | 329 GURL requesting_origin = requesting_url.GetOrigin(); |
336 EXPECT_EQ(1U, settings_state.state_map().count(requesting_origin)); | 330 EXPECT_EQ(1U, settings_state.state_map().count(requesting_origin)); |
337 ContentSetting expected_setting = | 331 ContentSetting expected_setting = |
338 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; | 332 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
339 EXPECT_EQ(expected_setting, | 333 EXPECT_EQ(expected_setting, |
340 settings_state.state_map().find(requesting_origin)->second); | 334 settings_state.state_map().find(requesting_origin)->second); |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 "window.domAutomationController.setAutomationId(0);" | 649 "window.domAutomationController.setAutomationId(0);" |
656 "window.domAutomationController.send(window.close());"; | 650 "window.domAutomationController.send(window.close());"; |
657 bool result = | 651 bool result = |
658 ui_test_utils::ExecuteJavaScript( | 652 ui_test_utils::ExecuteJavaScript( |
659 current_browser_->GetSelectedTabContents()->render_view_host(), | 653 current_browser_->GetSelectedTabContents()->render_view_host(), |
660 L"", UTF8ToWide(script)); | 654 L"", UTF8ToWide(script)); |
661 EXPECT_EQ(result, true); | 655 EXPECT_EQ(result, true); |
662 } | 656 } |
663 | 657 |
664 } // namespace | 658 } // namespace |
OLD | NEW |