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

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

Issue 11299035: Support manual (white|black)list, previewing and allowing after interstitial (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Allow/block flow which includes preview mode. Created 8 years 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 "chrome/browser/managed_mode/managed_mode_navigation_observer.h"
8 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/tab_contents/tab_util.h" 11 #include "chrome/browser/tab_contents/tab_util.h"
11 #include "chrome/common/jstemplate_builder.h" 12 #include "chrome/common/jstemplate_builder.h"
12 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
13 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
14 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/interstitial_page.h" 16 #include "content/public/browser/interstitial_page.h"
16 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
17 #include "content/public/browser/web_contents_delegate.h" 18 #include "content/public/browser/web_contents_delegate.h"
(...skipping 13 matching lines...) Expand all
31 const base::Callback<void(bool)>& callback) { 32 const base::Callback<void(bool)>& callback) {
32 // The tab might have been closed. 33 // The tab might have been closed.
33 content::WebContents* web_contents = 34 content::WebContents* web_contents =
34 tab_util::GetWebContentsByID(render_process_host_id, render_view_id); 35 tab_util::GetWebContentsByID(render_process_host_id, render_view_id);
35 if (!web_contents) { 36 if (!web_contents) {
36 BrowserThread::PostTask( 37 BrowserThread::PostTask(
37 BrowserThread::IO, FROM_HERE, base::Bind(callback, true)); 38 BrowserThread::IO, FROM_HERE, base::Bind(callback, true));
38 return; 39 return;
39 } 40 }
40 41
42 ManagedModeNavigationObserver* navigation_observer =
43 ManagedModeNavigationObserver::FromWebContents(web_contents);
44 navigation_observer->MarkShownInterstitial();
45
41 new ManagedModeInterstitial(web_contents, url, callback); 46 new ManagedModeInterstitial(web_contents, url, callback);
42 } 47 }
43 48
44 void GoToNewTabPage(content::WebContents* web_contents) { 49 void GoToNewTabPage(content::WebContents* web_contents) {
45 web_contents->GetDelegate()->OpenURLFromTab( 50 web_contents->GetDelegate()->OpenURLFromTab(
46 web_contents, 51 web_contents,
47 content::OpenURLParams(GURL(chrome::kChromeUINewTabURL), 52 content::OpenURLParams(GURL(chrome::kChromeUINewTabURL),
48 content::Referrer(), 53 content::Referrer(),
49 CURRENT_TAB, 54 CURRENT_TAB,
50 content::PAGE_TRANSITION_LINK, 55 content::PAGE_TRANSITION_LINK,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 strings.SetString("backButton", l10n_util::GetStringUTF16(IDS_BACK_BUTTON)); 103 strings.SetString("backButton", l10n_util::GetStringUTF16(IDS_BACK_BUTTON));
99 strings.SetString("familyUrlsSectionButton", 104 strings.SetString("familyUrlsSectionButton",
100 l10n_util::GetStringUTF16(IDS_FAMILY_URLS_SECTION_BUTTON)); 105 l10n_util::GetStringUTF16(IDS_FAMILY_URLS_SECTION_BUTTON));
101 strings.SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr"); 106 strings.SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr");
102 107
103 base::StringPiece html( 108 base::StringPiece html(
104 ResourceBundle::GetSharedInstance().GetRawDataResource( 109 ResourceBundle::GetSharedInstance().GetRawDataResource(
105 IDR_BLOCK_INTERSTITIAL_HTML)); 110 IDR_BLOCK_INTERSTITIAL_HTML));
106 111
107 return jstemplate_builder::GetI18nTemplateHtml(html, &strings); 112 return jstemplate_builder::GetI18nTemplateHtml(html, &strings);
108 113
Bernhard Bauer 2012/11/26 16:06:30 Nit: Unnecessary newline
Sergiu 2012/11/27 15:37:34 Done.
109 } 114 }
110 115
111 void ManagedModeInterstitial::CommandReceived(const std::string& command) { 116 void ManagedModeInterstitial::CommandReceived(const std::string& command) {
112 if (command == "\"allow\"") { 117 if (command == "\"allow\"") {
113 interstitial_page_->Proceed(); 118 interstitial_page_->Proceed();
114 return; 119 return;
115 } 120 }
116 121
117 if (command == "\"back\"") { 122 if (command == "\"back\"") {
118 interstitial_page_->DontProceed(); 123 interstitial_page_->DontProceed();
(...skipping 13 matching lines...) Expand all
132 } 137 }
133 138
134 void ManagedModeInterstitial::OnDontProceed() { 139 void ManagedModeInterstitial::OnDontProceed() {
135 DispatchContinueRequest(false); 140 DispatchContinueRequest(false);
136 } 141 }
137 142
138 void ManagedModeInterstitial::DispatchContinueRequest(bool continue_request) { 143 void ManagedModeInterstitial::DispatchContinueRequest(bool continue_request) {
139 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 144 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
140 base::Bind(callback_, continue_request)); 145 base::Bind(callback_, continue_request));
141 } 146 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698