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

Side by Side Diff: chrome/browser/google/google_url_tracker.cc

Issue 9811022: Misc. small cleanups to minimize TemplateURL refactoring diffs: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 (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/google/google_url_tracker.h" 5 #include "chrome/browser/google/google_url_tracker.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 21 matching lines...) Expand all
32 #include "net/url_request/url_request_status.h" 32 #include "net/url_request/url_request_status.h"
33 #include "ui/base/l10n/l10n_util.h" 33 #include "ui/base/l10n/l10n_util.h"
34 34
35 using content::NavigationController; 35 using content::NavigationController;
36 using content::OpenURLParams; 36 using content::OpenURLParams;
37 using content::Referrer; 37 using content::Referrer;
38 using content::WebContents; 38 using content::WebContents;
39 39
40 namespace { 40 namespace {
41 41
42 InfoBarDelegate* CreateInfobar(InfoBarTabHelper* infobar_helper, 42 InfoBarDelegate* CreateInfoBar(InfoBarTabHelper* infobar_helper,
43 GoogleURLTracker* google_url_tracker, 43 GoogleURLTracker* google_url_tracker,
44 const GURL& new_google_url) { 44 const GURL& new_google_url) {
45 InfoBarDelegate* infobar = new GoogleURLTrackerInfoBarDelegate(infobar_helper, 45 InfoBarDelegate* infobar = new GoogleURLTrackerInfoBarDelegate(infobar_helper,
46 google_url_tracker, new_google_url); 46 google_url_tracker, new_google_url);
47 infobar_helper->AddInfoBar(infobar); 47 infobar_helper->AddInfoBar(infobar);
48 return infobar; 48 return infobar;
49 } 49 }
50 50
51 } // namespace 51 } // namespace
52 52
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 113
114 // GoogleURLTracker ----------------------------------------------------------- 114 // GoogleURLTracker -----------------------------------------------------------
115 115
116 const char GoogleURLTracker::kDefaultGoogleHomepage[] = 116 const char GoogleURLTracker::kDefaultGoogleHomepage[] =
117 "http://www.google.com/"; 117 "http://www.google.com/";
118 const char GoogleURLTracker::kSearchDomainCheckURL[] = 118 const char GoogleURLTracker::kSearchDomainCheckURL[] =
119 "https://www.google.com/searchdomaincheck?format=domain&type=chrome"; 119 "https://www.google.com/searchdomaincheck?format=domain&type=chrome";
120 120
121 GoogleURLTracker::GoogleURLTracker(Mode mode) 121 GoogleURLTracker::GoogleURLTracker(Mode mode)
122 : infobar_creator_(&CreateInfobar), 122 : infobar_creator_(&CreateInfoBar),
123 google_url_(mode == UNIT_TEST_MODE ? kDefaultGoogleHomepage : 123 google_url_(mode == UNIT_TEST_MODE ? kDefaultGoogleHomepage :
124 g_browser_process->local_state()->GetString( 124 g_browser_process->local_state()->GetString(
125 prefs::kLastKnownGoogleURL)), 125 prefs::kLastKnownGoogleURL)),
126 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), 126 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)),
127 fetcher_id_(0), 127 fetcher_id_(0),
128 in_startup_sleep_(true), 128 in_startup_sleep_(true),
129 already_fetched_(false), 129 already_fetched_(false),
130 need_to_fetch_(false), 130 need_to_fetch_(false),
131 need_to_prompt_(false), 131 need_to_prompt_(false),
132 controller_(NULL), 132 controller_(NULL),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 178
179 // static 179 // static
180 void GoogleURLTracker::GoogleURLSearchCommitted() { 180 void GoogleURLTracker::GoogleURLSearchCommitted() {
181 GoogleURLTracker* tracker = g_browser_process->google_url_tracker(); 181 GoogleURLTracker* tracker = g_browser_process->google_url_tracker();
182 if (tracker) 182 if (tracker)
183 tracker->SearchCommitted(); 183 tracker->SearchCommitted();
184 } 184 }
185 185
186 void GoogleURLTracker::AcceptGoogleURL(const GURL& new_google_url) { 186 void GoogleURLTracker::AcceptGoogleURL(const GURL& new_google_url) {
187 google_url_ = new_google_url; 187 google_url_ = new_google_url;
188 g_browser_process->local_state()->SetString(prefs::kLastKnownGoogleURL, 188 PrefService* prefs = g_browser_process->local_state();
189 google_url_.spec()); 189 prefs->SetString(prefs::kLastKnownGoogleURL, google_url_.spec());
190 g_browser_process->local_state()->SetString(prefs::kLastPromptedGoogleURL, 190 prefs->SetString(prefs::kLastPromptedGoogleURL, google_url_.spec());
191 google_url_.spec());
192 content::NotificationService::current()->Notify( 191 content::NotificationService::current()->Notify(
193 chrome::NOTIFICATION_GOOGLE_URL_UPDATED, 192 chrome::NOTIFICATION_GOOGLE_URL_UPDATED,
194 content::NotificationService::AllSources(), 193 content::NotificationService::AllSources(),
195 content::NotificationService::NoDetails()); 194 content::NotificationService::NoDetails());
196 need_to_prompt_ = false; 195 need_to_prompt_ = false;
197 } 196 }
198 197
199 void GoogleURLTracker::CancelGoogleURL(const GURL& new_google_url) { 198 void GoogleURLTracker::CancelGoogleURL(const GURL& new_google_url) {
200 g_browser_process->local_state()->SetString(prefs::kLastPromptedGoogleURL, 199 g_browser_process->local_state()->SetString(prefs::kLastPromptedGoogleURL,
201 new_google_url.spec()); 200 new_google_url.spec());
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 content::NotificationService::AllBrowserContextsAndSources()); 347 content::NotificationService::AllBrowserContextsAndSources());
349 } 348 }
350 } 349 }
351 350
352 void GoogleURLTracker::OnNavigationPending( 351 void GoogleURLTracker::OnNavigationPending(
353 const content::NotificationSource& source, 352 const content::NotificationSource& source,
354 const GURL& pending_url) { 353 const GURL& pending_url) {
355 controller_ = content::Source<NavigationController>(source).ptr(); 354 controller_ = content::Source<NavigationController>(source).ptr();
356 search_url_ = pending_url; 355 search_url_ = pending_url;
357 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING, 356 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING,
358 content::NotificationService::AllSources()); 357 content::NotificationService::AllBrowserContextsAndSources());
359 // Start listening for the commit notification. We also need to listen for the 358 // Start listening for the commit notification. We also need to listen for the
360 // tab close command since that means the load will never commit. 359 // tab close command since that means the load will never commit.
361 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 360 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
362 content::Source<NavigationController>(controller_)); 361 content::Source<NavigationController>(controller_));
363 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, 362 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED,
364 content::Source<NavigationController>(controller_)); 363 content::Source<NavigationController>(controller_));
365 } 364 }
366 365
367 void GoogleURLTracker::OnNavigationCommittedOrTabClosed( 366 void GoogleURLTracker::OnNavigationCommittedOrTabClosed(
368 WebContents* web_contents, 367 WebContents* web_contents,
(...skipping 16 matching lines...) Expand all
385 384
386 // |tab_contents| can be NULL during tests. 385 // |tab_contents| can be NULL during tests.
387 InfoBarTabHelper* infobar_helper = NULL; 386 InfoBarTabHelper* infobar_helper = NULL;
388 if (web_contents) { 387 if (web_contents) {
389 TabContentsWrapper* wrapper = 388 TabContentsWrapper* wrapper =
390 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); 389 TabContentsWrapper::GetCurrentWrapperForContents(web_contents);
391 infobar_helper = wrapper->infobar_tab_helper(); 390 infobar_helper = wrapper->infobar_tab_helper();
392 } 391 }
393 infobar_ = (*infobar_creator_)(infobar_helper, this, fetched_google_url_); 392 infobar_ = (*infobar_creator_)(infobar_helper, this, fetched_google_url_);
394 } 393 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698