summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-27 14:51:21 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-27 14:51:21 +0000
commit96d3fb5954088dc929dcedfd82c5b6a05e0e3116 (patch)
tree76ed5f9f30336f17016d26856b85c55443664820 /chrome/browser
parent4079724701312d23a68a148158c8024f0433fbd8 (diff)
downloadchromium_src-96d3fb5954088dc929dcedfd82c5b6a05e0e3116.zip
chromium_src-96d3fb5954088dc929dcedfd82c5b6a05e0e3116.tar.gz
chromium_src-96d3fb5954088dc929dcedfd82c5b6a05e0e3116.tar.bz2
DevTools: Add 'Enable Developer Tools' option into the Advanced tab. Hide developer tools by default.
Review URL: http://codereview.chromium.org/117003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16984 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/debugger/devtools_manager.cc14
-rw-r--r--chrome/browser/debugger/devtools_manager.h2
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc3
-rw-r--r--chrome/browser/views/options/advanced_contents_view.cc81
4 files changed, 94 insertions, 6 deletions
diff --git a/chrome/browser/debugger/devtools_manager.cc b/chrome/browser/debugger/devtools_manager.cc
index 582cc90..67e3aa8 100644
--- a/chrome/browser/debugger/devtools_manager.cc
+++ b/chrome/browser/debugger/devtools_manager.cc
@@ -6,9 +6,12 @@
#include "chrome/browser/debugger/devtools_window.h"
#include "chrome/browser/debugger/devtools_client_host.h"
+#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/tab_contents/site_instance.h"
#include "chrome/common/devtools_messages.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/pref_service.h"
#include "googleurl/src/gurl.h"
DevToolsManager::DevToolsManager() {
@@ -85,6 +88,7 @@ void DevToolsManager::ForwardToDevToolsClient(RenderViewHost* inspected_rvh,
}
void DevToolsManager::OpenDevToolsWindow(RenderViewHost* inspected_rvh) {
+ EnableDevToolsInPrefs(inspected_rvh);
DevToolsClientHost* host = GetDevToolsClientHostFor(inspected_rvh);
if (!host) {
host = new DevToolsWindow(
@@ -165,3 +169,13 @@ void DevToolsManager::SendDetachToAgent(RenderViewHost* inspected_rvh) {
inspected_rvh->Send(m);
}
}
+
+void DevToolsManager::EnableDevToolsInPrefs(RenderViewHost* inspected_rvh) {
+ Profile* profile = inspected_rvh->site_instance()->browsing_instance()->
+ profile();
+ if (!profile->GetPrefs()->GetBoolean(prefs::kWebKitDeveloperExtrasEnabled)) {
+ //TODO(pfeldman): Show message box with warning to the user.
+ profile->GetPrefs()->SetBoolean(prefs::kWebKitDeveloperExtrasEnabled,
+ true);
+ }
+}
diff --git a/chrome/browser/debugger/devtools_manager.h b/chrome/browser/debugger/devtools_manager.h
index 3f9bdc8..7f8a225 100644
--- a/chrome/browser/debugger/devtools_manager.h
+++ b/chrome/browser/debugger/devtools_manager.h
@@ -67,6 +67,8 @@ private:
void SendAttachToAgent(RenderViewHost* inspected_rvh);
void SendDetachToAgent(RenderViewHost* inspected_rvh);
+ void EnableDevToolsInPrefs(RenderViewHost* inspected_rvh);
+
// These two maps are for tracking dependencies between inspected tabs and
// their DevToolsClientHosts. They are usful for routing devtools messages
// and allow us to have at most one devtools client host per tab. We use
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 0083ae2..a8eb3ed 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -132,6 +132,7 @@ const wchar_t* kPrefsToObserve[] = {
prefs::kWebKitLoadsImagesAutomatically,
prefs::kWebKitPluginsEnabled,
prefs::kWebKitUsesUniversalDetector,
+ prefs::kWebKitDeveloperExtrasEnabled,
prefs::kWebKitSerifFontFamily,
prefs::kWebKitSansSerifFontFamily,
prefs::kWebKitFixedFontFamily,
@@ -357,7 +358,7 @@ void TabContents::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterBooleanPref(prefs::kWebKitShrinksStandaloneImagesToFit,
pref_defaults.shrinks_standalone_images_to_fit);
prefs->RegisterBooleanPref(prefs::kWebKitDeveloperExtrasEnabled,
- true);
+ pref_defaults.developer_extras_enabled);
prefs->RegisterBooleanPref(prefs::kWebKitTextAreasAreResizable,
pref_defaults.text_areas_are_resizable);
prefs->RegisterBooleanPref(prefs::kWebKitJavaEnabled,
diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc
index 7d69b1e..1b6a0ef 100644
--- a/chrome/browser/views/options/advanced_contents_view.cc
+++ b/chrome/browser/views/options/advanced_contents_view.cc
@@ -73,7 +73,6 @@ class ListBackground : public views::Background {
DISALLOW_COPY_AND_ASSIGN(ListBackground);
};
-} // namespace
////////////////////////////////////////////////////////////////////////////////
// AdvancedSection
// A convenience view for grouping advanced options together into related
@@ -942,8 +941,6 @@ void SecuritySection::NotifyPrefChanged(const std::wstring* pref_name) {
////////////////////////////////////////////////////////////////////////////////
// NetworkSection
-namespace {
-
// A helper method that opens the Internet Options control panel dialog with
// the Connections tab selected.
class OpenConnectionDialogTask : public Task {
@@ -978,8 +975,6 @@ class OpenConnectionDialogTask : public Task {
DISALLOW_COPY_AND_ASSIGN(OpenConnectionDialogTask);
};
-} // namespace
-
class NetworkSection : public AdvancedSection,
public views::ButtonListener {
public:
@@ -1049,6 +1044,80 @@ void NetworkSection::NotifyPrefChanged(const std::wstring* pref_name) {
}
////////////////////////////////////////////////////////////////////////////////
+// DevToolsSection
+
+class DevToolsSection : public AdvancedSection,
+ public views::ButtonListener {
+ public:
+ explicit DevToolsSection(Profile* profile);
+ virtual ~DevToolsSection() {}
+
+ // Overridden from views::ButtonListener:
+ virtual void ButtonPressed(views::Button* sender);
+
+ protected:
+ // OptionsPageView overrides:
+ virtual void InitControlLayout();
+ virtual void NotifyPrefChanged(const std::wstring* pref_name);
+
+ private:
+ // Controls for this section:
+ views::Checkbox* enable_devtools_checkbox_;
+
+ // Preferences for this section:
+ BooleanPrefMember enable_devtools_;
+
+ DISALLOW_COPY_AND_ASSIGN(DevToolsSection);
+};
+
+DevToolsSection::DevToolsSection(Profile* profile)
+ : enable_devtools_checkbox_(NULL),
+ AdvancedSection(profile,
+ l10n_util::GetString(IDS_OPTIONS_ADVANCED_SECTION_TITLE_DEVTOOLS)) {
+}
+
+void DevToolsSection::ButtonPressed(views::Button* sender) {
+ if (sender == enable_devtools_checkbox_) {
+ bool enabled = enable_devtools_checkbox_->checked();
+ UserMetricsRecordAction(enabled ?
+ L"Options_DevToolsCheckbox_Enable" :
+ L"Options_DevToolsCheckbox_Disable",
+ profile()->GetPrefs());
+ enable_devtools_.SetValue(enabled);
+ }
+}
+
+void DevToolsSection::InitControlLayout() {
+ AdvancedSection::InitControlLayout();
+
+ enable_devtools_checkbox_ = new views::Checkbox(
+ l10n_util::GetString(IDS_OPTIONS_ENABLE_DEVTOOLS));
+ enable_devtools_checkbox_->set_listener(this);
+
+ GridLayout* layout = new GridLayout(contents_);
+ contents_->SetLayoutManager(layout);
+
+ const int single_column_view_set_id = 0;
+ AddWrappingColumnSet(layout, single_column_view_set_id);
+
+ AddWrappingCheckboxRow(layout, enable_devtools_checkbox_,
+ single_column_view_set_id, false);
+
+ // Init member prefs so we can update the controls if prefs change.
+ enable_devtools_.Init(prefs::kWebKitDeveloperExtrasEnabled,
+ profile()->GetPrefs(), this);
+}
+
+void DevToolsSection::NotifyPrefChanged(const std::wstring* pref_name) {
+ if (!pref_name || *pref_name == prefs::kWebKitDeveloperExtrasEnabled) {
+ enable_devtools_checkbox_->SetChecked(
+ enable_devtools_.GetValue());
+ }
+}
+
+} // namespace
+
+////////////////////////////////////////////////////////////////////////////////
// AdvancedContentsView
class AdvancedContentsView : public OptionsPageView {
@@ -1141,6 +1210,8 @@ void AdvancedContentsView::InitControlLayout() {
layout->AddView(new WebContentSection(profile()));
layout->StartRow(0, single_column_view_set_id);
layout->AddView(new SecuritySection(profile()));
+ layout->StartRow(0, single_column_view_set_id);
+ layout->AddView(new DevToolsSection(profile()));
}
////////////////////////////////////////////////////////////////////////////////