summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/views/about_network_dialog.cc76
-rw-r--r--chrome/browser/views/about_network_dialog.h29
-rw-r--r--chrome/browser/views/browser_views.vcproj8
-rw-r--r--chrome/browser/views/logging_about_dialog.cc72
-rw-r--r--chrome/browser/views/logging_about_dialog.h65
5 files changed, 167 insertions, 83 deletions
diff --git a/chrome/browser/views/about_network_dialog.cc b/chrome/browser/views/about_network_dialog.cc
index a1af274..4b961d9 100644
--- a/chrome/browser/views/about_network_dialog.cc
+++ b/chrome/browser/views/about_network_dialog.cc
@@ -265,7 +265,11 @@ JobTracker* tracker = NULL;
// AboutNetworkDialog ----------------------------------------------------------
-AboutNetworkDialog::AboutNetworkDialog() : tracking_(false) {
+AboutNetworkDialog::AboutNetworkDialog()
+ : track_toggle_(NULL),
+ show_button_(NULL),
+ clear_button_(NULL),
+ tracking_(false) {
SetupControls();
tracker = new JobTracker(this);
tracker->AddRef();
@@ -287,14 +291,16 @@ void AboutNetworkDialog::RunDialog() {
}
}
-void AboutNetworkDialog::AppendText(const std::wstring& text) {
- text_field_->AppendText(text);
+void AboutNetworkDialog::SetupButtonColumnSet(views::ColumnSet* set) {
+ set->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER,
+ 33.33f, views::GridLayout::FIXED, 0, 0);
+ set->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER,
+ 33.33f, views::GridLayout::FIXED, 0, 0);
+ set->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER,
+ 33.33f, views::GridLayout::FIXED, 0, 0);
}
-void AboutNetworkDialog::SetupControls() {
- views::GridLayout* layout = CreatePanelGridLayout(this);
- SetLayoutManager(layout);
-
+void AboutNetworkDialog::AddButtonControlsToLayout(views::GridLayout* layout) {
track_toggle_ = new views::TextButton(kStartTrackingLabel);
track_toggle_->SetListener(this, 1);
show_button_ = new views::TextButton(kShowCurrentLabel);
@@ -302,63 +308,9 @@ void AboutNetworkDialog::SetupControls() {
clear_button_ = new views::TextButton(kClearLabel);
clear_button_->SetListener(this, 3);
- text_field_ = new views::TextField(static_cast<views::TextField::StyleFlags>(
- views::TextField::STYLE_MULTILINE));
- text_field_->SetReadOnly(true);
-
- // TODO(brettw): We may want to add this in the future. It can't be called
- // from here, though, since the hwnd for the field hasn't been created yet.
- //
- // This raises the maximum number of chars from 32K to some large maximum,
- // probably 2GB. 32K is not nearly enough for our use-case.
- //SendMessageW(text_field_->GetNativeComponent(), EM_SETLIMITTEXT, 0, 0);
-
- static const int first_column_set = 1;
- views::ColumnSet* column_set = layout->AddColumnSet(first_column_set);
- column_set->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER,
- 33.33f, views::GridLayout::FIXED, 0, 0);
- column_set->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER,
- 33.33f, views::GridLayout::FIXED, 0, 0);
- column_set->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER,
- 33.33f, views::GridLayout::FIXED, 0, 0);
-
- static const int text_column_set = 2;
- column_set = layout->AddColumnSet(text_column_set);
- column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 100.0f,
- views::GridLayout::FIXED, 0, 0);
-
- layout->StartRow(0, first_column_set);
layout->AddView(track_toggle_);
layout->AddView(show_button_);
layout->AddView(clear_button_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(1.0f, text_column_set);
- layout->AddView(text_field_);
-}
-
-gfx::Size AboutNetworkDialog::GetPreferredSize() {
- return gfx::Size(800, 400);
-}
-
-views::View* AboutNetworkDialog::GetContentsView() {
- return this;
-}
-
-int AboutNetworkDialog::GetDialogButtons() const {
- // Don't want OK or Cancel.
- return 0;
-}
-
-std::wstring AboutNetworkDialog::GetWindowTitle() const {
- return L"about:network";
-}
-
-void AboutNetworkDialog::Layout() {
- GetLayoutManager()->Layout(this);
-}
-
-bool AboutNetworkDialog::CanResize() const {
- return true;
}
void AboutNetworkDialog::ButtonPressed(views::BaseButton* button) {
@@ -376,6 +328,6 @@ void AboutNetworkDialog::ButtonPressed(views::BaseButton* button) {
} else if (button == show_button_) {
tracker->ReportStatus();
} else if (button == clear_button_) {
- text_field_->SetText(std::wstring());
+ text_field()->SetText(std::wstring());
}
}
diff --git a/chrome/browser/views/about_network_dialog.h b/chrome/browser/views/about_network_dialog.h
index a9dd2cc..68d6690 100644
--- a/chrome/browser/views/about_network_dialog.h
+++ b/chrome/browser/views/about_network_dialog.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_VIEWS_ABOUT_NETWORK_DIALOG_H_
#include "base/singleton.h"
+#include "chrome/browser/views/logging_about_dialog.h"
#include "chrome/views/base_button.h"
#include "chrome/views/dialog_delegate.h"
@@ -14,9 +15,8 @@ class TextButton;
class TextField;
} // namespace views
-class AboutNetworkDialog : public views::DialogDelegate,
- public views::BaseButton::ButtonListener,
- public views::View {
+class AboutNetworkDialog : public LoggingAboutDialog,
+ public views::BaseButton::ButtonListener {
public:
// This dialog is a singleton. If the dialog is already opened, it won't do
// anything, so you can just blindly call this function all you want.
@@ -24,10 +24,6 @@ class AboutNetworkDialog : public views::DialogDelegate,
virtual ~AboutNetworkDialog();
- // Appends the given string to the dialog box. This is called by the job
- // tracker (see the .cc file) when "stuff happens."
- void AppendText(const std::wstring& text);
-
// Returns true if we're currently tracking network operations.
bool tracking() const { return tracking_; }
@@ -36,25 +32,16 @@ class AboutNetworkDialog : public views::DialogDelegate,
AboutNetworkDialog();
- // Sets up all UI controls for the dialog.
- void SetupControls();
-
- virtual gfx::Size GetPreferredSize();
- virtual views::View* GetContentsView();
- virtual int GetDialogButtons() const;
- virtual std::wstring GetWindowTitle() const;
- virtual void Layout();
-
- // views::WindowDelegate (via view::DialogDelegate).
- virtual bool CanResize() const;
-
- // views::BaseButton::ButtonListener.
+ // views::BaseButton::ButtonListener implementation.
virtual void ButtonPressed(views::BaseButton* button);
+ // LoggingAboutDialog implementation.
+ virtual void SetupButtonColumnSet(views::ColumnSet* set);
+ virtual void AddButtonControlsToLayout(views::GridLayout* layout);
+
views::TextButton* track_toggle_;
views::TextButton* show_button_;
views::TextButton* clear_button_;
- views::TextField* text_field_;
// Set to true when we're tracking network status.
bool tracking_;
diff --git a/chrome/browser/views/browser_views.vcproj b/chrome/browser/views/browser_views.vcproj
index 825d0cc..6ac7983 100644
--- a/chrome/browser/views/browser_views.vcproj
+++ b/chrome/browser/views/browser_views.vcproj
@@ -634,6 +634,14 @@
>
</File>
<File
+ RelativePath=".\logging_about_dialog.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\logging_about_dialog.h"
+ >
+ </File>
+ <File
RelativePath=".\login_view.cc"
>
</File>
diff --git a/chrome/browser/views/logging_about_dialog.cc b/chrome/browser/views/logging_about_dialog.cc
new file mode 100644
index 0000000..17913fd
--- /dev/null
+++ b/chrome/browser/views/logging_about_dialog.cc
@@ -0,0 +1,72 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/views/logging_about_dialog.h"
+
+#include "chrome/browser/views/standard_layout.h"
+#include "chrome/views/grid_layout.h"
+#include "chrome/views/text_field.h"
+#include "chrome/views/window.h"
+
+LoggingAboutDialog::LoggingAboutDialog() {
+}
+
+LoggingAboutDialog::~LoggingAboutDialog() {
+}
+
+void LoggingAboutDialog::SetupControls() {
+ views::GridLayout* layout = CreatePanelGridLayout(this);
+ SetLayoutManager(layout);
+
+ static const int first_column_set = 1;
+ views::ColumnSet* button_set = layout->AddColumnSet(first_column_set);
+ SetupButtonColumnSet(button_set);
+
+ text_field_ = new views::TextField(static_cast<views::TextField::StyleFlags>(
+ views::TextField::STYLE_MULTILINE));
+ text_field_->SetReadOnly(true);
+
+ // TODO(brettw): We may want to add this in the future. It can't be called
+ // from here, though, since the hwnd for the field hasn't been created yet.
+ //
+ // This raises the maximum number of chars from 32K to some large maximum,
+ // probably 2GB. 32K is not nearly enough for our use-case.
+ //SendMessageW(text_field_->GetNativeComponent(), EM_SETLIMITTEXT, 0, 0);
+
+ static const int text_column_set = 2;
+ views::ColumnSet* column_set = layout->AddColumnSet(text_column_set);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 100.0f,
+ views::GridLayout::FIXED, 0, 0);
+
+ layout->StartRow(0, first_column_set);
+ AddButtonControlsToLayout(layout);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+ layout->StartRow(1.0f, text_column_set);
+ layout->AddView(text_field_);
+}
+
+void LoggingAboutDialog::AppendText(const std::wstring& text) {
+ text_field_->AppendText(text);
+}
+
+gfx::Size LoggingAboutDialog::GetPreferredSize() {
+ return gfx::Size(800, 400);
+}
+
+views::View* LoggingAboutDialog::GetContentsView() {
+ return this;
+}
+
+int LoggingAboutDialog::GetDialogButtons() const {
+ // Don't want OK or Cancel.
+ return 0;
+}
+
+std::wstring LoggingAboutDialog::GetWindowTitle() const {
+ return L"about:network";
+}
+
+bool LoggingAboutDialog::CanResize() const {
+ return true;
+}
diff --git a/chrome/browser/views/logging_about_dialog.h b/chrome/browser/views/logging_about_dialog.h
new file mode 100644
index 0000000..7f24884
--- /dev/null
+++ b/chrome/browser/views/logging_about_dialog.h
@@ -0,0 +1,65 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_VIEWS_LOGGING_ABOUT_DIALOG_H_
+#define CHROME_BROWSER_VIEWS_LOGGING_ABOUT_DIALOG_H_
+
+#include "base/singleton.h"
+#include "chrome/views/base_button.h"
+#include "chrome/views/dialog_delegate.h"
+
+namespace views {
+class ColumnSet;
+class GridLayout;
+class TextButton;
+class TextField;
+} // namespace views
+
+// This is the base class for dialog boxes used in debugging that dump text
+// into a textbox. The derived class specifies which buttons appear at the top
+// of the dialog, this class manages the text area.
+class LoggingAboutDialog : public views::DialogDelegate,
+ public views::View {
+ public:
+ virtual ~LoggingAboutDialog();
+
+ // Appends the given string to the dialog box. This is called by the job
+ // tracker (see the .cc file) when "stuff happens."
+ void AppendText(const std::wstring& text);
+
+ protected:
+ // The derived class should be sure to call SetupControls. We don't want
+ // this class to do it becuase it calls virtual functions, and the derived
+ // class wouldn't be constructed yet.
+ LoggingAboutDialog();
+
+ // Sets up all UI controls for the dialog.
+ void SetupControls();
+
+ // Sets up the column set for the buttons that appears at the top of the
+ // dialog.
+ virtual void SetupButtonColumnSet(views::ColumnSet* set) = 0;
+
+ // Adds any custom buttons to the layout. This will be in the column set
+ // set up above.
+ virtual void AddButtonControlsToLayout(views::GridLayout* layout) = 0;
+
+ views::TextField* text_field() { return text_field_; }
+
+ private:
+ virtual gfx::Size GetPreferredSize();
+ virtual views::View* GetContentsView();
+ virtual int GetDialogButtons() const;
+ virtual std::wstring GetWindowTitle() const;
+
+ // views::WindowDelegate (via view::DialogDelegate).
+ virtual bool CanResize() const;
+
+ // The text field that contains the log messages.
+ views::TextField* text_field_;
+
+ DISALLOW_COPY_AND_ASSIGN(LoggingAboutDialog);
+};
+
+#endif // CHROME_BROWSER_VIEWS_LOGGING_ABOUT_DIALOG_H_