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

Side by Side Diff: chrome/browser/tab_contents/tab_contents.cc

Issue 2370001: Store blocked cookies in the tab contents. (Closed)
Patch Set: updates Created 10 years, 5 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/tab_contents/tab_contents.h" 5 #include "chrome/browser/tab_contents/tab_contents.h"
6 6
7 #if defined(OS_CHROMEOS) 7 #if defined(OS_CHROMEOS)
8 // For GdkScreen 8 // For GdkScreen
9 #include <gdk/gdk.h> 9 #include <gdk/gdk.h>
10 #endif // defined(OS_CHROMEOS) 10 #endif // defined(OS_CHROMEOS)
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 history_requests_(), 287 history_requests_(),
288 #if defined(OS_WIN) 288 #if defined(OS_WIN)
289 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), 289 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)),
290 #endif 290 #endif
291 last_javascript_message_dismissal_(), 291 last_javascript_message_dismissal_(),
292 suppress_javascript_messages_(false), 292 suppress_javascript_messages_(false),
293 is_showing_before_unload_dialog_(false), 293 is_showing_before_unload_dialog_(false),
294 renderer_preferences_(), 294 renderer_preferences_(),
295 opener_dom_ui_type_(DOMUIFactory::kNoDOMUI), 295 opener_dom_ui_type_(DOMUIFactory::kNoDOMUI),
296 language_state_(&controller_), 296 language_state_(&controller_),
297 geolocation_settings_state_(profile),
298 closed_by_user_gesture_(false) { 297 closed_by_user_gesture_(false) {
299 ClearBlockedContentSettings();
300 renderer_preferences_util::UpdateFromSystemSettings( 298 renderer_preferences_util::UpdateFromSystemSettings(
301 &renderer_preferences_, profile); 299 &renderer_preferences_, profile);
302 300
301 content_settings_delegate_.reset(
302 new TabSpecificContentSettings(this, profile));
303
303 #if defined(OS_CHROMEOS) 304 #if defined(OS_CHROMEOS)
304 // Make sure the thumbnailer is started before starting the render manager. 305 // Make sure the thumbnailer is started before starting the render manager.
305 // The thumbnailer will want to listen for RVH creations, one of which will 306 // The thumbnailer will want to listen for RVH creations, one of which will
306 // happen in RVHManager::Init. 307 // happen in RVHManager::Init.
307 ThumbnailGenerator* generator = g_browser_process->GetThumbnailGenerator(); 308 ThumbnailGenerator* generator = g_browser_process->GetThumbnailGenerator();
308 if (generator) 309 if (generator)
309 generator->StartThumbnailing(); 310 generator->StartThumbnailing();
310 #endif 311 #endif
311 312
312 render_manager_.Init(profile, site_instance, routing_id); 313 render_manager_.Init(profile, site_instance, routing_id);
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 // Always display a throbber during pending loads. 643 // Always display a throbber during pending loads.
643 if (controller_.GetLastCommittedEntry() && controller_.pending_entry()) 644 if (controller_.GetLastCommittedEntry() && controller_.pending_entry())
644 return true; 645 return true;
645 646
646 DOMUI* dom_ui = GetDOMUIForCurrentState(); 647 DOMUI* dom_ui = GetDOMUIForCurrentState();
647 if (dom_ui) 648 if (dom_ui)
648 return !dom_ui->hide_favicon(); 649 return !dom_ui->hide_favicon();
649 return true; 650 return true;
650 } 651 }
651 652
652 bool TabContents::IsContentBlocked(ContentSettingsType content_type) const {
653 DCHECK(content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION)
654 << "Geolocation settings handled by ContentSettingGeolocationImageModel";
655 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
656 << "Notifications settings handled by "
657 << "ContentSettingsNotificationsImageModel";
658
659 if (content_type == CONTENT_SETTINGS_TYPE_POPUPS)
660 return blocked_popups_ != NULL;
661
662 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES ||
663 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT ||
664 content_type == CONTENT_SETTINGS_TYPE_PLUGINS ||
665 content_type == CONTENT_SETTINGS_TYPE_COOKIES)
666 return content_blocked_[content_type];
667
668 NOTREACHED();
669 return false;
670 }
671
672 std::wstring TabContents::GetStatusText() const { 653 std::wstring TabContents::GetStatusText() const {
673 if (!is_loading() || load_state_ == net::LOAD_STATE_IDLE) 654 if (!is_loading() || load_state_ == net::LOAD_STATE_IDLE)
674 return std::wstring(); 655 return std::wstring();
675 656
676 switch (load_state_) { 657 switch (load_state_) {
677 case net::LOAD_STATE_WAITING_FOR_CACHE: 658 case net::LOAD_STATE_WAITING_FOR_CACHE:
678 return l10n_util::GetString(IDS_LOAD_STATE_WAITING_FOR_CACHE); 659 return l10n_util::GetString(IDS_LOAD_STATE_WAITING_FOR_CACHE);
679 case net::LOAD_STATE_ESTABLISHING_PROXY_TUNNEL: 660 case net::LOAD_STATE_ESTABLISHING_PROXY_TUNNEL:
680 return l10n_util::GetString(IDS_LOAD_STATE_ESTABLISHING_PROXY_TUNNEL); 661 return l10n_util::GetString(IDS_LOAD_STATE_ESTABLISHING_PROXY_TUNNEL);
681 case net::LOAD_STATE_RESOLVING_PROXY_FOR_URL: 662 case net::LOAD_STATE_RESOLVING_PROXY_FOR_URL:
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 return false; 931 return false;
951 932
952 return host->Send(new ViewMsg_ExecuteCode(host->routing_id(), 933 return host->Send(new ViewMsg_ExecuteCode(host->routing_id(),
953 ViewMsg_ExecuteCode_Params(request_id, extension_id, host_permissions, 934 ViewMsg_ExecuteCode_Params(request_id, extension_id, host_permissions,
954 is_js_code, code_string, all_frames))); 935 is_js_code, code_string, all_frames)));
955 } 936 }
956 937
957 void TabContents::PopupNotificationVisibilityChanged(bool visible) { 938 void TabContents::PopupNotificationVisibilityChanged(bool visible) {
958 if (is_being_destroyed_) 939 if (is_being_destroyed_)
959 return; 940 return;
941 content_settings_delegate_->SetPopupsBlocked(visible);
960 if (!dont_notify_render_view_) 942 if (!dont_notify_render_view_)
961 render_view_host()->AllowScriptToClose(!visible); 943 render_view_host()->AllowScriptToClose(!visible);
962 if (delegate_)
963 delegate_->OnContentSettingsChange(this);
964 } 944 }
965 945
966 gfx::NativeView TabContents::GetContentNativeView() const { 946 gfx::NativeView TabContents::GetContentNativeView() const {
967 return view_->GetContentNativeView(); 947 return view_->GetContentNativeView();
968 } 948 }
969 949
970 gfx::NativeView TabContents::GetNativeView() const { 950 gfx::NativeView TabContents::GetNativeView() const {
971 return view_->GetNativeView(); 951 return view_->GetNativeView();
972 } 952 }
973 953
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 new TabContents(profile(), NULL, MSG_ROUTING_NONE, NULL); 1367 new TabContents(profile(), NULL, MSG_ROUTING_NONE, NULL);
1388 new_contents->SetExtensionApp(extension_app_); 1368 new_contents->SetExtensionApp(extension_app_);
1389 new_contents->controller().RestoreFromState(navigations, 0, false); 1369 new_contents->controller().RestoreFromState(navigations, 0, false);
1390 1370
1391 if (!extension_app_ && entry) 1371 if (!extension_app_ && entry)
1392 new_contents->controller().GetActiveEntry()->favicon() = entry->favicon(); 1372 new_contents->controller().GetActiveEntry()->favicon() = entry->favicon();
1393 1373
1394 return new_contents; 1374 return new_contents;
1395 } 1375 }
1396 1376
1397 // Resets the |content_blocked_| array.
1398 void TabContents::ClearBlockedContentSettings() {
1399 for (size_t i = 0; i < arraysize(content_blocked_); ++i)
1400 content_blocked_[i] = false;
1401 }
1402
1403 // Notifies the RenderWidgetHost instance about the fact that the page is 1377 // Notifies the RenderWidgetHost instance about the fact that the page is
1404 // loading, or done loading and calls the base implementation. 1378 // loading, or done loading and calls the base implementation.
1405 void TabContents::SetIsLoading(bool is_loading, 1379 void TabContents::SetIsLoading(bool is_loading,
1406 LoadNotificationDetails* details) { 1380 LoadNotificationDetails* details) {
1407 if (is_loading == is_loading_) 1381 if (is_loading == is_loading_)
1408 return; 1382 return;
1409 1383
1410 if (!is_loading) { 1384 if (!is_loading) {
1411 load_state_ = net::LOAD_STATE_IDLE; 1385 load_state_ = net::LOAD_STATE_IDLE;
1412 load_state_host_.clear(); 1386 load_state_host_.clear();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 GURL creator = entry ? entry->virtual_url() : GURL::EmptyGURL(); 1420 GURL creator = entry ? entry->virtual_url() : GURL::EmptyGURL();
1447 1421
1448 if (creator.is_valid() && 1422 if (creator.is_valid() &&
1449 profile()->GetHostContentSettingsMap()->GetContentSetting( 1423 profile()->GetHostContentSettingsMap()->GetContentSetting(
1450 creator, CONTENT_SETTINGS_TYPE_POPUPS) == CONTENT_SETTING_ALLOW) { 1424 creator, CONTENT_SETTINGS_TYPE_POPUPS) == CONTENT_SETTING_ALLOW) {
1451 AddNewContents(new_contents, NEW_POPUP, initial_pos, true); 1425 AddNewContents(new_contents, NEW_POPUP, initial_pos, true);
1452 } else { 1426 } else {
1453 if (!blocked_popups_) 1427 if (!blocked_popups_)
1454 blocked_popups_ = new BlockedPopupContainer(this); 1428 blocked_popups_ = new BlockedPopupContainer(this);
1455 blocked_popups_->AddTabContents(new_contents, initial_pos); 1429 blocked_popups_->AddTabContents(new_contents, initial_pos);
1430 content_settings_delegate_->OnContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS);
1456 } 1431 }
1457 } 1432 }
1458 1433
1459 namespace { 1434 namespace {
1460 bool TransitionIsReload(PageTransition::Type transition) { 1435 bool TransitionIsReload(PageTransition::Type transition) {
1461 return PageTransition::StripQualifier(transition) == PageTransition::RELOAD; 1436 return PageTransition::StripQualifier(transition) == PageTransition::RELOAD;
1462 } 1437 }
1463 } 1438 }
1464 1439
1465 void TabContents::ExpireInfoBars( 1440 void TabContents::ExpireInfoBars(
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 } 1563 }
1589 1564
1590 // Close blocked popups. 1565 // Close blocked popups.
1591 if (blocked_popups_) { 1566 if (blocked_popups_) {
1592 AutoReset<bool> auto_reset(&dont_notify_render_view_, true); 1567 AutoReset<bool> auto_reset(&dont_notify_render_view_, true);
1593 blocked_popups_->Destroy(); 1568 blocked_popups_->Destroy();
1594 blocked_popups_ = NULL; 1569 blocked_popups_ = NULL;
1595 } 1570 }
1596 1571
1597 // Clear "blocked" flags. 1572 // Clear "blocked" flags.
1598 ClearBlockedContentSettings(); 1573 content_settings_delegate_->ClearBlockedContentSettings();
1599 geolocation_settings_state_.DidNavigate(details); 1574 content_settings_delegate_->GeolocationDidNavigate(details);
1600 if (delegate_)
1601 delegate_->OnContentSettingsChange(this);
1602 1575
1603 // Once the main frame is navigated, we're no longer considered to have 1576 // Once the main frame is navigated, we're no longer considered to have
1604 // displayed insecure content. 1577 // displayed insecure content.
1605 displayed_insecure_content_ = false; 1578 displayed_insecure_content_ = false;
1606 } 1579 }
1607 1580
1608 // Close constrained windows if necessary. 1581 // Close constrained windows if necessary.
1609 if (!net::RegistryControlledDomainService::SameDomainOrHost( 1582 if (!net::RegistryControlledDomainService::SameDomainOrHost(
1610 details.previous_url, details.entry->url())) 1583 details.previous_url, details.entry->url()))
1611 CloseConstrainedWindows(); 1584 CloseConstrainedWindows();
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
2131 NotificationService::current()->Notify( 2104 NotificationService::current()->Notify(
2132 NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR, 2105 NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR,
2133 Source<NavigationController>(&controller_), 2106 Source<NavigationController>(&controller_),
2134 Details<ProvisionalLoadDetails>(&details)); 2107 Details<ProvisionalLoadDetails>(&details));
2135 } 2108 }
2136 2109
2137 void TabContents::DocumentLoadedInFrame() { 2110 void TabContents::DocumentLoadedInFrame() {
2138 controller_.DocumentLoadedInFrame(); 2111 controller_.DocumentLoadedInFrame();
2139 } 2112 }
2140 2113
2141 void TabContents::OnContentBlocked(ContentSettingsType type) { 2114 void TabContents::OnContentSettingsChange() {
2142 DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION)
2143 << "Geolocation settings handled by OnGeolocationPermissionSet";
2144 content_blocked_[type] = true;
2145 if (delegate_) 2115 if (delegate_)
2146 delegate_->OnContentSettingsChange(this); 2116 delegate_->OnContentSettingsChange(this);
2147 } 2117 }
2148
2149 void TabContents::OnGeolocationPermissionSet(const GURL& requesting_origin,
2150 bool allowed) {
2151 geolocation_settings_state_.OnGeolocationPermissionSet(requesting_origin,
2152 allowed);
2153 if (delegate_)
2154 delegate_->OnContentSettingsChange(this);
2155 }
2156 2118
2157 RenderViewHostDelegate::View* TabContents::GetViewDelegate() { 2119 RenderViewHostDelegate::View* TabContents::GetViewDelegate() {
2158 return view_.get(); 2120 return view_.get();
2159 } 2121 }
2160 2122
2161 RenderViewHostDelegate::RendererManagement* 2123 RenderViewHostDelegate::RendererManagement*
2162 TabContents::GetRendererManagementDelegate() { 2124 TabContents::GetRendererManagementDelegate() {
2163 return &render_manager_; 2125 return &render_manager_;
2164 } 2126 }
2165 2127
2166 RenderViewHostDelegate::BrowserIntegration* 2128 RenderViewHostDelegate::BrowserIntegration*
2167 TabContents::GetBrowserIntegrationDelegate() { 2129 TabContents::GetBrowserIntegrationDelegate() {
2168 return this; 2130 return this;
2169 } 2131 }
2170 2132
2171 RenderViewHostDelegate::Resource* TabContents::GetResourceDelegate() { 2133 RenderViewHostDelegate::Resource* TabContents::GetResourceDelegate() {
2172 return this; 2134 return this;
2173 } 2135 }
2174 2136
2175 RenderViewHostDelegate::ContentSettings* 2137 RenderViewHostDelegate::ContentSettings*
2176 TabContents::GetContentSettingsDelegate() { 2138 TabContents::GetContentSettingsDelegate() {
2177 return this; 2139 return content_settings_delegate_.get();
2178 } 2140 }
2179 2141
2180 RenderViewHostDelegate::Save* TabContents::GetSaveDelegate() { 2142 RenderViewHostDelegate::Save* TabContents::GetSaveDelegate() {
2181 return save_package_.get(); // May be NULL, but we can return NULL. 2143 return save_package_.get(); // May be NULL, but we can return NULL.
2182 } 2144 }
2183 2145
2184 RenderViewHostDelegate::Printing* TabContents::GetPrintingDelegate() { 2146 RenderViewHostDelegate::Printing* TabContents::GetPrintingDelegate() {
2185 return &printing_; 2147 return &printing_;
2186 } 2148 }
2187 2149
(...skipping 18 matching lines...) Expand all
2206 2168
2207 RenderViewHostDelegate::BookmarkDrag* TabContents::GetBookmarkDragDelegate() { 2169 RenderViewHostDelegate::BookmarkDrag* TabContents::GetBookmarkDragDelegate() {
2208 return bookmark_drag_; 2170 return bookmark_drag_;
2209 } 2171 }
2210 2172
2211 void TabContents::SetBookmarkDragDelegate( 2173 void TabContents::SetBookmarkDragDelegate(
2212 RenderViewHostDelegate::BookmarkDrag* bookmark_drag) { 2174 RenderViewHostDelegate::BookmarkDrag* bookmark_drag) {
2213 bookmark_drag_ = bookmark_drag; 2175 bookmark_drag_ = bookmark_drag;
2214 } 2176 }
2215 2177
2178 TabSpecificContentSettings* TabContents::GetTabSpecificContentSettings() const {
2179 return content_settings_delegate_.get();
2180 }
2181
2216 RendererPreferences TabContents::GetRendererPrefs(Profile* profile) const { 2182 RendererPreferences TabContents::GetRendererPrefs(Profile* profile) const {
2217 return renderer_preferences_; 2183 return renderer_preferences_;
2218 } 2184 }
2219 2185
2220 TabContents* TabContents::GetAsTabContents() { 2186 TabContents* TabContents::GetAsTabContents() {
2221 return this; 2187 return this;
2222 } 2188 }
2223 2189
2224 ViewType::Type TabContents::GetRenderViewType() const { 2190 ViewType::Type TabContents::GetRenderViewType() const {
2225 return ViewType::TAB_CONTENTS; 2191 return ViewType::TAB_CONTENTS;
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
3181 AddInfoBar(new SavePasswordInfoBarDelegate(this, form_to_save)); 3147 AddInfoBar(new SavePasswordInfoBarDelegate(this, form_to_save));
3182 } 3148 }
3183 3149
3184 Profile* TabContents::GetProfileForPasswordManager() { 3150 Profile* TabContents::GetProfileForPasswordManager() {
3185 return profile(); 3151 return profile();
3186 } 3152 }
3187 3153
3188 bool TabContents::DidLastPageLoadEncounterSSLErrors() { 3154 bool TabContents::DidLastPageLoadEncounterSSLErrors() {
3189 return controller().ssl_manager()->ProcessedSSLErrorFromRequest(); 3155 return controller().ssl_manager()->ProcessedSSLErrorFromRequest();
3190 } 3156 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698