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

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

Issue 650180: Initial Geolocation location bar icons. (Closed)
Patch Set: Addresses Peter and Brett's comments. Created 10 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
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 #include "app/gfx/text_elider.h" 7 #include "app/gfx/text_elider.h"
8 #include "app/l10n_util.h" 8 #include "app/l10n_util.h"
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 bool TabContents::IsContentBlocked(ContentSettingsType content_type) const { 596 bool TabContents::IsContentBlocked(ContentSettingsType content_type) const {
597 if (content_type == CONTENT_SETTINGS_TYPE_POPUPS) 597 if (content_type == CONTENT_SETTINGS_TYPE_POPUPS)
598 return blocked_popups_ != NULL; 598 return blocked_popups_ != NULL;
599 599
600 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || 600 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES ||
601 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || 601 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT ||
602 content_type == CONTENT_SETTINGS_TYPE_PLUGINS || 602 content_type == CONTENT_SETTINGS_TYPE_PLUGINS ||
603 content_type == CONTENT_SETTINGS_TYPE_COOKIES) 603 content_type == CONTENT_SETTINGS_TYPE_COOKIES)
604 return content_blocked_[content_type]; 604 return content_blocked_[content_type];
605 605
606 if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
607 for (GeolocationContentSettings::const_iterator i =
608 geolocation_content_settings_.begin();
609 i != geolocation_content_settings_.end(); ++i ) {
610 if (i->second == CONTENT_SETTING_ALLOW)
611 return false;
612 }
613 // Note: this does not necessarily mean that Geolocation is blocked, rather
614 // that there are no frames currently using or allowed to use Geolocation.
615 return true;
616 }
617
606 NOTREACHED(); 618 NOTREACHED();
607 return false; 619 return false;
608 } 620 }
609 621
610 std::wstring TabContents::GetStatusText() const { 622 std::wstring TabContents::GetStatusText() const {
611 if (!is_loading() || load_state_ == net::LOAD_STATE_IDLE) 623 if (!is_loading() || load_state_ == net::LOAD_STATE_IDLE)
612 return std::wstring(); 624 return std::wstring();
613 625
614 switch (load_state_) { 626 switch (load_state_) {
615 case net::LOAD_STATE_WAITING_FOR_CACHE: 627 case net::LOAD_STATE_WAITING_FOR_CACHE:
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 1290
1279 return new_contents; 1291 return new_contents;
1280 } 1292 }
1281 1293
1282 // Resets the |content_blocked_| array. 1294 // Resets the |content_blocked_| array.
1283 void TabContents::ClearBlockedContentSettings() { 1295 void TabContents::ClearBlockedContentSettings() {
1284 for (size_t i = 0; i < arraysize(content_blocked_); ++i) 1296 for (size_t i = 0; i < arraysize(content_blocked_); ++i)
1285 content_blocked_[i] = false; 1297 content_blocked_[i] = false;
1286 } 1298 }
1287 1299
1300 // Resets the |geolocation_settings_| map.
1301 void TabContents::ClearGeolocationContentSettings() {
1302 geolocation_content_settings_.clear();
1303 }
1304
1288 // Notifies the RenderWidgetHost instance about the fact that the page is 1305 // Notifies the RenderWidgetHost instance about the fact that the page is
1289 // loading, or done loading and calls the base implementation. 1306 // loading, or done loading and calls the base implementation.
1290 void TabContents::SetIsLoading(bool is_loading, 1307 void TabContents::SetIsLoading(bool is_loading,
1291 LoadNotificationDetails* details) { 1308 LoadNotificationDetails* details) {
1292 if (is_loading == is_loading_) 1309 if (is_loading == is_loading_)
1293 return; 1310 return;
1294 1311
1295 if (!is_loading) { 1312 if (!is_loading) {
1296 load_state_ = net::LOAD_STATE_IDLE; 1313 load_state_ = net::LOAD_STATE_IDLE;
1297 load_state_host_.clear(); 1314 load_state_host_.clear();
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 1482
1466 // Close blocked popups. 1483 // Close blocked popups.
1467 if (blocked_popups_) { 1484 if (blocked_popups_) {
1468 AutoReset auto_reset(&dont_notify_render_view_, true); 1485 AutoReset auto_reset(&dont_notify_render_view_, true);
1469 blocked_popups_->Destroy(); 1486 blocked_popups_->Destroy();
1470 blocked_popups_ = NULL; 1487 blocked_popups_ = NULL;
1471 } 1488 }
1472 1489
1473 // Clear "blocked" flags. 1490 // Clear "blocked" flags.
1474 ClearBlockedContentSettings(); 1491 ClearBlockedContentSettings();
1492 ClearGeolocationContentSettings();
1475 if (delegate_) 1493 if (delegate_)
1476 delegate_->OnBlockedContentChange(this); 1494 delegate_->OnBlockedContentChange(this);
1477 } 1495 }
1478 1496
1479 // Close constrained windows if necessary. 1497 // Close constrained windows if necessary.
1480 if (!net::RegistryControlledDomainService::SameDomainOrHost( 1498 if (!net::RegistryControlledDomainService::SameDomainOrHost(
1481 details.previous_url, details.entry->url())) 1499 details.previous_url, details.entry->url()))
1482 CloseConstrainedWindows(); 1500 CloseConstrainedWindows();
1483 1501
1484 // Update the starred state. 1502 // Update the starred state.
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 void TabContents::DocumentLoadedInFrame() { 2017 void TabContents::DocumentLoadedInFrame() {
2000 controller_.DocumentLoadedInFrame(); 2018 controller_.DocumentLoadedInFrame();
2001 } 2019 }
2002 2020
2003 void TabContents::OnContentBlocked(ContentSettingsType type) { 2021 void TabContents::OnContentBlocked(ContentSettingsType type) {
2004 content_blocked_[type] = true; 2022 content_blocked_[type] = true;
2005 if (delegate_) 2023 if (delegate_)
2006 delegate_->OnBlockedContentChange(this); 2024 delegate_->OnBlockedContentChange(this);
2007 } 2025 }
2008 2026
2027 void TabContents::OnGeolocationPermissionSet(
2028 const std::string& host, bool allowed) {
2029 geolocation_content_settings_[host] =
2030 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
2031 // TODO(bulach): rename OnBlockedContentChange to OnContentSettingsChange.
2032 if (delegate_)
2033 delegate_->OnBlockedContentChange(this);
2034 }
2035
2009 RenderViewHostDelegate::View* TabContents::GetViewDelegate() { 2036 RenderViewHostDelegate::View* TabContents::GetViewDelegate() {
2010 return view_.get(); 2037 return view_.get();
2011 } 2038 }
2012 2039
2013 RenderViewHostDelegate::RendererManagement* 2040 RenderViewHostDelegate::RendererManagement*
2014 TabContents::GetRendererManagementDelegate() { 2041 TabContents::GetRendererManagementDelegate() {
2015 return &render_manager_; 2042 return &render_manager_;
2016 } 2043 }
2017 2044
2018 RenderViewHostDelegate::BrowserIntegration* 2045 RenderViewHostDelegate::BrowserIntegration*
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
2863 } 2890 }
2864 2891
2865 void TabContents::set_encoding(const std::string& encoding) { 2892 void TabContents::set_encoding(const std::string& encoding) {
2866 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); 2893 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding);
2867 } 2894 }
2868 2895
2869 void TabContents::SetAppIcon(const SkBitmap& app_icon) { 2896 void TabContents::SetAppIcon(const SkBitmap& app_icon) {
2870 app_icon_ = app_icon; 2897 app_icon_ = app_icon;
2871 NotifyNavigationStateChanged(INVALIDATE_TITLE); 2898 NotifyNavigationStateChanged(INVALIDATE_TITLE);
2872 } 2899 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.h ('k') | chrome/browser/views/content_blocked_bubble_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698