summaryrefslogtreecommitdiffstats
path: root/chrome/views
diff options
context:
space:
mode:
authormunjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-03 23:52:03 +0000
committermunjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-03 23:52:03 +0000
commitf253006b157f9c917fba21a7312290aaa2e889e7 (patch)
tree377183f9511bed141b5fd7a706c3407a122540d9 /chrome/views
parentdadacf06556b4f63a62ec3cea91d7fc5abccd67c (diff)
downloadchromium_src-f253006b157f9c917fba21a7312290aaa2e889e7.zip
chromium_src-f253006b157f9c917fba21a7312290aaa2e889e7.tar.gz
chromium_src-f253006b157f9c917fba21a7312290aaa2e889e7.tar.bz2
Chromium-MultiProfile-Prototype
Summary ======= Implement a prototype of multiple profiles in Chrome by utilizing the functionality of user-data-dir command line flag that already exists. A profile in this case is an umbrella for all user data including cookies, history, bookmarks, settings, etc. Each profile gives the user a separation of all these data elements. User Interface ============== - Wrench > "New window in profile" menu item, with sub-menu items. This new menu item has sub menu items for each existing profile, for up to 9 profiles, and one more sub menu item to launch a window in a new profile. The 9 sub-menu items also have the accelerators like CTRL + SHIFT + 1, CTRL + SHIFT + 2, etc. If there are more than 9 profiles, we will also show an extra sub-menu item, "Other...". - New Profile dialog box This dialog box is shown to the use when (s)he clicks Wrench > New window in profile > <New Profile>. It lets the user specify a profile name, and also shows a checkbox to create a desktop shortcut to launch Chrome in that profile. - Choose profile dialog box This dialog box lets the user select a profile from a drop down to open a new window in. It also has an item <New Profile> in the drop down, selecting which will show the new profile dialog box mentioned above. CTRL + M shortcut also launches this dialog box. Code Organization ================= chrome\browser\user_data_dir_profile_manager.h/.cc: This class provides an abstraction of profiles on top of the user data dir command line flag. chrome\browser\views\user_data_dir_new_profile_dialog.h/.cc New profile dialog box code. chrome\browser\views\user_data_dir_profiles_dialog.h/.cc Choose profile dialog box code. Review URL: http://codereview.chromium.org/12895 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6333 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views')
-rw-r--r--chrome/views/message_box_view.cc7
-rw-r--r--chrome/views/message_box_view.h6
-rw-r--r--chrome/views/window.cc26
-rw-r--r--chrome/views/window.h2
4 files changed, 33 insertions, 8 deletions
diff --git a/chrome/views/message_box_view.cc b/chrome/views/message_box_view.cc
index fc0b23f..2129212 100644
--- a/chrome/views/message_box_view.cc
+++ b/chrome/views/message_box_view.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/controller.h"
#include "chrome/browser/views/standard_layout.h"
#include "chrome/common/l10n_util.h"
+#include "chrome/views/checkbox.h"
#include "chrome/views/client_view.h"
#include "generated_resources.h"
@@ -71,6 +72,12 @@ void MessageBoxView::SetCheckBoxLabel(const std::wstring& label) {
ResetLayoutManager();
}
+void MessageBoxView::SetCheckBoxSelected(bool selected) {
+ if (!check_box_)
+ return;
+ check_box_->SetIsSelected(selected);
+}
+
///////////////////////////////////////////////////////////////////////////////
// MessageBoxView, views::View overrides:
diff --git a/chrome/views/message_box_view.h b/chrome/views/message_box_view.h
index 6ca5932..a8f0dca 100644
--- a/chrome/views/message_box_view.h
+++ b/chrome/views/message_box_view.h
@@ -43,6 +43,9 @@ class MessageBoxView : public views::View {
const std::wstring& message,
const std::wstring& default_prompt);
+ // Returns the text box.
+ views::TextField* text_box() { return prompt_field_; }
+
// Returns user entered data in the prompt field.
std::wstring GetInputText();
@@ -59,6 +62,9 @@ class MessageBoxView : public views::View {
// start, the message box has no checkbox until this function is called.
void SetCheckBoxLabel(const std::wstring& label);
+ // Sets the state of the check-box.
+ void SetCheckBoxSelected(bool selected);
+
protected:
// Layout and Painting functions.
virtual void ViewHierarchyChanged(bool is_add,
diff --git a/chrome/views/window.cc b/chrome/views/window.cc
index 051cd1f..df70094 100644
--- a/chrome/views/window.cc
+++ b/chrome/views/window.cc
@@ -201,20 +201,30 @@ void Window::ExecuteSystemMenuCommand(int command) {
}
// static
-gfx::Size Window::GetLocalizedContentsSize(int col_resource_id,
- int row_resource_id) {
+int Window::GetLocalizedContentsWidth(int col_resource_id) {
+ double chars = _wtof(l10n_util::GetString(col_resource_id).c_str());
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
ChromeFont font = rb.GetFont(ResourceBundle::BaseFont);
+ int width = font.GetExpectedTextWidth(static_cast<int>(chars));
+ DCHECK(width > 0);
+ return width;
+}
- double chars = _wtof(l10n_util::GetString(col_resource_id).c_str());
+// static
+int Window::GetLocalizedContentsHeight(int row_resource_id) {
double lines = _wtof(l10n_util::GetString(row_resource_id).c_str());
-
- int width = font.GetExpectedTextWidth(static_cast<int>(chars));
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ ChromeFont font = rb.GetFont(ResourceBundle::BaseFont);
int height = static_cast<int>(font.height() * lines);
+ DCHECK(height > 0);
+ return height;
+}
- DCHECK(width > 0 && height > 0);
-
- return gfx::Size(width, height);
+// static
+gfx::Size Window::GetLocalizedContentsSize(int col_resource_id,
+ int row_resource_id) {
+ return gfx::Size(GetLocalizedContentsWidth(col_resource_id),
+ GetLocalizedContentsHeight(row_resource_id));
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/views/window.h b/chrome/views/window.h
index 3a3ae7b..bdd3d6d 100644
--- a/chrome/views/window.h
+++ b/chrome/views/window.h
@@ -116,6 +116,8 @@ class Window : public WidgetWin {
// resource identified by |col_resource_id|, the height in the same fashion.
// TODO(beng): This should eventually live somewhere else, probably closer to
// ClientView.
+ static int GetLocalizedContentsWidth(int col_resource_id);
+ static int GetLocalizedContentsHeight(int row_resource_id);
static gfx::Size GetLocalizedContentsSize(int col_resource_id,
int row_resource_id);