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

Side by Side Diff: chrome/browser/managed_mode/managed_mode_interstitial.cc

Issue 228293004: InfoBarService inherits from InfoBarManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 6 years, 8 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/managed_mode/managed_mode_interstitial.h" 5 #include "chrome/browser/managed_mode/managed_mode_interstitial.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/infobars/infobar.h" 12 #include "chrome/browser/infobars/infobar.h"
13 #include "chrome/browser/infobars/infobar_delegate.h" 13 #include "chrome/browser/infobars/infobar_delegate.h"
14 #include "chrome/browser/infobars/infobar_manager.h"
15 #include "chrome/browser/infobars/infobar_service.h" 14 #include "chrome/browser/infobars/infobar_service.h"
16 #include "chrome/browser/managed_mode/managed_user_service.h" 15 #include "chrome/browser/managed_mode/managed_user_service.h"
17 #include "chrome/browser/managed_mode/managed_user_service_factory.h" 16 #include "chrome/browser/managed_mode/managed_user_service_factory.h"
18 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
20 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/interstitial_page.h" 20 #include "content/public/browser/interstitial_page.h"
22 #include "content/public/browser/navigation_controller.h" 21 #include "content/public/browser/navigation_controller.h"
23 #include "content/public/browser/navigation_details.h" 22 #include "content/public/browser/navigation_details.h"
24 #include "content/public/browser/navigation_entry.h" 23 #include "content/public/browser/navigation_entry.h"
(...skipping 21 matching lines...) Expand all
46 // It can happen that the site was only allowed very recently and the URL 45 // It can happen that the site was only allowed very recently and the URL
47 // filter on the IO thread had not been updated yet. Proceed with the 46 // filter on the IO thread had not been updated yet. Proceed with the
48 // request without showing the interstitial. 47 // request without showing the interstitial.
49 DispatchContinueRequest(true); 48 DispatchContinueRequest(true);
50 delete this; 49 delete this;
51 return; 50 return;
52 } 51 }
53 52
54 InfoBarService* service = InfoBarService::FromWebContents(web_contents); 53 InfoBarService* service = InfoBarService::FromWebContents(web_contents);
55 if (service) { 54 if (service) {
56 InfoBarManager* infobar_manager = service->infobar_manager();
57 // Remove all the infobars which are attached to |web_contents| and for 55 // Remove all the infobars which are attached to |web_contents| and for
58 // which ShouldExpire() returns true. 56 // which ShouldExpire() returns true.
59 content::LoadCommittedDetails details; 57 content::LoadCommittedDetails details;
60 // |details.is_in_page| is default false, and |details.is_main_frame| is 58 // |details.is_in_page| is default false, and |details.is_main_frame| is
61 // default true. This results in is_navigation_to_different_page() returning 59 // default true. This results in is_navigation_to_different_page() returning
62 // true. 60 // true.
63 DCHECK(details.is_navigation_to_different_page()); 61 DCHECK(details.is_navigation_to_different_page());
64 const content::NavigationController& controller = 62 const content::NavigationController& controller =
65 web_contents->GetController(); 63 web_contents->GetController();
66 details.entry = controller.GetActiveEntry(); 64 details.entry = controller.GetActiveEntry();
67 if (controller.GetLastCommittedEntry()) { 65 if (controller.GetLastCommittedEntry()) {
68 details.previous_entry_index = controller.GetLastCommittedEntryIndex(); 66 details.previous_entry_index = controller.GetLastCommittedEntryIndex();
69 details.previous_url = controller.GetLastCommittedEntry()->GetURL(); 67 details.previous_url = controller.GetLastCommittedEntry()->GetURL();
70 } 68 }
71 details.type = content::NAVIGATION_TYPE_NEW_PAGE; 69 details.type = content::NAVIGATION_TYPE_NEW_PAGE;
72 for (int i = infobar_manager->infobar_count() - 1; i >= 0; --i) { 70 for (int i = service->infobar_count() - 1; i >= 0; --i) {
73 InfoBar* infobar = infobar_manager->infobar_at(i); 71 InfoBar* infobar = service->infobar_at(i);
74 if (infobar->delegate()->ShouldExpire( 72 if (infobar->delegate()->ShouldExpire(
75 InfoBarService::NavigationDetailsFromLoadCommittedDetails( 73 InfoBarService::NavigationDetailsFromLoadCommittedDetails(
76 details))) 74 details)))
77 infobar_manager->RemoveInfoBar(infobar); 75 service->RemoveInfoBar(infobar);
78 } 76 }
79 } 77 }
80 78
81 // TODO(bauerb): Extract an observer callback on ManagedUserService for this. 79 // TODO(bauerb): Extract an observer callback on ManagedUserService for this.
82 Profile* profile = 80 Profile* profile =
83 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 81 Profile::FromBrowserContext(web_contents->GetBrowserContext());
84 PrefService* prefs = profile->GetPrefs(); 82 PrefService* prefs = profile->GetPrefs();
85 pref_change_registrar_.Init(prefs); 83 pref_change_registrar_.Init(prefs);
86 pref_change_registrar_.Add( 84 pref_change_registrar_.Add(
87 prefs::kDefaultManagedModeFilteringBehavior, 85 prefs::kDefaultManagedModeFilteringBehavior,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 204
207 void ManagedModeInterstitial::OnFilteringPrefsChanged() { 205 void ManagedModeInterstitial::OnFilteringPrefsChanged() {
208 if (ShouldProceed()) 206 if (ShouldProceed())
209 interstitial_page_->Proceed(); 207 interstitial_page_->Proceed();
210 } 208 }
211 209
212 void ManagedModeInterstitial::DispatchContinueRequest(bool continue_request) { 210 void ManagedModeInterstitial::DispatchContinueRequest(bool continue_request) {
213 BrowserThread::PostTask( 211 BrowserThread::PostTask(
214 BrowserThread::IO, FROM_HERE, base::Bind(callback_, continue_request)); 212 BrowserThread::IO, FROM_HERE, base::Bind(callback_, continue_request));
215 } 213 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698