summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorapavlov@chromium.org <apavlov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-25 11:22:46 +0000
committerapavlov@chromium.org <apavlov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-25 11:22:46 +0000
commit8e48e9848e1a6626c36e3efbe1750bbb3c8b3e4e (patch)
tree344faabdd8f1fe715c6d919de4a1d53bde344dbb /chrome
parent09c0077246c9be4122ca1fcbf892865a61ec12a8 (diff)
downloadchromium_src-8e48e9848e1a6626c36e3efbe1750bbb3c8b3e4e.zip
chromium_src-8e48e9848e1a6626c36e3efbe1750bbb3c8b3e4e.tar.gz
chromium_src-8e48e9848e1a6626c36e3efbe1750bbb3c8b3e4e.tar.bz2
Forbid reloading the Inspector window.
This CL disables reloading from the system menu, tab popup menu, and page context menu. BUG=27254,6902 TEST=none Review URL: http://codereview.chromium.org/391036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35275 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser.cc28
-rw-r--r--chrome/browser/browser.h8
-rw-r--r--chrome/browser/debugger/devtools_window.cc5
-rw-r--r--chrome/browser/debugger/devtools_window.h2
-rw-r--r--chrome/browser/sessions/session_service.cc5
-rw-r--r--chrome/browser/sessions/session_service.h3
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc9
-rw-r--r--chrome/browser/tab_contents/tab_contents_delegate.h4
-rw-r--r--chrome/browser/tabs/tab_strip_model.cc8
9 files changed, 62 insertions, 10 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 8d26f43..fac7afd 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/browser_window.h"
#include "chrome/browser/character_encoding.h"
#include "chrome/browser/debugger/devtools_manager.h"
+#include "chrome/browser/debugger/devtools_window.h"
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/download/download_shelf.h"
@@ -58,7 +59,6 @@
#include "chrome/browser/tab_contents/tab_contents_view.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/browser/window_sizer.h"
-#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
@@ -239,6 +239,14 @@ Browser* Browser::CreateForApp(const std::wstring& app_name,
return browser;
}
+// static
+Browser* Browser::CreateForDevTools(Profile* profile) {
+ Browser* browser = new Browser(TYPE_DEVTOOLS, profile);
+ browser->app_name_ = DevToolsWindow::kDevToolsApp;
+ browser->CreateBrowserWindow();
+ return browser;
+}
+
void Browser::CreateBrowserWindow() {
DCHECK(!window_);
@@ -1792,6 +1800,10 @@ bool Browser::RunUnloadListenerBeforeClosing(TabContents* contents) {
return false;
}
+bool Browser::CanReloadContents(TabContents* source) const {
+ return type() != TYPE_DEVTOOLS;
+}
+
bool Browser::CanCloseContentsAt(int index) {
if (tabstrip_model_.count() > 1)
return true;
@@ -2241,7 +2253,7 @@ void Browser::OnStartDownload(DownloadItem* download) {
// Don't show the animation for "Save file" downloads.
if (download->total_bytes() <= 0)
return;
-
+
// For non-theme extensions, we don't show the download animation.
if (download->is_extension_install() &&
!ExtensionsService::IsDownloadFromMiniGallery(download->url()))
@@ -2629,6 +2641,18 @@ void Browser::UpdateCommandsForTabState() {
SavePackage::IsSavableContents(current_tab->contents_mime_type()) &&
SavePackage::IsSavableURL(savable_url));
+ // Disable certain items if running DevTools
+ command_updater_.UpdateCommandEnabled(IDC_RELOAD,
+ CanReloadContents(current_tab));
+ bool enabled_for_non_devtools = type() != TYPE_DEVTOOLS;
+ command_updater_.UpdateCommandEnabled(IDC_FIND, enabled_for_non_devtools);
+ command_updater_.UpdateCommandEnabled(IDC_FIND_NEXT,
+ enabled_for_non_devtools);
+ command_updater_.UpdateCommandEnabled(IDC_FIND_PREVIOUS,
+ enabled_for_non_devtools);
+ command_updater_.UpdateCommandEnabled(IDC_COPY_URL,
+ enabled_for_non_devtools);
+
// Show various bits of UI
command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS,
web_app::IsValidUrl(current_tab->GetURL()));
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 7f5f85c..d60ae4e 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -56,7 +56,8 @@ class Browser : public TabStripModelDelegate,
TYPE_POPUP = 2,
TYPE_APP = 4,
TYPE_APP_POPUP = TYPE_APP | TYPE_POPUP,
- TYPE_ANY = TYPE_NORMAL | TYPE_POPUP | TYPE_APP
+ TYPE_DEVTOOLS = TYPE_APP | 8,
+ TYPE_ANY = TYPE_NORMAL | TYPE_POPUP | TYPE_APP | TYPE_DEVTOOLS
};
// Possible elements of the Browser window.
@@ -104,6 +105,10 @@ class Browser : public TabStripModelDelegate,
static Browser* CreateForApp(const std::wstring& app_name, Profile* profile,
bool is_popup);
+ // Like Create, but creates a tabstrip-less and toolbar-less
+ // DevTools "app" window.
+ static Browser* CreateForDevTools(Profile* profile);
+
// Set overrides for the initial window bounds and maximized state.
void set_override_bounds(const gfx::Rect& bounds) {
override_bounds_ = bounds;
@@ -559,6 +564,7 @@ class Browser : public TabStripModelDelegate,
virtual void MoveContents(TabContents* source, const gfx::Rect& pos);
virtual void DetachContents(TabContents* source);
virtual bool IsPopup(TabContents* source);
+ virtual bool CanReloadContents(TabContents* source) const;
virtual void ToolbarSizeChanged(TabContents* source, bool is_animating);
virtual void URLStarredChanged(TabContents* source, bool starred);
virtual void UpdateTargetURL(TabContents* source, const GURL& url);
diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc
index 273ab4e..0eaccdd 100644
--- a/chrome/browser/debugger/devtools_window.cc
+++ b/chrome/browser/debugger/devtools_window.cc
@@ -24,6 +24,7 @@
#include "chrome/common/url_constants.h"
#include "grit/generated_resources.h"
+const std::wstring DevToolsWindow::kDevToolsApp = L"DevToolsApp";
// static
TabContents* DevToolsWindow::GetDevToolsContents(TabContents* inspected_tab) {
@@ -175,7 +176,7 @@ void DevToolsWindow::CreateDevToolsBrowser() {
std::wstring wp_key = L"";
wp_key.append(prefs::kBrowserWindowPlacement);
wp_key.append(L"_");
- wp_key.append(L"DevToolsApp");
+ wp_key.append(kDevToolsApp);
PrefService* prefs = g_browser_process->local_state();
if (!prefs->FindPreference(wp_key.c_str())) {
@@ -193,7 +194,7 @@ void DevToolsWindow::CreateDevToolsBrowser() {
defaults->SetBoolean(L"always_on_top", false);
}
- browser_ = Browser::CreateForApp(L"DevToolsApp", profile_, false);
+ browser_ = Browser::CreateForDevTools(profile_);
browser_->tabstrip_model()->AddTabContents(
tab_contents_, -1, false, PageTransition::START_PAGE, true);
}
diff --git a/chrome/browser/debugger/devtools_window.h b/chrome/browser/debugger/devtools_window.h
index f583327..5350934 100644
--- a/chrome/browser/debugger/devtools_window.h
+++ b/chrome/browser/debugger/devtools_window.h
@@ -29,6 +29,7 @@ class DevToolsWindow
public NotificationObserver,
public TabContentsDelegate {
public:
+ static const std::wstring kDevToolsApp;
static TabContents* GetDevToolsContents(TabContents* inspected_tab);
DevToolsWindow(Profile* profile, RenderViewHost* inspected_rvh, bool docked);
@@ -77,6 +78,7 @@ class DevToolsWindow
virtual void CloseContents(TabContents* source) {}
virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {}
virtual bool IsPopup(TabContents* source) { return false; }
+ virtual bool CanReloadContents(TabContents* source) const { return false; }
virtual void URLStarredChanged(TabContents* source, bool starred) {}
virtual void UpdateTargetURL(TabContents* source, const GURL& url) {}
virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {}
diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc
index a4247c0..b52ee01 100644
--- a/chrome/browser/sessions/session_service.cc
+++ b/chrome/browser/sessions/session_service.cc
@@ -1179,6 +1179,8 @@ SessionService::WindowType SessionService::WindowTypeForBrowserType(
return TYPE_APP;
case Browser::TYPE_APP_POPUP:
return TYPE_APP_POPUP;
+ case Browser::TYPE_DEVTOOLS:
+ return TYPE_DEVTOOLS;
case Browser::TYPE_NORMAL:
default:
return TYPE_NORMAL;
@@ -1194,9 +1196,10 @@ Browser::Type SessionService::BrowserTypeForWindowType(
return Browser::TYPE_APP;
case TYPE_APP_POPUP:
return Browser::TYPE_APP_POPUP;
+ case TYPE_DEVTOOLS:
+ return Browser::TYPE_DEVTOOLS;
case TYPE_NORMAL:
default:
return Browser::TYPE_NORMAL;
}
}
-
diff --git a/chrome/browser/sessions/session_service.h b/chrome/browser/sessions/session_service.h
index a687125..fbeafd4 100644
--- a/chrome/browser/sessions/session_service.h
+++ b/chrome/browser/sessions/session_service.h
@@ -162,7 +162,8 @@ class SessionService : public BaseSessionService,
TYPE_NORMAL = 0,
TYPE_POPUP = 1,
TYPE_APP = 2,
- TYPE_APP_POPUP = TYPE_APP + TYPE_POPUP
+ TYPE_APP_POPUP = TYPE_APP + TYPE_POPUP,
+ TYPE_DEVTOOLS = TYPE_APP + 4
};
void Init();
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index aeb4a84..950929f 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -10,8 +10,10 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "chrome/app/chrome_dll_resource.h"
+#include "chrome/browser/browser.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/debugger/devtools_manager.h"
+#include "chrome/browser/debugger/devtools_window.h"
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/fonts_languages_window.h"
#include "chrome/browser/metrics/user_metrics.h"
@@ -353,10 +355,14 @@ bool RenderViewContextMenu::IsItemCommandEnabled(int id) const {
case IDS_CONTENT_CONTEXT_FORWARD:
return source_tab_contents_->controller().CanGoForward();
+ case IDS_CONTENT_CONTEXT_RELOAD:
+ return source_tab_contents_->delegate()->CanReloadContents(
+ source_tab_contents_);
+
case IDS_CONTENT_CONTEXT_VIEWPAGESOURCE:
case IDS_CONTENT_CONTEXT_VIEWFRAMESOURCE:
case IDS_CONTENT_CONTEXT_INSPECTELEMENT:
- // Viewing page info is not a delveloper command but is meaningful for the
+ // Viewing page info is not a developer command but is meaningful for the
// same set of pages which developer commands are meaningful for.
case IDS_CONTENT_CONTEXT_VIEWPAGEINFO:
return IsDevCommandEnabled(id);
@@ -472,7 +478,6 @@ bool RenderViewContextMenu::IsItemCommandEnabled(int id) const {
case IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY:
return !params_.misspelled_word.empty();
- case IDS_CONTENT_CONTEXT_RELOAD:
case IDS_CONTENT_CONTEXT_COPYIMAGE:
case IDS_CONTENT_CONTEXT_PRINT:
case IDS_CONTENT_CONTEXT_SEARCHWEBFOR:
diff --git a/chrome/browser/tab_contents/tab_contents_delegate.h b/chrome/browser/tab_contents/tab_contents_delegate.h
index f67d8bb..817bd25 100644
--- a/chrome/browser/tab_contents/tab_contents_delegate.h
+++ b/chrome/browser/tab_contents/tab_contents_delegate.h
@@ -123,6 +123,10 @@ class TabContentsDelegate {
// call. ConstrainedWindows shouldn't be able to be blurred.
virtual bool CanBlur() const { return true; }
+ // Whether the specified tab can be reloaded.
+ // Reloading can be disabled e. g. for the DevTools window.
+ virtual bool CanReloadContents(TabContents* source) const { return true; }
+
// Return the rect where to display the resize corner, if any, otherwise
// an empty rect.
virtual gfx::Rect GetRootWindowResizerRect() const { return gfx::Rect(); }
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
index ff17975..c8920aa 100644
--- a/chrome/browser/tabs/tab_strip_model.cc
+++ b/chrome/browser/tabs/tab_strip_model.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/tabs/tab_strip_model_order_controller.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/tab_contents/tab_contents_delegate.h"
#include "chrome/browser/tab_contents/tab_contents_view.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_service.h"
@@ -500,9 +501,14 @@ bool TabStripModel::IsContextMenuCommandEnabled(
DCHECK(command_id > CommandFirst && command_id < CommandLast);
switch (command_id) {
case CommandNewTab:
- case CommandReload:
case CommandCloseTab:
return true;
+ case CommandReload:
+ if (TabContents* contents = GetTabContentsAt(context_index)) {
+ return contents->delegate()->CanReloadContents(contents);
+ } else {
+ return false;
+ }
case CommandCloseOtherTabs:
return count() > 1;
case CommandCloseTabsToRight: