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

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

Issue 6413014: Original patch from issue 570048 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: a few fixes Created 9 years, 10 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <cmath> 7 #include <cmath>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 1441
1442 void TabContents::UpdateHistoryPageTitle(const NavigationEntry& entry) { 1442 void TabContents::UpdateHistoryPageTitle(const NavigationEntry& entry) {
1443 if (profile()->IsOffTheRecord()) 1443 if (profile()->IsOffTheRecord())
1444 return; 1444 return;
1445 1445
1446 HistoryService* hs = profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); 1446 HistoryService* hs = profile()->GetHistoryService(Profile::IMPLICIT_ACCESS);
1447 if (hs) 1447 if (hs)
1448 hs->SetPageTitle(entry.virtual_url(), entry.title()); 1448 hs->SetPageTitle(entry.virtual_url(), entry.title());
1449 } 1449 }
1450 1450
1451 int TabContents::SetZoomLevel(double zoom_level) {
1452 static int request_id = -1;
1453
1454 ++request_id;
Aaron Boodman 2011/02/07 09:26:55 Chromium style forbids post-increment.
1455 render_view_host()->SetZoomLevel(request_id, zoom_level);
1456 return request_id;
1457 }
1458
1451 double TabContents::GetZoomLevel() const { 1459 double TabContents::GetZoomLevel() const {
1452 HostZoomMap* zoom_map = profile()->GetHostZoomMap(); 1460 HostZoomMap* zoom_map = profile()->GetHostZoomMap();
1453 if (!zoom_map) 1461 if (!zoom_map)
1454 return 0; 1462 return 0;
1455 1463
1456 double zoom_level; 1464 double zoom_level;
1457 if (temporary_zoom_settings_) { 1465 if (temporary_zoom_settings_) {
1458 zoom_level = zoom_map->GetTemporaryZoomLevel( 1466 zoom_level = zoom_map->GetTemporaryZoomLevel(
1459 GetRenderProcessHost()->id(), render_view_host()->routing_id()); 1467 GetRenderProcessHost()->id(), render_view_host()->routing_id());
1460 } else { 1468 } else {
1461 zoom_level = zoom_map->GetZoomLevel(GetURL()); 1469 zoom_level = zoom_map->GetZoomLevel(GetURL());
1462 } 1470 }
1463 return zoom_level; 1471 return zoom_level;
1464 } 1472 }
1465 1473
1466 int TabContents::GetZoomPercent(bool* enable_increment, 1474 int TabContents::SetZoomPercent(double zoom_percent) {
1475 double zoom_level;
1476 zoom_level = WebKit::WebView::zoomFactorToZoomLevel(zoom_percent / 100);
1477 return SetZoomLevel(zoom_level);
1478 }
1479
1480 double TabContents::GetZoomPercent(bool* enable_increment,
1467 bool* enable_decrement) { 1481 bool* enable_decrement) {
1468 *enable_decrement = *enable_increment = false; 1482 *enable_decrement = *enable_increment = false;
1469 int percent = static_cast<int>( 1483 double percent = 0.0;
1470 WebKit::WebView::zoomLevelToZoomFactor(GetZoomLevel()) * 100); 1484 percent = WebKit::WebView::zoomLevelToZoomFactor(GetZoomLevel()) * 100;
1471 *enable_decrement = percent > minimum_zoom_percent_; 1485 *enable_decrement = percent > minimum_zoom_percent_;
1472 *enable_increment = percent < maximum_zoom_percent_; 1486 *enable_increment = percent < maximum_zoom_percent_;
1473 return percent; 1487 return percent;
1474 } 1488 }
1475 1489
1476 void TabContents::ViewSource() { 1490 void TabContents::ViewSource() {
1477 if (!delegate_) 1491 if (!delegate_)
1478 return; 1492 return;
1479 1493
1480 NavigationEntry* active_entry = controller().GetActiveEntry(); 1494 NavigationEntry* active_entry = controller().GetActiveEntry();
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 void TabContents::UpdateAlternateErrorPageURL() { 1905 void TabContents::UpdateAlternateErrorPageURL() {
1892 GURL url = GetAlternateErrorPageURL(); 1906 GURL url = GetAlternateErrorPageURL();
1893 render_view_host()->SetAlternateErrorPageURL(url); 1907 render_view_host()->SetAlternateErrorPageURL(url);
1894 } 1908 }
1895 1909
1896 void TabContents::UpdateWebPreferences() { 1910 void TabContents::UpdateWebPreferences() {
1897 render_view_host()->UpdateWebPreferences(GetWebkitPrefs()); 1911 render_view_host()->UpdateWebPreferences(GetWebkitPrefs());
1898 } 1912 }
1899 1913
1900 void TabContents::UpdateZoomLevel() { 1914 void TabContents::UpdateZoomLevel() {
1901 render_view_host()->SetZoomLevel(GetZoomLevel()); 1915 SetZoomLevel(GetZoomLevel());
1902 } 1916 }
1903 1917
1904 void TabContents::UpdateMaxPageIDIfNecessary(SiteInstance* site_instance, 1918 void TabContents::UpdateMaxPageIDIfNecessary(SiteInstance* site_instance,
1905 RenderViewHost* rvh) { 1919 RenderViewHost* rvh) {
1906 // If we are creating a RVH for a restored controller, then we might 1920 // If we are creating a RVH for a restored controller, then we might
1907 // have more page IDs than the SiteInstance's current max page ID. We must 1921 // have more page IDs than the SiteInstance's current max page ID. We must
1908 // make sure that the max page ID is larger than any restored page ID. 1922 // make sure that the max page ID is larger than any restored page ID.
1909 // Note that it is ok for conflicting page IDs to exist in another tab 1923 // Note that it is ok for conflicting page IDs to exist in another tab
1910 // (i.e., NavigationController), but if any page ID is larger than the max, 1924 // (i.e., NavigationController), but if any page ID is larger than the max,
1911 // the back/forward list will get confused. 1925 // the back/forward list will get confused.
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after
3128 } 3142 }
3129 3143
3130 bool TabContents::MaybeUsePreloadedPage(const GURL& url) { 3144 bool TabContents::MaybeUsePreloadedPage(const GURL& url) {
3131 PrerenderManager* pm = profile()->GetPrerenderManager(); 3145 PrerenderManager* pm = profile()->GetPrerenderManager();
3132 if (pm != NULL) { 3146 if (pm != NULL) {
3133 if (pm->MaybeUsePreloadedPage(this, url)) 3147 if (pm->MaybeUsePreloadedPage(this, url))
3134 return true; 3148 return true;
3135 } 3149 }
3136 return false; 3150 return false;
3137 } 3151 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698