summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authormirandac@google.com <mirandac@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-16 16:16:52 +0000
committermirandac@google.com <mirandac@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-16 16:16:52 +0000
commit2f24d2967d2e026cf6c1c517fca44591635ff5d7 (patch)
tree272bed44e9f223d390acfdcb638460be341eb235 /chrome/browser/views
parentb6f0f13b526b416f2858f0a263d81eab2806092f (diff)
downloadchromium_src-2f24d2967d2e026cf6c1c517fca44591635ff5d7.zip
chromium_src-2f24d2967d2e026cf6c1c517fca44591635ff5d7.tar.gz
chromium_src-2f24d2967d2e026cf6c1c517fca44591635ff5d7.tar.bz2
New first run sequence for Windows, with no UI. Organic builds will display the Search Engine Dialog, otherwise search engine is set to Google or silently imported, depending on master_preferences. (see go/chromefirstrun for details).
I also removed a no-longer-used SearchSelectObserver from FirstRunSearchView. BUG=42612 TEST=First run import works as intended (see go/chromefirstrun). master_preferences file can still turn off import of history, search engine, and home page. Review URL: http://codereview.chromium.org/2934011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52679 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/first_run_customize_view.cc247
-rw-r--r--chrome/browser/views/first_run_customize_view.h91
-rw-r--r--chrome/browser/views/first_run_search_engine_view.cc20
-rw-r--r--chrome/browser/views/first_run_search_engine_view.h21
-rw-r--r--chrome/browser/views/first_run_view.cc284
-rw-r--r--chrome/browser/views/first_run_view.h86
-rw-r--r--chrome/browser/views/first_run_view_base.cc257
-rw-r--r--chrome/browser/views/first_run_view_base.h111
-rw-r--r--chrome/browser/views/keyword_editor_view.cc6
9 files changed, 13 insertions, 1110 deletions
diff --git a/chrome/browser/views/first_run_customize_view.cc b/chrome/browser/views/first_run_customize_view.cc
deleted file mode 100644
index cbaab1d..0000000
--- a/chrome/browser/views/first_run_customize_view.cc
+++ /dev/null
@@ -1,247 +0,0 @@
-// Copyright (c) 2010 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/first_run_customize_view.h"
-
-#include "app/l10n_util.h"
-#include "app/resource_bundle.h"
-#include "base/win_util.h"
-#include "chrome/browser/importer/importer.h"
-#include "chrome/browser/first_run.h"
-#include "chrome/browser/metrics/user_metrics.h"
-#include "chrome/installer/util/browser_distribution.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "grit/theme_resources.h"
-#include "views/controls/button/checkbox.h"
-#include "views/controls/image_view.h"
-#include "views/controls/label.h"
-#include "views/controls/throbber.h"
-#include "views/standard_layout.h"
-#include "views/window/window.h"
-
-FirstRunCustomizeView::FirstRunCustomizeView(
- Profile* profile,
- ImporterHost* importer_host,
- CustomizeViewObserver* observer,
- bool default_browser_checked,
- bool homepage_defined,
- int import_items,
- int dont_import_items,
- bool search_engine_experiment,
- bool randomize_search_engine_experiment)
- : FirstRunViewBase(profile, homepage_defined, import_items,
- dont_import_items, search_engine_experiment,
- randomize_search_engine_experiment),
- main_label_(NULL),
- import_cbox_(NULL),
- import_from_combo_(NULL),
- shortcuts_label_(NULL),
- desktop_shortcut_cbox_(NULL),
- quick_shortcut_cbox_(NULL),
- customize_observer_(observer) {
- 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.
- if (default_browser_)
- default_browser_->SetChecked(default_browser_checked);
-}
-
-FirstRunCustomizeView::~FirstRunCustomizeView() {
-}
-
-views::Checkbox* FirstRunCustomizeView::MakeCheckBox(int label_id) {
- views::Checkbox* cbox = new views::Checkbox(l10n_util::GetString(label_id));
- cbox->set_listener(this);
- AddChildView(cbox);
- return cbox;
-}
-
-void FirstRunCustomizeView::SetupControls() {
- using views::Label;
- using views::Checkbox;
-
- main_label_ = new Label(l10n_util::GetString(IDS_FR_CUSTOMIZE_DLG_TEXT));
- main_label_->SetMultiLine(true);
- main_label_->SetHorizontalAlignment(Label::ALIGN_LEFT);
- AddChildView(main_label_);
-
- import_cbox_ = MakeCheckBox(IDS_FR_CUSTOMIZE_IMPORT);
-
- import_from_combo_ = new views::Combobox(this);
- AddChildView(import_from_combo_);
-
- shortcuts_label_ =
- new Label(l10n_util::GetString(IDS_FR_CUSTOMIZE_SHORTCUTS));
- shortcuts_label_->SetHorizontalAlignment(Label::ALIGN_LEFT);
- AddChildView(shortcuts_label_);
-
- // The two check boxes for the different shortcut creation.
- desktop_shortcut_cbox_ = MakeCheckBox(IDS_FR_CUSTOM_SHORTCUT_DESKTOP);
- desktop_shortcut_cbox_->SetChecked(true);
-
- quick_shortcut_cbox_ = MakeCheckBox(IDS_FR_CUSTOM_SHORTCUT_QUICKL);
- // For windows 7 create quick launch default is not checked.
- bool ql_default = (win_util::GetWinVersion() < win_util::WINVERSION_WIN7);
- quick_shortcut_cbox_->SetChecked(ql_default);
-}
-
-gfx::Size FirstRunCustomizeView::GetPreferredSize() {
- return gfx::Size(views::Window::GetLocalizedContentsSize(
- IDS_FIRSTRUNCUSTOMIZE_DIALOG_WIDTH_CHARS,
- IDS_FIRSTRUNCUSTOMIZE_DIALOG_HEIGHT_LINES));
-}
-
-void FirstRunCustomizeView::Layout() {
- FirstRunViewBase::Layout();
-
- const int kVertSpacing = 8;
- const int kComboExtraPad = 8;
-
- gfx::Size canvas = GetPreferredSize();
-
- // Welcome label goes in to to the left. It does not go across the
- // entire window because the background gets busy on the right.
- gfx::Size pref_size = main_label_->GetPreferredSize();
- main_label_->SetBounds(kPanelHorizMargin, kPanelVertMargin,
- canvas.width() - pref_size.width(),
- pref_size.height());
- AdjustDialogWidth(main_label_);
-
- int next_v_space = background_image()->y() +
- background_image()->height() + kPanelVertMargin;
-
- pref_size = import_cbox_->GetPreferredSize();
- import_cbox_->SetBounds(kPanelHorizMargin, next_v_space,
- pref_size.width(), pref_size.height());
-
- import_cbox_->SetChecked(true);
-
- int x_offset = import_cbox_->x() +
- import_cbox_->width();
-
- pref_size = import_from_combo_->GetPreferredSize();
- import_from_combo_->SetBounds(x_offset,
- next_v_space +
- (import_cbox_->height() -
- pref_size.height()) / 2,
- pref_size.width() + kComboExtraPad,
- pref_size.height());
-
- AdjustDialogWidth(import_from_combo_);
-
- next_v_space = import_cbox_->y() + import_cbox_->height() +
- kUnrelatedControlVerticalSpacing;
-
- pref_size = shortcuts_label_->GetPreferredSize();
- shortcuts_label_->SetBounds(kPanelHorizMargin, next_v_space,
- pref_size.width(), pref_size.height());
-
- AdjustDialogWidth(shortcuts_label_);
-
- next_v_space += shortcuts_label_->height() +
- kRelatedControlVerticalSpacing;
-
- pref_size = desktop_shortcut_cbox_->GetPreferredSize();
- desktop_shortcut_cbox_->SetBounds(kPanelHorizMargin, next_v_space,
- pref_size.width(), pref_size.height());
-
- AdjustDialogWidth(desktop_shortcut_cbox_);
-
- next_v_space += desktop_shortcut_cbox_->height() +
- kRelatedControlVerticalSpacing;
-
- pref_size = quick_shortcut_cbox_->GetPreferredSize();
- quick_shortcut_cbox_->SetBounds(kPanelHorizMargin, next_v_space,
- pref_size.width(), pref_size.height());
-
- AdjustDialogWidth(quick_shortcut_cbox_);
-}
-
-void FirstRunCustomizeView::ButtonPressed(
- views::Button* sender, const views::Event& event) {
- if (import_cbox_ == sender) {
- // Disable the import combobox if the user unchecks the checkbox.
- import_from_combo_->SetEnabled(import_cbox_->checked());
- }
-
- // Call the function of the base class to update its buttons.
- FirstRunViewBase::ButtonPressed(sender, event);
-}
-
-int FirstRunCustomizeView::GetItemCount() {
- return importer_host_->GetAvailableProfileCount();
-}
-
-std::wstring FirstRunCustomizeView::GetItemAt(int index) {
- return importer_host_->GetSourceProfileNameAt(index);
-}
-
-std::wstring FirstRunCustomizeView::GetWindowTitle() const {
- return l10n_util::GetString(IDS_FR_CUSTOMIZE_DLG_TITLE);
-}
-
-views::View* FirstRunCustomizeView::GetContentsView() {
- return this;
-}
-
-bool FirstRunCustomizeView::Accept() {
- if (!IsDialogButtonEnabled(MessageBoxFlags::DIALOGBUTTON_OK))
- return false;
-
- DisableButtons();
- import_cbox_->SetEnabled(false);
- import_from_combo_->SetEnabled(false);
- desktop_shortcut_cbox_->SetEnabled(false);
- quick_shortcut_cbox_->SetEnabled(false);
-
- if (desktop_shortcut_cbox_->checked()) {
- UserMetrics::RecordAction(
- UserMetricsAction("FirstRunCustom_Do_DesktopShortcut"), profile_);
- CreateDesktopShortcut();
- }
- if (quick_shortcut_cbox_->checked()) {
- UserMetrics::RecordAction(
- UserMetricsAction("FirstRunCustom_Do_QuickLShortcut"), profile_);
- CreateQuickLaunchShortcut();
- }
- if (!import_cbox_->checked()) {
- UserMetrics::RecordAction(UserMetricsAction("FirstRunCustom_No_Import"),
- profile_);
- } else {
- int browser_selected = import_from_combo_->selected_item();
- FirstRun::ImportSettings(profile_,
- importer_host_->GetSourceProfileInfoAt(browser_selected).browser_type,
- GetImportItems(), window()->GetNativeWindow());
- }
- if (default_browser_ && default_browser_->checked())
- SetDefaultBrowser();
-
- // The customize observer is responsible for shutting down the startup
- // message loop.
- if (customize_observer_) {
- customize_observer_->CustomizeAccepted();
- } else {
- // Exit the message loop we were started with so that startup can continue.
- MessageLoop::current()->Quit();
- FirstRunComplete();
- }
- return true;
-}
-
-bool FirstRunCustomizeView::Cancel() {
- if (customize_observer_)
- customize_observer_->CustomizeCanceled();
-
- // Don't quit the message loop in this case - we're still showing the main
- // First run dialog box underneath ourselves.
-
- return true;
-}
diff --git a/chrome/browser/views/first_run_customize_view.h b/chrome/browser/views/first_run_customize_view.h
deleted file mode 100644
index 11ee459..0000000
--- a/chrome/browser/views/first_run_customize_view.h
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright (c) 2010 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_FIRST_RUN_CUSTOMIZE_VIEW_H_
-#define CHROME_BROWSER_VIEWS_FIRST_RUN_CUSTOMIZE_VIEW_H_
-
-#include "app/combobox_model.h"
-#include "chrome/browser/views/first_run_view_base.h"
-#include "views/controls/button/button.h"
-#include "views/controls/combobox/combobox.h"
-#include "views/view.h"
-#include "views/window/dialog_delegate.h"
-
-namespace views {
-class Checkbox;
-class ComboBox;
-class ImageView;
-class Label;
-class Separator;
-class Window;
-}
-
-class Profile;
-
-// FirstRunCustomizeView implements the dialog that allows the user to do
-// some simple customizations during the first run.
-class FirstRunCustomizeView : public FirstRunViewBase,
- public ComboboxModel {
- public:
- class CustomizeViewObserver {
- public:
- // Called when the user has accepted the dialog.
- virtual void CustomizeAccepted() = 0;
- // Called when the user has canceled the dialog.
- virtual void CustomizeCanceled() = 0;
- };
-
- FirstRunCustomizeView(Profile* profile,
- ImporterHost* importer_host,
- CustomizeViewObserver* observer,
- bool default_browser_checked,
- bool homepage_defined,
- int import_items,
- int dont_import_items,
- bool randomize_search_engine_experiment,
- bool search_engine_experiment);
- virtual ~FirstRunCustomizeView();
-
- // Overridden from views::View.
- virtual gfx::Size GetPreferredSize();
- virtual void Layout();
-
- // Overridden from views::DialogDelegate.
- virtual bool Accept();
- virtual bool Cancel();
-
- // Overridden form FirstRunViewBase.
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- // Overridden form ComboboxModel.
- virtual int GetItemCount();
- virtual std::wstring GetItemAt(int index);
-
- // Overridden from views::WindowDelegate.
- virtual std::wstring GetWindowTitle() const;
- virtual views::View* GetContentsView();
- // Yes, we're modal.
- // NOTE: if you change this you'll need to make sure it isn't possible to
- // close the window while importing.
- virtual bool IsModal() const { return true; }
-
- private:
- // Initializes the controls on the dialog.
- void SetupControls();
-
- views::Checkbox* MakeCheckBox(int resource_id);
-
- views::Label* main_label_;
- views::Checkbox* import_cbox_;
- views::Combobox* import_from_combo_;
- views::Label* shortcuts_label_;
- views::Checkbox* desktop_shortcut_cbox_;
- views::Checkbox* quick_shortcut_cbox_;
-
- CustomizeViewObserver* customize_observer_;
-
- DISALLOW_COPY_AND_ASSIGN(FirstRunCustomizeView);
-};
-
-#endif // CHROME_BROWSER_VIEWS_FIRST_RUN_CUSTOMIZE_VIEW_H_
diff --git a/chrome/browser/views/first_run_search_engine_view.cc b/chrome/browser/views/first_run_search_engine_view.cc
index 5cca996..174f830 100644
--- a/chrome/browser/views/first_run_search_engine_view.cc
+++ b/chrome/browser/views/first_run_search_engine_view.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/options_window.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
#include "gfx/font.h"
#include "grit/browser_resources.h"
@@ -155,13 +154,11 @@ void SearchEngineChoice::SetChoiceViewBounds(int x, int y, int width,
}
FirstRunSearchEngineView::FirstRunSearchEngineView(
- SearchEngineSelectionObserver* observer, Profile* profile, bool randomize)
+ Profile* profile, bool randomize)
: background_image_(NULL),
profile_(profile),
- observer_(observer),
text_direction_is_rtl_(base::i18n::IsRTL()),
randomize_(randomize) {
- DCHECK(observer);
// Don't show ourselves until all the search engines have loaded from
// the profile -- otherwise we have nothing to show.
SetVisible(false);
@@ -185,9 +182,14 @@ FirstRunSearchEngineView::~FirstRunSearchEngineView() {
void FirstRunSearchEngineView::ButtonPressed(views::Button* sender,
const views::Event& event) {
SearchEngineChoice* choice = static_cast<SearchEngineChoice*>(sender);
- profile_->GetTemplateURLModel()->SetSearchEngineDialogSlot(
- choice->slot());
- observer_->SearchEngineChosen(choice->GetSearchEngine());
+ TemplateURLModel* template_url_model = profile_->GetTemplateURLModel();
+ DCHECK(template_url_model);
+ template_url_model->SetSearchEngineDialogSlot(choice->slot());
+ const TemplateURL* default_search = choice->GetSearchEngine();
+ if (default_search)
+ template_url_model->SetDefaultSearchProvider(default_search);
+
+ MessageLoop::current()->Quit();
}
void FirstRunSearchEngineView::OnTemplateURLModelChanged() {
@@ -204,10 +206,8 @@ void FirstRunSearchEngineView::OnTemplateURLModelChanged() {
// If we have fewer than three search engines, signal that the search engine
// experiment is over, leaving imported default search engine setting intact.
- if (template_urls.size() < 3) {
- observer_->SearchEngineChosen(NULL);
+ if (template_urls.size() < 3)
return;
- }
std::vector<const TemplateURL*>::iterator search_engine_iter;
diff --git a/chrome/browser/views/first_run_search_engine_view.h b/chrome/browser/views/first_run_search_engine_view.h
index 1cdc188..6e162a7 100644
--- a/chrome/browser/views/first_run_search_engine_view.h
+++ b/chrome/browser/views/first_run_search_engine_view.h
@@ -7,7 +7,7 @@
#include <vector>
-#include "chrome/browser/views/keyword_editor_view.h"
+#include "chrome/browser/search_engines/template_url_model.h"
#include "gfx/size.h"
#include "views/controls/button/native_button.h"
#include "views/view.h"
@@ -73,14 +73,6 @@ class SearchEngineChoice : public views::NativeButton {
DISALLOW_COPY_AND_ASSIGN(SearchEngineChoice);
};
-// This class receives a callback when the search engine dialog closes.
-class SearchEngineSelectionObserver {
- public:
- virtual ~SearchEngineSelectionObserver() {}
- // Called when the user has chosen a search engine.
- virtual void SearchEngineChosen(const TemplateURL* default_search) = 0;
-};
-
// This class displays a large search engine choice dialog view during
// initial first run import.
class FirstRunSearchEngineView
@@ -89,13 +81,9 @@ class FirstRunSearchEngineView
public views::WindowDelegate,
public TemplateURLModelObserver {
public:
- // |observer| is the FirstRunView that waits for us to pass back a search
- // engine choice.
- // |profile| allows us to get the set of imported search engines, and
- // display the KeywordEditorView on demand.
+ // |profile| allows us to get the set of imported search engines.
// |randomize| is true if logos are to be displayed in random order.
- FirstRunSearchEngineView(SearchEngineSelectionObserver* observer,
- Profile* profile, bool randomize);
+ FirstRunSearchEngineView(Profile* profile, bool randomize);
virtual ~FirstRunSearchEngineView();
@@ -135,9 +123,6 @@ class FirstRunSearchEngineView
// The profile associated with this import process.
Profile* profile_;
- // Gets called back when one of the choice buttons is pressed.
- SearchEngineSelectionObserver* observer_;
-
bool text_direction_is_rtl_;
// Image of browser search box with grey background and bubble arrow.
diff --git a/chrome/browser/views/first_run_view.cc b/chrome/browser/views/first_run_view.cc
deleted file mode 100644
index 209c9be..0000000
--- a/chrome/browser/views/first_run_view.cc
+++ /dev/null
@@ -1,284 +0,0 @@
-// Copyright (c) 2010 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/first_run_view.h"
-
-#include "app/l10n_util.h"
-#include "app/resource_bundle.h"
-#include "base/win_util.h"
-#include "chrome/browser/importer/importer.h"
-#include "chrome/browser/first_run.h"
-#include "chrome/browser/metrics/user_metrics.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
-#include "chrome/browser/views/first_run_customize_view.h"
-#include "chrome/browser/views/first_run_search_engine_view.h"
-#include "chrome/installer/util/browser_distribution.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "grit/theme_resources.h"
-#include "views/controls/button/checkbox.h"
-#include "views/controls/image_view.h"
-#include "views/controls/label.h"
-#include "views/controls/throbber.h"
-#include "views/controls/separator.h"
-#include "views/standard_layout.h"
-#include "views/window/window.h"
-
-namespace {
-
-// Adds a bullet glyph to a string.
-std::wstring AddBullet(const std::wstring& text) {
- std::wstring btext(L" " + text);
- return btext.insert(0, 1, L'\u2022');
-}
-
-} // namespace
-
-FirstRunView::FirstRunView(Profile* profile, bool homepage_defined,
- int import_items, int dont_import_items,
- bool search_engine_experiment,
- bool randomize_search_engine_experiment)
- : FirstRunViewBase(profile, homepage_defined, import_items,
- dont_import_items, search_engine_experiment,
- randomize_search_engine_experiment),
- welcome_label_(NULL),
- actions_label_(NULL),
- actions_import_(NULL),
- actions_shorcuts_(NULL),
- customize_link_(NULL),
- customize_selected_(false),
- accepted_(false) {
- importer_host_ = new ImporterHost();
- SetupControls();
-}
-
-FirstRunView::~FirstRunView() {
-}
-
-void FirstRunView::SetupControls() {
- using views::Label;
- using views::Link;
-
- if (default_browser_)
- default_browser_->SetChecked(true);
-
- welcome_label_ = new Label(l10n_util::GetString(IDS_FIRSTRUN_DLG_TEXT));
- welcome_label_->SetColor(SK_ColorBLACK);
- welcome_label_->SetMultiLine(true);
- welcome_label_->SetHorizontalAlignment(Label::ALIGN_LEFT);
- welcome_label_->SizeToFit(0);
- AddChildView(welcome_label_);
-
- if (!search_engine_experiment_) {
- actions_label_ = new Label(l10n_util::GetString(IDS_FIRSTRUN_DLG_DETAIL));
- } else {
- if (importer_host_->GetAvailableProfileCount() > 0) {
- actions_label_ = new Label(l10n_util::GetStringF(
- IDS_FIRSTRUN_DLG_ACTION1_ALT,
- l10n_util::GetString(IDS_PRODUCT_NAME),
- importer_host_->GetSourceProfileNameAt(0)));
- actions_label_->SetMultiLine(true);
- actions_label_->SetHorizontalAlignment(Label::ALIGN_LEFT);
- actions_label_->SizeToFit(0);
- } else {
- NOTREACHED();
- }
- }
-
- actions_label_->SetHorizontalAlignment(Label::ALIGN_LEFT);
- AddChildView(actions_label_);
-
- if (!search_engine_experiment_) {
- // The first action label will tell what we are going to import from which
- // browser, which we obtain from the ImporterHost. We need that the first
- // browser profile be the default browser.
- std::wstring label1;
- if (importer_host_->GetAvailableProfileCount() > 0) {
- label1 = l10n_util::GetStringF(IDS_FIRSTRUN_DLG_ACTION1,
- importer_host_->GetSourceProfileNameAt(0));
- } else {
- NOTREACHED();
- }
- actions_import_ = new Label(AddBullet(label1));
- actions_import_->SetMultiLine(true);
- actions_import_->SetHorizontalAlignment(Label::ALIGN_LEFT);
- AddChildView(actions_import_);
- std::wstring label2 = l10n_util::GetString(IDS_FIRSTRUN_DLG_ACTION2);
- actions_shorcuts_ = new Label(AddBullet(label2));
- actions_shorcuts_->SetHorizontalAlignment(Label::ALIGN_LEFT);
- actions_shorcuts_->SetMultiLine(true);
- AddChildView(actions_shorcuts_);
- }
-
- customize_link_ = new Link(l10n_util::GetString(IDS_FIRSTRUN_DLG_OVERRIDE));
- customize_link_->SetController(this);
- AddChildView(customize_link_);
-}
-
-gfx::Size FirstRunView::GetPreferredSize() {
- return gfx::Size(views::Window::GetLocalizedContentsSize(
- IDS_FIRSTRUN_DIALOG_WIDTH_CHARS,
- IDS_FIRSTRUN_DIALOG_HEIGHT_LINES));
-}
-
-void FirstRunView::Layout() {
- FirstRunViewBase::Layout();
-
- const int kVertSpacing = 8;
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
-
- gfx::Size pref_size = welcome_label_->GetPreferredSize();
- // Wrap the label text before we overlap the product icon.
- int label_width = background_image()->width() -
- rb.GetBitmapNamed(IDR_WIZARD_ICON)->width() - kPanelHorizMargin;
- welcome_label_->SetBounds(kPanelHorizMargin, kPanelVertMargin,
- label_width, pref_size.height());
- AdjustDialogWidth(welcome_label_);
-
- int next_v_space = background_image()->y() +
- background_image()->height() + kPanelVertMargin;
-
- label_width = width() - (2 * kPanelHorizMargin);
-
- pref_size = actions_label_->GetPreferredSize();
- actions_label_->SetBounds(kPanelHorizMargin, next_v_space,
- label_width, pref_size.height());
- AdjustDialogWidth(actions_label_);
-
- next_v_space = actions_label_->y() +
- actions_label_->height() + kVertSpacing;
-
- if (!search_engine_experiment_) {
- int label_height = actions_import_->GetHeightForWidth(label_width);
- actions_import_->SetBounds(kPanelHorizMargin, next_v_space, label_width,
- label_height);
-
- next_v_space = actions_import_->y() +
- actions_import_->height() + kVertSpacing;
- AdjustDialogWidth(actions_import_);
-
- label_height = actions_shorcuts_->GetHeightForWidth(label_width);
- actions_shorcuts_->SetBounds(kPanelHorizMargin, next_v_space, label_width,
- label_height);
- AdjustDialogWidth(actions_shorcuts_);
-
- next_v_space = actions_shorcuts_->y() +
- actions_shorcuts_->height() +
- kUnrelatedControlVerticalSpacing;
- }
-
- pref_size = customize_link_->GetPreferredSize();
- customize_link_->SetBounds(kPanelHorizMargin, next_v_space,
- pref_size.width(), pref_size.height());
-}
-
-void FirstRunView::OpenCustomizeDialog() {
- // The customize dialog now owns the importer host object.
- views::Window::CreateChromeWindow(
- window()->GetNativeWindow(),
- gfx::Rect(),
- new FirstRunCustomizeView(profile_,
- importer_host_,
- this,
- default_browser_ && default_browser_->checked(),
- homepage_defined_,
- import_items_,
- dont_import_items_,
- search_engine_experiment_,
- randomize_search_engine_experiment_))->Show();
-}
-
-void FirstRunView::OpenSearchEngineDialog(bool randomize) {
- views::Window::CreateChromeWindow(
- window()->GetNativeWindow(),
- gfx::Rect(),
- new FirstRunSearchEngineView(this,
- profile_,
- randomize))->Show();
-}
-
-void FirstRunView::LinkActivated(views::Link* source, int event_flags) {
- OpenCustomizeDialog();
-}
-
-std::wstring FirstRunView::GetWindowTitle() const {
- return l10n_util::GetString(IDS_FIRSTRUN_DLG_TITLE);
-}
-
-views::View* FirstRunView::GetContentsView() {
- return this;
-}
-
-bool FirstRunView::Accept() {
- if (!IsDialogButtonEnabled(MessageBoxFlags::DIALOGBUTTON_OK))
- return false;
-
- DisableButtons();
- customize_link_->SetEnabled(false);
- CreateDesktopShortcut();
- // Windows 7 has deprecated the quick launch bar.
- if (win_util::GetWinVersion() < win_util::WINVERSION_WIN7)
- CreateQuickLaunchShortcut();
- // Index 0 is the default browser.
- FirstRun::ImportSettings(profile_,
- importer_host_->GetSourceProfileInfoAt(0).browser_type,
- GetImportItems(), window()->GetNativeWindow());
- UserMetrics::RecordAction(UserMetricsAction("FirstRunDef_Accept"), profile_);
- if (default_browser_ && default_browser_->checked())
- SetDefaultBrowser();
-
- // Launch the search engine dialog.
- if (search_engine_experiment_) {
- OpenSearchEngineDialog(randomize_search_engine_experiment_);
- // Leave without shutting down; we'll observe the search engine dialog and
- // shut down after it closes.
- return false;
- }
-
- accepted_ = true;
- FirstRunComplete();
- MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
- return true;
-}
-
-bool FirstRunView::Cancel() {
- UserMetrics::RecordAction(UserMetricsAction("FirstRunDef_Cancel"), profile_);
- MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
- return true;
-}
-
-// Notification from the customize dialog that the user accepted. Since all
-// the work is done there we have nothing else to do.
-void FirstRunView::CustomizeAccepted() {
- if (search_engine_experiment_) {
- OpenSearchEngineDialog(randomize_search_engine_experiment_);
- // We'll shut down after search engine has been chosen.
- return;
- }
- accepted_ = true;
- FirstRunComplete();
- window()->Close();
- MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
-}
-
-// Notification from the customize dialog that the user cancelled.
-void FirstRunView::CustomizeCanceled() {
- UserMetrics::RecordAction(UserMetricsAction("FirstRunCustom_Cancel"),
- profile_);
-}
-
-void FirstRunView::SearchEngineChosen(const TemplateURL* default_search) {
- // default_search may be NULL if the user closed the search view without
- // making a choice, or if a choice was made through the KeywordEditor.
- if (default_search)
- profile_->GetTemplateURLModel()->SetDefaultSearchProvider(default_search);
- accepted_ = true;
- FirstRunComplete();
- window()->Close();
- MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
-}
-
diff --git a/chrome/browser/views/first_run_view.h b/chrome/browser/views/first_run_view.h
deleted file mode 100644
index bab3581f..0000000
--- a/chrome/browser/views/first_run_view.h
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (c) 2010 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_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"
-#include "chrome/browser/views/first_run_search_engine_view.h"
-#include "views/controls/link.h"
-#include "views/view.h"
-#include "views/window/dialog_delegate.h"
-
-namespace views {
-class Label;
-class Window;
-}
-
-class Profile;
-class ImporterHost;
-class TemplateURL;
-
-// FirstRunView implements the dialog that welcomes to user to Chrome after
-// a fresh install.
-class FirstRunView : public FirstRunViewBase,
- public views::LinkController,
- public FirstRunCustomizeView::CustomizeViewObserver,
- public SearchEngineSelectionObserver {
- public:
- explicit FirstRunView(Profile* profile, bool homepage_defined,
- int import_items, int dont_import_items,
- bool search_engine_experiment,
- bool randomize_search_engine_experiment);
- virtual ~FirstRunView();
-
- bool accepted() const { return accepted_;}
-
- // Overridden from views::View:
- virtual gfx::Size GetPreferredSize();
- virtual void Layout();
-
- // Overridden from views::DialogDelegate:
- virtual bool Accept();
- virtual bool Cancel();
-
- // Overridden from views::WindowDelegate:
- virtual std::wstring GetWindowTitle() const;
- virtual views::View* GetContentsView();
-
- // Overridden from views::LinkActivated:
- virtual void LinkActivated(views::Link* source, int event_flags);
-
- // Overridden from FirstRunCustomizeView:
- virtual void CustomizeAccepted();
- virtual void CustomizeCanceled();
-
- // Overridden from SearchEngineSelectionObserver:
- virtual void SearchEngineChosen(const TemplateURL* default_search);
-
- private:
- // Initializes the controls on the dialog.
- void SetupControls();
-
- // Creates the dialog that allows the user to customize work items.
- void OpenCustomizeDialog();
-
- // Creates the search engine selection dialog. If |randomize|, the display
- // of search engine logos should be randomized.
- void OpenSearchEngineDialog(bool randomize);
-
- views::Label* welcome_label_;
- views::Label* actions_label_;
- views::Label* actions_import_;
- views::Label* actions_shorcuts_;
- views::Link* customize_link_;
- bool customize_selected_;
-
- // Whether the user accepted (pressed the "Start" button as opposed to
- // "Cancel").
- bool accepted_;
-
- DISALLOW_COPY_AND_ASSIGN(FirstRunView);
-};
-
-#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
deleted file mode 100644
index 2067618..0000000
--- a/chrome/browser/views/first_run_view_base.cc
+++ /dev/null
@@ -1,257 +0,0 @@
-// Copyright (c) 2010 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/first_run_view_base.h"
-
-#include "app/l10n_util.h"
-#include "app/resource_bundle.h"
-#include "base/command_line.h"
-#include "base/path_service.h"
-#include "base/thread.h"
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/first_run.h"
-#include "chrome/browser/importer/importer.h"
-#include "chrome/browser/metrics/user_metrics.h"
-#include "chrome/browser/pref_service.h"
-#include "chrome/browser/shell_integration.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/installer/util/browser_distribution.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "grit/theme_resources.h"
-#include "views/background.h"
-#include "views/controls/button/checkbox.h"
-#include "views/controls/image_view.h"
-#include "views/controls/label.h"
-#include "views/controls/throbber.h"
-#include "views/controls/separator.h"
-#include "views/standard_layout.h"
-#include "views/window/client_view.h"
-#include "views/window/window.h"
-
-FirstRunViewBase::FirstRunViewBase(Profile* profile, bool homepage_defined,
- int import_items, int dont_import_items,
- bool search_engine_experiment,
- bool randomize_search_engine_experiment)
- : preferred_width_(0),
- background_image_(NULL),
- separator_1_(NULL),
- default_browser_(NULL),
- non_default_browser_label_(NULL),
- separator_2_(NULL),
- importer_host_(NULL),
- profile_(profile),
- homepage_defined_(homepage_defined),
- import_items_(import_items),
- dont_import_items_(dont_import_items),
- search_engine_experiment_(search_engine_experiment),
- randomize_search_engine_experiment_(randomize_search_engine_experiment) {
- DCHECK(profile);
- SetupControls();
-}
-
-FirstRunViewBase::~FirstRunViewBase() {
- FirstRun::SetShowFirstRunBubblePref(true);
- FirstRun::SetShowWelcomePagePref();
-}
-
-void FirstRunViewBase::SetupControls() {
- using views::Label;
- using views::ImageView;
- using views::Background;
-
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- background_image_ = new views::ImageView();
- background_image_->SetImage(rb.GetBitmapNamed(IDR_WIZARD_ICON));
- background_image_->SetHorizontalAlignment(ImageView::TRAILING);
-
- int color = 0;
- {
- SkAutoLockPixels pixel_loc(background_image_->GetImage());
- uint32_t* pixel = background_image_->GetImage().getAddr32(0, 0);
- color = (0xff & (*pixel));
- }
- Background* bkg = Background::CreateSolidBackground(color, color, color);
-
- // The bitmap we use as the background contains a clipped logo and therefore
- // we can not automatically mirror it for RTL UIs by simply flipping it. This
- // is why we load a different bitmap if the View is using a right-to-left UI
- // layout.
- //
- // Note that we first load the LTR image and then replace it with the RTL
- // image because the code above derives the background color from the LTR
- // image so we have to use the LTR logo initially and then replace it with
- // the RTL logo if we find out that we are running in a right-to-left locale.
- if (base::i18n::IsRTL())
- background_image_->SetImage(rb.GetBitmapNamed(IDR_WIZARD_ICON_RTL));
-
- background_image_->set_background(bkg);
- AddChildView(background_image_);
-
- // The first separator marks the end of the image.
- separator_1_ = new views::Separator;
- AddChildView(separator_1_);
-
- if (BrowserDistribution::GetDistribution()->CanSetAsDefault()) {
- // The "make us default browser" check box.
- default_browser_ = new views::Checkbox(
- l10n_util::GetString(IDS_FR_CUSTOMIZE_DEFAULT_BROWSER));
- default_browser_->SetMultiLine(true);
- AddChildView(default_browser_);
- default_browser_->set_listener(this);
- } else {
- non_default_browser_label_ = new Label(
- l10n_util::GetStringF(IDS_OPTIONS_DEFAULTBROWSER_SXS,
- l10n_util::GetString(IDS_PRODUCT_NAME)));
- non_default_browser_label_->SetMultiLine(true);
- non_default_browser_label_->SetHorizontalAlignment(
- views::Label::ALIGN_LEFT);
- AddChildView(non_default_browser_label_);
- }
-
- // The second separator marks the start of buttons.
- separator_2_ = new views::Separator;
- AddChildView(separator_2_);
-}
-
-void FirstRunViewBase::AdjustDialogWidth(const views::View* sub_view) {
- gfx::Rect sub_view_bounds = sub_view->bounds();
- preferred_width_ =
- std::max(preferred_width_,
- static_cast<int>(sub_view_bounds.right()) + kPanelHorizMargin);
-}
-
-void FirstRunViewBase::SetMinimumDialogWidth(int width) {
- preferred_width_ = std::max(preferred_width_, width);
-}
-
-void FirstRunViewBase::Layout() {
- const int kVertSpacing = 8;
-
- gfx::Size canvas = GetPreferredSize();
-
- gfx::Size pref_size = background_image_->GetPreferredSize();
- background_image_->SetBounds(0, 0, canvas.width(), pref_size.height());
-
- int next_v_space = background_image_->y() +
- background_image_->height() - 2;
-
- pref_size = separator_1_->GetPreferredSize();
- separator_1_->SetBounds(0, next_v_space, canvas.width() + 1,
- pref_size.height());
-
- next_v_space = canvas.height() - kPanelSubVerticalSpacing - 2 * kVertSpacing;
- pref_size = separator_2_->GetPreferredSize();
- separator_2_->SetBounds(kPanelHorizMargin , next_v_space,
- canvas.width() - 2 * kPanelHorizMargin,
- pref_size.height());
-
- next_v_space = separator_2_->y() + separator_2_->height() + kVertSpacing;
-
- int width = canvas.width() - 2 * kPanelHorizMargin;
- if (default_browser_) {
-#if defined(OS_WIN)
- // Add or remove a shield icon before calculating the button width.
- // (If a button has a shield icon, Windows automatically adds the icon width
- // to the button width.)
- views::DialogClientView* client_view = GetDialogClientView();
- if (client_view)
- client_view->ok_button()->SetNeedElevation(default_browser_->checked());
-#endif
-
- int height = default_browser_->GetHeightForWidth(width);
- default_browser_->SetBounds(kPanelHorizMargin, next_v_space, width, height);
- AdjustDialogWidth(default_browser_);
- } else {
- int height = non_default_browser_label_->GetHeightForWidth(width);
- non_default_browser_label_->SetBounds(kPanelHorizMargin, next_v_space,
- width, height);
- AdjustDialogWidth(non_default_browser_label_);
- }
-}
-
-void FirstRunViewBase::ButtonPressed(views::Button* sender,
- const views::Event& event) {
-#if defined(OS_WIN)
- if (default_browser_ && sender == default_browser_) {
- // Update the elevation state of the "start chromium" button so we can add
- // a shield icon when we need elevation.
- views::DialogClientView* client_view = GetDialogClientView();
- client_view->ok_button()->SetNeedElevation(default_browser_->checked());
- }
-#endif
-}
-
-bool FirstRunViewBase::CanResize() const {
- return false;
-}
-
-bool FirstRunViewBase::CanMaximize() const {
- return false;
-}
-
-bool FirstRunViewBase::IsAlwaysOnTop() const {
- return false;
-}
-
-bool FirstRunViewBase::HasAlwaysOnTopMenu() const {
- return false;
-}
-
-std::wstring FirstRunViewBase::GetDialogButtonLabel(
- MessageBoxFlags::DialogButton button) const {
- if (MessageBoxFlags::DIALOGBUTTON_OK == button)
- return search_engine_experiment_ ?
- l10n_util::GetString(IDS_ACCNAME_NEXT) :
- l10n_util::GetString(IDS_FIRSTRUN_DLG_OK);
- // The other buttons get the default text.
- return std::wstring();
-}
-
-int FirstRunViewBase::GetImportItems() 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
- // being we say: TODO(CPU): Bug 1196875
- int items = import_items_;
- if (!(dont_import_items_ & importer::HISTORY))
- items = items | importer::HISTORY;
- if (!(dont_import_items_ & importer::FAVORITES))
- items = items | importer::FAVORITES;
- if (!(dont_import_items_ & importer::PASSWORDS))
- items = items | importer::PASSWORDS;
- if (!(dont_import_items_ & importer::SEARCH_ENGINES))
- items = items | importer::SEARCH_ENGINES;
- if (!homepage_defined_)
- items = items | importer::HOME_PAGE;
- return items;
-};
-
-void FirstRunViewBase::DisableButtons() {
- window()->EnableClose(false);
- views::DialogClientView* dcv = GetDialogClientView();
- dcv->ok_button()->SetEnabled(false);
- dcv->cancel_button()->SetEnabled(false);
- if (default_browser_)
- default_browser_->SetEnabled(false);
-}
-
-bool FirstRunViewBase::CreateDesktopShortcut() {
- return FirstRun::CreateChromeDesktopShortcut();
-}
-
-bool FirstRunViewBase::CreateQuickLaunchShortcut() {
- return FirstRun::CreateChromeQuickLaunchShortcut();
-}
-
-bool FirstRunViewBase::SetDefaultBrowser() {
- UserMetrics::RecordAction(UserMetricsAction("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
deleted file mode 100644
index 9198e22..0000000
--- a/chrome/browser/views/first_run_view_base.h
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright (c) 2010 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_FIRST_RUN_VIEW_BASE_H_
-#define CHROME_BROWSER_VIEWS_FIRST_RUN_VIEW_BASE_H_
-
-#include "chrome/browser/importer/importer.h"
-#include "views/view.h"
-#include "views/window/dialog_delegate.h"
-
-namespace views {
-class Checkbox;
-class Label;
-class Window;
-class ImageView;
-class Separator;
-class Throbber;
-}
-
-class Profile;
-class ImporterHost;
-
-// This class abstracts the code that creates the dialog look for the two
-// first-run dialogs. This amounts to the bitmap, the two separators, the
-// progress throbber and some common resize code.
-class FirstRunViewBase : public views::View,
- public views::ButtonListener,
- public views::DialogDelegate {
- public:
- explicit FirstRunViewBase(Profile* profile, bool homepage_defined,
- int import_items, int dont_import_items,
- bool search_engine_experiment,
- bool randomize_search_engine_experiment);
- virtual ~FirstRunViewBase();
-
- // Overridden from views::View.
- virtual void Layout();
-
- // Overridden from views::WindowDelegate.
- virtual bool CanResize() const;
- virtual bool CanMaximize() const;
- virtual bool IsAlwaysOnTop() const;
- virtual bool HasAlwaysOnTopMenu() const;
-
- // Overridden form views::ButtonListener.
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- // Overridden from views::DialogDelegate.
- std::wstring GetDialogButtonLabel(MessageBoxFlags::DialogButton button) const;
-
- protected:
- // Returns the items that the first run process should import
- // from other browsers. If there are any items that should or should not
- // be imported (read and passed through from master preferences), it will
- // take those into account.
- int GetImportItems() const;
-
- // Creates the desktop and quick launch shortcut. Existing shortcut is lost.
- 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.
- void AdjustDialogWidth(const views::View* sub_view);
-
- // Sets a minimum dialog size.
- void SetMinimumDialogWidth(int width);
-
- // Returns the background image. It is useful for getting the metrics.
- const views::ImageView* background_image() const {
- return background_image_;
- }
- // Returns the computed preferred width of the dialog. This value can change
- // when AdjustDialogWidth() is called during layout.
- int preferred_width() const {
- return preferred_width_;
- }
-
- scoped_refptr<ImporterHost> importer_host_;
- Profile* profile_;
- views::Checkbox* default_browser_;
- views::Label* non_default_browser_label_;
-
- protected:
- bool homepage_defined_;
- int import_items_;
- int dont_import_items_;
- bool search_engine_experiment_;
- bool randomize_search_engine_experiment_;
-
- private:
- // Initializes the controls on the dialog.
- void SetupControls();
- views::ImageView* background_image_;
- views::Separator* separator_1_;
- views::Separator* separator_2_;
- int preferred_width_;
-
- DISALLOW_COPY_AND_ASSIGN(FirstRunViewBase);
-};
-
-#endif // CHROME_BROWSER_VIEWS_FIRST_RUN_VIEW_BASE_H_
diff --git a/chrome/browser/views/keyword_editor_view.cc b/chrome/browser/views/keyword_editor_view.cc
index 666c7d8..e40a704 100644
--- a/chrome/browser/views/keyword_editor_view.cc
+++ b/chrome/browser/views/keyword_editor_view.cc
@@ -137,17 +137,11 @@ int KeywordEditorView::GetDialogButtons() const {
}
bool KeywordEditorView::Accept() {
- if (observer_)
- observer_->SearchEngineChosen(
- profile_->GetTemplateURLModel()->GetDefaultSearchProvider());
open_window = NULL;
return true;
}
bool KeywordEditorView::Cancel() {
- if (observer_)
- observer_->SearchEngineChosen(
- profile_->GetTemplateURLModel()->GetDefaultSearchProvider());
open_window = NULL;
return true;
}