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

Side by Side Diff: chrome/browser/ui/browser_init.cc

Issue 8513020: base::Bind migrations in chrome/browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: review fix Created 9 years, 1 month 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) 2011 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/ui/browser_init.h" 5 #include "chrome/browser/ui/browser_init.h"
6 6
7 #include <algorithm> // For max(). 7 #include <algorithm> // For max().
8 8
9 #include "base/bind.h"
10 #include "base/bind_helpers.h"
9 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
10 #include "base/environment.h" 12 #include "base/environment.h"
11 #include "base/event_recorder.h" 13 #include "base/event_recorder.h"
12 #include "base/file_path.h" 14 #include "base/file_path.h"
13 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h"
14 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
15 #include "base/path_service.h" 18 #include "base/path_service.h"
16 #include "base/string_number_conversions.h" 19 #include "base/string_number_conversions.h"
17 #include "base/string_split.h" 20 #include "base/string_split.h"
18 #include "base/threading/thread_restrictions.h" 21 #include "base/threading/thread_restrictions.h"
19 #include "base/utf_string_conversions.h" 22 #include "base/utf_string_conversions.h"
20 #include "chrome/browser/automation/automation_provider.h" 23 #include "chrome/browser/automation/automation_provider.h"
21 #include "chrome/browser/automation/automation_provider_list.h" 24 #include "chrome/browser/automation/automation_provider_list.h"
22 #include "chrome/browser/automation/chrome_frame_automation_provider.h" 25 #include "chrome/browser/automation/chrome_frame_automation_provider.h"
23 #include "chrome/browser/automation/testing_automation_provider.h" 26 #include "chrome/browser/automation/testing_automation_provider.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // The prefs to use. 168 // The prefs to use.
166 PrefService* prefs_; 169 PrefService* prefs_;
167 170
168 // Whether the user clicked one of the buttons. 171 // Whether the user clicked one of the buttons.
169 bool action_taken_; 172 bool action_taken_;
170 173
171 // Whether the info-bar should be dismissed on the next navigation. 174 // Whether the info-bar should be dismissed on the next navigation.
172 bool should_expire_; 175 bool should_expire_;
173 176
174 // Used to delay the expiration of the info-bar. 177 // Used to delay the expiration of the info-bar.
175 ScopedRunnableMethodFactory<DefaultBrowserInfoBarDelegate> method_factory_; 178 base::WeakPtrFactory<DefaultBrowserInfoBarDelegate> weak_factory_;
176 179
177 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserInfoBarDelegate); 180 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserInfoBarDelegate);
178 }; 181 };
179 182
180 DefaultBrowserInfoBarDelegate::DefaultBrowserInfoBarDelegate( 183 DefaultBrowserInfoBarDelegate::DefaultBrowserInfoBarDelegate(
181 InfoBarTabHelper* infobar_helper, 184 InfoBarTabHelper* infobar_helper,
182 PrefService* prefs) 185 PrefService* prefs)
183 : ConfirmInfoBarDelegate(infobar_helper), 186 : ConfirmInfoBarDelegate(infobar_helper),
184 prefs_(prefs), 187 prefs_(prefs),
185 action_taken_(false), 188 action_taken_(false),
186 should_expire_(false), 189 should_expire_(false),
187 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { 190 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
188 // We want the info-bar to stick-around for few seconds and then be hidden 191 // We want the info-bar to stick-around for few seconds and then be hidden
189 // on the next navigation after that. 192 // on the next navigation after that.
190 MessageLoop::current()->PostDelayedTask(FROM_HERE, 193 MessageLoop::current()->PostDelayedTask(
191 method_factory_.NewRunnableMethod( 194 FROM_HERE, base::Bind(&DefaultBrowserInfoBarDelegate::AllowExpiry,
192 &DefaultBrowserInfoBarDelegate::AllowExpiry), 8000); // 8 seconds. 195 weak_factory_.GetWeakPtr()),
196 8000); // 8 seconds.
193 } 197 }
194 198
195 DefaultBrowserInfoBarDelegate::~DefaultBrowserInfoBarDelegate() { 199 DefaultBrowserInfoBarDelegate::~DefaultBrowserInfoBarDelegate() {
196 if (!action_taken_) 200 if (!action_taken_)
197 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.Ignored", 1); 201 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.Ignored", 1);
198 } 202 }
199 203
200 bool DefaultBrowserInfoBarDelegate::ShouldExpire( 204 bool DefaultBrowserInfoBarDelegate::ShouldExpire(
201 const content::LoadCommittedDetails& details) const { 205 const content::LoadCommittedDetails& details) const {
202 return details.is_navigation_to_different_page() && should_expire_; 206 return details.is_navigation_to_different_page() && should_expire_;
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 // - There is a policy in control of this setting. 1329 // - There is a policy in control of this setting.
1326 if (!profile->GetPrefs()->GetBoolean(prefs::kCheckDefaultBrowser) || 1330 if (!profile->GetPrefs()->GetBoolean(prefs::kCheckDefaultBrowser) ||
1327 is_first_run_) { 1331 is_first_run_) {
1328 return; 1332 return;
1329 } 1333 }
1330 if (g_browser_process->local_state()->IsManagedPreference( 1334 if (g_browser_process->local_state()->IsManagedPreference(
1331 prefs::kDefaultBrowserSettingEnabled)) { 1335 prefs::kDefaultBrowserSettingEnabled)) {
1332 if (g_browser_process->local_state()->GetBoolean( 1336 if (g_browser_process->local_state()->GetBoolean(
1333 prefs::kDefaultBrowserSettingEnabled)) { 1337 prefs::kDefaultBrowserSettingEnabled)) {
1334 BrowserThread::PostTask( 1338 BrowserThread::PostTask(
1335 BrowserThread::FILE, FROM_HERE, NewRunnableFunction( 1339 BrowserThread::FILE, FROM_HERE,
1336 &ShellIntegration::SetAsDefaultBrowser)); 1340 base::IgnoreReturn<bool>(
1341 base::Bind(&ShellIntegration::SetAsDefaultBrowser)));
1337 } else { 1342 } else {
1338 // TODO(pastarmovj): We can't really do anything meaningful here yet but 1343 // TODO(pastarmovj): We can't really do anything meaningful here yet but
1339 // just prevent showing the infobar. 1344 // just prevent showing the infobar.
1340 } 1345 }
1341 return; 1346 return;
1342 } 1347 }
1343 BrowserThread::PostTask( 1348 BrowserThread::PostTask(
1344 BrowserThread::FILE, FROM_HERE, new CheckDefaultBrowserTask()); 1349 BrowserThread::FILE, FROM_HERE, new CheckDefaultBrowserTask());
1345 } 1350 }
1346 1351
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 if (!automation->InitializeChannel(channel_id)) 1554 if (!automation->InitializeChannel(channel_id))
1550 return false; 1555 return false;
1551 automation->SetExpectedTabCount(expected_tabs); 1556 automation->SetExpectedTabCount(expected_tabs);
1552 1557
1553 AutomationProviderList* list = g_browser_process->GetAutomationProviderList(); 1558 AutomationProviderList* list = g_browser_process->GetAutomationProviderList();
1554 DCHECK(list); 1559 DCHECK(list);
1555 list->AddProvider(automation); 1560 list->AddProvider(automation);
1556 1561
1557 return true; 1562 return true;
1558 } 1563 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698