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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/content_settings/content_settings_usages_state.h" | 12 #include "chrome/browser/content_settings/content_settings_usages_state.h" |
13 #include "chrome/browser/content_settings/host_content_settings_map.h" | 13 #include "chrome/browser/content_settings/host_content_settings_map.h" |
14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
15 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 15 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
16 #include "chrome/browser/infobars/infobar.h" | |
17 #include "chrome/browser/infobars/infobar_service.h" | 16 #include "chrome/browser/infobars/infobar_service.h" |
18 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/browser_commands.h" | 19 #include "chrome/browser/ui/browser_commands.h" |
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
22 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
23 #include "chrome/common/content_settings_pattern.h" | 22 #include "chrome/common/content_settings_pattern.h" |
24 #include "chrome/test/base/in_process_browser_test.h" | 23 #include "chrome/test/base/in_process_browser_test.h" |
25 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
| 25 #include "components/infobars/core/infobar.h" |
26 #include "content/public/browser/dom_operation_notification_details.h" | 26 #include "content/public/browser/dom_operation_notification_details.h" |
27 #include "content/public/browser/navigation_controller.h" | 27 #include "content/public/browser/navigation_controller.h" |
28 #include "content/public/browser/notification_details.h" | 28 #include "content/public/browser/notification_details.h" |
29 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
30 #include "content/public/browser/render_frame_host.h" | 30 #include "content/public/browser/render_frame_host.h" |
31 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
32 #include "content/public/test/browser_test_utils.h" | 32 #include "content/public/test/browser_test_utils.h" |
33 #include "net/base/net_util.h" | 33 #include "net/base/net_util.h" |
34 #include "net/test/embedded_test_server/embedded_test_server.h" | 34 #include "net/test/embedded_test_server/embedded_test_server.h" |
35 | 35 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 131 |
132 // content::NotificationObserver: | 132 // content::NotificationObserver: |
133 virtual void Observe(int type, | 133 virtual void Observe(int type, |
134 const content::NotificationSource& source, | 134 const content::NotificationSource& source, |
135 const content::NotificationDetails& details) OVERRIDE; | 135 const content::NotificationDetails& details) OVERRIDE; |
136 | 136 |
137 void AddWatchAndWaitForNotification( | 137 void AddWatchAndWaitForNotification( |
138 content::RenderFrameHost* render_frame_host); | 138 content::RenderFrameHost* render_frame_host); |
139 | 139 |
140 bool has_infobar() const { return !!infobar_; } | 140 bool has_infobar() const { return !!infobar_; } |
141 InfoBar* infobar() { return infobar_; } | 141 infobars::InfoBar* infobar() { return infobar_; } |
142 | 142 |
143 private: | 143 private: |
144 content::NotificationRegistrar registrar_; | 144 content::NotificationRegistrar registrar_; |
145 bool wait_for_infobar_; | 145 bool wait_for_infobar_; |
146 InfoBar* infobar_; | 146 infobars::InfoBar* infobar_; |
147 bool navigation_started_; | 147 bool navigation_started_; |
148 bool navigation_completed_; | 148 bool navigation_completed_; |
149 std::string javascript_response_; | 149 std::string javascript_response_; |
150 | 150 |
151 DISALLOW_COPY_AND_ASSIGN(GeolocationNotificationObserver); | 151 DISALLOW_COPY_AND_ASSIGN(GeolocationNotificationObserver); |
152 }; | 152 }; |
153 | 153 |
154 GeolocationNotificationObserver::GeolocationNotificationObserver( | 154 GeolocationNotificationObserver::GeolocationNotificationObserver( |
155 bool wait_for_infobar) | 155 bool wait_for_infobar) |
156 : wait_for_infobar_(wait_for_infobar), | 156 : wait_for_infobar_(wait_for_infobar), |
(...skipping 16 matching lines...) Expand all Loading... |
173 } | 173 } |
174 | 174 |
175 GeolocationNotificationObserver::~GeolocationNotificationObserver() { | 175 GeolocationNotificationObserver::~GeolocationNotificationObserver() { |
176 } | 176 } |
177 | 177 |
178 void GeolocationNotificationObserver::Observe( | 178 void GeolocationNotificationObserver::Observe( |
179 int type, | 179 int type, |
180 const content::NotificationSource& source, | 180 const content::NotificationSource& source, |
181 const content::NotificationDetails& details) { | 181 const content::NotificationDetails& details) { |
182 if (type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED) { | 182 if (type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED) { |
183 infobar_ = content::Details<InfoBar::AddedDetails>(details).ptr(); | 183 infobar_ = content::Details<infobars::InfoBar::AddedDetails>(details).ptr(); |
184 ASSERT_FALSE(infobar_->delegate()->GetIcon().IsEmpty()); | 184 ASSERT_FALSE(infobar_->delegate()->GetIcon().IsEmpty()); |
185 ASSERT_TRUE(infobar_->delegate()->AsConfirmInfoBarDelegate()); | 185 ASSERT_TRUE(infobar_->delegate()->AsConfirmInfoBarDelegate()); |
186 } else if (type == content::NOTIFICATION_DOM_OPERATION_RESPONSE) { | 186 } else if (type == content::NOTIFICATION_DOM_OPERATION_RESPONSE) { |
187 content::Details<DomOperationNotificationDetails> dom_op_details(details); | 187 content::Details<DomOperationNotificationDetails> dom_op_details(details); |
188 javascript_response_ = dom_op_details->json; | 188 javascript_response_ = dom_op_details->json; |
189 LOG(WARNING) << "javascript_response " << javascript_response_; | 189 LOG(WARNING) << "javascript_response " << javascript_response_; |
190 } else if ((type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) || | 190 } else if ((type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) || |
191 (type == content::NOTIFICATION_LOAD_START)) { | 191 (type == content::NOTIFICATION_LOAD_START)) { |
192 navigation_started_ = true; | 192 navigation_started_ = true; |
193 } else if ((type == content::NOTIFICATION_LOAD_STOP) && navigation_started_) { | 193 } else if ((type == content::NOTIFICATION_LOAD_STOP) && navigation_started_) { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 content::RenderFrameHost* render_frame_host); | 287 content::RenderFrameHost* render_frame_host); |
288 | 288 |
289 // Executes |function| and checks that the return value matches |expected|. | 289 // Executes |function| and checks that the return value matches |expected|. |
290 void CheckStringValueFromJavascript(const std::string& expected, | 290 void CheckStringValueFromJavascript(const std::string& expected, |
291 const std::string& function); | 291 const std::string& function); |
292 | 292 |
293 // Sets a new position and sends a notification with the new position. | 293 // Sets a new position and sends a notification with the new position. |
294 void NotifyGeoposition(double latitude, double longitude); | 294 void NotifyGeoposition(double latitude, double longitude); |
295 | 295 |
296 private: | 296 private: |
297 InfoBar* infobar_; | 297 infobars::InfoBar* infobar_; |
298 Browser* current_browser_; | 298 Browser* current_browser_; |
299 // path element of a URL referencing the html content for this test. | 299 // path element of a URL referencing the html content for this test. |
300 std::string html_for_tests_; | 300 std::string html_for_tests_; |
301 // This member defines the frame where the JavaScript calls will run. | 301 // This member defines the frame where the JavaScript calls will run. |
302 content::RenderFrameHost* render_frame_host_; | 302 content::RenderFrameHost* render_frame_host_; |
303 // The current url for the top level page. | 303 // The current url for the top level page. |
304 GURL current_url_; | 304 GURL current_url_; |
305 // If not empty, the GURLs for the iframes loaded by LoadIFrames(). | 305 // If not empty, the GURLs for the iframes loaded by LoadIFrames(). |
306 std::vector<GURL> iframe_urls_; | 306 std::vector<GURL> iframe_urls_; |
307 double fake_latitude_; | 307 double fake_latitude_; |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 | 762 |
763 SetFrameHost("iframe_2"); | 763 SetFrameHost("iframe_2"); |
764 AddGeolocationWatch(false); | 764 AddGeolocationWatch(false); |
765 | 765 |
766 std::string script = | 766 std::string script = |
767 "window.domAutomationController.send(window.close());"; | 767 "window.domAutomationController.send(window.close());"; |
768 bool result = content::ExecuteScript( | 768 bool result = content::ExecuteScript( |
769 current_browser()->tab_strip_model()->GetActiveWebContents(), script); | 769 current_browser()->tab_strip_model()->GetActiveWebContents(), script); |
770 EXPECT_EQ(result, true); | 770 EXPECT_EQ(result, true); |
771 } | 771 } |
OLD | NEW |