| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/search/iframe_source.h" | 5 #include "chrome/browser/search/iframe_source.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "chrome/browser/search/instant_io_context.h" | 12 #include "chrome/browser/search/instant_io_context.h" |
| 13 #include "chrome/grit/browser_resources.h" | 13 #include "chrome/grit/browser_resources.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/resource_request_info.h" | 15 #include "content/public/browser/resource_request_info.h" |
| 16 #include "content/public/test/mock_resource_context.h" | 16 #include "content/public/test/mock_resource_context.h" |
| 17 #include "content/public/test/test_browser_thread_bundle.h" | 17 #include "content/public/test/test_browser_thread_bundle.h" |
| 18 #include "ipc/ipc_message.h" | 18 #include "ipc/ipc_message.h" |
| 19 #include "net/base/request_priority.h" | 19 #include "net/base/request_priority.h" |
| 20 #include "net/url_request/url_request.h" | 20 #include "net/url_request/url_request.h" |
| 21 #include "net/url_request/url_request_context.h" | 21 #include "net/url_request/url_request_context.h" |
| 22 #include "net/url_request/url_request_test_util.h" | 22 #include "net/url_request/url_request_test_util.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 25 | 25 |
| 26 using content::ResourceType; | |
| 27 | |
| 28 const int kNonInstantRendererPID = 0; | 26 const int kNonInstantRendererPID = 0; |
| 29 const char kNonInstantOrigin[] = "http://evil"; | 27 const char kNonInstantOrigin[] = "http://evil"; |
| 30 const int kInstantRendererPID = 1; | 28 const int kInstantRendererPID = 1; |
| 31 const char kInstantOrigin[] = "chrome-search://instant"; | 29 const char kInstantOrigin[] = "chrome-search://instant"; |
| 32 const int kInvalidRendererPID = 42; | 30 const int kInvalidRendererPID = 42; |
| 33 | 31 |
| 34 class TestIframeSource : public IframeSource { | 32 class TestIframeSource : public IframeSource { |
| 35 public: | 33 public: |
| 36 using IframeSource::GetMimeType; | 34 using IframeSource::GetMimeType; |
| 37 using IframeSource::ShouldServiceRequest; | 35 using IframeSource::ShouldServiceRequest; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 source()->set_origin(kInstantOrigin); | 187 source()->set_origin(kInstantOrigin); |
| 190 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS); | 188 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS); |
| 191 EXPECT_FALSE(response_string().empty()); | 189 EXPECT_FALSE(response_string().empty()); |
| 192 source()->set_origin(kNonInstantOrigin); | 190 source()->set_origin(kNonInstantOrigin); |
| 193 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS); | 191 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS); |
| 194 EXPECT_FALSE(response_string().empty()); | 192 EXPECT_FALSE(response_string().empty()); |
| 195 source()->set_origin(std::string()); | 193 source()->set_origin(std::string()); |
| 196 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS); | 194 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS); |
| 197 EXPECT_TRUE(response_string().empty()); | 195 EXPECT_TRUE(response_string().empty()); |
| 198 } | 196 } |
| OLD | NEW |