| OLD | NEW |
| 1 // Copyright (c) 2010 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 "chrome/browser/tab_contents/tab_contents.h" | 5 #include "chrome/browser/tab_contents/tab_contents.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| 11 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
| (...skipping 2141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2153 const NavigationEntry* previous_entry = | 2153 const NavigationEntry* previous_entry = |
| 2154 controller_.GetEntryAtIndex(last_index - 1); | 2154 controller_.GetEntryAtIndex(last_index - 1); |
| 2155 if (IsFormSubmit(previous_entry)) { | 2155 if (IsFormSubmit(previous_entry)) { |
| 2156 // Only generate a keyword if the previous page wasn't itself a form | 2156 // Only generate a keyword if the previous page wasn't itself a form |
| 2157 // submit. | 2157 // submit. |
| 2158 return; | 2158 return; |
| 2159 } | 2159 } |
| 2160 | 2160 |
| 2161 GURL keyword_url = previous_entry->user_typed_url().is_valid() ? | 2161 GURL keyword_url = previous_entry->user_typed_url().is_valid() ? |
| 2162 previous_entry->user_typed_url() : previous_entry->url(); | 2162 previous_entry->user_typed_url() : previous_entry->url(); |
| 2163 std::wstring keyword = | 2163 string16 keyword = |
| 2164 TemplateURLModel::GenerateKeyword(keyword_url, true); // autodetected | 2164 TemplateURLModel::GenerateKeyword(keyword_url, true); // autodetected |
| 2165 if (keyword.empty()) | 2165 if (keyword.empty()) |
| 2166 return; | 2166 return; |
| 2167 | 2167 |
| 2168 TemplateURLModel* url_model = profile()->GetTemplateURLModel(); | 2168 TemplateURLModel* url_model = profile()->GetTemplateURLModel(); |
| 2169 if (!url_model) | 2169 if (!url_model) |
| 2170 return; | 2170 return; |
| 2171 | 2171 |
| 2172 if (!url_model->loaded()) { | 2172 if (!url_model->loaded()) { |
| 2173 url_model->Load(); | 2173 url_model->Load(); |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2981 | 2981 |
| 2982 // We want to use the user typed URL if available since that represents what | 2982 // We want to use the user typed URL if available since that represents what |
| 2983 // the user typed to get here, and fall back on the regular URL if not. | 2983 // the user typed to get here, and fall back on the regular URL if not. |
| 2984 if (!base_entry) | 2984 if (!base_entry) |
| 2985 return; | 2985 return; |
| 2986 GURL keyword_url = base_entry->user_typed_url().is_valid() ? | 2986 GURL keyword_url = base_entry->user_typed_url().is_valid() ? |
| 2987 base_entry->user_typed_url() : base_entry->url(); | 2987 base_entry->user_typed_url() : base_entry->url(); |
| 2988 if (!keyword_url.is_valid()) | 2988 if (!keyword_url.is_valid()) |
| 2989 return; | 2989 return; |
| 2990 | 2990 |
| 2991 std::wstring keyword = TemplateURLModel::GenerateKeyword( | 2991 string16 keyword = TemplateURLModel::GenerateKeyword( |
| 2992 keyword_url, | 2992 keyword_url, |
| 2993 provider_type == TemplateURLFetcher::AUTODETECTED_PROVIDER); | 2993 provider_type == TemplateURLFetcher::AUTODETECTED_PROVIDER); |
| 2994 | 2994 |
| 2995 // Download the OpenSearch description document. If this is successful, a | 2995 // Download the OpenSearch description document. If this is successful, a |
| 2996 // new keyword will be created when done. | 2996 // new keyword will be created when done. |
| 2997 profile()->GetTemplateURLFetcher()->ScheduleDownload( | 2997 profile()->GetTemplateURLFetcher()->ScheduleDownload( |
| 2998 keyword, | 2998 keyword, |
| 2999 url, | 2999 url, |
| 3000 base_entry->favicon().url(), | 3000 base_entry->favicon().url(), |
| 3001 new TemplateURLFetcherUICallbacks(this), | 3001 new TemplateURLFetcherUICallbacks(this), |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3363 } | 3363 } |
| 3364 | 3364 |
| 3365 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { | 3365 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { |
| 3366 render_manager_.SwapInRenderViewHost(rvh); | 3366 render_manager_.SwapInRenderViewHost(rvh); |
| 3367 } | 3367 } |
| 3368 | 3368 |
| 3369 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 3369 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 3370 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 3370 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
| 3371 rwh_view->SetSize(view()->GetContainerSize()); | 3371 rwh_view->SetSize(view()->GetContainerSize()); |
| 3372 } | 3372 } |
| OLD | NEW |