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 "chrome/browser/instant/instant_loader.h" | 5 #include "chrome/browser/instant/instant_loader.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // Only track the histogram for the instant loaders, for now. | 86 // Only track the histogram for the instant loaders, for now. |
87 if (template_url_id) { | 87 if (template_url_id) { |
88 base::Histogram* histogram = base::LinearHistogram::FactoryGet( | 88 base::Histogram* histogram = base::LinearHistogram::FactoryGet( |
89 "Instant.Previews" + group, 1, PREVIEW_NUM_TYPES, PREVIEW_NUM_TYPES + 1, | 89 "Instant.Previews" + group, 1, PREVIEW_NUM_TYPES, PREVIEW_NUM_TYPES + 1, |
90 base::Histogram::kUmaTargetedHistogramFlag); | 90 base::Histogram::kUmaTargetedHistogramFlag); |
91 histogram->Add(usage); | 91 histogram->Add(usage); |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 SessionStorageNamespace* GetSessionStorageNamespace(TabContents* tab) { | 95 SessionStorageNamespace* GetSessionStorageNamespace(TabContents* tab) { |
96 return tab->web_contents()->GetController().GetSessionStorageNamespace(); | 96 // TODO(ajwong): This is wrong because it assumes a default |
| 97 // SessionStorageNamespace for a TabContents. |
| 98 // |
| 99 // http://crbug.com/140612 |
| 100 return tab->web_contents()->GetController() |
| 101 .GetDefaultSessionStorageNamespace(); |
97 } | 102 } |
98 | 103 |
99 } // namespace | 104 } // namespace |
100 | 105 |
101 // static | 106 // static |
102 const char* const InstantLoader::kInstantHeader = "X-Purpose"; | 107 const char* const InstantLoader::kInstantHeader = "X-Purpose"; |
103 // static | 108 // static |
104 const char* const InstantLoader::kInstantHeaderValue = "instant"; | 109 const char* const InstantLoader::kInstantHeaderValue = "instant"; |
105 | 110 |
106 // FrameLoadObserver is responsible for determining if the page supports | 111 // FrameLoadObserver is responsible for determining if the page supports |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 #endif | 849 #endif |
845 } | 850 } |
846 preview_contents_->web_contents()->SetDelegate(NULL); | 851 preview_contents_->web_contents()->SetDelegate(NULL); |
847 ready_ = false; | 852 ready_ = false; |
848 } | 853 } |
849 update_bounds_timer_.Stop(); | 854 update_bounds_timer_.Stop(); |
850 AddPreviewUsageForHistogram(template_url_id_, | 855 AddPreviewUsageForHistogram(template_url_id_, |
851 type == INSTANT_COMMIT_DESTROY ? PREVIEW_DELETED : PREVIEW_COMMITTED, | 856 type == INSTANT_COMMIT_DESTROY ? PREVIEW_DELETED : PREVIEW_COMMITTED, |
852 group_); | 857 group_); |
853 if (type != INSTANT_COMMIT_DESTROY) { | 858 if (type != INSTANT_COMMIT_DESTROY) { |
| 859 // This tracks the number of times a committed preview page destroys the |
| 860 // Session Storage for the tab. |
854 base::Histogram* histogram = base::LinearHistogram::FactoryGet( | 861 base::Histogram* histogram = base::LinearHistogram::FactoryGet( |
855 "Instant.SessionStorageNamespace" + group_, 1, 2, 3, | 862 "Instant.SessionStorageNamespace" + group_, 1, 2, 3, |
856 base::Histogram::kUmaTargetedHistogramFlag); | 863 base::Histogram::kUmaTargetedHistogramFlag); |
857 histogram->Add(tab_contents == NULL || session_storage_namespace_ == | 864 histogram->Add(tab_contents == NULL || session_storage_namespace_ == |
858 GetSessionStorageNamespace(tab_contents)); | 865 GetSessionStorageNamespace(tab_contents)); |
859 // Now that the ownership is being passed to the caller, the thumbnailer | 866 // Now that the ownership is being passed to the caller, the thumbnailer |
860 // needs to resume taking thumbnails. | 867 // needs to resume taking thumbnails. |
861 if (preview_contents_->thumbnail_generator()) | 868 if (preview_contents_->thumbnail_generator()) |
862 preview_contents_->thumbnail_generator()->set_enabled(true); | 869 preview_contents_->thumbnail_generator()->set_enabled(true); |
863 } | 870 } |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 preview_contents_->web_contents()->GetView()->SizeContents(tab_bounds.size()); | 1144 preview_contents_->web_contents()->GetView()->SizeContents(tab_bounds.size()); |
1138 | 1145 |
1139 // Carry over the user agent override string. | 1146 // Carry over the user agent override string. |
1140 const std::string& override = | 1147 const std::string& override = |
1141 tab_contents->web_contents()->GetUserAgentOverride(); | 1148 tab_contents->web_contents()->GetUserAgentOverride(); |
1142 preview_contents_->web_contents()->SetUserAgentOverride(override); | 1149 preview_contents_->web_contents()->SetUserAgentOverride(override); |
1143 } | 1150 } |
1144 | 1151 |
1145 void InstantLoader::CreatePreviewContents(TabContents* tab_contents) { | 1152 void InstantLoader::CreatePreviewContents(TabContents* tab_contents) { |
1146 WebContents* new_contents = WebContents::Create( | 1153 WebContents* new_contents = WebContents::Create( |
1147 tab_contents->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); | 1154 tab_contents->profile(), NULL, MSG_ROUTING_NONE, NULL); |
1148 preview_contents_.reset(new TabContents(new_contents)); | 1155 preview_contents_.reset(new TabContents(new_contents)); |
1149 AddPreviewUsageForHistogram(template_url_id_, PREVIEW_CREATED, group_); | 1156 AddPreviewUsageForHistogram(template_url_id_, PREVIEW_CREATED, group_); |
1150 session_storage_namespace_ = GetSessionStorageNamespace(tab_contents); | 1157 session_storage_namespace_ = GetSessionStorageNamespace(tab_contents); |
1151 preview_tab_contents_delegate_.reset(new WebContentsDelegateImpl(this)); | 1158 preview_tab_contents_delegate_.reset(new WebContentsDelegateImpl(this)); |
1152 SetupPreviewContents(tab_contents); | 1159 SetupPreviewContents(tab_contents); |
1153 | 1160 |
1154 // TODO(beng): investigate if we can avoid this and instead rely on the | 1161 // TODO(beng): investigate if we can avoid this and instead rely on the |
1155 // visibility of the WebContentsView | 1162 // visibility of the WebContentsView |
1156 preview_contents_->web_contents()->WasShown(); | 1163 preview_contents_->web_contents()->WasShown(); |
1157 } | 1164 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 host->Send(new ChromeViewMsg_SearchBoxResize( | 1201 host->Send(new ChromeViewMsg_SearchBoxResize( |
1195 host->GetRoutingID(), GetOmniboxBoundsInTermsOfPreview())); | 1202 host->GetRoutingID(), GetOmniboxBoundsInTermsOfPreview())); |
1196 } else { | 1203 } else { |
1197 host->Send(new ChromeViewMsg_SearchBoxChange( | 1204 host->Send(new ChromeViewMsg_SearchBoxChange( |
1198 host->GetRoutingID(), user_text, verbatim, 0, 0)); | 1205 host->GetRoutingID(), user_text, verbatim, 0, 0)); |
1199 } | 1206 } |
1200 | 1207 |
1201 frame_load_observer_.reset(new FrameLoadObserver( | 1208 frame_load_observer_.reset(new FrameLoadObserver( |
1202 this, preview_contents()->web_contents(), user_text, verbatim)); | 1209 this, preview_contents()->web_contents(), user_text, verbatim)); |
1203 } | 1210 } |
OLD | NEW |