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/ui/search/instant_search_prerenderer.h" | 5 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 public: | 49 public: |
50 DummyPrerenderContents( | 50 DummyPrerenderContents( |
51 PrerenderManager* prerender_manager, | 51 PrerenderManager* prerender_manager, |
52 Profile* profile, | 52 Profile* profile, |
53 const GURL& url, | 53 const GURL& url, |
54 const Referrer& referrer, | 54 const Referrer& referrer, |
55 Origin origin, | 55 Origin origin, |
56 bool call_did_finish_load, | 56 bool call_did_finish_load, |
57 const content::SessionStorageNamespaceMap& session_storage_namespace_map); | 57 const content::SessionStorageNamespaceMap& session_storage_namespace_map); |
58 | 58 |
59 virtual void StartPrerendering( | 59 void StartPrerendering( |
60 int creator_child_id, | 60 int creator_child_id, |
61 const gfx::Size& size, | 61 const gfx::Size& size, |
62 content::SessionStorageNamespace* session_storage_namespace, | 62 content::SessionStorageNamespace* session_storage_namespace, |
63 net::URLRequestContextGetter* request_context) override; | 63 net::URLRequestContextGetter* request_context) override; |
64 virtual bool GetChildId(int* child_id) const override; | 64 bool GetChildId(int* child_id) const override; |
65 virtual bool GetRouteId(int* route_id) const override; | 65 bool GetRouteId(int* route_id) const override; |
66 | 66 |
67 private: | 67 private: |
68 Profile* profile_; | 68 Profile* profile_; |
69 const GURL url_; | 69 const GURL url_; |
70 bool call_did_finish_load_; | 70 bool call_did_finish_load_; |
71 content::SessionStorageNamespaceMap session_storage_namespace_map_; | 71 content::SessionStorageNamespaceMap session_storage_namespace_map_; |
72 | 72 |
73 DISALLOW_COPY_AND_ASSIGN(DummyPrerenderContents); | 73 DISALLOW_COPY_AND_ASSIGN(DummyPrerenderContents); |
74 }; | 74 }; |
75 | 75 |
76 class DummyPrerenderContentsFactory : public PrerenderContents::Factory { | 76 class DummyPrerenderContentsFactory : public PrerenderContents::Factory { |
77 public: | 77 public: |
78 DummyPrerenderContentsFactory( | 78 DummyPrerenderContentsFactory( |
79 bool call_did_finish_load, | 79 bool call_did_finish_load, |
80 const content::SessionStorageNamespaceMap& session_storage_namespace_map) | 80 const content::SessionStorageNamespaceMap& session_storage_namespace_map) |
81 : call_did_finish_load_(call_did_finish_load), | 81 : call_did_finish_load_(call_did_finish_load), |
82 session_storage_namespace_map_(session_storage_namespace_map) { | 82 session_storage_namespace_map_(session_storage_namespace_map) { |
83 } | 83 } |
84 | 84 |
85 virtual PrerenderContents* CreatePrerenderContents( | 85 PrerenderContents* CreatePrerenderContents( |
86 PrerenderManager* prerender_manager, | 86 PrerenderManager* prerender_manager, |
87 Profile* profile, | 87 Profile* profile, |
88 const GURL& url, | 88 const GURL& url, |
89 const Referrer& referrer, | 89 const Referrer& referrer, |
90 Origin origin, | 90 Origin origin, |
91 uint8 experiment_id) override; | 91 uint8 experiment_id) override; |
92 | 92 |
93 private: | 93 private: |
94 bool call_did_finish_load_; | 94 bool call_did_finish_load_; |
95 content::SessionStorageNamespaceMap session_storage_namespace_map_; | 95 content::SessionStorageNamespaceMap session_storage_namespace_map_; |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 // key. Make sure UsePrerenderedPage() extracts the search terms from the URL | 487 // key. Make sure UsePrerenderedPage() extracts the search terms from the URL |
488 // and uses the prerendered page contents. | 488 // and uses the prerendered page contents. |
489 GURL url("https://www.google.com/alt#quux=foo"); | 489 GURL url("https://www.google.com/alt#quux=foo"); |
490 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB, | 490 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB, |
491 ui::PAGE_TRANSITION_TYPED, | 491 ui::PAGE_TRANSITION_TYPED, |
492 false)); | 492 false)); |
493 EXPECT_EQ(GetPrerenderURL(), GetActiveWebContents()->GetURL()); | 493 EXPECT_EQ(GetPrerenderURL(), GetActiveWebContents()->GetURL()); |
494 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle()); | 494 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle()); |
495 } | 495 } |
496 #endif | 496 #endif |
OLD | NEW |