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

Side by Side Diff: chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc

Issue 9762004: Block scripted printing. (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
« no previous file with comments | « chrome/browser/printing/print_view_manager.cc ('k') | chrome/common/print_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ui/blocked_content/blocked_content_tab_helper.h" 5 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "chrome/browser/content_settings/host_content_settings_map.h" 8 #include "chrome/browser/content_settings/host_content_settings_map.h"
9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
10 #include "chrome/browser/printing/print_view_manager.h"
10 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/blocked_content/blocked_content_container.h" 12 #include "chrome/browser/ui/blocked_content/blocked_content_container.h"
12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
13 #include "content/public/browser/navigation_controller.h" 14 #include "content/public/browser/navigation_controller.h"
14 #include "content/public/browser/navigation_details.h" 15 #include "content/public/browser/navigation_details.h"
15 #include "content/public/browser/navigation_entry.h" 16 #include "content/public/browser/navigation_entry.h"
16 #include "content/public/browser/render_view_host.h" 17 #include "content/public/browser/render_view_host.h"
17 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
18 19
19 using content::NavigationEntry; 20 using content::NavigationEntry;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 53 }
53 54
54 void BlockedContentTabHelper::SetAllContentsBlocked(bool value) { 55 void BlockedContentTabHelper::SetAllContentsBlocked(bool value) {
55 if (all_contents_blocked_ == value) 56 if (all_contents_blocked_ == value)
56 return; 57 return;
57 58
58 all_contents_blocked_ = value; 59 all_contents_blocked_ = value;
59 if (!all_contents_blocked_ && blocked_contents_->GetBlockedContentsCount()) { 60 if (!all_contents_blocked_ && blocked_contents_->GetBlockedContentsCount()) {
60 std::vector<TabContentsWrapper*> blocked; 61 std::vector<TabContentsWrapper*> blocked;
61 blocked_contents_->GetBlockedContents(&blocked); 62 blocked_contents_->GetBlockedContents(&blocked);
62 for (size_t i = 0; i < blocked.size(); ++i) 63 for (size_t i = 0; i < blocked.size(); ++i) {
64 blocked[i]->print_view_manager()->SetScriptedPrintingBlocked(false);
63 blocked_contents_->LaunchForContents(blocked[i]); 65 blocked_contents_->LaunchForContents(blocked[i]);
66 }
64 } 67 }
65 } 68 }
66 69
67 void BlockedContentTabHelper::AddTabContents(TabContentsWrapper* new_contents, 70 void BlockedContentTabHelper::AddTabContents(TabContentsWrapper* new_contents,
68 WindowOpenDisposition disposition, 71 WindowOpenDisposition disposition,
69 const gfx::Rect& initial_pos, 72 const gfx::Rect& initial_pos,
70 bool user_gesture) { 73 bool user_gesture) {
71 if (!blocked_contents_->GetBlockedContentsCount()) 74 if (!blocked_contents_->GetBlockedContentsCount())
72 PopupNotificationVisibilityChanged(true); 75 PopupNotificationVisibilityChanged(true);
76 new_contents->print_view_manager()->SetScriptedPrintingBlocked(true);
73 blocked_contents_->AddTabContents( 77 blocked_contents_->AddTabContents(
74 new_contents, disposition, initial_pos, user_gesture); 78 new_contents, disposition, initial_pos, user_gesture);
75 } 79 }
76 80
77 void BlockedContentTabHelper::AddPopup(TabContentsWrapper* new_contents, 81 void BlockedContentTabHelper::AddPopup(TabContentsWrapper* new_contents,
78 const gfx::Rect& initial_pos, 82 const gfx::Rect& initial_pos,
79 bool user_gesture) { 83 bool user_gesture) {
80 // A page can't spawn popups (or do anything else, either) until its load 84 // A page can't spawn popups (or do anything else, either) until its load
81 // commits, so when we reach here, the popup was spawned by the 85 // commits, so when we reach here, the popup was spawned by the
82 // NavigationController's last committed entry, not the active entry. For 86 // NavigationController's last committed entry, not the active entry. For
(...skipping 13 matching lines...) Expand all
96 creator, 100 creator,
97 CONTENT_SETTINGS_TYPE_POPUPS, 101 CONTENT_SETTINGS_TYPE_POPUPS,
98 "") == CONTENT_SETTING_ALLOW) { 102 "") == CONTENT_SETTING_ALLOW) {
99 web_contents()->AddNewContents(new_contents->web_contents(), 103 web_contents()->AddNewContents(new_contents->web_contents(),
100 NEW_POPUP, 104 NEW_POPUP,
101 initial_pos, 105 initial_pos,
102 true); // user_gesture 106 true); // user_gesture
103 } else { 107 } else {
104 // Call blocked_contents_->AddTabContents with user_gesture == true 108 // Call blocked_contents_->AddTabContents with user_gesture == true
105 // so that the contents will not get blocked again. 109 // so that the contents will not get blocked again.
110 new_contents->print_view_manager()->SetScriptedPrintingBlocked(true);
106 blocked_contents_->AddTabContents(new_contents, 111 blocked_contents_->AddTabContents(new_contents,
107 NEW_POPUP, 112 NEW_POPUP,
108 initial_pos, 113 initial_pos,
109 true); // user_gesture 114 true); // user_gesture
110 tab_contents_wrapper_->content_settings()->OnContentBlocked( 115 tab_contents_wrapper_->content_settings()->OnContentBlocked(
111 CONTENT_SETTINGS_TYPE_POPUPS, std::string()); 116 CONTENT_SETTINGS_TYPE_POPUPS, std::string());
112 } 117 }
113 } 118 }
114 119
115 void BlockedContentTabHelper::LaunchForContents( 120 void BlockedContentTabHelper::LaunchForContents(
116 TabContentsWrapper* tab_contents) { 121 TabContentsWrapper* tab_contents) {
122 tab_contents->print_view_manager()->SetScriptedPrintingBlocked(false);
117 blocked_contents_->LaunchForContents(tab_contents); 123 blocked_contents_->LaunchForContents(tab_contents);
118 if (!blocked_contents_->GetBlockedContentsCount()) 124 if (!blocked_contents_->GetBlockedContentsCount())
119 PopupNotificationVisibilityChanged(false); 125 PopupNotificationVisibilityChanged(false);
120 } 126 }
121 127
122 size_t BlockedContentTabHelper::GetBlockedContentsCount() const { 128 size_t BlockedContentTabHelper::GetBlockedContentsCount() const {
123 return blocked_contents_->GetBlockedContentsCount(); 129 return blocked_contents_->GetBlockedContentsCount();
124 } 130 }
125 131
126 void BlockedContentTabHelper::GetBlockedContents( 132 void BlockedContentTabHelper::GetBlockedContents(
127 std::vector<TabContentsWrapper*>* blocked_contents) const { 133 std::vector<TabContentsWrapper*>* blocked_contents) const {
128 blocked_contents_->GetBlockedContents(blocked_contents); 134 blocked_contents_->GetBlockedContents(blocked_contents);
129 } 135 }
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_view_manager.cc ('k') | chrome/common/print_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698