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

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

Issue 66061: Disable view-source if the page source is not viewable as text.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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/browser.h" 5 #include "chrome/browser/browser.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/idle_timer.h" 8 #include "base/idle_timer.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "chrome/common/pref_service.h" 42 #include "chrome/common/pref_service.h"
43 #include "chrome/common/url_constants.h" 43 #include "chrome/common/url_constants.h"
44 #ifdef CHROME_PERSONALIZATION 44 #ifdef CHROME_PERSONALIZATION
45 #include "chrome/personalization/personalization.h" 45 #include "chrome/personalization/personalization.h"
46 #endif 46 #endif
47 #include "grit/chromium_strings.h" 47 #include "grit/chromium_strings.h"
48 #include "grit/generated_resources.h" 48 #include "grit/generated_resources.h"
49 #include "grit/locale_settings.h" 49 #include "grit/locale_settings.h"
50 #include "net/base/cookie_monster.h" 50 #include "net/base/cookie_monster.h"
51 #include "net/base/cookie_policy.h" 51 #include "net/base/cookie_policy.h"
52 #include "net/base/mime_util.h"
52 #include "net/base/net_util.h" 53 #include "net/base/net_util.h"
53 #include "net/base/registry_controlled_domain.h" 54 #include "net/base/registry_controlled_domain.h"
54 #include "net/url_request/url_request_context.h" 55 #include "net/url_request/url_request_context.h"
55 #include "webkit/glue/window_open_disposition.h" 56 #include "webkit/glue/window_open_disposition.h"
56 57
57 #if defined(OS_WIN) 58 #if defined(OS_WIN)
58 #include <windows.h> 59 #include <windows.h>
59 #include <shellapi.h> 60 #include <shellapi.h>
60 61
61 #include "chrome/browser/automation/ui_controls.h" 62 #include "chrome/browser/automation/ui_controls.h"
(...skipping 2113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2175 command_updater_.UpdateCommandEnabled(IDC_FORWARD, nc->CanGoForward()); 2176 command_updater_.UpdateCommandEnabled(IDC_FORWARD, nc->CanGoForward());
2176 2177
2177 // Window management commands 2178 // Window management commands
2178 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, 2179 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB,
2179 CanDuplicateContentsAt(selected_index())); 2180 CanDuplicateContentsAt(selected_index()));
2180 2181
2181 // Initialize commands available only for web content. 2182 // Initialize commands available only for web content.
2182 { 2183 {
2183 WebContents* web_contents = current_tab->AsWebContents(); 2184 WebContents* web_contents = current_tab->AsWebContents();
2184 bool is_web_contents = web_contents != NULL; 2185 bool is_web_contents = web_contents != NULL;
2186 bool is_source_viewable =
2187 is_web_contents &&
2188 net::IsSupportedNonImageMimeType(
2189 web_contents->contents_mime_type().c_str());
2185 2190
2186 // Current navigation entry, may be NULL. 2191 // Current navigation entry, may be NULL.
2187 NavigationEntry* active_entry = current_tab->controller()->GetActiveEntry(); 2192 NavigationEntry* active_entry = current_tab->controller()->GetActiveEntry();
2188 2193
2189 // Page-related commands 2194 // Page-related commands
2190 // Only allow bookmarking for web content in normal windows. 2195 // Only allow bookmarking for web content in normal windows.
2191 command_updater_.UpdateCommandEnabled(IDC_STAR, 2196 command_updater_.UpdateCommandEnabled(IDC_STAR,
2192 is_web_contents && (type() == TYPE_NORMAL)); 2197 is_web_contents && (type() == TYPE_NORMAL));
2193 window_->SetStarredState(is_web_contents && web_contents->is_starred()); 2198 window_->SetStarredState(is_web_contents && web_contents->is_starred());
2194 // View-source should not be enabled if already in view-source mode. 2199 // View-source should not be enabled if already in view-source mode or
2200 // the source is not viewable.
2195 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE, 2201 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE,
2196 is_web_contents && active_entry && !active_entry->IsViewSourceMode()); 2202 is_web_contents && active_entry && !active_entry->IsViewSourceMode() &&
2203 is_source_viewable);
2197 command_updater_.UpdateCommandEnabled(IDC_PRINT, is_web_contents); 2204 command_updater_.UpdateCommandEnabled(IDC_PRINT, is_web_contents);
2198 command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE, 2205 command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE,
2199 is_web_contents && SavePackage::IsSavableURL(current_tab->GetURL())); 2206 is_web_contents && SavePackage::IsSavableURL(current_tab->GetURL()));
2200 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU, 2207 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU,
2201 is_web_contents && 2208 is_web_contents &&
2202 SavePackage::IsSavableContents(web_contents->contents_mime_type()) && 2209 SavePackage::IsSavableContents(web_contents->contents_mime_type()) &&
2203 SavePackage::IsSavableURL(current_tab->GetURL())); 2210 SavePackage::IsSavableURL(current_tab->GetURL()));
2204 2211
2205 // Find-in-page 2212 // Find-in-page
2206 command_updater_.UpdateCommandEnabled(IDC_FIND, is_web_contents); 2213 command_updater_.UpdateCommandEnabled(IDC_FIND, is_web_contents);
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
2648 2655
2649 // We need to register the window position pref. 2656 // We need to register the window position pref.
2650 std::wstring window_pref(prefs::kBrowserWindowPlacement); 2657 std::wstring window_pref(prefs::kBrowserWindowPlacement);
2651 window_pref.append(L"_"); 2658 window_pref.append(L"_");
2652 window_pref.append(app_name); 2659 window_pref.append(app_name);
2653 PrefService* prefs = g_browser_process->local_state(); 2660 PrefService* prefs = g_browser_process->local_state();
2654 DCHECK(prefs); 2661 DCHECK(prefs);
2655 2662
2656 prefs->RegisterDictionaryPref(window_pref.c_str()); 2663 prefs->RegisterDictionaryPref(window_pref.c_str());
2657 } 2664 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698