OLD | NEW |
---|---|
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/zoom/zoom_controller.h" | 5 #include "chrome/browser/ui/zoom/zoom_controller.h" |
6 | 6 |
7 #include "chrome/browser/prefs/pref_service.h" | 7 #include "chrome/browser/prefs/pref_service.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
10 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
11 #include "chrome/common/chrome_notification_types.h" | 11 #include "chrome/common/chrome_notification_types.h" |
12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
13 #include "content/public/browser/host_zoom_map.h" | 13 #include "content/public/browser/host_zoom_map.h" |
14 #include "content/public/browser/navigation_entry.h" | |
14 #include "content/public/browser/notification_types.h" | 15 #include "content/public/browser/notification_types.h" |
15 #include "content/public/browser/notification_details.h" | 16 #include "content/public/browser/notification_details.h" |
16 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
18 #include "content/public/common/page_zoom.h" | 19 #include "content/public/common/page_zoom.h" |
19 #include "grit/theme_resources.h" | 20 #include "grit/theme_resources.h" |
20 #include "net/base/net_util.h" | 21 #include "net/base/net_util.h" |
21 | 22 |
22 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ZoomController) | 23 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ZoomController) |
23 | 24 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 } | 74 } |
74 case content::NOTIFICATION_ZOOM_LEVEL_CHANGED: | 75 case content::NOTIFICATION_ZOOM_LEVEL_CHANGED: |
75 UpdateState(*content::Details<std::string>(details).ptr()); | 76 UpdateState(*content::Details<std::string>(details).ptr()); |
76 break; | 77 break; |
77 default: | 78 default: |
78 NOTREACHED(); | 79 NOTREACHED(); |
79 } | 80 } |
80 } | 81 } |
81 | 82 |
82 void ZoomController::UpdateState(const std::string& host) { | 83 void ZoomController::UpdateState(const std::string& host) { |
83 if (!host.empty() && | 84 if (host.empty()) |
84 host != net::GetHostOrSpecFromURL(web_contents()->GetURL())) { | |
85 return; | 85 return; |
86 | |
87 content::NavigationEntry* active_entry = | |
88 web_contents()->GetController().GetActiveEntry(); | |
89 if (active_entry) { | |
90 // Prefer to ask the navigation controller for the non-virtual URL. | |
sky
2012/10/04 16:01:12
Document why we need to do this.
Dan Beam
2012/10/04 16:03:11
Is the explanation a couple lines below sufficient
Dan Beam
2012/10/04 19:05:42
OK, so I added a comment in the newest version wit
| |
91 if (host != net::GetHostOrSpecFromURL(active_entry->GetURL())) | |
92 return; | |
93 } else { | |
Kyle Horimoto
2012/10/04 03:00:22
When exactly is active_entry NULL? A little confus
Dan Beam
2012/10/04 03:13:04
http://code.google.com/searchframe#OAMlx_jo-ck/src
| |
94 // If that's not available, just ask the web contents (doesn't work on pages | |
95 // with virtual URLs, e.g. chrome://settings). | |
96 if (host != net::GetHostOrSpecFromURL(web_contents()->GetURL())) | |
97 return; | |
86 } | 98 } |
87 | 99 |
88 bool dummy; | 100 bool dummy; |
89 zoom_percent_ = web_contents()->GetZoomPercent(&dummy, &dummy); | 101 zoom_percent_ = web_contents()->GetZoomPercent(&dummy, &dummy); |
90 | 102 |
91 if (observer_) | 103 if (observer_) |
92 observer_->OnZoomChanged(web_contents(), !host.empty()); | 104 observer_->OnZoomChanged(web_contents(), !host.empty()); |
93 } | 105 } |
OLD | NEW |