diff options
author | Ben Murdoch <benm@google.com> | 2010-11-18 18:32:45 +0000 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-11-18 18:38:07 +0000 |
commit | 513209b27ff55e2841eac0e4120199c23acce758 (patch) | |
tree | aeba30bb08c5f47c57003544e378a377c297eee6 /chrome/browser/views | |
parent | 164f7496de0fbee436b385a79ead9e3cb81a50c1 (diff) | |
download | external_chromium-513209b27ff55e2841eac0e4120199c23acce758.zip external_chromium-513209b27ff55e2841eac0e4120199c23acce758.tar.gz external_chromium-513209b27ff55e2841eac0e4120199c23acce758.tar.bz2 |
Merge Chromium at r65505: Initial merge by git.
Change-Id: I31d8f1d8cd33caaf7f47ffa7350aef42d5fbdb45
Diffstat (limited to 'chrome/browser/views')
76 files changed, 761 insertions, 794 deletions
diff --git a/chrome/browser/views/about_ipc_dialog.cc b/chrome/browser/views/about_ipc_dialog.cc index a23b122..358e28f 100644 --- a/chrome/browser/views/about_ipc_dialog.cc +++ b/chrome/browser/views/about_ipc_dialog.cc @@ -19,6 +19,7 @@ #include "base/thread.h" #include "base/time.h" #include "base/utf_string_conversions.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/browser_process.h" #include "chrome/common/chrome_constants.h" diff --git a/chrome/browser/views/accelerator_table_gtk.cc b/chrome/browser/views/accelerator_table_gtk.cc index 3baa65e..261420e 100644 --- a/chrome/browser/views/accelerator_table_gtk.cc +++ b/chrome/browser/views/accelerator_table_gtk.cc @@ -6,14 +6,14 @@ #include "app/keyboard_codes.h" #include "base/basictypes.h" -#include "chrome/app/chrome_dll_resource.h" +#include "chrome/app/chrome_command_ids.h" namespace browser { // NOTE: Keep this list in the same (mostly-alphabetical) order as // the Windows accelerators in ../../app/chrome_dll.rc. const AcceleratorMapping kAcceleratorMap[] = { - // Keycode Shift Ctrl Alt Command ID + // Keycode Shift Ctrl Alt Command ID { app::VKEY_A, true, true, false, IDC_AUTOFILL_DEFAULT }, { app::VKEY_LEFT, false, false, true, IDC_BACK }, { app::VKEY_BACK, false, false, false, IDC_BACK }, @@ -81,6 +81,10 @@ const AcceleratorMapping kAcceleratorMap[] = { #if !defined(OS_CHROMEOS) { app::VKEY_F1, false, false, false, IDC_HELP_PAGE }, #endif +#if defined(OS_CHROMEOS) + { app::VKEY_OEM_2, false, true, false, IDC_HELP_PAGE }, + { app::VKEY_OEM_2, true, true, false, IDC_HELP_PAGE }, +#endif { app::VKEY_I, true, true, false, IDC_DEV_TOOLS }, { app::VKEY_J, true, true, false, IDC_DEV_TOOLS_CONSOLE }, { app::VKEY_C, true, true, false, IDC_DEV_TOOLS_INSPECT }, diff --git a/chrome/browser/views/app_launched_animation_win.cc b/chrome/browser/views/app_launched_animation_win.cc index 8a23d43..50efc5d 100644 --- a/chrome/browser/views/app_launched_animation_win.cc +++ b/chrome/browser/views/app_launched_animation_win.cc @@ -38,7 +38,7 @@ class AppLaunchedAnimationWin : public AnimationDelegate, public ImageLoadingTracker::Observer, public views::ImageView { public: - AppLaunchedAnimationWin(Extension* extension, const gfx::Rect& rect); + AppLaunchedAnimationWin(const Extension* extension, const gfx::Rect& rect); private: // AnimationDelegate @@ -65,7 +65,7 @@ class AppLaunchedAnimationWin : public AnimationDelegate, DISALLOW_COPY_AND_ASSIGN(AppLaunchedAnimationWin); }; -AppLaunchedAnimationWin::AppLaunchedAnimationWin(Extension* extension, +AppLaunchedAnimationWin::AppLaunchedAnimationWin(const Extension* extension, const gfx::Rect& rect) : popup_(NULL), rect_(rect), @@ -128,7 +128,8 @@ void AppLaunchedAnimationWin::OnImageLoaded(SkBitmap* image, } // namespace // static -void AppLaunchedAnimation::Show(Extension* extension, const gfx::Rect& rect) { +void AppLaunchedAnimation::Show(const Extension* extension, + const gfx::Rect& rect) { // The animation will delete itself when it's finished. new AppLaunchedAnimationWin(extension, rect); } diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc index 807ee00..bfd7321 100644 --- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc +++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc @@ -13,6 +13,7 @@ #include "base/i18n/rtl.h" #include "base/utf_string_conversions.h" #include "chrome/browser/autocomplete/autocomplete_edit_view.h" +#include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/autocomplete/autocomplete_popup_model.h" #include "chrome/browser/instant/instant_opt_in.h" #include "chrome/browser/views/bubble_border.h" diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h index 2924ce2..9a3e2bc 100644 --- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h +++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h @@ -22,6 +22,7 @@ class AutocompleteEditModel; class AutocompleteEditViewWin; +struct AutocompleteMatch; class BubbleBorder; class Profile; diff --git a/chrome/browser/views/autofill_profiles_view_win.cc b/chrome/browser/views/autofill_profiles_view_win.cc index 5c991f8..414e0ba 100644 --- a/chrome/browser/views/autofill_profiles_view_win.cc +++ b/chrome/browser/views/autofill_profiles_view_win.cc @@ -56,28 +56,6 @@ const int kDialogPadding = 7; const int kSubViewHorizotalInsets = 18; const int kSubViewVerticalInsets = 5; -// This is a helper to compare items that were just created with items returned -// from the db. -// ProfileType could be either AutofillProfile or CreditCard. -// The second argument could have an incomplete ID (0) - change it to first -// argument's id for comparison and then change it back. -template<class ProfileType> bool IsEqualDataWithIncompleteId( - ProfileType const * data_to_compare, ProfileType* data_with_incomplete_id) { - if (!data_with_incomplete_id->unique_id()) { - bool label_unset = data_with_incomplete_id->Label().empty(); - if (label_unset) - data_with_incomplete_id->set_label(data_to_compare->Label()); - data_with_incomplete_id->set_unique_id(data_to_compare->unique_id()); - bool are_equal = (*data_to_compare == *data_with_incomplete_id); - data_with_incomplete_id->set_unique_id(0); - if (label_unset) - data_with_incomplete_id->set_label(string16()); - return are_equal; - } else { - return (*data_to_compare == *data_with_incomplete_id); - } -} - }; // namespace ///////////////////////////////////////////////////////////////////////////// @@ -104,7 +82,6 @@ AutoFillProfilesView::AutoFillProfilesView( remove_button_(NULL), scroll_view_(NULL), focus_manager_(NULL), - billing_model_(true), child_dialog_opened_(false) { DCHECK(preferences_); enable_auto_fill_.Init(prefs::kAutoFillEnabled, preferences_, this); @@ -156,16 +133,16 @@ void AutoFillProfilesView::AddClicked(int group_type) { std::vector<EditableSetInfo>::iterator it = profiles_set_.end(); int added_item_index = -1; if (group_type == ContentListTableModel::kAddressGroup) { - AutoFillProfile address(std::wstring(), 0); + AutoFillProfile address; info.reset(new EditableSetInfo(&address)); } else if (group_type == ContentListTableModel::kCreditCardGroup) { - CreditCard credit_card(std::wstring(), 0); + CreditCard credit_card; info.reset(new EditableSetInfo(&credit_card)); } else { NOTREACHED(); } EditableSetViewContents *edit_view = new - EditableSetViewContents(this, &billing_model_, true, *info); + EditableSetViewContents(this, true, *info); views::Window::CreateChromeWindow(window()->GetNativeWindow(), gfx::Rect(), edit_view); edit_view->window()->Show(); @@ -185,7 +162,7 @@ void AutoFillProfilesView::EditClicked() { it = credit_card_set_.begin() + (index - profiles_set_.size()); EditableSetViewContents *edit_view = new - EditableSetViewContents(this, &billing_model_, false, *it); + EditableSetViewContents(this, false, *it); views::Window::CreateChromeWindow(window()->GetNativeWindow(), gfx::Rect(), edit_view); edit_view->window()->Show(); @@ -203,7 +180,6 @@ void AutoFillProfilesView::DeleteClicked() { last_view_row = table_model_->RowCount() - 1; if (last_view_row >= 0) scroll_view_->Select(scroll_view_->ViewToModel(last_view_row)); - UpdateBillingModel(); UpdateWidgetState(); SaveData(); } @@ -216,18 +192,16 @@ void AutoFillProfilesView::EditAccepted(EditableSetInfo* data, std::vector<EditableSetInfo>::iterator end_it; end_it = data->is_address ? profiles_set_.end() : credit_card_set_.end(); for (; it != end_it; ++it) { - if (it->unique_id() == data->unique_id()) { + if (it->guid() == data->guid()) { *it = *data; break; } if (new_item) { if (data->is_address) { - if (IsEqualDataWithIncompleteId<AutoFillProfile>(&it->address, - &data->address)) + if (it->address.Compare(data->address) == 0) break; } else { - if (IsEqualDataWithIncompleteId<CreditCard>(&it->credit_card, - &data->credit_card)) + if (it->credit_card.Compare(data->credit_card) == 0) break; } } @@ -238,7 +212,6 @@ void AutoFillProfilesView::EditAccepted(EditableSetInfo* data, else credit_card_set_.push_back(*data); } - UpdateBillingModel(); UpdateWidgetState(); SaveData(); } @@ -261,19 +234,6 @@ void AutoFillProfilesView::UpdateWidgetState() { autofill_enabled); } -void AutoFillProfilesView::UpdateProfileLabels() { - std::vector<AutoFillProfile*> profiles; - profiles.resize(profiles_set_.size()); - for (size_t i = 0; i < profiles_set_.size(); ++i) { - profiles[i] = &(profiles_set_[i].address); - } - AutoFillProfile::AdjustInferredLabels(&profiles); -} - -void AutoFillProfilesView::UpdateBillingModel() { - billing_model_.SetAddressLabels(profiles_set_); -} - void AutoFillProfilesView::ChildWindowOpened() { child_dialog_opened_ = true; UpdateWidgetState(); @@ -453,7 +413,6 @@ void AutoFillProfilesView::OnPersonalDataChanged() { ++address_it) { profiles_set_.push_back(EditableSetInfo(*address_it)); } - UpdateProfileLabels(); credit_card_set_.clear(); for (std::vector<CreditCard*>::const_iterator cc_it = @@ -492,8 +451,6 @@ void AutoFillProfilesView::Init() { l10n_util::GetString(IDS_OPTIONS_AUTOFILL_ENABLE)); enable_auto_fill_button_->set_listener(this); - billing_model_.SetAddressLabels(profiles_set_); - table_model_.reset(new ContentListTableModel(&profiles_set_, &credit_card_set_)); std::vector<TableColumn> columns; @@ -572,7 +529,6 @@ void AutoFillProfilesView::GetData() { profiles_set_.push_back(EditableSetInfo(*address_it)); } } - UpdateProfileLabels(); if (!imported_data_present) { credit_card_set_.reserve(personal_data_manager_->credit_cards().size()); @@ -732,14 +688,11 @@ AutoFillProfilesView::EditableSetViewContents::TextFieldToAutoFill // AutoFillProfilesView::EditableSetViewContents, public: AutoFillProfilesView::EditableSetViewContents::EditableSetViewContents( AutoFillProfilesView* observer, - AddressComboBoxModel* billing_model, bool new_item, const EditableSetInfo& field_set) : temporary_info_(field_set), has_credit_card_number_been_edited_(false), observer_(observer), - billing_model_(billing_model), - combo_box_billing_(NULL), new_item_(new_item) { ZeroMemory(text_fields_, sizeof(text_fields_)); } @@ -863,7 +816,6 @@ AutoFillProfilesView::EditableSetViewContents::GetWindowTitle() const { } void AutoFillProfilesView::EditableSetViewContents::WindowClosing() { - billing_model_->ClearComboBoxes(); observer_->ChildWindowClosed(); } @@ -876,7 +828,6 @@ bool AutoFillProfilesView::EditableSetViewContents::Cancel() { // Remove added item - it is last in the list. if (temporary_info_.is_address) { observer_->profiles_set_.pop_back(); - observer_->UpdateBillingModel(); } else { observer_->credit_card_set_.pop_back(); } @@ -946,16 +897,7 @@ bool AutoFillProfilesView::EditableSetViewContents::HandleKeystroke( // views::Combobox::Listener implementations: void AutoFillProfilesView::EditableSetViewContents::ItemChanged( views::Combobox* combo_box, int prev_index, int new_index) { - DCHECK(billing_model_); - if (combo_box == combo_box_billing_) { - if (new_index == -1) { - NOTREACHED(); - } else { - DCHECK(new_index < static_cast<int>(observer_->profiles_set_.size())); - temporary_info_.credit_card.set_billing_address_id( - observer_->profiles_set_[new_index].address.unique_id()); - } - } else if (combo_box == combo_box_month_) { + if (combo_box == combo_box_month_) { if (new_index == -1) { NOTREACHED(); } else { @@ -1078,7 +1020,6 @@ void AutoFillProfilesView::EditableSetViewContents::InitAddressFields( void AutoFillProfilesView::EditableSetViewContents::InitCreditCardFields( views::GridLayout* layout) { DCHECK(!temporary_info_.is_address); - DCHECK(billing_model_); // Create combo box models. combo_box_model_month_.reset(new StringVectorComboboxModel); @@ -1120,20 +1061,6 @@ void AutoFillProfilesView::EditableSetViewContents::InitCreditCardFields( layout->StartRow(0, double_column_fill_view_set_id_); layout->AddView(text_fields_[TEXT_CC_NAME]); - // Address combo boxes. - combo_box_billing_ = new views::Combobox(billing_model_); - combo_box_billing_->set_listener(this); - int billing_id = temporary_info_.credit_card.billing_address_id(); - if (billing_id) - combo_box_billing_->SetSelectedItem(billing_model_->GetIndex(billing_id)); - billing_model_->UsedWithComboBox(combo_box_billing_); - - layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); - layout->StartRow(0, double_column_fill_view_set_id_); - layout->AddView(CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_BILLING_ADDRESS)); - layout->StartRow(0, double_column_fill_view_set_id_); - layout->AddView(combo_box_billing_); - // Layout credit card info layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); layout->StartRow(0, double_column_ccnumber_cvc_); @@ -1288,78 +1215,6 @@ bool AutoFillProfilesView::EditableSetViewContents::UpdateContentsPhoneViews( return false; } -///////////////////////////////////////////////////////////////////////////// -// AutoFillProfilesView::AddressComboBoxModel, public: -AutoFillProfilesView::AddressComboBoxModel::AddressComboBoxModel( - bool is_billing) - : is_billing_(is_billing) { -} - -void AutoFillProfilesView::AddressComboBoxModel::SetAddressLabels( - const std::vector<EditableSetInfo>& address_labels) { - address_labels_.clear(); - for (size_t i = 0; i < address_labels.size(); ++i) { - const EditableSetInfo& item = address_labels[i]; - DCHECK(item.is_address); - FieldTypeSet fields; - item.address.GetAvailableFieldTypes(&fields); - if (fields.find(ADDRESS_HOME_LINE1) == fields.end() && - fields.find(ADDRESS_HOME_LINE2) == fields.end() && - fields.find(ADDRESS_HOME_APT_NUM) == fields.end() && - fields.find(ADDRESS_HOME_CITY) == fields.end() && - fields.find(ADDRESS_HOME_STATE) == fields.end() && - fields.find(ADDRESS_HOME_ZIP) == fields.end() && - fields.find(ADDRESS_HOME_COUNTRY) == fields.end()) { - // No address information in this profile; it's useless as a billing - // address. - continue; - } - address_labels_.push_back(item); - } - NotifyChanged(); -} - -void AutoFillProfilesView::AddressComboBoxModel::UsedWithComboBox( - views::Combobox* combo_box) { - combo_boxes_.push_back(combo_box); -} - -void AutoFillProfilesView::AddressComboBoxModel::NotifyChanged() { - for (std::list<views::Combobox*>::iterator it = combo_boxes_.begin(); - it != combo_boxes_.end(); - ++it) - (*it)->ModelChanged(); -} - -int AutoFillProfilesView::AddressComboBoxModel::GetIndex(int unique_id) { - int shift = is_billing_ ? 0 : 1; - for (size_t i = 0; i < address_labels_.size(); ++i) { - if (address_labels_.at(i).address.unique_id() == unique_id) - return i + shift; - } - return -1; -} - -///////////////////////////////////////////////////////////////////////////// -// AutoFillProfilesView::AddressComboBoxModel, ComboboxModel methods -int AutoFillProfilesView::AddressComboBoxModel::GetItemCount() { - int shift = is_billing_ ? 0 : 1; - return static_cast<int>(address_labels_.size()) + shift; -} - -string16 AutoFillProfilesView::AddressComboBoxModel::GetItemAt(int index) { - int shift = is_billing_ ? 0 : 1; - DCHECK(index < (static_cast<int>(address_labels_.size()) + shift)); - if (!is_billing_ && !index) - return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAME_AS_BILLING); - DCHECK(address_labels_.at(index - shift).is_address); - string16 label = - WideToUTF16Hack(address_labels_.at(index - shift).address.Label()); - if (label.empty()) - label = l10n_util::GetStringUTF16(IDS_AUTOFILL_NEW_ADDRESS); - return label; -} - void AutoFillProfilesView::StringVectorComboboxModel::set_cb_strings( std::vector<std::wstring> *source) { cb_strings_.swap(*source); @@ -1423,7 +1278,7 @@ std::wstring AutoFillProfilesView::ContentListTableModel::GetText( int row, int column_id) { DCHECK(row < static_cast<int>(profiles_->size() + credit_cards_->size())); if (row < static_cast<int>(profiles_->size())) { - return profiles_->at(row).address.PreviewSummary(); + return profiles_->at(row).address.Label(); } else { row -= profiles_->size(); return credit_cards_->at(row).credit_card.PreviewSummary(); diff --git a/chrome/browser/views/autofill_profiles_view_win.h b/chrome/browser/views/autofill_profiles_view_win.h index dc0f051..efeaf59 100644 --- a/chrome/browser/views/autofill_profiles_view_win.h +++ b/chrome/browser/views/autofill_profiles_view_win.h @@ -89,13 +89,6 @@ class AutoFillProfilesView : public views::View, // Updates state of the buttons. void UpdateWidgetState(); - // Updates inferred labels. - void UpdateProfileLabels(); - - // Updates the billing model. This is invoked any time the profile_set_ - // changes. - void UpdateBillingModel(); - // Following two functions are called from opened child dialog to // disable/enable buttons. void ChildWindowOpened(); @@ -173,11 +166,11 @@ class AutoFillProfilesView : public views::View, is_address(false) { } - int unique_id() const { + std::string guid() const { if (is_address) - return address.unique_id(); + return address.guid(); else - return credit_card.unique_id(); + return credit_card.guid(); } }; @@ -249,7 +242,6 @@ class AutoFillProfilesView : public views::View, }; // Forward declaration. - class AddressComboBoxModel; class StringVectorComboboxModel; // Sub-view for editing/adding a credit card or address. @@ -260,7 +252,6 @@ class AutoFillProfilesView : public views::View, public views::Combobox::Listener { public: EditableSetViewContents(AutoFillProfilesView* observer, - AddressComboBoxModel* billing_model, bool new_item, const EditableSetInfo& field_set); virtual ~EditableSetViewContents() {} @@ -339,8 +330,6 @@ class AutoFillProfilesView : public views::View, EditableSetInfo temporary_info_; bool has_credit_card_number_been_edited_; AutoFillProfilesView* observer_; - AddressComboBoxModel* billing_model_; - views::Combobox* combo_box_billing_; scoped_ptr<StringVectorComboboxModel> combo_box_model_month_; views::Combobox* combo_box_month_; scoped_ptr<StringVectorComboboxModel> combo_box_model_year_; @@ -368,43 +357,6 @@ class AutoFillProfilesView : public views::View, DISALLOW_COPY_AND_ASSIGN(EditableSetViewContents); }; - // Encapsulates ComboboxModel for address. - class AddressComboBoxModel : public ComboboxModel { - public: - explicit AddressComboBoxModel(bool is_billing); - virtual ~AddressComboBoxModel() {} - - // Updates address_labels_ from |address_labels|. - void SetAddressLabels(const std::vector<EditableSetInfo>& address_labels); - - // When you add a CB view that relies on this model, call this function - // so the CB can be notified if strings change. Can be called multiple - // times if several combo boxes relying on the model. - // Model does not own |combo_box|. - void UsedWithComboBox(views::Combobox *combo_box); - - // Need to be called when comboboxes are destroyed. - void ClearComboBoxes() { combo_boxes_.clear(); } - - // Call this function if one of the labels has changed - void NotifyChanged(); - - // Gets index of the item in the model or -1 if not found. - int GetIndex(int unique_id); - - // Overridden from ComboboxModel: - // Public as they are used from EditableSetViewContents. - virtual int GetItemCount(); - virtual string16 GetItemAt(int index); - - private: - std::list<views::Combobox*> combo_boxes_; - std::vector<EditableSetInfo> address_labels_; - bool is_billing_; - - DISALLOW_COPY_AND_ASSIGN(AddressComboBoxModel); - }; - class StringVectorComboboxModel : public ComboboxModel { public: StringVectorComboboxModel() {} @@ -468,8 +420,6 @@ class AutoFillProfilesView : public views::View, std::vector<EditableSetInfo> profiles_set_; std::vector<EditableSetInfo> credit_card_set_; - AddressComboBoxModel billing_model_; - BooleanPrefMember enable_auto_fill_; views::Checkbox* enable_auto_fill_button_; diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc index 8ce71e7..9188aa5 100644 --- a/chrome/browser/views/bookmark_bar_view.cc +++ b/chrome/browser/views/bookmark_bar_view.cc @@ -160,10 +160,9 @@ static std::wstring CreateToolTipForURLAndTitle(const gfx::Point& screen_loc, // "/http://www.yahoo.com" when rendered, as is, in an RTL context since // the Unicode BiDi algorithm puts certain characters on the left by // default. - std::wstring elided_url(gfx::ElideUrl(url, tt_font, max_width, languages)); - elided_url = UTF16ToWide(base::i18n::GetDisplayStringInLTRDirectionality( - WideToUTF16(elided_url))); - result.append(elided_url); + string16 elided_url(gfx::ElideUrl(url, tt_font, max_width, languages)); + elided_url = base::i18n::GetDisplayStringInLTRDirectionality(elided_url); + result.append(UTF16ToWideHack(elided_url)); } return result; } @@ -448,11 +447,13 @@ void BookmarkBarView::SetProfile(Profile* profile) { delete GetChildViewAt(0); model_ = profile_->GetBookmarkModel(); - model_->AddObserver(this); - if (model_->IsLoaded()) - Loaded(model_); - // else case: we'll receive notification back from the BookmarkModel when done - // loading, then we'll populate the bar. + if (model_) { + model_->AddObserver(this); + if (model_->IsLoaded()) + Loaded(model_); + // else case: we'll receive notification back from the BookmarkModel when + // done loading, then we'll populate the bar. + } } void BookmarkBarView::SetPageNavigator(PageNavigator* navigator) { diff --git a/chrome/browser/views/bookmark_bar_view_test.cc b/chrome/browser/views/bookmark_bar_view_test.cc index 06e1242..d30d0e4 100644 --- a/chrome/browser/views/bookmark_bar_view_test.cc +++ b/chrome/browser/views/bookmark_bar_view_test.cc @@ -53,6 +53,13 @@ #endif +#if defined(OS_LINUX) +// See bug http://crbug.com/60444 for details. +#define MAYBE_ScrollButtonScrolls DISABLED_ScrollButtonScrolls +#else +#define MAYBE_ScrollButtonScrolls ScrollButtonScrolls +#endif + namespace { class ViewsDelegateImpl : public views::ViewsDelegate { @@ -849,7 +856,7 @@ class BookmarkBarViewTest9 : public BookmarkBarViewEventTestBase { views::MenuItemView* first_menu_; }; -VIEW_TEST(BookmarkBarViewTest9, ScrollButtonScrolls) +VIEW_TEST(BookmarkBarViewTest9, MAYBE_ScrollButtonScrolls) // Tests up/down/left/enter key messages. class BookmarkBarViewTest10 : public BookmarkBarViewEventTestBase { diff --git a/chrome/browser/views/bookmark_bubble_view.cc b/chrome/browser/views/bookmark_bubble_view.cc index c13f53f..a1f651b 100644 --- a/chrome/browser/views/bookmark_bubble_view.cc +++ b/chrome/browser/views/bookmark_bubble_view.cc @@ -9,7 +9,7 @@ #include "app/resource_bundle.h" #include "base/string16.h" #include "base/string_util.h" -#include "chrome/app/chrome_dll_resource.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/browser/bookmarks/bookmark_editor.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_utils.h" @@ -88,9 +88,9 @@ void BookmarkBubbleView::Show(views::Window* parent, return; bubble_ = new BookmarkBubbleView(delegate, profile, url, newly_bookmarked); - InfoBubble* info_bubble = - InfoBubble::Show(parent->GetClientView()->GetWidget(), bounds, - BubbleBorder::TOP_RIGHT, bubble_, bubble_); + InfoBubble* info_bubble = InfoBubble::Show( + parent->GetClientView()->GetWidget(), bounds, BubbleBorder::TOP_RIGHT, + bubble_, bubble_); bubble_->set_info_bubble(info_bubble); GURL url_ptr(url); NotificationService::current()->Notify( diff --git a/chrome/browser/views/browser_actions_container.cc b/chrome/browser/views/browser_actions_container.cc index d2db56c..b630806 100644 --- a/chrome/browser/views/browser_actions_container.cc +++ b/chrome/browser/views/browser_actions_container.cc @@ -58,7 +58,7 @@ bool BrowserActionsContainer::disable_animations_during_testing_ = false; //////////////////////////////////////////////////////////////////////////////// // BrowserActionButton -BrowserActionButton::BrowserActionButton(Extension* extension, +BrowserActionButton::BrowserActionButton(const Extension* extension, BrowserActionsContainer* panel) : ALLOW_THIS_IN_INITIALIZER_LIST( MenuButton(this, std::wstring(), NULL, false)), @@ -281,7 +281,7 @@ BrowserActionButton::~BrowserActionButton() { //////////////////////////////////////////////////////////////////////////////// // BrowserActionView -BrowserActionView::BrowserActionView(Extension* extension, +BrowserActionView::BrowserActionView(const Extension* extension, BrowserActionsContainer* panel) : panel_(panel) { button_ = new BrowserActionButton(extension, panel); @@ -838,7 +838,7 @@ void BrowserActionsContainer::MoveBrowserAction(const std::string& extension_id, size_t new_index) { ExtensionsService* service = profile_->GetExtensionsService(); if (service) { - Extension* extension = service->GetExtensionById(extension_id, false); + const Extension* extension = service->GetExtensionById(extension_id, false); model_->MoveBrowserAction(extension, new_index); SchedulePaint(); } @@ -886,7 +886,7 @@ int BrowserActionsContainer::IconHeight() { return icon_height; } -void BrowserActionsContainer::BrowserActionAdded(Extension* extension, +void BrowserActionsContainer::BrowserActionAdded(const Extension* extension, int index) { #if defined(DEBUG) for (size_t i = 0; i < browser_action_views_.size(); ++i) { @@ -915,7 +915,8 @@ void BrowserActionsContainer::BrowserActionAdded(Extension* extension, // Enlarge the container if it was already at maximum size and we're not in // the middle of upgrading. - if ((model_->GetVisibleIconCount() < 0) && !extension->being_upgraded()) { + if ((model_->GetVisibleIconCount() < 0) && + !profile_->GetExtensionsService()->IsBeingUpgraded(extension)) { suppress_chevron_ = true; SaveDesiredSizeAndAnimate(Tween::LINEAR, visible_actions + 1); } else { @@ -924,7 +925,7 @@ void BrowserActionsContainer::BrowserActionAdded(Extension* extension, } } -void BrowserActionsContainer::BrowserActionRemoved(Extension* extension) { +void BrowserActionsContainer::BrowserActionRemoved(const Extension* extension) { CloseOverflowMenu(); if (popup_ && popup_->host()->extension() == extension) @@ -940,7 +941,7 @@ void BrowserActionsContainer::BrowserActionRemoved(Extension* extension) { // If the extension is being upgraded we don't want the bar to shrink // because the icon is just going to get re-added to the same location. - if (extension->being_upgraded()) + if (profile_->GetExtensionsService()->IsBeingUpgraded(extension)) return; if (browser_action_views_.size() > visible_actions) { @@ -961,7 +962,7 @@ void BrowserActionsContainer::BrowserActionRemoved(Extension* extension) { } } -void BrowserActionsContainer::BrowserActionMoved(Extension* extension, +void BrowserActionsContainer::BrowserActionMoved(const Extension* extension, int index) { if (!ShouldDisplayBrowserAction(extension)) return; @@ -1091,7 +1092,8 @@ void BrowserActionsContainer::SaveDesiredSizeAndAnimate( } } -bool BrowserActionsContainer::ShouldDisplayBrowserAction(Extension* extension) { +bool BrowserActionsContainer::ShouldDisplayBrowserAction( + const Extension* extension) { // Only display incognito-enabled extensions while in incognito mode. return (!profile_->IsOffTheRecord() || profile_->GetExtensionsService()->IsIncognitoEnabled(extension)); diff --git a/chrome/browser/views/browser_actions_container.h b/chrome/browser/views/browser_actions_container.h index cd376f7..0bc5fdd 100644 --- a/chrome/browser/views/browser_actions_container.h +++ b/chrome/browser/views/browser_actions_container.h @@ -54,13 +54,14 @@ class BrowserActionButton : public views::MenuButton, public ImageLoadingTracker::Observer, public NotificationObserver { public: - BrowserActionButton(Extension* extension, BrowserActionsContainer* panel); + BrowserActionButton(const Extension* extension, + BrowserActionsContainer* panel); // Call this instead of delete. void Destroy(); ExtensionAction* browser_action() const { return browser_action_; } - Extension* extension() { return extension_; } + const Extension* extension() { return extension_; } // Called to update the display to match the browser action's state. void UpdateState(); @@ -112,7 +113,7 @@ class BrowserActionButton : public views::MenuButton, ExtensionAction* browser_action_; // The extension associated with the browser action we're displaying. - Extension* extension_; + const Extension* extension_; // The object that is waiting for the image loading to complete // asynchronously. @@ -146,7 +147,7 @@ class BrowserActionButton : public views::MenuButton, class BrowserActionView : public views::View { public: - BrowserActionView(Extension* extension, BrowserActionsContainer* panel); + BrowserActionView(const Extension* extension, BrowserActionsContainer* panel); virtual ~BrowserActionView(); BrowserActionButton* button() { return button_; } @@ -391,9 +392,9 @@ class BrowserActionsContainer static int IconHeight(); // ExtensionToolbarModel::Observer implementation. - virtual void BrowserActionAdded(Extension* extension, int index); - virtual void BrowserActionRemoved(Extension* extension); - virtual void BrowserActionMoved(Extension* extension, int index); + virtual void BrowserActionAdded(const Extension* extension, int index); + virtual void BrowserActionRemoved(const Extension* extension); + virtual void BrowserActionMoved(const Extension* extension, int index); virtual void ModelLoaded(); void LoadImages(); @@ -441,7 +442,7 @@ class BrowserActionsContainer // Returns true if this extension should be shown in this toolbar. This can // return false if we are in an incognito window and the extension is disabled // for incognito. - bool ShouldDisplayBrowserAction(Extension* extension); + bool ShouldDisplayBrowserAction(const Extension* extension); // The vector of browser actions (icons/image buttons for each action). Note // that not every BrowserAction in the ToolbarModel will necessarily be in diff --git a/chrome/browser/views/browser_actions_container_browsertest.cc b/chrome/browser/views/browser_actions_container_browsertest.cc index 664b510..ee30ddb 100644 --- a/chrome/browser/views/browser_actions_container_browsertest.cc +++ b/chrome/browser/views/browser_actions_container_browsertest.cc @@ -172,7 +172,7 @@ IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest, TestCrash57536) { .AppendASCII("browser_action") .AppendASCII("crash_57536"))); - Extension* extension = service->extensions()->at(size_before); + const Extension* extension = service->extensions()->at(size_before); std::cout << "Creating bitmap\n" << std::flush; diff --git a/chrome/browser/views/clear_server_data.cc b/chrome/browser/views/clear_server_data.cc index d01daf6..2cd3be7 100644 --- a/chrome/browser/views/clear_server_data.cc +++ b/chrome/browser/views/clear_server_data.cc @@ -250,9 +250,7 @@ void ClearServerDataView::LinkActivated(views::Link* source, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); browser->window()->Show(); } else { - browser->OpenURL(GURL(l10n_util::GetStringUTF8(IDS_PRIVACY_DASHBOARD_URL)), - GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); - browser->window()->Show(); + browser->OpenPrivacyDashboardTabAndActivate(); } } diff --git a/chrome/browser/views/constrained_html_delegate_win.cc b/chrome/browser/views/constrained_html_delegate_win.cc new file mode 100644 index 0000000..6d53e22 --- /dev/null +++ b/chrome/browser/views/constrained_html_delegate_win.cc @@ -0,0 +1,113 @@ +// 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/dom_ui/constrained_html_ui.h" + +#include "chrome/browser/dom_ui/html_dialog_tab_contents_delegate.h" +#include "chrome/browser/dom_ui/html_dialog_ui.h" +#include "chrome/browser/profile.h" +#include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/views/tab_contents/tab_contents_container.h" +#include "gfx/rect.h" +#include "ipc/ipc_message.h" +#include "views/view.h" +#include "views/widget/widget_win.h" +#include "views/window/window_delegate.h" + +class ConstrainedHtmlDelegateWin : public TabContentsContainer, + public ConstrainedHtmlUIDelegate, + public ConstrainedWindowDelegate, + public HtmlDialogTabContentsDelegate { + public: + ConstrainedHtmlDelegateWin(Profile* profile, + HtmlDialogUIDelegate* delegate); + ~ConstrainedHtmlDelegateWin(); + + // ConstrainedHtmlUIDelegate interface. + virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate(); + virtual void OnDialogClose(); + + // ConstrainedWindowDelegate (aka views::WindowDelegate) interface. + virtual bool CanResize() const { return true; } + virtual views::View* GetContentsView() { + return this; + } + virtual void WindowClosing() { + html_delegate_->OnDialogClosed(""); + } + + // HtmlDialogTabContentsDelegate interface. + void MoveContents(TabContents* source, const gfx::Rect& pos) {} + void ToolbarSizeChanged(TabContents* source, bool is_animating) {} + void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {} + + // Overridden from TabContentsContainer. + virtual gfx::Size GetPreferredSize() { + gfx::Size size; + html_delegate_->GetDialogSize(&size); + return size; + } + + virtual void ViewHierarchyChanged(bool is_add, + views::View* parent, + views::View* child) { + TabContentsContainer::ViewHierarchyChanged(is_add, parent, child); + if (is_add && child == this) { + ChangeTabContents(&html_tab_contents_); + } + } + + void set_window(ConstrainedWindow* window) { + window_ = window; + } + +private: + TabContents html_tab_contents_; + + HtmlDialogUIDelegate* html_delegate_; + + // The constrained window that owns |this|. Saved so we can close it later. + ConstrainedWindow* window_; +}; + +ConstrainedHtmlDelegateWin::ConstrainedHtmlDelegateWin( + Profile* profile, + HtmlDialogUIDelegate* delegate) + : HtmlDialogTabContentsDelegate(profile), + html_tab_contents_(profile, NULL, MSG_ROUTING_NONE, NULL, NULL), + html_delegate_(delegate), + window_(NULL) { + CHECK(delegate); + html_tab_contents_.set_delegate(this); + + // Set |this| as a property so the ConstrainedHtmlUI can retrieve it. + ConstrainedHtmlUI::GetPropertyAccessor().SetProperty( + html_tab_contents_.property_bag(), this); + html_tab_contents_.controller().LoadURL(delegate->GetDialogContentURL(), + GURL(), + PageTransition::START_PAGE); +} + +ConstrainedHtmlDelegateWin::~ConstrainedHtmlDelegateWin() { +} + +HtmlDialogUIDelegate* ConstrainedHtmlDelegateWin::GetHtmlDialogUIDelegate() { + return html_delegate_; +} + +void ConstrainedHtmlDelegateWin::OnDialogClose() { + window_->CloseConstrainedWindow(); +} + +// static +void ConstrainedHtmlUI::CreateConstrainedHtmlDialog( + Profile* profile, + HtmlDialogUIDelegate* delegate, + TabContents* container) { + ConstrainedHtmlDelegateWin* constrained_delegate = + new ConstrainedHtmlDelegateWin(profile, delegate); + ConstrainedWindow* constrained_window = + container->CreateConstrainedDialog(constrained_delegate); + constrained_delegate->set_window(constrained_window); +} diff --git a/chrome/browser/views/constrained_html_dialog_browsertest.cc b/chrome/browser/views/constrained_html_dialog_browsertest.cc deleted file mode 100644 index c868fb8..0000000 --- a/chrome/browser/views/constrained_html_dialog_browsertest.cc +++ /dev/null @@ -1,93 +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. - -#if defined(OS_WIN) - -#include "chrome/test/ui/ui_test.h" - -#include "base/file_path.h" -#include "base/message_loop.h" -#include "chrome/browser/browser_thread.h" -#include "chrome/browser/dom_ui/constrained_html_dialog.h" -#include "chrome/browser/renderer_host/render_widget_host_view.h" -#include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/browser/views/constrained_html_dialog_win.h" -#include "chrome/browser/views/html_dialog_view.h" -#include "chrome/common/url_constants.h" -#include "chrome/test/in_process_browser_test.h" -#include "chrome/test/ui_test_utils.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "views/widget/widget.h" -#include "views/window/window.h" - -using testing::Eq; - -namespace { - -// Window non-client-area means that the minimum size for the window -// won't be the actual minimum size - our layout and resizing code -// makes sure the chrome is always visible. -const int kMinimumWidthToTestFor = 20; -const int kMinimumHeightToTestFor = 30; - -class TestHtmlDialogUIDelegate : public HtmlDialogUIDelegate { - public: - TestHtmlDialogUIDelegate() {} - virtual ~TestHtmlDialogUIDelegate() {} - - // HTMLDialogUIDelegate implementation: - virtual bool IsDialogModal() const { - return true; - } - virtual std::wstring GetDialogTitle() const { - return std::wstring(L"Test"); - } - virtual GURL GetDialogContentURL() const { - return GURL(chrome::kAboutAboutURL); - } - virtual void GetDOMMessageHandlers( - std::vector<DOMMessageHandler*>* handlers) const {} - virtual void GetDialogSize(gfx::Size* size) const { - size->set_width(400); - size->set_height(400); - } - virtual std::string GetDialogArgs() const { - return std::string(); - } - virtual void OnDialogClosed(const std::string& json_retval) { } - virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) { - if (out_close_dialog) - *out_close_dialog = true; - } -}; - -} // namespace - -class ConstrainedHtmlDialogBrowserTest : public InProcessBrowserTest { - public: - ConstrainedHtmlDialogBrowserTest() {} -}; - -IN_PROC_BROWSER_TEST_F(ConstrainedHtmlDialogBrowserTest, LoadWindow) { - HtmlDialogUIDelegate* delegate = new TestHtmlDialogUIDelegate(); - - ConstrainedHtmlDialogWin* dialog = - new ConstrainedHtmlDialogWin(browser()->profile(), delegate); - - TabContents* tab_contents = browser()->GetSelectedTabContents(); - ASSERT_TRUE(tab_contents != NULL); - ConstrainedWindow* window = tab_contents->CreateConstrainedDialog( - dialog->GetConstrainedWindowDelegate()); - - EXPECT_EQ(1, tab_contents->constrained_window_count()); - - gfx::Rect bounds = dialog->GetContentsView()->bounds(); - EXPECT_LT(0, bounds.width()); - EXPECT_LT(0, bounds.height()); - EXPECT_GE(400, bounds.width()); - EXPECT_GE(400, bounds.height()); -} - -#endif // OS_WIN diff --git a/chrome/browser/views/constrained_html_dialog_win.cc b/chrome/browser/views/constrained_html_dialog_win.cc deleted file mode 100644 index 2cdc81c..0000000 --- a/chrome/browser/views/constrained_html_dialog_win.cc +++ /dev/null @@ -1,118 +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/constrained_html_dialog_win.h" - -#include "chrome/browser/dom_ui/html_dialog_ui.h" -#include "chrome/browser/profile.h" -#include "chrome/browser/renderer_host/render_view_host.h" -#include "chrome/browser/renderer_host/render_view_host_delegate.h" -#include "chrome/browser/renderer_host/render_widget_host_view_win.h" -#include "chrome/browser/renderer_host/site_instance.h" -#include "chrome/common/bindings_policy.h" -#include "chrome/common/renderer_preferences.h" -#include "views/widget/widget_win.h" -#include "views/window/window_delegate.h" - -class ConstrainedHtmlDialogHostView : public views::NativeViewHost { - public: - explicit ConstrainedHtmlDialogHostView(ConstrainedHtmlDialogWin* dialog) - : dialog_(dialog), - initialized_(false) { - } - - virtual void ViewHierarchyChanged(bool is_add, - views::View* parent, - views::View* child) { - NativeViewHost::ViewHierarchyChanged(is_add, parent, child); - if (is_add && GetWidget() && !initialized_) { - dialog_->Init(GetWidget()->GetNativeView()); - initialized_ = true; - } - } - - private: - ConstrainedHtmlDialogWin* dialog_; - bool initialized_; -}; - -ConstrainedHtmlDialogWin::ConstrainedHtmlDialogWin( - Profile* profile, - HtmlDialogUIDelegate* delegate) - : ConstrainedHtmlDialog(profile, delegate) { - CHECK(delegate); - native_view_host_ = new ConstrainedHtmlDialogHostView(this); - - // Size the native view to match the delegate preferred size. - gfx::Size size; - delegate->GetDialogSize(&size); - native_view_host_->SetPreferredSize(size); - - // Create a site instance for the correct URL. - dialog_url_ = delegate->GetDialogContentURL(); - site_instance_ = - SiteInstance::CreateSiteInstanceForURL(profile, dialog_url_); -} - -ConstrainedHtmlDialogWin::~ConstrainedHtmlDialogWin() { -} - -ConstrainedWindowDelegate* -ConstrainedHtmlDialogWin::GetConstrainedWindowDelegate() { - return this; -} - -bool ConstrainedHtmlDialogWin::CanResize() const { - return true; -} - -views::View* ConstrainedHtmlDialogWin::GetContentsView() { - return native_view_host_; -} - -void ConstrainedHtmlDialogWin::WindowClosing() { - html_dialog_ui_delegate()->OnDialogClosed(""); -} - -int ConstrainedHtmlDialogWin::GetBrowserWindowID() const { - return 0; -} - -ViewType::Type ConstrainedHtmlDialogWin::GetRenderViewType() const { - return ViewType::HTML_DIALOG_UI; -} - -RendererPreferences ConstrainedHtmlDialogWin::GetRendererPrefs( - Profile* profile) const { - return RendererPreferences(); -} - -void ConstrainedHtmlDialogWin::ProcessDOMUIMessage( - const ViewHostMsg_DomMessage_Params& params) { - DOMUI::ProcessDOMUIMessage(params); -} - -void ConstrainedHtmlDialogWin::Init(gfx::NativeView parent_view) { - render_view_host_.reset(new RenderViewHost(site_instance_, - this, - MSG_ROUTING_NONE, - NULL)); - render_view_host_->AllowBindings(BindingsPolicy::DOM_UI); - render_widget_host_view_ = - new RenderWidgetHostViewWin(render_view_host_.get()); - render_view_host_->set_view(render_widget_host_view_); - render_view_host_->CreateRenderView(string16()); - render_view_host_->NavigateToURL(dialog_url_); - HWND hwnd = render_widget_host_view_->Create(parent_view); - render_widget_host_view_->ShowWindow(SW_SHOW); - native_view_host_->Attach(hwnd); - - InitializeDOMUI(render_view_host_.get()); -} - -// static -ConstrainedHtmlDialog* ConstrainedHtmlDialog::CreateConstrainedHTMLDialog( - Profile* profile, HtmlDialogUIDelegate* delegate) { - return new ConstrainedHtmlDialogWin(profile, delegate); -} diff --git a/chrome/browser/views/constrained_html_dialog_win.h b/chrome/browser/views/constrained_html_dialog_win.h deleted file mode 100644 index 6faa821..0000000 --- a/chrome/browser/views/constrained_html_dialog_win.h +++ /dev/null @@ -1,66 +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_CONSTRAINED_HTML_DIALOG_WIN_H_ -#define CHROME_BROWSER_VIEWS_CONSTRAINED_HTML_DIALOG_WIN_H_ -#pragma once - -#include <string> - -#include "chrome/browser/dom_ui/constrained_html_dialog.h" -#include "chrome/browser/dom_ui/html_dialog_ui.h" -#include "chrome/browser/renderer_host/render_view_host_delegate.h" -#include "chrome/browser/renderer_host/site_instance.h" -#include "chrome/common/bindings_policy.h" -#include "chrome/common/renderer_preferences.h" -#include "views/controls/native/native_view_host.h" -#include "views/window/window_delegate.h" - -class RenderViewHost; -class RenderWidgetHostViewWin; - -class ConstrainedHtmlDialogWin : public ConstrainedHtmlDialog, - public ConstrainedWindowDelegate, - public RenderViewHostDelegate { - public: - ConstrainedHtmlDialogWin(Profile* profile, - HtmlDialogUIDelegate* delegate); - ~ConstrainedHtmlDialogWin(); - - // Called when the dialog is actually being added to the views hierarchy. - void Init(gfx::NativeView parent_window); - - // ConstrainedHtmlDialog override. - virtual ConstrainedWindowDelegate* GetConstrainedWindowDelegate(); - - // ConstrainedWindowDelegate (aka views::WindowDelegate) override. - virtual bool CanResize() const; - virtual views::View* GetContentsView(); - virtual void WindowClosing(); - - // RenderViewHostDelegate overrides. - virtual int GetBrowserWindowID() const; - virtual ViewType::Type GetRenderViewType() const; - virtual RendererPreferences GetRendererPrefs(Profile* profile) const; - virtual void ProcessDOMUIMessage( - const ViewHostMsg_DomMessage_Params& params); - virtual void UpdateInspectorSetting(const std::string& key, - const std::string& value) {} - virtual void ClearInspectorSettings() {} - - private: - SiteInstance* site_instance_; - scoped_ptr<RenderViewHost> render_view_host_; - - // URL to be displayed in the dialog. - GURL dialog_url_; - - // Pointer owned by the |render_view_host_| object. - RenderWidgetHostViewWin* render_widget_host_view_; - - // View pointer owned by the views hierarchy. - views::NativeViewHost* native_view_host_; -}; - -#endif // CHROME_BROWSER_VIEWS_CONSTRAINED_HTML_DIALOG_WIN_H_ diff --git a/chrome/browser/views/constrained_window_win.cc b/chrome/browser/views/constrained_window_win.cc index f997c3d..7fa1dc6 100644 --- a/chrome/browser/views/constrained_window_win.cc +++ b/chrome/browser/views/constrained_window_win.cc @@ -6,7 +6,7 @@ #include "app/resource_bundle.h" #include "app/win_util.h" -#include "chrome/app/chrome_dll_resource.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profile.h" @@ -564,7 +564,7 @@ views::NonClientFrameView* ConstrainedWindowWin::CreateFrameViewForWindow() { void ConstrainedWindowWin::FocusConstrainedWindow() { if ((!owner_->delegate() || - owner_->delegate()->ShouldFocusConstrainedWindow(owner_)) && + owner_->delegate()->ShouldFocusConstrainedWindow()) && GetDelegate() && GetDelegate()->GetInitiallyFocusedView()) { GetDelegate()->GetInitiallyFocusedView()->RequestFocus(); } diff --git a/chrome/browser/views/content_setting_bubble_contents.cc b/chrome/browser/views/content_setting_bubble_contents.cc index 240fbcf..cea404d 100644 --- a/chrome/browser/views/content_setting_bubble_contents.cc +++ b/chrome/browser/views/content_setting_bubble_contents.cc @@ -30,6 +30,14 @@ #include "views/standard_layout.h" #include "webkit/glue/plugins/plugin_list.h" +// If we don't clamp the maximum width, then very long URLs and titles can make +// the bubble arbitrarily wide. +const int kMaxContentsWidth = 500; + +// When we have multiline labels, we should set a minimum width lest we get very +// narrow bubbles with lots of line-wrapping. +const int kMinMultiLineContentsWidth = 250; + class ContentSettingBubbleContents::Favicon : public views::ImageView { public: Favicon(const SkBitmap& image, @@ -115,6 +123,16 @@ ContentSettingBubbleContents::ContentSettingBubbleContents( ContentSettingBubbleContents::~ContentSettingBubbleContents() { } +gfx::Size ContentSettingBubbleContents::GetPreferredSize() { + gfx::Size preferred_size(views::View::GetPreferredSize()); + int preferred_width = + (!content_setting_bubble_model_->bubble_content().domain_lists.empty() && + (kMinMultiLineContentsWidth > preferred_size.width())) ? + kMinMultiLineContentsWidth : preferred_size.width(); + preferred_size.set_width(std::min(preferred_width, kMaxContentsWidth)); + return preferred_size; +} + void ContentSettingBubbleContents::ViewHierarchyChanged(bool is_add, View* parent, View* child) { @@ -240,6 +258,7 @@ void ContentSettingBubbleContents::InitControlLayout() { views::Link* link = new views::Link(UTF8ToWide(i->title)); link->SetController(this); + link->SetElideInMiddle(true); popup_links_[link] = i - bubble_content.popup_items.begin(); layout->AddView(new Favicon((*i).bitmap, this, link)); layout->AddView(link); @@ -289,11 +308,6 @@ void ContentSettingBubbleContents::InitControlLayout() { layout->StartRow(0, single_column_set_id); views::Label* section_title = new views::Label(UTF8ToWide(i->title)); section_title->SetMultiLine(true); - // TODO(joth): Should need to have hard coded size here, but without it - // we get empty space at very end of bubble (as it's initially sized really - // tall & skinny but then widens once the link/buttons are added - // at the end of this method). - section_title->SizeToFit(256); section_title->SetHorizontalAlignment(views::Label::ALIGN_LEFT); layout->AddView(section_title, 1, 1, GridLayout::FILL, GridLayout::LEADING); for (std::set<std::string>::const_iterator j = i->hosts.begin(); diff --git a/chrome/browser/views/content_setting_bubble_contents.h b/chrome/browser/views/content_setting_bubble_contents.h index b469cc2..b35744f 100644 --- a/chrome/browser/views/content_setting_bubble_contents.h +++ b/chrome/browser/views/content_setting_bubble_contents.h @@ -48,6 +48,8 @@ class ContentSettingBubbleContents : public views::View, // the bubble and must keep it alive. void set_info_bubble(InfoBubble* info_bubble) { info_bubble_ = info_bubble; } + virtual gfx::Size GetPreferredSize(); + private: class Favicon; diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc index 695abe4..3ceaf52 100644 --- a/chrome/browser/views/download_item_view.cc +++ b/chrome/browser/views/download_item_view.cc @@ -209,7 +209,7 @@ DownloadItemView::DownloadItemView(DownloadItem* download, dangerous_mode_body_image_set_ = dangerous_mode_body_image_set; LoadIcon(); - tooltip_text_ = download_->GetFileName().ToWStringHack(); + tooltip_text_ = download_->GetFileNameToReportUser().ToWStringHack(); font_ = ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); box_height_ = std::max<int>(2 * kVerticalPadding + font_.GetHeight() + @@ -257,11 +257,11 @@ DownloadItemView::DownloadItemView(DownloadItem* download, // Ensure the file name is not too long. // Extract the file extension (if any). - FilePath filepath(download->original_name()); + FilePath filename(download->target_name()); #if defined(OS_LINUX) - std::wstring extension = base::SysNativeMBToWide(filepath.Extension()); + std::wstring extension = base::SysNativeMBToWide(filename.Extension()); #else - std::wstring extension = filepath.Extension(); + std::wstring extension = filename.Extension(); #endif // Remove leading '.' @@ -269,9 +269,9 @@ DownloadItemView::DownloadItemView(DownloadItem* download, extension = extension.substr(1); #if defined(OS_LINUX) std::wstring rootname = - base::SysNativeMBToWide(filepath.BaseName().RemoveExtension().value()); + base::SysNativeMBToWide(filename.RemoveExtension().value()); #else - std::wstring rootname = filepath.BaseName().RemoveExtension().value(); + std::wstring rootname = filename.RemoveExtension().value(); #endif // Elide giant extensions (this shouldn't currently be hit, but might @@ -602,7 +602,7 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) { if (!IsDangerousMode()) { string16 filename; if (!disabled_while_opening_) { - filename = gfx::ElideFilename(download_->GetFileName(), + filename = gfx::ElideFilename(download_->GetFileNameToReportUser(), font_, kTextWidth); } else { // First, Calculate the download status opening string width. @@ -612,7 +612,7 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) { int status_string_width = font_.GetStringWidth(status_string); // Then, elide the file name. string16 filename_string = - gfx::ElideFilename(download_->GetFileName(), font_, + gfx::ElideFilename(download_->GetFileNameToReportUser(), font_, kTextWidth - status_string_width); // Last, concat the whole string. filename = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING, @@ -637,7 +637,7 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) { // Paint the icon. IconManager* im = g_browser_process->icon_manager(); SkBitmap* icon = IsDangerousMode() ? warning_icon_ : - im->LookupIcon(download_->full_path(), IconLoader::SMALL); + im->LookupIcon(download_->GetUserVerifiedFileName(), IconLoader::SMALL); // We count on the fact that the icon manager will cache the icons and if one // is available, it will be cached here. We *don't* want to request the icon @@ -731,7 +731,7 @@ void DownloadItemView::ClearDangerousMode() { // We need to load the icon now that the download_ has the real path. LoadIcon(); - tooltip_text_ = download_->GetFileName().ToWStringHack(); + tooltip_text_ = download_->GetFileNameToReportUser().ToWStringHack(); // Force the shelf to layout again as our size has changed. parent_->Layout(); @@ -849,7 +849,7 @@ bool DownloadItemView::OnMouseDragged(const views::MouseEvent& event) { if (dragging_) { if (download_->state() == DownloadItem::COMPLETE) { IconManager* im = g_browser_process->icon_manager(); - SkBitmap* icon = im->LookupIcon(download_->full_path(), + SkBitmap* icon = im->LookupIcon(download_->GetUserVerifiedFileName(), IconLoader::SMALL); if (icon) { views::Widget* widget = GetWidget(); @@ -960,7 +960,8 @@ void DownloadItemView::OnExtractIconComplete(IconManager::Handle handle, void DownloadItemView::LoadIcon() { IconManager* im = g_browser_process->icon_manager(); - im->LoadIcon(download_->full_path(), IconLoader::SMALL, &icon_consumer_, + im->LoadIcon(download_->GetUserVerifiedFileName(), + IconLoader::SMALL, &icon_consumer_, NewCallback(this, &DownloadItemView::OnExtractIconComplete)); } @@ -1062,7 +1063,7 @@ void DownloadItemView::UpdateAccessibleName() { new_name = dangerous_download_label_->GetText(); } else { new_name = status_text_ + L" " + - download_->GetFileName().ToWStringHack(); + download_->GetFileNameToReportUser().ToWStringHack(); } // If the name has changed, call SetAccessibleName and notify diff --git a/chrome/browser/views/extensions/extension_install_prompt.cc b/chrome/browser/views/extensions/extension_install_prompt.cc index f75b557..5cf1e7b 100644 --- a/chrome/browser/views/extensions/extension_install_prompt.cc +++ b/chrome/browser/views/extensions/extension_install_prompt.cc @@ -9,6 +9,7 @@ #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/extensions/extension_install_ui.h" +#include "chrome/browser/views/window.h" #include "chrome/common/extensions/extension.h" #include "grit/generated_resources.h" #include "views/controls/button/checkbox.h" @@ -35,8 +36,10 @@ const int kIconSize = 69; class InstallDialogContent : public views::View, public views::DialogDelegate { public: InstallDialogContent(ExtensionInstallUI::Delegate* delegate, - Extension* extension, SkBitmap* icon, ExtensionInstallUI::PromptType type) - : delegate_(delegate), icon_(NULL), type_(type) { + const Extension* extension, + SkBitmap* icon, + ExtensionInstallUI::PromptType type) + : delegate_(delegate), icon_(NULL), type_(type) { // Scale down to icon size, but allow smaller icons (don't scale up). gfx::Size size(icon->width(), icon->height()); if (size.width() > kIconSize || size.height() > kIconSize) @@ -141,7 +144,10 @@ class InstallDialogContent : public views::View, public views::DialogDelegate { // static void ExtensionInstallUI::ShowExtensionInstallUIPromptImpl( - Profile* profile, Delegate* delegate, Extension* extension, SkBitmap* icon, + Profile* profile, + Delegate* delegate, + const Extension* extension, + SkBitmap* icon, PromptType type) { Browser* browser = BrowserList::GetLastActiveWithProfile(profile); if (!browser) { @@ -155,7 +161,7 @@ void ExtensionInstallUI::ShowExtensionInstallUIPromptImpl( return; } - views::Window::CreateChromeWindow(window->GetNativeHandle(), gfx::Rect(), + browser::CreateViewsWindow(window->GetNativeHandle(), gfx::Rect(), new InstallDialogContent(delegate, extension, icon, type))->Show(); } diff --git a/chrome/browser/views/extensions/extension_install_prompt2.cc b/chrome/browser/views/extensions/extension_install_prompt2.cc index 467ae20..ba9631e 100644 --- a/chrome/browser/views/extensions/extension_install_prompt2.cc +++ b/chrome/browser/views/extensions/extension_install_prompt2.cc @@ -58,7 +58,7 @@ class InstallDialogContent2 : public views::View, public views::DialogDelegate { public: InstallDialogContent2(ExtensionInstallUI::Delegate* delegate, - Extension* extension, + const Extension* extension, SkBitmap* icon, const std::vector<string16>& permissions); @@ -109,7 +109,7 @@ class InstallDialogContent2 InstallDialogContent2::InstallDialogContent2( - ExtensionInstallUI::Delegate* delegate, Extension* extension, + ExtensionInstallUI::Delegate* delegate, const Extension* extension, SkBitmap* icon, const std::vector<string16>& permissions) : delegate_(delegate), icon_(NULL), @@ -292,7 +292,8 @@ void InstallDialogContent2::Layout() { // static void ExtensionInstallUI::ShowExtensionInstallUIPrompt2Impl( - Profile* profile, Delegate* delegate, Extension* extension, SkBitmap* icon, + Profile* profile, Delegate* delegate, const Extension* extension, + SkBitmap* icon, const std::vector<string16>& permissions) { #if defined(OS_CHROMEOS) // Use a normal browser window as parent on ChromeOS. diff --git a/chrome/browser/views/extensions/extension_installed_bubble.cc b/chrome/browser/views/extensions/extension_installed_bubble.cc index 4997ac6..8cb9397 100644 --- a/chrome/browser/views/extensions/extension_installed_bubble.cc +++ b/chrome/browser/views/extensions/extension_installed_bubble.cc @@ -69,7 +69,7 @@ const int kAnimationWaitMaxRetry = 10; class InstalledBubbleContent : public views::View, public views::ButtonListener { public: - InstalledBubbleContent(Extension* extension, + InstalledBubbleContent(const Extension* extension, ExtensionInstalledBubble::BubbleType type, SkBitmap* icon) : info_bubble_(NULL), @@ -241,12 +241,13 @@ class InstalledBubbleContent : public views::View, DISALLOW_COPY_AND_ASSIGN(InstalledBubbleContent); }; -void ExtensionInstalledBubble::Show(Extension *extension, Browser *browser, +void ExtensionInstalledBubble::Show(const Extension* extension, + Browser *browser, SkBitmap icon) { new ExtensionInstalledBubble(extension, browser, icon); } -ExtensionInstalledBubble::ExtensionInstalledBubble(Extension *extension, +ExtensionInstalledBubble::ExtensionInstalledBubble(const Extension* extension, Browser *browser, SkBitmap icon) : extension_(extension), @@ -272,20 +273,26 @@ ExtensionInstalledBubble::ExtensionInstalledBubble(Extension *extension, // be sure that a BrowserAction or PageAction has had views created which we // can inspect for the purpose of previewing of pointing to them. registrar_.Add(this, NotificationType::EXTENSION_LOADED, - NotificationService::AllSources()); + Source<Profile>(browser->profile())); + registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, + Source<Profile>(browser->profile())); } void ExtensionInstalledBubble::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { if (type == NotificationType::EXTENSION_LOADED) { - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); if (extension == extension_) { animation_wait_retries_ = 0; // PostTask to ourself to allow all EXTENSION_LOADED Observers to run. MessageLoopForUI::current()->PostTask(FROM_HERE, NewRunnableMethod(this, &ExtensionInstalledBubble::ShowInternal)); } + } else if (type == NotificationType::EXTENSION_UNLOADED) { + const Extension* extension = Details<const Extension>(details).ptr(); + if (extension == extension_) + extension_ = NULL; } else { NOTREACHED() << L"Received unexpected notification"; } @@ -354,25 +361,27 @@ void ExtensionInstalledBubble::ShowInternal() { // InfoBubbleDelegate void ExtensionInstalledBubble::InfoBubbleClosing(InfoBubble* info_bubble, bool closed_by_escape) { - if (type_ == PAGE_ACTION) { - BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow( - browser_->window()->GetNativeHandle()); - browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( - extension_->page_action(), - false); // preview_enabled - } else if (type_ == EXTENSION_APP) { - if (bubble_content_->create_shortcut()) { - ShellIntegration::ShortcutInfo shortcut_info; - shortcut_info.url = extension_->GetFullLaunchURL(); - shortcut_info.extension_id = UTF8ToUTF16(extension_->id()); - shortcut_info.title = UTF8ToUTF16(extension_->name()); - shortcut_info.description = UTF8ToUTF16(extension_->description()); - shortcut_info.favicon = icon_; - shortcut_info.create_on_desktop = true; - shortcut_info.create_in_applications_menu = false; - shortcut_info.create_in_quick_launch_bar = false; - web_app::CreateShortcut(browser_->profile()->GetPath(), shortcut_info, - NULL); + if (extension_) { + if (type_ == PAGE_ACTION) { + BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow( + browser_->window()->GetNativeHandle()); + browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( + extension_->page_action(), + false); // preview_enabled + } else if (type_ == EXTENSION_APP) { + if (bubble_content_->create_shortcut()) { + ShellIntegration::ShortcutInfo shortcut_info; + shortcut_info.url = extension_->GetFullLaunchURL(); + shortcut_info.extension_id = UTF8ToUTF16(extension_->id()); + shortcut_info.title = UTF8ToUTF16(extension_->name()); + shortcut_info.description = UTF8ToUTF16(extension_->description()); + shortcut_info.favicon = icon_; + shortcut_info.create_on_desktop = true; + shortcut_info.create_in_applications_menu = false; + shortcut_info.create_in_quick_launch_bar = false; + web_app::CreateShortcut(browser_->profile()->GetPath(), shortcut_info, + NULL); + } } } diff --git a/chrome/browser/views/extensions/extension_installed_bubble.h b/chrome/browser/views/extensions/extension_installed_bubble.h index 81c12a6..a35f820 100644 --- a/chrome/browser/views/extensions/extension_installed_bubble.h +++ b/chrome/browser/views/extensions/extension_installed_bubble.h @@ -44,13 +44,13 @@ class ExtensionInstalledBubble // the extension has loaded. |extension| is the installed extension. |browser| // is the browser window which will host the bubble. |icon| is the install // icon of the extension. - static void Show(Extension *extension, Browser *browser, SkBitmap icon); + static void Show(const Extension* extension, Browser *browser, SkBitmap icon); private: friend class base::RefCountedThreadSafe<ExtensionInstalledBubble>; // Private ctor. Registers a listener for EXTENSION_LOADED. - ExtensionInstalledBubble(Extension *extension, Browser *browser, + ExtensionInstalledBubble(const Extension* extension, Browser *browser, SkBitmap icon); ~ExtensionInstalledBubble() {} @@ -69,7 +69,7 @@ class ExtensionInstalledBubble virtual bool CloseOnEscape() { return true; } virtual bool FadeInOnShow() { return true; } - Extension* extension_; + const Extension* extension_; Browser* browser_; SkBitmap icon_; NotificationRegistrar registrar_; diff --git a/chrome/browser/views/extensions/extension_view.cc b/chrome/browser/views/extensions/extension_view.cc index 4ba38ca..fcace1a 100644 --- a/chrome/browser/views/extensions/extension_view.cc +++ b/chrome/browser/views/extensions/extension_view.cc @@ -39,7 +39,7 @@ ExtensionView::~ExtensionView() { CleanUp(); } -Extension* ExtensionView::extension() const { +const Extension* ExtensionView::extension() const { return host_->extension(); } diff --git a/chrome/browser/views/extensions/extension_view.h b/chrome/browser/views/extensions/extension_view.h index 6eded74..037c2e8 100644 --- a/chrome/browser/views/extensions/extension_view.h +++ b/chrome/browser/views/extensions/extension_view.h @@ -36,7 +36,7 @@ class ExtensionView : public views::NativeViewHost { ExtensionHost* host() const { return host_; } Browser* browser() const { return browser_; } - Extension* extension() const; + const Extension* extension() const; RenderViewHost* render_view_host() const; void DidStopLoading(); void SetIsClipped(bool is_clipped); diff --git a/chrome/browser/views/external_protocol_dialog.cc b/chrome/browser/views/external_protocol_dialog.cc index 3022c28..5b6d975 100644 --- a/chrome/browser/views/external_protocol_dialog.cc +++ b/chrome/browser/views/external_protocol_dialog.cc @@ -9,6 +9,7 @@ #include "base/metrics/histogram.h" #include "base/string_util.h" #include "base/thread.h" +#include "base/thread_restrictions.h" #include "base/utf_string_conversions.h" #include "base/win/registry.h" #include "chrome/browser/browser_process.h" @@ -157,6 +158,10 @@ ExternalProtocolDialog::ExternalProtocolDialog(TabContents* tab_contents, // static std::wstring ExternalProtocolDialog::GetApplicationForProtocol( const GURL& url) { + // We shouldn't be accessing the registry from the UI thread, since it can go + // to disk. http://crbug.com/61996 + base::ThreadRestrictions::ScopedAllowIO allow_io; + std::wstring url_spec = ASCIIToWide(url.possibly_invalid_spec()); std::wstring cmd_key_path = ASCIIToWide(url.scheme() + "\\shell\\open\\command"); diff --git a/chrome/browser/views/find_bar_host_interactive_uitest.cc b/chrome/browser/views/find_bar_host_interactive_uitest.cc index 9c2750e..12537fb 100644 --- a/chrome/browser/views/find_bar_host_interactive_uitest.cc +++ b/chrome/browser/views/find_bar_host_interactive_uitest.cc @@ -50,9 +50,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) { browser()->Find(); // Open another tab (tab B). - Browser::AddTabWithURLParams params(url, PageTransition::TYPED); - browser()->AddTabWithURL(¶ms); - EXPECT_EQ(browser(), params.target); + browser()->AddSelectedTabWithURL(url, PageTransition::TYPED); browser()->Find(); EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), diff --git a/chrome/browser/views/find_bar_host_uitest.cc b/chrome/browser/views/find_bar_host_uitest.cc index df4ea0e..8dd6dbb 100644 --- a/chrome/browser/views/find_bar_host_uitest.cc +++ b/chrome/browser/views/find_bar_host_uitest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/app/chrome_dll_resource.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/ui/ui_test.h" diff --git a/chrome/browser/views/first_run_search_engine_view.cc b/chrome/browser/views/first_run_search_engine_view.cc index e4ba4a6..6688d9e 100644 --- a/chrome/browser/views/first_run_search_engine_view.cc +++ b/chrome/browser/views/first_run_search_engine_view.cc @@ -15,9 +15,9 @@ #include "base/time.h" #include "chrome/browser/options_window.h" #include "chrome/browser/profile.h" +#include "chrome/browser/search_engines/search_engine_type.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/canvas.h" #include "gfx/font.h" #include "grit/browser_resources.h" @@ -36,7 +36,6 @@ #include "views/window/window.h" using base::Time; -using TemplateURLPrepopulateData::SearchEngineType; namespace { @@ -63,7 +62,7 @@ SearchEngineChoice::SearchEngineChoice(views::ButtonListener* listener, use_images = true; #endif int logo_id = search_engine_->logo_id(); - if (use_images && logo_id > 0) { + if (use_images && logo_id != kNoSearchEngineLogo) { is_image_label_ = true; views::ImageView* logo_image = new views::ImageView(); SkBitmap* logo_bmp = diff --git a/chrome/browser/views/frame/browser_root_view.cc b/chrome/browser/views/frame/browser_root_view.cc index d2985dd..e423603 100644 --- a/chrome/browser/views/frame/browser_root_view.cc +++ b/chrome/browser/views/frame/browser_root_view.cc @@ -9,6 +9,7 @@ #include "app/os_exchange_data.h" #include "chrome/browser/autocomplete/autocomplete.h" #include "chrome/browser/autocomplete/autocomplete_classifier.h" +#include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/location_bar.h" #include "chrome/browser/profile.h" #include "chrome/browser/views/frame/browser_view.h" diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index b09242b..949b73b 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -14,6 +14,7 @@ #include "base/i18n/rtl.h" #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/app_modal_dialog_queue.h" #include "chrome/browser/autocomplete/autocomplete_popup_model.h" @@ -555,12 +556,6 @@ gfx::Rect BrowserView::GetClientAreaBounds() const { return container_bounds; } -bool BrowserView::ShouldFindBarBlendWithBookmarksBar() const { - if (bookmark_bar_view_.get()) - return bookmark_bar_view_->IsAlwaysShown(); - return false; -} - gfx::Rect BrowserView::GetFindBarBoundingBox() const { return GetBrowserViewLayout()->GetFindBarBoundingBox(); } @@ -1068,9 +1063,7 @@ views::Window* BrowserView::ShowAboutChromeDialog() { } void BrowserView::ShowUpdateChromeDialog() { -#if defined(OS_WIN) UpdateRecommendedMessageBox::ShowMessageBox(GetWindow()->GetNativeWindow()); -#endif } void BrowserView::ShowTaskManager() { @@ -1851,7 +1844,7 @@ void BrowserView::Init() { // Stow a pointer to this object onto the window handle so that we can get // at it later when all we have is a native view. #if defined(OS_WIN) - SetProp(GetWidget()->GetNativeView(), kBrowserViewKey, this); + GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this); #else g_object_set_data(G_OBJECT(GetWidget()->GetNativeView()), kBrowserViewKey, this); diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index 32272ab..d113525 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -128,12 +128,6 @@ class BrowserView : public BrowserBubbleHost, // BrowserView's parent. gfx::Rect GetClientAreaBounds() const; - // Returns true if the Find Bar should be rendered such that it appears to - // blend with the Bookmarks Bar. False if it should appear to blend with the - // main Toolbar. The return value will vary depending on whether or not the - // Bookmark Bar is always shown. - bool ShouldFindBarBlendWithBookmarksBar() const; - // Returns the constraining bounding box that should be used to lay out the // FindBar within. This is _not_ the size of the find bar, just the bounding // box it should be laid out within. The coordinate system of the returned diff --git a/chrome/browser/views/frame/glass_browser_frame_view.cc b/chrome/browser/views/frame/glass_browser_frame_view.cc index b532273..fdc1956 100644 --- a/chrome/browser/views/frame/glass_browser_frame_view.cc +++ b/chrome/browser/views/frame/glass_browser_frame_view.cc @@ -6,6 +6,7 @@ #include "app/resource_bundle.h" #include "app/theme_provider.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/views/frame/browser_view.h" diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc index c3c1a0a..94d0ffa 100644 --- a/chrome/browser/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc @@ -919,7 +919,14 @@ void OpaqueBrowserFrameView::LayoutWindowControls() { close_button_size.height()); #if defined(OS_CHROMEOS) - if (is_maximized) { + // LayoutWindowControls could be triggered from WindowGtk::UpdateWindowTitle, + // which could happen when user navigates in fullscreen mode. And because + // BrowserFrameChromeos::IsMaximized return false for fullscreen mode, we + // explicitly test fullscreen mode here and make it use the same code path + // as maximized mode. + // TODO(oshima): Optimize the relayout logic to defer the frame view's + // relayout until it is necessary, i.e when it becomes visible. + if (is_maximized || frame_->GetWindow()->IsFullscreen()) { minimize_button_->SetVisible(false); restore_button_->SetVisible(false); maximize_button_->SetVisible(false); diff --git a/chrome/browser/views/fullscreen_exit_bubble.cc b/chrome/browser/views/fullscreen_exit_bubble.cc index 4777f51..635e9d2 100644 --- a/chrome/browser/views/fullscreen_exit_bubble.cc +++ b/chrome/browser/views/fullscreen_exit_bubble.cc @@ -7,7 +7,7 @@ #include "app/keyboard_codes.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "chrome/app/chrome_dll_resource.h" +#include "chrome/app/chrome_command_ids.h" #include "gfx/canvas_skia.h" #include "grit/generated_resources.h" #include "views/screen.h" diff --git a/chrome/browser/views/generic_info_view_unittest.cc b/chrome/browser/views/generic_info_view_unittest.cc index 2fa0e9d..6c26603 100644 --- a/chrome/browser/views/generic_info_view_unittest.cc +++ b/chrome/browser/views/generic_info_view_unittest.cc @@ -11,10 +11,11 @@ #include "views/controls/label.h" #include "views/controls/textfield/textfield.h" #include "views/widget/root_view.h" +#include "views/window/window.h" + #if defined(OS_WIN) #include "views/widget/widget_win.h" #endif -#include "views/window/window.h" // This class is only used on windows for now. #if defined(OS_WIN) @@ -59,5 +60,6 @@ TEST_F(GenericInfoViewTest, GenericInfoView) { string16 product_desc = l10n_util::GetString(IDS_PRODUCT_DESCRIPTION); EXPECT_EQ(product_name, view2->name_views_[0]->GetText()); EXPECT_EQ(product_desc, view2->name_views_[1]->GetText()); + window->CloseNow(); } #endif // OS_WIN diff --git a/chrome/browser/views/html_dialog_view.cc b/chrome/browser/views/html_dialog_view.cc index 7d12d78..f28e609 100644 --- a/chrome/browser/views/html_dialog_view.cc +++ b/chrome/browser/views/html_dialog_view.cc @@ -98,6 +98,10 @@ views::View* HtmlDialogView::GetInitiallyFocusedView() { return this; } +bool HtmlDialogView::ShouldShowWindowTitle() const { + return ShouldShowDialogTitle(); +} + //////////////////////////////////////////////////////////////////////////////// // HtmlDialogUIDelegate implementation: @@ -150,6 +154,13 @@ void HtmlDialogView::OnCloseContents(TabContents* source, delegate_->OnCloseContents(source, out_close_dialog); } +bool HtmlDialogView::ShouldShowDialogTitle() const { + if (delegate_) + return delegate_->ShouldShowDialogTitle(); + else + return true; +} + //////////////////////////////////////////////////////////////////////////////// // TabContentsDelegate implementation: diff --git a/chrome/browser/views/html_dialog_view.h b/chrome/browser/views/html_dialog_view.h index 9c05291..1d42b6f 100644 --- a/chrome/browser/views/html_dialog_view.h +++ b/chrome/browser/views/html_dialog_view.h @@ -55,6 +55,7 @@ class HtmlDialogView virtual void WindowClosing(); virtual views::View* GetContentsView(); virtual views::View* GetInitiallyFocusedView(); + virtual bool ShouldShowWindowTitle() const; // Overridden from HtmlDialogUIDelegate: virtual bool IsDialogModal() const; @@ -66,6 +67,7 @@ class HtmlDialogView virtual std::string GetDialogArgs() const; virtual void OnDialogClosed(const std::string& json_retval); virtual void OnCloseContents(TabContents* source, bool* out_close_dialog); + virtual bool ShouldShowDialogTitle() const; // Overridden from TabContentsDelegate: virtual void MoveContents(TabContents* source, const gfx::Rect& pos); diff --git a/chrome/browser/views/html_dialog_view_browsertest.cc b/chrome/browser/views/html_dialog_view_browsertest.cc index bbcc6a0..a2bcd35 100644 --- a/chrome/browser/views/html_dialog_view_browsertest.cc +++ b/chrome/browser/views/html_dialog_view_browsertest.cc @@ -58,6 +58,7 @@ class TestHtmlDialogUIDelegate : public HtmlDialogUIDelegate { if (out_close_dialog) *out_close_dialog = true; } + virtual bool ShouldShowDialogTitle() const { return true; } }; } // namespace diff --git a/chrome/browser/views/importing_progress_view.cc b/chrome/browser/views/importing_progress_view.cc index f3c2627..ae3135e 100644 --- a/chrome/browser/views/importing_progress_view.cc +++ b/chrome/browser/views/importing_progress_view.cc @@ -290,7 +290,7 @@ void ImportingProgressView::InitControlLayout() { // StartImportingWithUI void StartImportingWithUI(HWND parent_window, - int16 items, + uint16 items, ImporterHost* coordinator, const ProfileInfo& source_profile, Profile* target_profile, diff --git a/chrome/browser/views/indexed_db_info_view.cc b/chrome/browser/views/indexed_db_info_view.cc index 1b0b28c..733ef6e 100644 --- a/chrome/browser/views/indexed_db_info_view.cc +++ b/chrome/browser/views/indexed_db_info_view.cc @@ -23,8 +23,7 @@ static const int kIndexedDBInfoViewInsetSize = 3; // IndexedDBInfoView, public: IndexedDBInfoView::IndexedDBInfoView() - : name_value_field_(NULL), - origin_value_field_(NULL), + : origin_value_field_(NULL), size_value_field_(NULL), last_modified_value_field_(NULL) { } @@ -34,10 +33,6 @@ IndexedDBInfoView::~IndexedDBInfoView() { void IndexedDBInfoView::SetIndexedDBInfo( const BrowsingDataIndexedDBHelper::IndexedDBInfo& indexed_db_info) { - name_value_field_->SetText( - indexed_db_info.database_name.empty() ? - l10n_util::GetString(IDS_COOKIES_WEB_DATABASE_UNNAMED_NAME) : - UTF8ToWide(indexed_db_info.database_name)); origin_value_field_->SetText(UTF8ToWide(indexed_db_info.origin)); size_value_field_->SetText( FormatBytes(indexed_db_info.size, @@ -49,7 +44,6 @@ void IndexedDBInfoView::SetIndexedDBInfo( } void IndexedDBInfoView::EnableIndexedDBDisplay(bool enabled) { - name_value_field_->SetEnabled(enabled); origin_value_field_->SetEnabled(enabled); size_value_field_->SetEnabled(enabled); last_modified_value_field_->SetEnabled(enabled); @@ -58,7 +52,6 @@ void IndexedDBInfoView::EnableIndexedDBDisplay(bool enabled) { void IndexedDBInfoView::ClearIndexedDBDisplay() { std::wstring no_cookie_string = l10n_util::GetString(IDS_COOKIES_COOKIE_NONESELECTED); - name_value_field_->SetText(no_cookie_string); origin_value_field_->SetText(no_cookie_string); size_value_field_->SetText(no_cookie_string); last_modified_value_field_->SetText(no_cookie_string); @@ -84,9 +77,6 @@ void IndexedDBInfoView::Init() { kIndexedDBInfoViewBorderSize, border_color); set_border(border); - views::Label* name_label = new views::Label( - l10n_util::GetString(IDS_COOKIES_COOKIE_NAME_LABEL)); - name_value_field_ = new views::Textfield; views::Label* origin_label = new views::Label( l10n_util::GetString(IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL)); origin_value_field_ = new views::Textfield; @@ -115,10 +105,6 @@ void IndexedDBInfoView::Init() { GridLayout::USE_PREF, 0, 0); layout->StartRow(0, three_column_layout_id); - layout->AddView(name_label); - layout->AddView(name_value_field_); - layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing); - layout->StartRow(0, three_column_layout_id); layout->AddView(origin_label); layout->AddView(origin_value_field_); layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing); @@ -133,9 +119,6 @@ void IndexedDBInfoView::Init() { // Color these borderless text areas the same as the containing dialog. SkColor text_area_background = color_utils::GetSysSkColor(COLOR_3DFACE); // Now that the Textfields are in the view hierarchy, we can initialize them. - name_value_field_->SetReadOnly(true); - name_value_field_->RemoveBorder(); - name_value_field_->SetBackgroundColor(text_area_background); origin_value_field_->SetReadOnly(true); origin_value_field_->RemoveBorder(); origin_value_field_->SetBackgroundColor(text_area_background); diff --git a/chrome/browser/views/indexed_db_info_view.h b/chrome/browser/views/indexed_db_info_view.h index 20ba89b..4be00a5 100644 --- a/chrome/browser/views/indexed_db_info_view.h +++ b/chrome/browser/views/indexed_db_info_view.h @@ -45,7 +45,6 @@ class IndexedDBInfoView : public views::View { void Init(); // Individual property labels - views::Textfield* name_value_field_; views::Textfield* origin_value_field_; views::Textfield* size_value_field_; views::Textfield* last_modified_value_field_; diff --git a/chrome/browser/views/infobars/extension_infobar.cc b/chrome/browser/views/infobars/extension_infobar.cc index 441a95e..e2fb43f 100644 --- a/chrome/browser/views/infobars/extension_infobar.cc +++ b/chrome/browser/views/infobars/extension_infobar.cc @@ -164,7 +164,7 @@ void ExtensionInfoBar::SetupIconAndMenu() { menu_->SetVisible(false); AddChildView(menu_); - Extension* extension = delegate_->extension_host()->extension(); + const Extension* extension = delegate_->extension_host()->extension(); ExtensionResource icon_resource = extension->GetIconResource( Extension::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY); if (!icon_resource.relative_path().empty()) { diff --git a/chrome/browser/views/location_bar/content_setting_image_view.cc b/chrome/browser/views/location_bar/content_setting_image_view.cc index baeed23..2d5af65 100644 --- a/chrome/browser/views/location_bar/content_setting_image_view.cc +++ b/chrome/browser/views/location_bar/content_setting_image_view.cc @@ -70,9 +70,8 @@ void ContentSettingImageView::OnMouseReleased(const views::MouseEvent& event, tab_contents, profile_, content_setting_image_model_->get_content_settings_type()), profile_, tab_contents); - info_bubble_ = - InfoBubble::Show(GetWidget(), screen_bounds, BubbleBorder::TOP_LEFT, - bubble_contents, this); + info_bubble_ = InfoBubble::Show(GetWidget(), screen_bounds, + BubbleBorder::TOP_RIGHT, bubble_contents, this); bubble_contents->set_info_bubble(info_bubble_); } diff --git a/chrome/browser/views/location_bar/keyword_hint_view.cc b/chrome/browser/views/location_bar/keyword_hint_view.cc index 14974c8..eec0dd1 100644 --- a/chrome/browser/views/location_bar/keyword_hint_view.cc +++ b/chrome/browser/views/location_bar/keyword_hint_view.cc @@ -7,7 +7,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/logging.h" -#include "chrome/app/chrome_dll_resource.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/browser/profile.h" #include "chrome/browser/search_engines/template_url_model.h" #include "gfx/canvas.h" diff --git a/chrome/browser/views/location_bar/location_bar_view.cc b/chrome/browser/views/location_bar/location_bar_view.cc index 8d43f78..09c18a9 100644 --- a/chrome/browser/views/location_bar/location_bar_view.cc +++ b/chrome/browser/views/location_bar/location_bar_view.cc @@ -14,7 +14,7 @@ #include "app/theme_provider.h" #include "base/stl_util-inl.h" #include "base/utf_string_conversions.h" -#include "chrome/app/chrome_dll_resource.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/browser/alternate_nav_url_fetcher.h" #include "chrome/browser/autocomplete/autocomplete_popup_model.h" #include "chrome/browser/defaults.h" @@ -736,25 +736,8 @@ void LocationBarView::OnAutocompleteLosingFocus( SetSuggestedText(string16()); InstantController* instant = delegate_->GetInstant(); - if (!instant) - return; - - if (!instant->is_active() || !instant->GetPreviewContents()) - return; - - switch (GetCommitType(view_gaining_focus)) { - case COMMIT_INSTANT_IMMEDIATELY: - instant->CommitCurrentPreview(INSTANT_COMMIT_FOCUS_LOST); - break; - case COMMIT_INSTANT_ON_MOUSE_UP: - instant->SetCommitOnMouseUp(); - break; - case REVERT_INSTANT: - instant->DestroyPreviewContents(); - break; - default: - NOTREACHED(); - } + if (instant) + instant->OnAutocompleteLostFocus(view_gaining_focus); } void LocationBarView::OnAutocompleteWillAccept() { @@ -774,6 +757,10 @@ bool LocationBarView::OnCommitSuggestedText(const std::wstring& typed_text) { return true; } +void LocationBarView::OnSetSuggestedSearchText(const string16& suggested_text) { + SetSuggestedText(suggested_text); +} + void LocationBarView::OnPopupBoundsChanged(const gfx::Rect& bounds) { InstantController* instant = delegate_->GetInstant(); if (instant) @@ -1206,45 +1193,3 @@ void LocationBarView::OnTemplateURLModelChanged() { template_url_model_ = NULL; ShowFirstRunBubble(bubble_type_); } - -LocationBarView::InstantCommitType LocationBarView::GetCommitType( - gfx::NativeView view_gaining_focus) { - // The InstantController is active. Destroy it if the user didn't click on the - // TabContents (or one of its children). -#if defined(OS_WIN) - InstantController* instant = delegate_->GetInstant(); - RenderWidgetHostView* rwhv = - instant->GetPreviewContents()->GetRenderWidgetHostView(); - if (!view_gaining_focus || !rwhv) - return REVERT_INSTANT; - - gfx::NativeView tab_view = instant->GetPreviewContents()->GetNativeView(); - if (rwhv->GetNativeView() == view_gaining_focus || - tab_view == view_gaining_focus) { - // Focus is going to the renderer. Only commit instant if the mouse is - // down. If the mouse isn't down it means someone else moved focus and we - // shouldn't commit. - if (instant->IsMouseDownFromActivate()) { - if (instant->IsShowingInstant()) { - // We're showing instant results. As instant results may shift when - // committing we commit on the mouse up. This way a slow click still - // works fine. - return COMMIT_INSTANT_ON_MOUSE_UP; - } - return COMMIT_INSTANT_IMMEDIATELY; - } - return REVERT_INSTANT; - } - gfx::NativeView view_gaining_focus_ancestor = view_gaining_focus; - while (view_gaining_focus_ancestor && - view_gaining_focus_ancestor != tab_view) { - view_gaining_focus_ancestor = ::GetParent(view_gaining_focus_ancestor); - } - return view_gaining_focus_ancestor != NULL ? - COMMIT_INSTANT_IMMEDIATELY : REVERT_INSTANT; -#else - // TODO: implement me. - NOTIMPLEMENTED(); - return REVERT_INSTANT; -#endif -} diff --git a/chrome/browser/views/location_bar/location_bar_view.h b/chrome/browser/views/location_bar/location_bar_view.h index 2895450..019e7a1 100644 --- a/chrome/browser/views/location_bar/location_bar_view.h +++ b/chrome/browser/views/location_bar/location_bar_view.h @@ -183,6 +183,7 @@ class LocationBarView : public LocationBar, virtual void OnAutocompleteLosingFocus(gfx::NativeView view_gaining_focus); virtual void OnAutocompleteWillAccept(); virtual bool OnCommitSuggestedText(const std::wstring& typed_text); + virtual void OnSetSuggestedSearchText(const string16& suggested_text); virtual void OnPopupBoundsChanged(const gfx::Rect& bounds); virtual void OnAutocompleteAccept(const GURL& url, WindowOpenDisposition disposition, @@ -261,18 +262,6 @@ class LocationBarView : public LocationBar, private: typedef std::vector<ContentSettingImageView*> ContentSettingViews; - // Enumeration of what should happen to instant on focus lost. - enum InstantCommitType { - // The instant preview should be committed immediately. - COMMIT_INSTANT_IMMEDIATELY, - - // The instant preview should be committed on mouse up. - COMMIT_INSTANT_ON_MOUSE_UP, - - // The instant preview should be reverted. - REVERT_INSTANT - }; - friend class PageActionImageView; friend class PageActionWithBadgeView; typedef std::vector<PageActionWithBadgeView*> PageActionViews; @@ -315,10 +304,6 @@ class LocationBarView : public LocationBar, // Helper to show the first run info bubble. void ShowFirstRunBubbleInternal(FirstRun::BubbleType bubble_type); - // Returns what should happen to the InstantController as a result of focus - // being lost. - InstantCommitType GetCommitType(gfx::NativeView view_gaining_focus); - // Current profile. Not owned by us. Profile* profile_; diff --git a/chrome/browser/views/location_bar/page_action_image_view.cc b/chrome/browser/views/location_bar/page_action_image_view.cc index aa739c0..c7155bf 100644 --- a/chrome/browser/views/location_bar/page_action_image_view.cc +++ b/chrome/browser/views/location_bar/page_action_image_view.cc @@ -26,8 +26,8 @@ PageActionImageView::PageActionImageView(LocationBarView* owner, current_tab_id_(-1), preview_enabled_(false), popup_(NULL) { - Extension* extension = profile->GetExtensionsService()->GetExtensionById( - page_action->extension_id(), false); + const Extension* extension = profile->GetExtensionsService()-> + GetExtensionById(page_action->extension_id(), false); DCHECK(extension); // Load all the icons declared in the manifest. This is the contents of the @@ -146,8 +146,8 @@ bool PageActionImageView::OnKeyPressed(const views::KeyEvent& e) { void PageActionImageView::ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) { - Extension* extension = profile_->GetExtensionsService()->GetExtensionById( - page_action()->extension_id(), false); + const Extension* extension = profile_->GetExtensionsService()-> + GetExtensionById(page_action()->extension_id(), false); Browser* browser = BrowserView::GetBrowserViewForNativeWindow( platform_util::GetTopLevel(GetWidget()->GetNativeView()))->browser(); context_menu_contents_ = diff --git a/chrome/browser/views/location_bar/star_view.cc b/chrome/browser/views/location_bar/star_view.cc index 88360ec..7d22441 100644 --- a/chrome/browser/views/location_bar/star_view.cc +++ b/chrome/browser/views/location_bar/star_view.cc @@ -6,7 +6,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "chrome/app/chrome_dll_resource.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/browser/command_updater.h" #include "chrome/browser/view_ids.h" #include "chrome/browser/views/browser_dialogs.h" diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc index ba3f426..b8513b6 100644 --- a/chrome/browser/views/options/advanced_contents_view.cc +++ b/chrome/browser/views/options/advanced_contents_view.cc @@ -1674,7 +1674,8 @@ void AdvancedContentsView::InitControlLayout() { layout->StartRow(0, single_column_view_set_id); layout->AddView(new SecuritySection(profile())); if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableCloudPrintProxy)) { + switches::kEnableCloudPrintProxy) && + profile()->GetCloudPrintProxyService()) { layout->StartRow(0, single_column_view_set_id); layout->AddView(new CloudPrintProxySection(profile())); } diff --git a/chrome/browser/views/options/fonts_languages_window_view.cc b/chrome/browser/views/options/fonts_languages_window_view.cc index ff6a998..cab82c7 100644 --- a/chrome/browser/views/options/fonts_languages_window_view.cc +++ b/chrome/browser/views/options/fonts_languages_window_view.cc @@ -49,8 +49,7 @@ bool FontsLanguagesWindowView::Accept() { // FontsLanguagesWindowView, views::WindowDelegate implementation: std::wstring FontsLanguagesWindowView::GetWindowTitle() const { - return l10n_util::GetStringF(IDS_FONT_LANGUAGE_SETTING_WINDOWS_TITLE, - l10n_util::GetString(IDS_PRODUCT_NAME)); + return l10n_util::GetString(IDS_FONT_LANGUAGE_SETTING_WINDOWS_TITLE); } void FontsLanguagesWindowView::WindowClosing() { diff --git a/chrome/browser/views/page_info_bubble_view.cc b/chrome/browser/views/page_info_bubble_view.cc index 0aa1d71..90fa667 100644 --- a/chrome/browser/views/page_info_bubble_view.cc +++ b/chrome/browser/views/page_info_bubble_view.cc @@ -140,8 +140,6 @@ void PageInfoBubbleView::LayoutSections() { for (int i = 0; i < count; ++i) { PageInfoModel::SectionInfo info = model_.GetSectionInfo(i); layout->StartRow(0, 0); - // TODO(finnur): Remove title from the info struct, since it is - // not used anymore. const SkBitmap* icon = model_.GetIconImage(info.icon_id); layout->AddView(new Section(this, info, icon, cert_id_ > 0)); diff --git a/chrome/browser/views/reload_button.cc b/chrome/browser/views/reload_button.cc index 71dc5b1..43015e7 100644 --- a/chrome/browser/views/reload_button.cc +++ b/chrome/browser/views/reload_button.cc @@ -5,7 +5,7 @@ #include "chrome/browser/views/reload_button.h" #include "app/l10n_util.h" -#include "chrome/app/chrome_dll_resource.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/browser/browser.h" #include "chrome/browser/views/event_utils.h" #include "chrome/browser/views/location_bar/location_bar_view.h" @@ -19,8 +19,12 @@ ReloadButton::ReloadButton(LocationBarView* location_bar, Browser* browser) location_bar_(location_bar), browser_(browser), intended_mode_(MODE_RELOAD), - visible_mode_(MODE_RELOAD) { - DCHECK(location_bar_); + visible_mode_(MODE_RELOAD), + double_click_timer_delay_( + base::TimeDelta::FromMilliseconds(GetDoubleClickTimeMS())), + stop_to_reload_timer_delay_(base::TimeDelta::FromMilliseconds(1350)), + testing_mouse_hovered_(false), + testing_reload_count_(0) { } ReloadButton::~ReloadButton() { @@ -32,32 +36,43 @@ void ReloadButton::ChangeMode(Mode mode, bool force) { // If the change is forced, or the user isn't hovering the icon, or it's safe // to change it to the other image type, make the change immediately; // otherwise we'll let it happen later. - if (force || !IsMouseHovered() || ((mode == MODE_STOP) ? - !timer_.IsRunning() : (visible_mode_ != MODE_STOP))) { - timer_.Stop(); + if (force || (!IsMouseHovered() && !testing_mouse_hovered_) || + ((mode == MODE_STOP) ? + !double_click_timer_.IsRunning() : (visible_mode_ != MODE_STOP))) { + double_click_timer_.Stop(); + stop_to_reload_timer_.Stop(); SetToggled(mode == MODE_STOP); visible_mode_ = mode; SetEnabled(true); // We want to disable the button if we're preventing a change from stop to // reload due to hovering, but not if we're preventing a change from reload to - // stop due to the timer running. (There is no disabled reload state.) + // stop due to the double-click timer running. (There is no disabled reload + // state.) } else if (visible_mode_ != MODE_RELOAD) { SetEnabled(false); + + // Go ahead and change to reload after a bit, which allows repeated reloads + // without moving the mouse. + if (!stop_to_reload_timer_.IsRunning()) { + stop_to_reload_timer_.Start(stop_to_reload_timer_delay_, this, + &ReloadButton::OnStopToReloadTimer); + } } } //////////////////////////////////////////////////////////////////////////////// // ReloadButton, views::ButtonListener implementation: -void ReloadButton::ButtonPressed(views::Button* button, +void ReloadButton::ButtonPressed(views::Button* /* button */, const views::Event& event) { if (visible_mode_ == MODE_STOP) { - browser_->Stop(); + if (browser_) + browser_->Stop(); // The user has clicked, so we can feel free to update the button, // even if the mouse is still hovering. ChangeMode(MODE_RELOAD, true); - } else if (!timer_.IsRunning()) { + } else if (!double_click_timer_.IsRunning()) { // Shift-clicking or ctrl-clicking the reload button means we should ignore // any cached content. // TODO(avayvod): eliminate duplication of this logic in @@ -74,7 +89,7 @@ void ReloadButton::ButtonPressed(views::Button* button, WindowOpenDisposition disposition = event_utils::DispositionFromEventFlags(flags); - if (disposition == CURRENT_TAB) { + if ((disposition == CURRENT_TAB) && location_bar_) { // Forcibly reset the location bar, since otherwise it won't discard any // ongoing user edits, since it doesn't realize this is a user-initiated // action. @@ -86,11 +101,12 @@ void ReloadButton::ButtonPressed(views::Button* button, // here as the browser will do that when it actually starts loading (which // may happen synchronously, thus the need to do this before telling the // browser to execute the reload command). - timer_.Stop(); - timer_.Start(base::TimeDelta::FromMilliseconds(GetDoubleClickTimeMS()), - this, &ReloadButton::OnButtonTimer); + double_click_timer_.Start(double_click_timer_delay_, this, + &ReloadButton::OnDoubleClickTimer); - browser_->ExecuteCommandWithDisposition(command, disposition); + if (browser_) + browser_->ExecuteCommandWithDisposition(command, disposition); + ++testing_reload_count_; } } @@ -112,6 +128,10 @@ bool ReloadButton::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { //////////////////////////////////////////////////////////////////////////////// // ReloadButton, private: -void ReloadButton::OnButtonTimer() { +void ReloadButton::OnDoubleClickTimer() { ChangeMode(intended_mode_, false); } + +void ReloadButton::OnStopToReloadTimer() { + ChangeMode(intended_mode_, true); +} diff --git a/chrome/browser/views/reload_button.h b/chrome/browser/views/reload_button.h index 6a8c29c..0c253bf 100644 --- a/chrome/browser/views/reload_button.h +++ b/chrome/browser/views/reload_button.h @@ -7,6 +7,7 @@ #pragma once #include "base/basictypes.h" +#include "base/gtest_prod_util.h" #include "base/timer.h" #include "views/controls/button/image_button.h" @@ -37,26 +38,44 @@ class ReloadButton : public views::ToggleImageButton, void ChangeMode(Mode mode, bool force); // Overridden from views::ButtonListener: - virtual void ButtonPressed(views::Button* button, const views::Event& event); + virtual void ButtonPressed(views::Button* /* button */, + const views::Event& event); // Overridden from views::View: virtual void OnMouseExited(const views::MouseEvent& e); virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip); private: - void OnButtonTimer(); + friend class ReloadButtonTest; - base::OneShotTimer<ReloadButton> timer_; + void OnDoubleClickTimer(); + void OnStopToReloadTimer(); + base::OneShotTimer<ReloadButton> double_click_timer_; + base::OneShotTimer<ReloadButton> stop_to_reload_timer_; + + // These may be NULL when testing. LocationBarView* location_bar_; Browser* browser_; - // The mode we should be in + // The mode we should be in assuming no timers are running. Mode intended_mode_; - // The currently-visible mode - this may different from the intended mode + // The currently-visible mode - this may differ from the intended mode. Mode visible_mode_; + // The delay times for the timers. These are members so that tests can modify + // them. + base::TimeDelta double_click_timer_delay_; + base::TimeDelta stop_to_reload_timer_delay_; + + // TESTING ONLY + // True if we should pretend the button is hovered. + bool testing_mouse_hovered_; + // Increments when we would tell the browser to "reload", so + // test code can tell whether we did so (as there may be no |browser_|). + int testing_reload_count_; + DISALLOW_IMPLICIT_CONSTRUCTORS(ReloadButton); }; diff --git a/chrome/browser/views/reload_button_unittest.cc b/chrome/browser/views/reload_button_unittest.cc new file mode 100644 index 0000000..5f8255b --- /dev/null +++ b/chrome/browser/views/reload_button_unittest.cc @@ -0,0 +1,150 @@ +// 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 "base/message_loop.h" +#include "chrome/browser/views/reload_button.h" +#include "testing/gtest/include/gtest/gtest.h" + +class ReloadButtonTest : public testing::Test { + public: + ReloadButtonTest(); + + void CheckState(bool enabled, + ReloadButton::Mode intended_mode, + ReloadButton::Mode visible_mode, + bool double_click_timer_running, + bool stop_to_reload_timer_running); + + // These accessors eliminate the need to declare each testcase as a friend. + void set_mouse_hovered(bool hovered) { + reload_.testing_mouse_hovered_ = hovered; + } + int reload_count() { return reload_.testing_reload_count_; } + + protected: + // We need a message loop for the timers to post events. + MessageLoop loop_; + + ReloadButton reload_; +}; + +ReloadButtonTest::ReloadButtonTest() : reload_(NULL, NULL) { + // Set the timer delays to 0 so that timers will fire as soon as we tell the + // message loop to run pending tasks. + reload_.double_click_timer_delay_ = base::TimeDelta(); + reload_.stop_to_reload_timer_delay_ = base::TimeDelta(); +} + +void ReloadButtonTest::CheckState(bool enabled, + ReloadButton::Mode intended_mode, + ReloadButton::Mode visible_mode, + bool double_click_timer_running, + bool stop_to_reload_timer_running) { + EXPECT_EQ(enabled, reload_.IsEnabled()); + EXPECT_EQ(intended_mode, reload_.intended_mode_); + EXPECT_EQ(visible_mode, reload_.visible_mode_); + EXPECT_EQ(double_click_timer_running, + reload_.double_click_timer_.IsRunning()); + EXPECT_EQ(stop_to_reload_timer_running, + reload_.stop_to_reload_timer_.IsRunning()); +} + +TEST_F(ReloadButtonTest, Basic) { + // The stop/reload button starts in the "enabled reload" state with no timers + // running. + CheckState(true, ReloadButton::MODE_RELOAD, ReloadButton::MODE_RELOAD, false, + false); + + // Press the button. This should start the double-click timer. + views::MouseEvent e(views::Event::ET_MOUSE_PRESSED, 0, 0, 0); + reload_.ButtonPressed(&reload_, e); + CheckState(true, ReloadButton::MODE_RELOAD, ReloadButton::MODE_RELOAD, true, + false); + + // Now change the mode (as if the browser had started loading the page). This + // should cancel the double-click timer since the button is not hovered. + reload_.ChangeMode(ReloadButton::MODE_STOP, false); + CheckState(true, ReloadButton::MODE_STOP, ReloadButton::MODE_STOP, false, + false); + + // Press the button again. This should change back to reload. + reload_.ButtonPressed(&reload_, e); + CheckState(true, ReloadButton::MODE_RELOAD, ReloadButton::MODE_RELOAD, false, + false); +} + +TEST_F(ReloadButtonTest, DoubleClickTimer) { + // Start by pressing the button. + views::MouseEvent e(views::Event::ET_MOUSE_PRESSED, 0, 0, 0); + reload_.ButtonPressed(&reload_, e); + + // Try to press the button again. This should do nothing because the timer is + // running. + int original_reload_count = reload_count(); + reload_.ButtonPressed(&reload_, e); + CheckState(true, ReloadButton::MODE_RELOAD, ReloadButton::MODE_RELOAD, true, + false); + EXPECT_EQ(original_reload_count, reload_count()); + + // Hover the button, and change mode. The visible mode should not change, + // again because the timer is running. + set_mouse_hovered(true); + reload_.ChangeMode(ReloadButton::MODE_STOP, false); + CheckState(true, ReloadButton::MODE_STOP, ReloadButton::MODE_RELOAD, true, + false); + + // Now fire the timer. This should complete the mode change. + loop_.RunAllPending(); + CheckState(true, ReloadButton::MODE_STOP, ReloadButton::MODE_STOP, false, + false); +} + +TEST_F(ReloadButtonTest, DisableOnHover) { + // Change to stop and hover. + views::MouseEvent e(views::Event::ET_MOUSE_PRESSED, 0, 0, 0); + reload_.ButtonPressed(&reload_, e); + reload_.ChangeMode(ReloadButton::MODE_STOP, false); + set_mouse_hovered(true); + + // Now change back to reload. This should result in a disabled stop button + // due to the hover. + reload_.ChangeMode(ReloadButton::MODE_RELOAD, false); + CheckState(false, ReloadButton::MODE_RELOAD, ReloadButton::MODE_STOP, false, + true); + + // Un-hover the button, which should allow it to reset. + set_mouse_hovered(false); + views::MouseEvent e2(views::Event::ET_MOUSE_MOVED, 0, 0, 0); + reload_.OnMouseExited(e2); + CheckState(true, ReloadButton::MODE_RELOAD, ReloadButton::MODE_RELOAD, false, + false); +} + +TEST_F(ReloadButtonTest, ResetOnClick) { + // Change to stop and hover. + views::MouseEvent e(views::Event::ET_MOUSE_PRESSED, 0, 0, 0); + reload_.ButtonPressed(&reload_, e); + reload_.ChangeMode(ReloadButton::MODE_STOP, false); + set_mouse_hovered(true); + + // Press the button. This should change back to reload despite the hover, + // because it's a direct user action. + reload_.ButtonPressed(&reload_, e); + CheckState(true, ReloadButton::MODE_RELOAD, ReloadButton::MODE_RELOAD, false, + false); +} + +TEST_F(ReloadButtonTest, ResetOnTimer) { + // Change to stop, hover, and change back to reload. + views::MouseEvent e(views::Event::ET_MOUSE_PRESSED, 0, 0, 0); + reload_.ButtonPressed(&reload_, e); + reload_.ChangeMode(ReloadButton::MODE_STOP, false); + set_mouse_hovered(true); + reload_.ChangeMode(ReloadButton::MODE_RELOAD, false); + + // Now fire the stop-to-reload timer. This should reset the button. + loop_.RunAllPending(); + CheckState(true, ReloadButton::MODE_RELOAD, ReloadButton::MODE_RELOAD, false, + false); +} diff --git a/chrome/browser/views/select_file_dialog.cc b/chrome/browser/views/select_file_dialog.cc index 9b9c2ef..da8427c 100644 --- a/chrome/browser/views/select_file_dialog.cc +++ b/chrome/browser/views/select_file_dialog.cc @@ -115,6 +115,7 @@ class SelectFileDialogImpl : public SelectFileDialog { virtual void OnDialogClosed(const std::string& json_retval); virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) { } + virtual bool ShouldShowDialogTitle() const { return true; } DISALLOW_COPY_AND_ASSIGN(FileBrowseDelegate); }; diff --git a/chrome/browser/views/shell_dialogs_win.cc b/chrome/browser/views/shell_dialogs_win.cc index d3fe7ae..bc5f92b 100644 --- a/chrome/browser/views/shell_dialogs_win.cc +++ b/chrome/browser/views/shell_dialogs_win.cc @@ -891,10 +891,11 @@ bool SelectFileDialogImpl::RunOpenMultiFileDialog( ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = owner; - wchar_t filename[MAX_PATH] = L""; + scoped_array<wchar_t> filename(new wchar_t[UNICODE_STRING_MAX_CHARS]); + filename[0] = 0; - ofn.lpstrFile = filename; - ofn.nMaxFile = MAX_PATH; + ofn.lpstrFile = filename.get(); + ofn.nMaxFile = UNICODE_STRING_MAX_CHARS; // We use OFN_NOCHANGEDIR so that the user can rename or delete the directory // without having to close Chrome first. ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_EXPLORER diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc index 2f92daf..234b6f0 100644 --- a/chrome/browser/views/status_bubble_views.cc +++ b/chrome/browser/views/status_bubble_views.cc @@ -646,8 +646,8 @@ void StatusBubbleViews::SetURL(const GURL& url, const string16& languages) { popup_->GetBounds(&popup_bounds, true); int text_width = static_cast<int>(popup_bounds.width() - (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1); - url_text_ = WideToUTF16(gfx::ElideUrl(url, view_->Label::font(), - text_width, UTF16ToWide(languages))); + url_text_ = gfx::ElideUrl(url, view_->Label::font(), + text_width, UTF16ToWideHack(languages)); std::wstring original_url_text = UTF16ToWideHack(net::FormatUrl(url, UTF16ToUTF8(languages))); @@ -801,8 +801,8 @@ void StatusBubbleViews::ExpandBubble() { gfx::Rect popup_bounds; popup_->GetBounds(&popup_bounds, true); int max_status_bubble_width = GetMaxStatusBubbleWidth(); - url_text_ = WideToUTF16(gfx::ElideUrl(url_, view_->Label::font(), - max_status_bubble_width, UTF16ToWideHack(languages_))); + url_text_ = gfx::ElideUrl(url_, view_->Label::font(), + max_status_bubble_width, UTF16ToWideHack(languages_)); int expanded_bubble_width =std::max(GetStandardStatusBubbleWidth(), std::min(view_->Label::font().GetStringWidth(UTF16ToWide(url_text_)) + (kShadowThickness * 2) + kTextPositionX + diff --git a/chrome/browser/views/tab_contents/render_view_context_menu_views.cc b/chrome/browser/views/tab_contents/render_view_context_menu_views.cc index 8efb30b..e7ac1a6 100644 --- a/chrome/browser/views/tab_contents/render_view_context_menu_views.cc +++ b/chrome/browser/views/tab_contents/render_view_context_menu_views.cc @@ -6,7 +6,7 @@ #include "app/keyboard_codes.h" #include "base/compiler_specific.h" -#include "chrome/app/chrome_dll_resource.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/browser/profile.h" #include "grit/generated_resources.h" #include "views/accelerator.h" diff --git a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc index e13d441..0a31684 100644 --- a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc +++ b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc @@ -393,6 +393,16 @@ void TabContentsViewGtk::ShowContextMenu(const ContextMenuParams& params) { MessageLoop::current()->SetNestableTasksAllowed(old_state); } +void TabContentsViewGtk::ShowPopupMenu(const gfx::Rect& bounds, + int item_height, + double item_font_size, + int selected_item, + const std::vector<WebMenuItem>& items, + bool right_aligned) { + // External popup menus are only used on Mac. + NOTREACHED(); +} + gboolean TabContentsViewGtk::OnButtonPress(GtkWidget* widget, GdkEventButton* event) { last_mouse_down_ = *event; @@ -426,10 +436,13 @@ gboolean TabContentsViewGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) { // we need to pass on the message to paint the page gfx::Rect bounds; GetBounds(&bounds, true); - views::View *view = reinterpret_cast<RenderWidgetHostViewViews *>(tab_contents()->render_view_host()->view()); - view->SetBounds(gfx::Rect(0, 0, bounds.width(), bounds.height())); - gfx::CanvasSkiaPaint canvas(event); - view->ProcessPaint(&canvas); + views::View *view = reinterpret_cast<RenderWidgetHostViewViews *> + (tab_contents()->render_view_host()->view()); + if (view) { + view->SetBounds(gfx::Rect(0, 0, bounds.width(), bounds.height())); + gfx::CanvasSkiaPaint canvas(event); + view->ProcessPaint(&canvas); + } #endif } return false; // False indicates other widgets should get the event as well. @@ -485,7 +498,7 @@ void TabContentsViewGtk::SetFloatingPosition(const gfx::Size& size) { gtk_widget_size_request(widget, &requisition); int child_x = std::max(half_view_width - (requisition.width / 2), 0); - PositionChild(widget, child_x, 0, requisition.width, requisition.height); + PositionChild(widget, child_x, 0, 0, 0); } } diff --git a/chrome/browser/views/tab_contents/tab_contents_view_gtk.h b/chrome/browser/views/tab_contents/tab_contents_view_gtk.h index a46c4a3..890c6b1 100644 --- a/chrome/browser/views/tab_contents/tab_contents_view_gtk.h +++ b/chrome/browser/views/tab_contents/tab_contents_view_gtk.h @@ -65,6 +65,12 @@ class TabContentsViewGtk : public TabContentsView, // Backend implementation of RenderViewHostDelegate::View. virtual void ShowContextMenu(const ContextMenuParams& params); + virtual void ShowPopupMenu(const gfx::Rect& bounds, + int item_height, + double item_font_size, + int selected_item, + const std::vector<WebMenuItem>& items, + bool right_aligned); virtual void StartDragging(const WebDropData& drop_data, WebKit::WebDragOperationsMask ops_allowed, const SkBitmap& image, diff --git a/chrome/browser/views/tab_contents/tab_contents_view_win.cc b/chrome/browser/views/tab_contents/tab_contents_view_win.cc index 91e2036..f3126d1 100644 --- a/chrome/browser/views/tab_contents/tab_contents_view_win.cc +++ b/chrome/browser/views/tab_contents/tab_contents_view_win.cc @@ -145,6 +145,8 @@ void TabContentsViewWin::OnDestroy() { RevokeDragDrop(GetNativeView()); drop_target_ = NULL; } + + WidgetWin::OnDestroy(); } void TabContentsViewWin::SetPageTitle(const std::wstring& title) { @@ -343,6 +345,16 @@ void TabContentsViewWin::ShowContextMenu(const ContextMenuParams& params) { MessageLoop::current()->SetNestableTasksAllowed(old_state); } +void TabContentsViewWin::ShowPopupMenu(const gfx::Rect& bounds, + int item_height, + double item_font_size, + int selected_item, + const std::vector<WebMenuItem>& items, + bool right_aligned) { + // External popup menus are only used on Mac. + NOTREACHED(); +} + void TabContentsViewWin::OnHScroll(int scroll_type, short position, HWND scrollbar) { ScrollCommon(WM_HSCROLL, scroll_type, position, scrollbar); diff --git a/chrome/browser/views/tab_contents/tab_contents_view_win.h b/chrome/browser/views/tab_contents/tab_contents_view_win.h index 471869c..a42ffd7 100644 --- a/chrome/browser/views/tab_contents/tab_contents_view_win.h +++ b/chrome/browser/views/tab_contents/tab_contents_view_win.h @@ -59,6 +59,12 @@ class TabContentsViewWin : public TabContentsView, // Backend implementation of RenderViewHostDelegate::View. virtual void ShowContextMenu(const ContextMenuParams& params); + virtual void ShowPopupMenu(const gfx::Rect& bounds, + int item_height, + double item_font_size, + int selected_item, + const std::vector<WebMenuItem>& items, + bool right_aligned); virtual void StartDragging(const WebDropData& drop_data, WebKit::WebDragOperationsMask operations, const SkBitmap& image, diff --git a/chrome/browser/views/tab_icon_view.cc b/chrome/browser/views/tab_icon_view.cc index db8a8e8..547b039 100644 --- a/chrome/browser/views/tab_icon_view.cc +++ b/chrome/browser/views/tab_icon_view.cc @@ -13,7 +13,7 @@ #include "app/theme_provider.h" #include "base/file_util.h" #include "base/logging.h" -#include "chrome/app/chrome_dll_resource.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "gfx/canvas.h" #include "gfx/favicon_size.h" diff --git a/chrome/browser/views/tabs/tab_dragging_test.cc b/chrome/browser/views/tabs/tab_dragging_test.cc index 91286ec..2cb0171 100644 --- a/chrome/browser/views/tabs/tab_dragging_test.cc +++ b/chrome/browser/views/tabs/tab_dragging_test.cc @@ -4,7 +4,7 @@ #include "base/command_line.h" #include "base/file_util.h" -#include "chrome/app/chrome_dll_resource.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/browser/view_ids.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" @@ -18,12 +18,13 @@ #include "net/base/net_util.h" #include "views/event.h" -#if defined(OS_CHROMEOS) +#if defined(OS_LINUX) // This test doesn't make sense on chromeos as chromeos doesn't allow dragging // tabs out. #define MAYBE_Tab2OutOfTabStrip DISABLED_Tab2OutOfTabStrip #else -#define MAYBE_Tab2OutOfTabStrip Tab2OutOfTabStrip +// Flaky, http://crbug.com/62311. +#define MAYBE_Tab2OutOfTabStrip FLAKY_Tab2OutOfTabStrip #endif #if defined(OS_LINUX) @@ -42,8 +43,9 @@ #define MAYBE_Tab1Tab2 DISABLED_Tab1Tab2 #define MAYBE_Tab1Tab3 DISABLED_Tab1Tab3 #else -#define MAYBE_Tab1Tab2 Tab1Tab2 -#define MAYBE_Tab1Tab3 Tab1Tab3 +// Flaky, http://crbug.com/62311. +#define MAYBE_Tab1Tab2 FLAKY_Tab1Tab2 +#define MAYBE_Tab1Tab3 FLAKY_Tab1Tab3 #endif class TabDraggingTest : public UITest { diff --git a/chrome/browser/views/task_manager_view.cc b/chrome/browser/views/task_manager_view.cc index a4d74c2..f8432d4 100644 --- a/chrome/browser/views/task_manager_view.cc +++ b/chrome/browser/views/task_manager_view.cc @@ -9,7 +9,7 @@ #include "base/command_line.h" #include "base/metrics/stats_table.h" #include "base/utf_string_conversions.h" -#include "chrome/app/chrome_dll_resource.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_window.h" diff --git a/chrome/browser/views/textfield_views.cc b/chrome/browser/views/textfield_views.cc new file mode 100644 index 0000000..f15be68 --- /dev/null +++ b/chrome/browser/views/textfield_views.cc @@ -0,0 +1,34 @@ +// 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/textfield_views.h" + +#include "base/utf_string_conversions.h" +#include "base/values.h" +#include "chrome/browser/dom_ui/textfields_ui.h" +#include "chrome/browser/tab_contents/tab_contents.h" + +TextfieldViews::TextfieldViews() : DOMView() {} + +std::wstring TextfieldViews::GetText() { + TextfieldsUI* textfields_ui = dom_ui(); + return (textfields_ui) ? textfields_ui->text() : std::wstring(); +} + +void TextfieldViews::SetText(const std::wstring& text) { + TextfieldsUI* textfields_ui = dom_ui(); + if (textfields_ui) { + StringValue text_value(WideToUTF16(text)); + textfields_ui->CallJavascriptFunction(L"setTextfieldValue", text_value); + } + SchedulePaint(); +} + +TextfieldsUI* TextfieldViews::dom_ui() { + TextfieldsUI* dom_ui = NULL; + if (tab_contents_.get() && tab_contents_->dom_ui()) { + dom_ui = static_cast<TextfieldsUI*>(tab_contents_->dom_ui()); + } + return dom_ui; +} diff --git a/chrome/browser/views/textfield_views.h b/chrome/browser/views/textfield_views.h new file mode 100644 index 0000000..506a2e6 --- /dev/null +++ b/chrome/browser/views/textfield_views.h @@ -0,0 +1,27 @@ +// 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_TEXTFIELD_VIEWS_H_ +#define CHROME_BROWSER_VIEWS_TEXTFIELD_VIEWS_H_ +#pragma once + +#include <string> + +#include "chrome/browser/views/dom_view.h" + +class TextfieldsUI; + +class TextfieldViews : public DOMView { + public: + TextfieldViews(); + std::wstring GetText(); + void SetText(const std::wstring& text); + + private: + TextfieldsUI* dom_ui(); + + DISALLOW_COPY_AND_ASSIGN(TextfieldViews); +}; + +#endif // CHROME_BROWSER_VIEWS_TEXTFIELD_VIEWS_H_ diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc index ded8a63..cc82cdc 100644 --- a/chrome/browser/views/toolbar_view.cc +++ b/chrome/browser/views/toolbar_view.cc @@ -6,7 +6,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "chrome/app/chrome_dll_resource.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/browser/accessibility/browser_accessibility_state.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_window.h" @@ -41,6 +41,10 @@ #endif #include "chrome/browser/views/wrench_menu.h" +#if defined(OS_WIN) +#include "chrome/browser/enumerate_modules_model_win.h" +#endif + // The space between items is 4 px in general. const int ToolbarView::kStandardSpacing = 4; // The top of the toolbar has an edge we have to skip over in addition to the 4 @@ -102,6 +106,8 @@ ToolbarView::ToolbarView(Browser* browser) registrar_.Add(this, NotificationType::UPGRADE_RECOMMENDED, NotificationService::AllSources()); } + registrar_.Add(this, NotificationType::MODULE_INCOMPATIBILITY_DETECTED, + NotificationService::AllSources()); } ToolbarView::~ToolbarView() { @@ -175,8 +181,8 @@ void ToolbarView::Init(Profile* profile) { app_menu_->SetID(VIEW_ID_APP_MENU); // Catch the case where the window is created after we detect a new version. - if (IsUpgradeRecommended()) - ShowUpgradeReminder(); + if (IsUpgradeRecommended() || ShouldShowIncompatibilityWarning()) + ShowNotificationDot(); LoadImages(); @@ -317,8 +323,8 @@ cleanup: return; destroyed_flag_ = NULL; - // Stop pulsating the upgrade reminder on the app menu, if active. - upgrade_reminder_pulse_timer_.Stop(); + // Stop pulsating the notification dot on the app menu (if active). + notification_dot_pulse_timer_.Stop(); } //////////////////////////////////////////////////////////////////////////////// @@ -401,7 +407,11 @@ void ToolbarView::Observe(NotificationType type, SchedulePaint(); } } else if (type == NotificationType::UPGRADE_RECOMMENDED) { - ShowUpgradeReminder(); + ShowNotificationDot(); + } else if (type == NotificationType::MODULE_INCOMPATIBILITY_DETECTED) { + bool confirmed_bad = *Details<bool>(details).ptr(); + if (confirmed_bad) + ShowNotificationDot(); } } @@ -580,6 +590,15 @@ bool ToolbarView::IsUpgradeRecommended() { #endif } +bool ToolbarView::ShouldShowIncompatibilityWarning() { +#if defined(OS_WIN) + EnumerateModulesModel* loaded_modules = EnumerateModulesModel::GetSingleton(); + return loaded_modules->confirmed_bad_modules_detected() > 0; +#else + return false; +#endif +} + int ToolbarView::PopupTopSpacing() const { return GetWindow()->GetNonClientView()->UseNativeFrame() ? 0 : kPopupTopSpacingNonGlass; @@ -629,20 +648,21 @@ void ToolbarView::LoadImages() { app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); } -void ToolbarView::ShowUpgradeReminder() { - update_reminder_animation_.reset(new SlideAnimation(this)); - update_reminder_animation_->SetSlideDuration(kPulseDuration); +void ToolbarView::ShowNotificationDot() { + notification_dot_animation_.reset(new SlideAnimation(this)); + notification_dot_animation_->SetSlideDuration(kPulseDuration); // Then start the recurring timer for pulsating it. - upgrade_reminder_pulse_timer_.Start( + notification_dot_pulse_timer_.Stop(); + notification_dot_pulse_timer_.Start( base::TimeDelta::FromMilliseconds(kPulsateEveryMs), - this, &ToolbarView::PulsateUpgradeNotifier); + this, &ToolbarView::PulsateNotificationDot); } -void ToolbarView::PulsateUpgradeNotifier() { +void ToolbarView::PulsateNotificationDot() { // Start the pulsating animation. - update_reminder_animation_->Reset(0.0); - update_reminder_animation_->Show(); + notification_dot_animation_->Reset(0.0); + notification_dot_animation_->Show(); } SkBitmap ToolbarView::GetAppMenuIcon(views::CustomButton::ButtonState state) { @@ -657,7 +677,8 @@ SkBitmap ToolbarView::GetAppMenuIcon(views::CustomButton::ButtonState state) { } SkBitmap icon = *tp->GetBitmapNamed(id); - if (!IsUpgradeRecommended()) + bool add_badge = IsUpgradeRecommended() || ShouldShowIncompatibilityWarning(); + if (!add_badge) return icon; // Draw the chrome app menu icon onto the canvas. @@ -668,27 +689,48 @@ SkBitmap ToolbarView::GetAppMenuIcon(views::CustomButton::ButtonState state) { SkBitmap badge; static bool has_faded_in = false; if (!has_faded_in) { - SkBitmap* dot = tp->GetBitmapNamed(IDR_UPGRADE_DOT_INACTIVE); + SkBitmap* dot = NULL; + if (ShouldShowIncompatibilityWarning()) { +#if defined(OS_WIN) + dot = tp->GetBitmapNamed(IDR_INCOMPATIBILITY_DOT_INACTIVE); +#else + NOTREACHED(); +#endif + } else { + dot = tp->GetBitmapNamed(IDR_UPGRADE_DOT_INACTIVE); + } SkBitmap transparent; transparent.setConfig(dot->getConfig(), dot->width(), dot->height()); transparent.allocPixels(); transparent.eraseARGB(0, 0, 0, 0); badge = SkBitmapOperations::CreateBlendedBitmap( - *dot, transparent, 1.0 - update_reminder_animation_->GetCurrentValue()); - if (update_reminder_animation_->GetCurrentValue() == 1.0) + *dot, transparent, + 1.0 - notification_dot_animation_->GetCurrentValue()); + if (notification_dot_animation_->GetCurrentValue() == 1.0) has_faded_in = true; } else { // Convert animation values that start from 0.0 and incrementally go // up to 1.0 into values that start in 0.0, go to 1.0 and then back // to 0.0 (to create a pulsing effect). double value = - 1.0 - abs(2.0 * update_reminder_animation_->GetCurrentValue() - 1.0); + 1.0 - abs(2.0 * notification_dot_animation_->GetCurrentValue() - 1.0); // Add the badge to it. - badge = SkBitmapOperations::CreateBlendedBitmap( - *tp->GetBitmapNamed(IDR_UPGRADE_DOT_INACTIVE), - *tp->GetBitmapNamed(IDR_UPGRADE_DOT_ACTIVE), - value); + if (ShouldShowIncompatibilityWarning()) { +#if defined(OS_WIN) + badge = SkBitmapOperations::CreateBlendedBitmap( + *tp->GetBitmapNamed(IDR_INCOMPATIBILITY_DOT_INACTIVE), + *tp->GetBitmapNamed(IDR_INCOMPATIBILITY_DOT_ACTIVE), + value); +#else + NOTREACHED(); +#endif + } else { + badge = SkBitmapOperations::CreateBlendedBitmap( + *tp->GetBitmapNamed(IDR_UPGRADE_DOT_INACTIVE), + *tp->GetBitmapNamed(IDR_UPGRADE_DOT_ACTIVE), + value); + } } static const int kBadgeLeftSpacing = 8; diff --git a/chrome/browser/views/toolbar_view.h b/chrome/browser/views/toolbar_view.h index 8715dc5..c9b92bd 100644 --- a/chrome/browser/views/toolbar_view.h +++ b/chrome/browser/views/toolbar_view.h @@ -142,6 +142,9 @@ class ToolbarView : public AccessiblePaneView, // Returns true if we should show the upgrade recommended dot. bool IsUpgradeRecommended(); + // Returns true if we should show the warning for incompatible software. + bool ShouldShowIncompatibilityWarning(); + // Returns the number of pixels above the location bar in non-normal display. int PopupTopSpacing() const; @@ -158,12 +161,12 @@ class ToolbarView : public AccessiblePaneView, return display_mode_ == DISPLAYMODE_NORMAL; } - // Starts the recurring timer that periodically asks the upgrade notifier + // Starts the recurring timer that periodically asks the notification dot // to pulsate. - void ShowUpgradeReminder(); + void ShowNotificationDot(); - // Show the reminder, tempting the user to upgrade by pulsating. - void PulsateUpgradeNotifier(); + // Show the reminder, tempting the user to take a look. + void PulsateNotificationDot(); // Gets a canvas with the icon for the app menu. It will possibly contain // an overlaid badge if an update is recommended. @@ -210,12 +213,12 @@ class ToolbarView : public AccessiblePaneView, // Vector of listeners to receive callbacks when the menu opens. std::vector<views::MenuListener*> menu_listeners_; - // The animation that makes the update reminder pulse. - scoped_ptr<SlideAnimation> update_reminder_animation_; + // The animation that makes the notification dot pulse. + scoped_ptr<SlideAnimation> notification_dot_animation_; // We periodically restart the animation after it has been showed // once, to create a pulsating effect. - base::RepeatingTimer<ToolbarView> upgrade_reminder_pulse_timer_; + base::RepeatingTimer<ToolbarView> notification_dot_pulse_timer_; // Used to post tasks to switch to the next/previous menu. ScopedRunnableMethodFactory<ToolbarView> method_factory_; diff --git a/chrome/browser/views/update_recommended_message_box.cc b/chrome/browser/views/update_recommended_message_box.cc index 99ecbbd..baf69ab 100644 --- a/chrome/browser/views/update_recommended_message_box.cc +++ b/chrome/browser/views/update_recommended_message_box.cc @@ -9,12 +9,18 @@ #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/prefs/pref_service.h" +#include "chrome/browser/views/window.h" #include "chrome/common/pref_names.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "views/controls/message_box_view.h" #include "views/window/window.h" +#if defined(OS_CHROMEOS) +#include "chrome/browser/chromeos/cros/cros_library.h" +#include "chrome/browser/chromeos/cros/power_library.h" +#endif + //////////////////////////////////////////////////////////////////////////////// // UpdateRecommendedMessageBox, public: @@ -30,6 +36,10 @@ bool UpdateRecommendedMessageBox::Accept() { PrefService* pref_service = g_browser_process->local_state(); pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); +#if defined(OS_CHROMEOS) + chromeos::CrosLibrary::Get()->GetPowerLibrary()->RequestRestart(); + // If running the Chrome OS build, but we're not on the device, fall through +#endif BrowserList::CloseAllBrowsersAndExit(); return true; @@ -71,14 +81,18 @@ views::View* UpdateRecommendedMessageBox::GetContentsView() { UpdateRecommendedMessageBox::UpdateRecommendedMessageBox( gfx::NativeWindow parent_window) { const int kDialogWidth = 400; +#if defined(OS_CHROMEOS) + const std::wstring product_name = l10n_util::GetString(IDS_PRODUCT_OS_NAME); +#else + const std::wstring product_name = l10n_util::GetString(IDS_PRODUCT_NAME); +#endif // Also deleted when the window closes. message_box_view_ = new MessageBoxView( MessageBoxFlags::kFlagHasMessage | MessageBoxFlags::kFlagHasOKButton, - l10n_util::GetStringF(IDS_UPDATE_RECOMMENDED, - l10n_util::GetString(IDS_PRODUCT_NAME)), + l10n_util::GetStringF(IDS_UPDATE_RECOMMENDED, product_name), std::wstring(), kDialogWidth); - views::Window::CreateChromeWindow(parent_window, gfx::Rect(), this)->Show(); + browser::CreateViewsWindow(parent_window, gfx::Rect(), this)->Show(); } UpdateRecommendedMessageBox::~UpdateRecommendedMessageBox() { diff --git a/chrome/browser/views/window.cc b/chrome/browser/views/window.cc index bd8a304..ae28ce4 100644 --- a/chrome/browser/views/window.cc +++ b/chrome/browser/views/window.cc @@ -17,7 +17,10 @@ views::Window* CreateViewsWindow(gfx::NativeWindow parent, const gfx::Rect& bounds, views::WindowDelegate* delegate) { #if defined(OS_CHROMEOS) - return chromeos::BubbleWindow::Create(parent, gfx::Rect(), delegate); + return chromeos::BubbleWindow::Create(parent, + gfx::Rect(), + chromeos::BubbleWindow::STYLE_GENERIC, + delegate); #else return views::Window::CreateChromeWindow(parent, gfx::Rect(), delegate); #endif diff --git a/chrome/browser/views/wrench_menu.cc b/chrome/browser/views/wrench_menu.cc index 0c51c68..4ad20f0 100644 --- a/chrome/browser/views/wrench_menu.cc +++ b/chrome/browser/views/wrench_menu.cc @@ -10,7 +10,7 @@ #include "app/resource_bundle.h" #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" -#include "chrome/app/chrome_dll_resource.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/browser/browser.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" |