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

Side by Side Diff: chrome/browser/ui/search/instant_test_utils.cc

Issue 338363004: Remove Profile* from TemplateURL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
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_test_utils.h" 5 #include "chrome/browser/ui/search/instant_test_utils.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 data.short_name = base::ASCIIToUTF16("name"); 58 data.short_name = base::ASCIIToUTF16("name");
59 data.SetURL(instant_url_.spec() + 59 data.SetURL(instant_url_.spec() +
60 "q={searchTerms}&is_search&{google:omniboxStartMarginParameter}"); 60 "q={searchTerms}&is_search&{google:omniboxStartMarginParameter}");
61 data.instant_url = instant_url_.spec(); 61 data.instant_url = instant_url_.spec();
62 data.new_tab_url = ntp_url_.spec(); 62 data.new_tab_url = ntp_url_.spec();
63 if (init_suggestions_url_) 63 if (init_suggestions_url_)
64 data.suggestions_url = instant_url_.spec() + "#q={searchTerms}"; 64 data.suggestions_url = instant_url_.spec() + "#q={searchTerms}";
65 data.alternate_urls.push_back(instant_url_.spec() + "#q={searchTerms}"); 65 data.alternate_urls.push_back(instant_url_.spec() + "#q={searchTerms}");
66 data.search_terms_replacement_key = "strk"; 66 data.search_terms_replacement_key = "strk";
67 67
68 TemplateURL* template_url = new TemplateURL(browser_->profile(), data); 68 TemplateURL* template_url = new TemplateURL(data);
69 service->Add(template_url); // Takes ownership of |template_url|. 69 service->Add(template_url); // Takes ownership of |template_url|.
70 service->SetUserSelectedDefaultSearchProvider(template_url); 70 service->SetUserSelectedDefaultSearchProvider(template_url);
71 } 71 }
72 72
73 void InstantTestBase::SetInstantURL(const std::string& url) { 73 void InstantTestBase::SetInstantURL(const std::string& url) {
74 TemplateURLService* service = 74 TemplateURLService* service =
75 TemplateURLServiceFactory::GetForProfile(browser_->profile()); 75 TemplateURLServiceFactory::GetForProfile(browser_->profile());
76 ui_test_utils::WaitForTemplateURLServiceToLoad(service); 76 ui_test_utils::WaitForTemplateURLServiceToLoad(service);
77 77
78 TemplateURLData data; 78 TemplateURLData data;
79 data.short_name = base::ASCIIToUTF16("name"); 79 data.short_name = base::ASCIIToUTF16("name");
80 data.SetURL(url); 80 data.SetURL(url);
81 data.instant_url = url; 81 data.instant_url = url;
82 82
83 TemplateURL* template_url = new TemplateURL(browser_->profile(), data); 83 TemplateURL* template_url = new TemplateURL(data);
84 service->Add(template_url); // Takes ownership of |template_url|. 84 service->Add(template_url); // Takes ownership of |template_url|.
85 service->SetUserSelectedDefaultSearchProvider(template_url); 85 service->SetUserSelectedDefaultSearchProvider(template_url);
86 } 86 }
87 87
88 void InstantTestBase::Init(const GURL& instant_url, 88 void InstantTestBase::Init(const GURL& instant_url,
89 const GURL& ntp_url, 89 const GURL& ntp_url,
90 bool init_suggestions_url) { 90 bool init_suggestions_url) {
91 instant_url_ = instant_url; 91 instant_url_ = instant_url;
92 ntp_url_ = ntp_url; 92 ntp_url_ = ntp_url;
93 init_suggestions_url_ = init_suggestions_url; 93 init_suggestions_url_ = init_suggestions_url;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 return content::ExecuteScriptAndExtractBool(rvh, js_chrome, loaded); 171 return content::ExecuteScriptAndExtractBool(rvh, js_chrome, loaded);
172 } 172 }
173 173
174 base::string16 InstantTestBase::GetBlueText() { 174 base::string16 InstantTestBase::GetBlueText() {
175 size_t start = 0, end = 0; 175 size_t start = 0, end = 0;
176 omnibox()->GetSelectionBounds(&start, &end); 176 omnibox()->GetSelectionBounds(&start, &end);
177 if (start > end) 177 if (start > end)
178 std::swap(start, end); 178 std::swap(start, end);
179 return omnibox()->GetText().substr(start, end - start); 179 return omnibox()->GetText().substr(start, end - start);
180 } 180 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_view_browsertest.cc ('k') | chrome/browser/ui/search/search_ipc_router_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698