Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: chrome/browser/search_engines/template_url_prepopulate_data.cc

Issue 10108026: Transmit a X-Chrome-UMA-Enabled bit to Google domains from clients that have UMA enabled. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: merge to tot Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/search_engines/template_url_prepopulate_data.h" 5 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
6 6
7 #if defined(OS_POSIX) && !defined(OS_MACOSX) 7 #if defined(OS_POSIX) && !defined(OS_MACOSX)
8 #include <locale.h> 8 #include <locale.h>
9 #endif 9 #endif
10 10
(...skipping 3266 matching lines...) Expand 10 before | Expand all | Expand 10 after
3277 // and thus won't ever string-compare successfully against |url|. 3277 // and thus won't ever string-compare successfully against |url|.
3278 return (url == google.search_url) ? &google : NULL; 3278 return (url == google.search_url) ? &google : NULL;
3279 } 3279 }
3280 3280
3281 // For all other cases, check using origins, in order to more aggressively 3281 // For all other cases, check using origins, in order to more aggressively
3282 // match search engine types for data imported from other browsers. 3282 // match search engine types for data imported from other browsers.
3283 // 3283 //
3284 // First special-case Google, because the prepopulate URL for it will not 3284 // First special-case Google, because the prepopulate URL for it will not
3285 // convert to a GURL and thus won't have an origin. Instead see if the 3285 // convert to a GURL and thus won't have an origin. Instead see if the
3286 // incoming URL's host is "[*.]google.<TLD>". 3286 // incoming URL's host is "[*.]google.<TLD>".
3287 if (google_util::IsGoogleHostname(as_gurl.host())) 3287 if (google_util::IsGoogleHostname(as_gurl.host(),
3288 google_util::DISALLOW_SUBDOMAIN))
3288 return &google; 3289 return &google;
3289 3290
3290 // Now check the rest of the prepopulate data. 3291 // Now check the rest of the prepopulate data.
3291 GURL origin(as_gurl.GetOrigin()); 3292 GURL origin(as_gurl.GetOrigin());
3292 for (size_t i = 0; i < arraysize(kAllEngines); ++i) { 3293 for (size_t i = 0; i < arraysize(kAllEngines); ++i) {
3293 GURL engine_url(kAllEngines[i]->search_url); 3294 GURL engine_url(kAllEngines[i]->search_url);
3294 if (engine_url.is_valid() && (origin == engine_url.GetOrigin())) 3295 if (engine_url.is_valid() && (origin == engine_url.GetOrigin()))
3295 return kAllEngines[i]; 3296 return kAllEngines[i];
3296 } 3297 }
3297 3298
3298 return NULL; 3299 return NULL;
3299 } 3300 }
3300 3301
3301 string16 GetEngineName(const std::string& url) { 3302 string16 GetEngineName(const std::string& url) {
3302 const PrepopulatedEngine* engine = GetEngineForURL(url); 3303 const PrepopulatedEngine* engine = GetEngineForURL(url);
3303 if (engine) 3304 if (engine)
3304 return WideToUTF16(engine->name); 3305 return WideToUTF16(engine->name);
3305 GURL as_gurl(url); 3306 GURL as_gurl(url);
3306 return (as_gurl.is_valid() && !as_gurl.host().empty()) ? 3307 return (as_gurl.is_valid() && !as_gurl.host().empty()) ?
3307 UTF8ToUTF16(as_gurl.host()) : 3308 UTF8ToUTF16(as_gurl.host()) :
3308 l10n_util::GetStringUTF16(IDS_UNKNOWN_SEARCH_ENGINE_NAME); 3309 l10n_util::GetStringUTF16(IDS_UNKNOWN_SEARCH_ENGINE_NAME);
3309 } 3310 }
3310 3311
3311 SearchEngineType GetEngineType(const std::string& url) { 3312 SearchEngineType GetEngineType(const std::string& url) {
3312 const PrepopulatedEngine* engine = GetEngineForURL(url); 3313 const PrepopulatedEngine* engine = GetEngineForURL(url);
3313 return engine ? engine->type : SEARCH_ENGINE_OTHER; 3314 return engine ? engine->type : SEARCH_ENGINE_OTHER;
3314 } 3315 }
3315 3316
3316 } // namespace TemplateURLPrepopulateData 3317 } // namespace TemplateURLPrepopulateData
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698