OLD | NEW |
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/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #endif // OS_WIN | 10 #endif // OS_WIN |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 "broken_website&format=inproduct&p.page_title=$1&p.page_url=$2"; | 188 "broken_website&format=inproduct&p.page_title=$1&p.page_url=$2"; |
189 | 189 |
190 // The URL for the privacy dashboard. | 190 // The URL for the privacy dashboard. |
191 const char kPrivacyDashboardUrl[] = "https://www.google.com/dashboard"; | 191 const char kPrivacyDashboardUrl[] = "https://www.google.com/dashboard"; |
192 | 192 |
193 // How long we wait before updating the browser chrome while loading a page. | 193 // How long we wait before updating the browser chrome while loading a page. |
194 const int kUIUpdateCoalescingTimeMS = 200; | 194 const int kUIUpdateCoalescingTimeMS = 200; |
195 | 195 |
196 const char kHashMark[] = "#"; | 196 const char kHashMark[] = "#"; |
197 | 197 |
| 198 // Returns |true| if entry has an internal chrome:// URL, |false| otherwise. |
| 199 bool HasInternalURL(const NavigationEntry* entry) { |
| 200 if (!entry) |
| 201 return false; |
| 202 |
| 203 // Check the |virtual_url()| first. This catches regular chrome:// URLs |
| 204 // including URLs that were rewritten (such as chrome://bookmarks). |
| 205 if (entry->virtual_url().SchemeIs(chrome::kChromeUIScheme)) |
| 206 return true; |
| 207 |
| 208 // If the |virtual_url()| isn't a chrome:// URL, check if it's actually |
| 209 // view-source: of a chrome:// URL. |
| 210 if (entry->virtual_url().SchemeIs(chrome::kViewSourceScheme)) |
| 211 return entry->url().SchemeIs(chrome::kChromeUIScheme); |
| 212 |
| 213 return false; |
| 214 } |
| 215 |
198 } // namespace | 216 } // namespace |
199 | 217 |
200 extern bool g_log_bug53991; | 218 extern bool g_log_bug53991; |
201 | 219 |
202 //////////////////////////////////////////////////////////////////////////////// | 220 //////////////////////////////////////////////////////////////////////////////// |
203 // Browser, CreateParams: | 221 // Browser, CreateParams: |
204 | 222 |
205 Browser::CreateParams::CreateParams(Type type, Profile* profile) | 223 Browser::CreateParams::CreateParams(Type type, Profile* profile) |
206 : type(type), | 224 : type(type), |
207 profile(profile) { | 225 profile(profile) { |
(...skipping 3763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3971 window_->SetStarredState( | 3989 window_->SetStarredState( |
3972 current_tab_wrapper->bookmark_tab_helper()->is_starred()); | 3990 current_tab_wrapper->bookmark_tab_helper()->is_starred()); |
3973 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE, | 3991 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE, |
3974 current_tab->controller().CanViewSource()); | 3992 current_tab->controller().CanViewSource()); |
3975 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, | 3993 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, |
3976 current_tab->ShouldDisplayURL() && current_tab->GetURL().is_valid()); | 3994 current_tab->ShouldDisplayURL() && current_tab->GetURL().is_valid()); |
3977 if (is_devtools()) | 3995 if (is_devtools()) |
3978 command_updater_.UpdateCommandEnabled(IDC_OPEN_FILE, false); | 3996 command_updater_.UpdateCommandEnabled(IDC_OPEN_FILE, false); |
3979 | 3997 |
3980 // Changing the encoding is not possible on Chrome-internal webpages. | 3998 // Changing the encoding is not possible on Chrome-internal webpages. |
3981 // Instead of using GetURL here, we use url() (which is the "real" url of the | 3999 bool is_chrome_internal = HasInternalURL(nc.GetActiveEntry()); |
3982 // page) from the NavigationEntry because its reflects their origin rather | |
3983 // than the display one (returned by GetURL) which may be different (like | |
3984 // having "view-source:" on the front). | |
3985 NavigationEntry* active_entry = nc.GetActiveEntry(); | |
3986 bool is_chrome_internal = (active_entry ? | |
3987 active_entry->url().SchemeIs(chrome::kChromeUIScheme) : false); | |
3988 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU, | 4000 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU, |
3989 !is_chrome_internal && SavePackage::IsSavableContents( | 4001 !is_chrome_internal && SavePackage::IsSavableContents( |
3990 current_tab->contents_mime_type())); | 4002 current_tab->contents_mime_type())); |
3991 | 4003 |
3992 // Show various bits of UI | 4004 // Show various bits of UI |
3993 // TODO(pinkerton): Disable app-mode in the model until we implement it | 4005 // TODO(pinkerton): Disable app-mode in the model until we implement it |
3994 // on the Mac. Be sure to remove both ifdefs. http://crbug.com/13148 | 4006 // on the Mac. Be sure to remove both ifdefs. http://crbug.com/13148 |
3995 #if !defined(OS_MACOSX) | 4007 #if !defined(OS_MACOSX) |
3996 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, | 4008 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, |
3997 web_app::IsValidUrl(current_tab->GetURL())); | 4009 web_app::IsValidUrl(current_tab->GetURL())); |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4721 // end up querying state once they process the tab switch. | 4733 // end up querying state once they process the tab switch. |
4722 return; | 4734 return; |
4723 } | 4735 } |
4724 | 4736 |
4725 BookmarkBar::AnimateChangeType animate_type = | 4737 BookmarkBar::AnimateChangeType animate_type = |
4726 (reason == BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE) ? | 4738 (reason == BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE) ? |
4727 BookmarkBar::ANIMATE_STATE_CHANGE : | 4739 BookmarkBar::ANIMATE_STATE_CHANGE : |
4728 BookmarkBar::DONT_ANIMATE_STATE_CHANGE; | 4740 BookmarkBar::DONT_ANIMATE_STATE_CHANGE; |
4729 window_->BookmarkBarStateChanged(animate_type); | 4741 window_->BookmarkBarStateChanged(animate_type); |
4730 } | 4742 } |
OLD | NEW |