summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/views/first_run_customize_view.cc37
-rw-r--r--chrome/browser/views/first_run_customize_view.h9
-rw-r--r--chrome/browser/views/first_run_view.cc17
-rw-r--r--chrome/browser/views/first_run_view.h12
-rw-r--r--chrome/browser/views/first_run_view_base.cc36
-rw-r--r--chrome/browser/views/first_run_view_base.h20
6 files changed, 78 insertions, 53 deletions
diff --git a/chrome/browser/views/first_run_customize_view.cc b/chrome/browser/views/first_run_customize_view.cc
index 378a135..9c0b0ab 100644
--- a/chrome/browser/views/first_run_customize_view.cc
+++ b/chrome/browser/views/first_run_customize_view.cc
@@ -8,7 +8,6 @@
#include "chrome/app/theme/theme_resources.h"
#include "chrome/browser/importer/importer.h"
#include "chrome/browser/first_run.h"
-#include "chrome/browser/shell_integration.h"
#include "chrome/browser/user_metrics.h"
#include "chrome/browser/views/standard_layout.h"
#include "chrome/common/l10n_util.h"
@@ -25,11 +24,11 @@
FirstRunCustomizeView::FirstRunCustomizeView(Profile* profile,
ImporterHost* importer_host,
- CustomizeViewObserver* observer)
+ CustomizeViewObserver* observer,
+ bool default_browser_checked)
: FirstRunViewBase(profile),
main_label_(NULL),
import_cbox_(NULL),
- default_browser_cbox_(NULL),
import_from_combo_(NULL),
shortcuts_label_(NULL),
desktop_shortcut_cbox_(NULL),
@@ -38,6 +37,12 @@ FirstRunCustomizeView::FirstRunCustomizeView(Profile* profile,
importer_host_ = importer_host;
DCHECK(importer_host_);
SetupControls();
+
+ // The checkbox for Default Browser should be the same for FirstRun and
+ // the customize view, so that the user selection isn't lost when you uncheck
+ // and then open the Customize dialog. Therefore, we propagate the selection
+ // status of the default browser here.
+ default_browser_->SetIsSelected(default_browser_checked);
}
FirstRunCustomizeView::~FirstRunCustomizeView() {
@@ -65,8 +70,6 @@ void FirstRunCustomizeView::SetupControls() {
import_from_combo_ = new ChromeViews::ComboBox(this);
AddChildView(import_from_combo_);
- default_browser_cbox_ = MakeCheckBox(IDS_FR_CUSTOMIZE_DEFAULT_BROWSER);
-
shortcuts_label_ =
new Label(l10n_util::GetString(IDS_FR_CUSTOMIZE_SHORTCUTS));
shortcuts_label_->SetHorizontalAlignment(Label::ALIGN_LEFT);
@@ -117,23 +120,18 @@ void FirstRunCustomizeView::Layout() {
import_cbox_->width();
import_from_combo_->GetPreferredSize(&pref_size);
- import_from_combo_->SetBounds(x_offset, next_v_space,
- pref_size.cx + kComboExtraPad, pref_size.cy);
+ import_from_combo_->SetBounds(x_offset,
+ next_v_space +
+ (import_cbox_->height() -
+ pref_size.cy) / 2,
+ pref_size.cx + kComboExtraPad,
+ pref_size.cy);
AdjustDialogWidth(import_from_combo_);
next_v_space = import_cbox_->y() + import_cbox_->height() +
kUnrelatedControlVerticalSpacing;
- default_browser_cbox_->GetPreferredSize(&pref_size);
- default_browser_cbox_->SetBounds(kPanelHorizMargin, next_v_space,
- pref_size.cx, pref_size.cy);
-
- AdjustDialogWidth(default_browser_cbox_);
-
- next_v_space += default_browser_cbox_->height() +
- kUnrelatedControlVerticalSpacing;
-
shortcuts_label_->GetPreferredSize(&pref_size);
shortcuts_label_->SetBounds(kPanelHorizMargin, next_v_space,
pref_size.cx, pref_size.cy);
@@ -190,7 +188,6 @@ bool FirstRunCustomizeView::Accept() {
DisableButtons();
import_cbox_->SetEnabled(false);
import_from_combo_->SetEnabled(false);
- default_browser_cbox_->SetEnabled(false);
desktop_shortcut_cbox_->SetEnabled(false);
quick_shortcut_cbox_->SetEnabled(false);
@@ -209,10 +206,8 @@ bool FirstRunCustomizeView::Accept() {
FirstRun::ImportSettings(profile_, browser_selected,
GetDefaultImportItems(), window()->GetHWND());
}
- if (default_browser_cbox_->IsSelected()) {
- UserMetrics::RecordAction(L"FirstRunCustom_Do_DefBrowser", profile_);
- ShellIntegration::SetAsDefaultBrowser();
- }
+ if (default_browser_->IsSelected())
+ SetDefaultBrowser();
if (customize_observer_)
customize_observer_->CustomizeAccepted();
diff --git a/chrome/browser/views/first_run_customize_view.h b/chrome/browser/views/first_run_customize_view.h
index 4a6f863..2edcc42 100644
--- a/chrome/browser/views/first_run_customize_view.h
+++ b/chrome/browser/views/first_run_customize_view.h
@@ -12,14 +12,11 @@
#include "chrome/views/view.h"
namespace ChromeViews {
-
class Label;
class Window;
class ImageView;
class Separator;
-class CheckBox;
class ComboBox;
-
}
class Profile;
@@ -40,7 +37,8 @@ class FirstRunCustomizeView : public FirstRunViewBase,
FirstRunCustomizeView(Profile* profile,
ImporterHost* importer_host,
- CustomizeViewObserver* observer);
+ CustomizeViewObserver* observer,
+ bool default_browser_checked);
virtual ~FirstRunCustomizeView();
// Overridden from ChromeViews::View.
@@ -74,7 +72,6 @@ class FirstRunCustomizeView : public FirstRunViewBase,
ChromeViews::Label* main_label_;
ChromeViews::CheckBox* import_cbox_;
- ChromeViews::CheckBox* default_browser_cbox_;
ChromeViews::ComboBox* import_from_combo_;
ChromeViews::Label* shortcuts_label_;
ChromeViews::CheckBox* desktop_shortcut_cbox_;
@@ -82,7 +79,7 @@ class FirstRunCustomizeView : public FirstRunViewBase,
CustomizeViewObserver* customize_observer_;
- DISALLOW_EVIL_CONSTRUCTORS(FirstRunCustomizeView);
+ DISALLOW_COPY_AND_ASSIGN(FirstRunCustomizeView);
};
#endif // CHROME_BROWSER_VIEWS_FIRST_RUN_CUSTOMIZE_VIEW_H_
diff --git a/chrome/browser/views/first_run_view.cc b/chrome/browser/views/first_run_view.cc
index 1796b56..e310e0a 100644
--- a/chrome/browser/views/first_run_view.cc
+++ b/chrome/browser/views/first_run_view.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/user_metrics.h"
#include "chrome/common/l10n_util.h"
#include "chrome/common/resource_bundle.h"
+#include "chrome/views/checkbox.h"
#include "chrome/views/image_view.h"
#include "chrome/views/label.h"
#include "chrome/views/throbber.h"
@@ -55,6 +56,8 @@ void FirstRunView::SetupControls() {
using ChromeViews::Label;
using ChromeViews::Link;
+ default_browser_->SetIsSelected(true);
+
welcome_label_ = new Label(l10n_util::GetString(IDS_FIRSTRUN_DLG_TEXT));
welcome_label_->SetMultiLine(true);
welcome_label_->SetHorizontalAlignment(Label::ALIGN_LEFT);
@@ -147,19 +150,15 @@ void FirstRunView::Layout() {
pref_size.cx, pref_size.cy);
}
-std::wstring FirstRunView::GetDialogButtonLabel(DialogButton button) const {
- if (DIALOGBUTTON_OK == button)
- return l10n_util::GetString(IDS_FIRSTRUN_DLG_OK);
- // The other buttons get the default text.
- return std::wstring();
-}
-
void FirstRunView::OpenCustomizeDialog() {
// The customize dialog now owns the importer host object.
ChromeViews::Window::CreateChromeWindow(
window()->GetHWND(),
gfx::Rect(),
- new FirstRunCustomizeView(profile_, importer_host_, this))->Show();
+ new FirstRunCustomizeView(profile_,
+ importer_host_,
+ this,
+ default_browser_->IsSelected()))->Show();
}
void FirstRunView::LinkActivated(ChromeViews::Link* source, int event_flags) {
@@ -182,6 +181,8 @@ bool FirstRunView::Accept() {
customize_link_->SetEnabled(false);
CreateDesktopShortcut();
CreateQuickLaunchShortcut();
+ if (default_browser_->IsSelected())
+ SetDefaultBrowser();
// Index 0 is the default browser.
FirstRun::ImportSettings(profile_, 0, GetDefaultImportItems(),
window()->GetHWND());
diff --git a/chrome/browser/views/first_run_view.h b/chrome/browser/views/first_run_view.h
index d078248..87b0152 100644
--- a/chrome/browser/views/first_run_view.h
+++ b/chrome/browser/views/first_run_view.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_VIEWS_FIRST_RUN_VIEW_H__
-#define CHROME_BROWSER_VIEWS_FIRST_RUN_VIEW_H__
+#ifndef CHROME_BROWSER_VIEWS_FIRST_RUN_VIEW_H_
+#define CHROME_BROWSER_VIEWS_FIRST_RUN_VIEW_H_
#include "chrome/browser/views/first_run_view_base.h"
#include "chrome/browser/views/first_run_customize_view.h"
@@ -12,10 +12,8 @@
#include "chrome/views/view.h"
namespace ChromeViews {
-
class Label;
class Window;
-
}
class Profile;
@@ -35,7 +33,6 @@ class FirstRunView : public FirstRunViewBase,
virtual void Layout();
// Overridden from ChromeViews::DialogDelegate:
- virtual std::wstring GetDialogButtonLabel(DialogButton button) const;
virtual bool Accept();
virtual bool Cancel();
@@ -64,8 +61,7 @@ class FirstRunView : public FirstRunViewBase,
ChromeViews::Link* customize_link_;
bool customize_selected_;
- DISALLOW_EVIL_CONSTRUCTORS(FirstRunView);
+ DISALLOW_COPY_AND_ASSIGN(FirstRunView);
};
-#endif // CHROME_BROWSER_VIEWS_FIRST_RUN_VIEW_H__
-
+#endif // CHROME_BROWSER_VIEWS_FIRST_RUN_VIEW_H_
diff --git a/chrome/browser/views/first_run_view_base.cc b/chrome/browser/views/first_run_view_base.cc
index df1268b..81e72fee 100644
--- a/chrome/browser/views/first_run_view_base.cc
+++ b/chrome/browser/views/first_run_view_base.cc
@@ -12,6 +12,8 @@
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/first_run.h"
+#include "chrome/browser/shell_integration.h"
+#include "chrome/browser/user_metrics.h"
#include "chrome/browser/views/standard_layout.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/l10n_util.h"
@@ -19,6 +21,7 @@
#include "chrome/common/pref_service.h"
#include "chrome/common/resource_bundle.h"
#include "chrome/views/background.h"
+#include "chrome/views/checkbox.h"
#include "chrome/views/client_view.h"
#include "chrome/views/image_view.h"
#include "chrome/views/label.h"
@@ -26,12 +29,14 @@
#include "chrome/views/separator.h"
#include "chrome/views/window.h"
+#include "chromium_strings.h"
#include "generated_resources.h"
FirstRunViewBase::FirstRunViewBase(Profile* profile)
: preferred_width_(0),
background_image_(NULL),
separator_1_(NULL),
+ default_browser_(NULL),
separator_2_(NULL),
importer_host_(NULL),
profile_(profile) {
@@ -91,6 +96,12 @@ void FirstRunViewBase::SetupControls() {
separator_1_ = new ChromeViews::Separator;
AddChildView(separator_1_);
+ // The "make us default browser" check box.
+ default_browser_ = new ChromeViews::CheckBox(
+ l10n_util::GetString(IDS_FR_CUSTOMIZE_DEFAULT_BROWSER));
+ default_browser_->SetMultiLine(true);
+ AddChildView(default_browser_);
+
// The second separator marks the start of buttons.
separator_2_ = new ChromeViews::Separator;
AddChildView(separator_2_);
@@ -124,10 +135,17 @@ void FirstRunViewBase::Layout() {
separator_1_->GetPreferredSize(&pref_size);
separator_1_->SetBounds(0 , next_v_space, canvas.cx + 1, pref_size.cy);
- next_v_space = canvas.cy - kPanelSubVerticalSpacing;
+ next_v_space = canvas.cy - kPanelSubVerticalSpacing - 2 * kVertSpacing;
separator_2_->GetPreferredSize(&pref_size);
separator_2_->SetBounds(kPanelHorizMargin , next_v_space,
- canvas.cx - 2*kPanelHorizMargin, pref_size.cy);
+ canvas.cx - 2 * kPanelHorizMargin, pref_size.cy);
+
+ next_v_space = separator_2_->y() + separator_2_->height() + kVertSpacing;
+
+ int width = canvas.cx - 2 * kPanelHorizMargin;
+ int height = default_browser_->GetHeightForWidth(width);
+ default_browser_->SetBounds(kPanelHorizMargin, next_v_space, width, height);
+ AdjustDialogWidth(default_browser_);
}
bool FirstRunViewBase::CanResize() const {
@@ -146,6 +164,13 @@ bool FirstRunViewBase::HasAlwaysOnTopMenu() const {
return false;
}
+std::wstring FirstRunViewBase::GetDialogButtonLabel(DialogButton button) const {
+ if (DIALOGBUTTON_OK == button)
+ return l10n_util::GetString(IDS_FIRSTRUN_DLG_OK);
+ // The other buttons get the default text.
+ return std::wstring();
+}
+
int FirstRunViewBase::GetDefaultImportItems() const {
// It is best to avoid importing cookies because there is a bug that make
// the process take way too much time among other issues. So for the time
@@ -158,6 +183,7 @@ void FirstRunViewBase::DisableButtons() {
ChromeViews::DialogClientView* dcv = GetDialogClientView();
dcv->ok_button()->SetEnabled(false);
dcv->cancel_button()->SetEnabled(false);
+ default_browser_->SetEnabled(false);
}
bool FirstRunViewBase::CreateDesktopShortcut() {
@@ -168,7 +194,11 @@ bool FirstRunViewBase::CreateQuickLaunchShortcut() {
return FirstRun::CreateChromeQuickLaunchShortcut();
}
+bool FirstRunViewBase::SetDefaultBrowser() {
+ UserMetrics::RecordAction(L"FirstRun_Do_DefBrowser", profile_);
+ return ShellIntegration::SetAsDefaultBrowser();
+}
+
bool FirstRunViewBase::FirstRunComplete() {
return FirstRun::CreateSentinel();
}
-
diff --git a/chrome/browser/views/first_run_view_base.h b/chrome/browser/views/first_run_view_base.h
index da0fe65..1d1d9a5 100644
--- a/chrome/browser/views/first_run_view_base.h
+++ b/chrome/browser/views/first_run_view_base.h
@@ -2,20 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_VIEWS_FIRST_RUN_VIEW_BASE_H__
-#define CHROME_BROWSER_VIEWS_FIRST_RUN_VIEW_BASE_H__
+#ifndef CHROME_BROWSER_VIEWS_FIRST_RUN_VIEW_BASE_H_
+#define CHROME_BROWSER_VIEWS_FIRST_RUN_VIEW_BASE_H_
#include "chrome/browser/importer/importer.h"
#include "chrome/views/dialog_delegate.h"
#include "chrome/views/view.h"
namespace ChromeViews {
-
+class CheckBox;
class Window;
class ImageView;
class Separator;
class Throbber;
-
}
class Profile;
@@ -39,6 +38,9 @@ class FirstRunViewBase : public ChromeViews::View,
virtual bool IsAlwaysOnTop() const;
virtual bool HasAlwaysOnTopMenu() const;
+ // Overridden from ChromeViews::DialogDelegate.
+ std::wstring GetDialogButtonLabel(DialogButton button) const;
+
protected:
// Returns the items that the first run process is required to import
// from other browsers.
@@ -48,10 +50,13 @@ class FirstRunViewBase : public ChromeViews::View,
bool CreateDesktopShortcut();
bool CreateQuickLaunchShortcut();
+ // Set us as default browser if the user checked the box.
+ bool SetDefaultBrowser();
+
// Modifies the chrome configuration so that the first-run dialogs are not
// shown again.
bool FirstRunComplete();
-
+
// Disables the standard buttons of the dialog. Useful when importing.
void DisableButtons();
// Computes a tight dialog width given a contained UI element.
@@ -72,6 +77,7 @@ class FirstRunViewBase : public ChromeViews::View,
scoped_refptr<ImporterHost> importer_host_;
Profile* profile_;
+ ChromeViews::CheckBox* default_browser_;
private:
// Initializes the controls on the dialog.
@@ -81,8 +87,8 @@ class FirstRunViewBase : public ChromeViews::View,
ChromeViews::Separator* separator_2_;
int preferred_width_;
- DISALLOW_EVIL_CONSTRUCTORS(FirstRunViewBase);
+ DISALLOW_COPY_AND_ASSIGN(FirstRunViewBase);
};
-#endif // CHROME_BROWSER_VIEWS_FIRST_RUN_VIEW_BASE_H__
+#endif // CHROME_BROWSER_VIEWS_FIRST_RUN_VIEW_BASE_H_