diff options
Diffstat (limited to 'chrome/browser/ui/views')
23 files changed, 140 insertions, 263 deletions
diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc index f82f0d5..4f60c52 100644 --- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc +++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc @@ -229,11 +229,11 @@ AutocompletePopupContentsView::AutocompletePopupContentsView( const gfx::Font& font, OmniboxView* omnibox_view, AutocompleteEditModel* edit_model, - Profile* profile, views::View* location_bar) - : model_(new AutocompletePopupModel(this, edit_model, profile)), + : model_(new AutocompletePopupModel(this, edit_model)), opt_in_view_(NULL), omnibox_view_(omnibox_view), + profile_(edit_model->profile()), location_bar_(location_bar), result_font_(font.DeriveFont(kEditFontAdjust)), result_bold_font_(result_font_.DeriveFont(0, gfx::Font::BOLD)), @@ -331,7 +331,7 @@ void AutocompletePopupContentsView::UpdatePopupAppearance() { for (size_t i = model_->result().size(); i < child_rv_count; ++i) child_at(i)->SetVisible(false); - PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); + PromoCounter* counter = profile_->GetInstantPromoCounter(); if (!opt_in_view_ && counter && counter->ShouldShow(base::Time::Now())) { opt_in_view_ = new InstantOptInView(this, result_bold_font_, result_font_); AddChildView(opt_in_view_); @@ -694,12 +694,12 @@ gfx::Rect AutocompletePopupContentsView::CalculateTargetBounds(int h) { void AutocompletePopupContentsView::UserPressedOptIn(bool opt_in) { delete opt_in_view_; opt_in_view_ = NULL; - PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); + PromoCounter* counter = profile_->GetInstantPromoCounter(); DCHECK(counter); counter->Hide(); if (opt_in) { browser::ShowInstantConfirmDialogIfNecessary( - location_bar_->GetWidget()->GetNativeWindow(), model_->profile()); + location_bar_->GetWidget()->GetNativeWindow(), profile_); } UpdatePopupAppearance(); } diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h index 92d6c12..ba07542 100644 --- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h +++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h @@ -36,7 +36,6 @@ class AutocompletePopupContentsView : public views::View, AutocompletePopupContentsView(const gfx::Font& font, OmniboxView* omnibox_view, AutocompleteEditModel* edit_model, - Profile* profile, views::View* location_bar); virtual ~AutocompletePopupContentsView(); @@ -143,6 +142,8 @@ class AutocompletePopupContentsView : public views::View, // The edit view that invokes us. OmniboxView* omnibox_view_; + Profile* profile_; + // An object that the popup positions itself against. views::View* location_bar_; diff --git a/chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.cc b/chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.cc index 48f2588..c49b4b1 100644 --- a/chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.cc +++ b/chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.cc @@ -4,7 +4,6 @@ #include "chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.h" -#include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/omnibox/omnibox_view.h" #include "third_party/skia/include/core/SkPaint.h" #include "ui/gfx/canvas.h" @@ -57,9 +56,8 @@ TouchAutocompletePopupContentsView::TouchAutocompletePopupContentsView( const gfx::Font& font, OmniboxView* omnibox_view, AutocompleteEditModel* edit_model, - Profile* profile, views::View* location_bar) - : AutocompletePopupContentsView(font, omnibox_view, edit_model, profile, + : AutocompletePopupContentsView(font, omnibox_view, edit_model, location_bar) { } diff --git a/chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.h b/chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.h index 061ef4a..245c338 100644 --- a/chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.h +++ b/chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.h @@ -11,7 +11,6 @@ class AutocompleteEditModel; class OmniboxView; -class Profile; namespace gfx { class Canvas; @@ -47,7 +46,6 @@ class TouchAutocompletePopupContentsView TouchAutocompletePopupContentsView(const gfx::Font& font, OmniboxView* omnibox_view, AutocompleteEditModel* edit_model, - Profile* profile, views::View* location_bar); virtual ~TouchAutocompletePopupContentsView(); diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc index 5f5d238..c701e65 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc @@ -362,16 +362,15 @@ static const SkBitmap& GetFolderIcon() { return *kFolderIcon; } -BookmarkBarView::BookmarkBarView(Profile* profile, Browser* browser) - : profile_(NULL), - page_navigator_(NULL), +BookmarkBarView::BookmarkBarView(Browser* browser) + : page_navigator_(NULL), model_(NULL), bookmark_menu_(NULL), bookmark_drop_menu_(NULL), other_bookmarked_button_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(show_folder_method_factory_(this)), sync_error_button_(NULL), - sync_service_(NULL), + sync_service_(browser->profile()->GetProfileSyncService()), overflow_button_(NULL), instructions_(NULL), bookmarks_separator_view_(NULL), @@ -380,16 +379,11 @@ BookmarkBarView::BookmarkBarView(Profile* profile, Browser* browser) throbbing_view_(NULL), bookmark_bar_state_(BookmarkBar::SHOW), animating_detached_(false) { - if (profile->GetProfileSyncService()) { - // Obtain a pointer to the profile sync service and add our instance as an - // observer. - sync_service_ = profile->GetProfileSyncService(); + if (sync_service_) sync_service_->AddObserver(this); - } set_id(VIEW_ID_BOOKMARK_BAR); Init(); - SetProfile(profile); size_animation_->Reset(1); } @@ -409,43 +403,6 @@ BookmarkBarView::~BookmarkBarView() { sync_service_->RemoveObserver(this); } -void BookmarkBarView::SetProfile(Profile* profile) { - DCHECK(profile); - if (profile_ == profile) - return; - - StopThrobbing(true); - - // Cancels the current cancelable. - registrar_.RemoveAll(); - - profile_ = profile; - - if (model_) - model_->RemoveObserver(this); - - // Disable the other bookmarked button, we'll re-enable when the model is - // loaded. - other_bookmarked_button_->SetEnabled(false); - - Source<Profile> ns_source(profile_->GetOriginalProfile()); - registrar_.Add(this, chrome::NOTIFICATION_BOOKMARK_BUBBLE_SHOWN, ns_source); - registrar_.Add(this, chrome::NOTIFICATION_BOOKMARK_BUBBLE_HIDDEN, ns_source); - - // Remove any existing bookmark buttons. - while (GetBookmarkButtonCount()) - delete child_at(0); - - model_ = profile_->GetBookmarkModel(); - if (model_) { - model_->AddObserver(this); - if (model_->IsLoaded()) - Loaded(model_, false); - // else case: we'll receive notification back from the BookmarkModel when - // done loading, then we'll populate the bar. - } -} - void BookmarkBarView::SetPageNavigator(PageNavigator* navigator) { page_navigator_ = navigator; } @@ -725,7 +682,8 @@ bool BookmarkBarView::AreDropTypesRequired() { bool BookmarkBarView::CanDrop(const ui::OSExchangeData& data) { if (!model_ || !model_->IsLoaded() || - !profile_->GetPrefs()->GetBoolean(prefs::kEditBookmarksEnabled)) + !browser_->profile()->GetPrefs()->GetBoolean( + prefs::kEditBookmarksEnabled)) return false; if (!drop_info_.get()) @@ -837,8 +795,8 @@ int BookmarkBarView::OnPerformDrop(const DropTargetEvent& event) { const BookmarkNodeData data = drop_info_->data; DCHECK(data.is_valid()); drop_info_.reset(); - return bookmark_utils::PerformBookmarkDrop(profile_, data, parent_node, - index); + return bookmark_utils::PerformBookmarkDrop(browser_->profile(), data, + parent_node, index); } void BookmarkBarView::ShowContextMenu(const gfx::Point& p, @@ -1019,7 +977,7 @@ int BookmarkBarView::GetDragOperationsForView(View* sender, for (int i = 0; i < GetBookmarkButtonCount(); ++i) { if (sender == GetBookmarkButton(i)) { return bookmark_utils::BookmarkDragOperation( - profile_, model_->bookmark_bar_node()->GetChild(i)); + browser_->profile(), model_->bookmark_bar_node()->GetChild(i)); } } NOTREACHED(); @@ -1065,8 +1023,8 @@ void BookmarkBarView::RunMenu(views::View* view, const gfx::Point& pt) { node = model_->bookmark_bar_node()->GetChild(button_index); } - bookmark_menu_ = new BookmarkMenuController( - profile_, page_navigator_, GetWidget(), node, start_index); + bookmark_menu_ = new BookmarkMenuController(browser_->profile(), + page_navigator_, GetWidget(), node, start_index); bookmark_menu_->set_observer(this); bookmark_menu_->RunMenuAt(this, false); } @@ -1094,12 +1052,13 @@ void BookmarkBarView::ButtonPressed(views::Button* sender, WindowOpenDisposition disposition_from_event_flags = event_utils::DispositionFromEventFlags(sender->mouse_event_flags()); + Profile* profile = browser_->profile(); if (node->is_url()) { - RecordAppLaunch(profile_, node->url()); + RecordAppLaunch(profile, node->url()); page_navigator_->OpenURL(node->url(), GURL(), disposition_from_event_flags, PageTransition::AUTO_BOOKMARK); } else { - bookmark_utils::OpenAll(GetWidget()->GetNativeWindow(), profile_, + bookmark_utils::OpenAll(GetWidget()->GetNativeWindow(), profile, page_navigator_, node, disposition_from_event_flags); } UserMetrics::RecordAction(UserMetricsAction("ClickedBookmarkBarURLButton")); @@ -1134,21 +1093,19 @@ void BookmarkBarView::ShowContextMenuForView(View* source, parent = model_->bookmark_bar_node(); nodes.push_back(parent); } - // Browser may be null during testing. - PageNavigator* navigator = - browser() ? browser()->GetSelectedTabContents() : NULL; + Profile* profile = browser_->profile(); bool close_on_remove = - (parent == profile_->GetBookmarkModel()->other_node() && - parent->child_count() == 1); - BookmarkContextMenu controller(GetWidget(), profile_, - navigator, parent, nodes, close_on_remove); + (parent == profile->GetBookmarkModel()->other_node()) && + (parent->child_count() == 1); + BookmarkContextMenu controller(GetWidget(), profile, + browser_->GetSelectedTabContents(), parent, nodes, close_on_remove); controller.RunMenuAt(p); } void BookmarkBarView::Observe(int type, const NotificationSource& source, const NotificationDetails& details) { - DCHECK(profile_); + DCHECK(browser_->profile()); switch (type) { case chrome::NOTIFICATION_BOOKMARK_BUBBLE_SHOWN: { StopThrobbing(true); @@ -1189,6 +1146,8 @@ void BookmarkBarView::Init() { AddChildView(overflow_button_); other_bookmarked_button_ = CreateOtherBookmarkedButton(); + // We'll re-enable when the model is loaded. + other_bookmarked_button_->SetEnabled(false); AddChildView(other_bookmarked_button_); bookmarks_separator_view_ = new ButtonSeparatorView(); @@ -1200,6 +1159,20 @@ void BookmarkBarView::Init() { set_context_menu_controller(this); size_animation_.reset(new ui::SlideAnimation(this)); + + Profile* profile = browser_->profile(); + Source<Profile> ns_source(profile->GetOriginalProfile()); + registrar_.Add(this, chrome::NOTIFICATION_BOOKMARK_BUBBLE_SHOWN, ns_source); + registrar_.Add(this, chrome::NOTIFICATION_BOOKMARK_BUBBLE_HIDDEN, ns_source); + + model_ = profile->GetBookmarkModel(); + if (model_) { + model_->AddObserver(this); + if (model_->IsLoaded()) + Loaded(model_, false); + // else case: we'll receive notification back from the BookmarkModel when + // done loading, then we'll populate the bar. + } } int BookmarkBarView::GetBookmarkButtonCount() { @@ -1280,7 +1253,7 @@ views::TextButton* BookmarkBarView::CreateSyncErrorButton() { views::View* BookmarkBarView::CreateBookmarkButton(const BookmarkNode* node) { if (node->is_url()) { BookmarkButton* button = new BookmarkButton(this, node->url(), - UTF16ToWide(node->GetTitle()), profile_); + UTF16ToWide(node->GetTitle()), browser_->profile()); ConfigureButton(node, button); return button; } else { @@ -1393,8 +1366,8 @@ void BookmarkBarView::ShowDropFolderForNode(const BookmarkNode* node) { start_index = GetFirstHiddenNodeIndex(); drop_info_->is_menu_showing = true; - bookmark_drop_menu_ = new BookmarkMenuController( - profile_, page_navigator_, GetWidget(), node, start_index); + bookmark_drop_menu_ = new BookmarkMenuController(browser_->profile(), + page_navigator_, GetWidget(), node, start_index); bookmark_drop_menu_->set_observer(this); bookmark_drop_menu_->RunMenuAt(this, true); } @@ -1436,6 +1409,7 @@ void BookmarkBarView::CalculateDropLocation(const DropTargetEvent& event, bool found = false; const int other_delta_x = mirrored_x - other_bookmarked_button_->x(); + Profile* profile = browser_->profile(); if (other_bookmarked_button_->IsVisible() && other_delta_x >= 0 && other_delta_x < other_bookmarked_button_->width()) { // Mouse is over 'other' folder. @@ -1445,9 +1419,8 @@ void BookmarkBarView::CalculateDropLocation(const DropTargetEvent& event, } else if (!GetBookmarkButtonCount()) { // No bookmarks, accept the drop. location->index = 0; - int ops = data.GetFirstNode(profile_) - ? ui::DragDropTypes::DRAG_MOVE - : ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK; + int ops = data.GetFirstNode(profile) ? ui::DragDropTypes::DRAG_MOVE : + ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK; location->operation = bookmark_utils::PreferredDropOperation(event.source_operations(), ops); return; @@ -1510,18 +1483,16 @@ void BookmarkBarView::CalculateDropLocation(const DropTargetEvent& event, model_->other_node() : model_->bookmark_bar_node()->GetChild(location->index); location->operation = - bookmark_utils::BookmarkDropOperation(profile_, event, data, parent, + bookmark_utils::BookmarkDropOperation(profile, event, data, parent, parent->child_count()); if (!location->operation && !data.has_single_url() && - data.GetFirstNode(profile_) == parent) { + data.GetFirstNode(profile) == parent) { // Don't open a menu if the node being dragged is the menu to open. location->on = false; } } else { - location->operation = - bookmark_utils::BookmarkDropOperation(profile_, event, data, - model_->bookmark_bar_node(), - location->index); + location->operation = bookmark_utils::BookmarkDropOperation(profile, event, + data, model_->bookmark_bar_node(), location->index); } } @@ -1529,7 +1500,7 @@ void BookmarkBarView::WriteBookmarkDragData(const BookmarkNode* node, ui::OSExchangeData* data) { DCHECK(node && data); BookmarkNodeData drag_data(node); - drag_data.Write(profile_, data); + drag_data.Write(browser_->profile(), data); } void BookmarkBarView::StartThrobbing(const BookmarkNode* node, diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h index a3651e4..44aa561 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h @@ -70,13 +70,9 @@ class BookmarkBarView : public DetachableToolbarView, // Maximum size of buttons on the bookmark bar. static const int kMaxButtonWidth; - BookmarkBarView(Profile* profile, Browser* browser); + explicit BookmarkBarView(Browser* browser); virtual ~BookmarkBarView(); - // Resets the profile. This removes any buttons for the current profile and - // recreates the models. - void SetProfile(Profile* profile); - // Returns the current browser. Browser* browser() const { return browser_; } @@ -362,8 +358,6 @@ class BookmarkBarView : public DetachableToolbarView, NotificationRegistrar registrar_; - Profile* profile_; - // Used for opening urls. PageNavigator* page_navigator_; @@ -405,7 +399,7 @@ class BookmarkBarView : public DetachableToolbarView, ButtonSeparatorView* bookmarks_separator_view_; - // Owning browser. This is NULL during testing. + // Owning browser. Browser* browser_; // True if the owning browser is showing an infobar. diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc index 0f3cbf0..a27d3f2 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc @@ -11,12 +11,14 @@ #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/ui_test_utils.h" #include "chrome/test/base/testing_profile.h" #include "chrome/test/base/view_event_test_base.h" +#include "chrome/test/testing_browser_process.h" #include "content/browser/tab_contents/page_navigator.h" #include "content/common/notification_service.h" #include "grit/generated_resources.h" @@ -180,10 +182,12 @@ class BookmarkBarViewEventTestBase : public ViewEventTestBase { profile_->BlockUntilBookmarkModelLoaded(); profile_->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true); + browser_.reset(new Browser(Browser::TYPE_TABBED, profile_.get())); + model_ = profile_->GetBookmarkModel(); model_->ClearStore(); - bb_view_ = new BookmarkBarView(profile_.get(), NULL); + bb_view_.reset(new BookmarkBarView(browser_.get())); bb_view_->SetPageNavigator(&navigator_); AddTestData(CreateBigMenu()); @@ -200,7 +204,7 @@ class BookmarkBarViewEventTestBase : public ViewEventTestBase { // we brute force search for a size that triggers the overflow button. views::View tmp_parent; - tmp_parent.AddChildView(bb_view_); + tmp_parent.AddChildView(bb_view_.get()); bb_view_pref_ = bb_view_->GetPreferredSize(); bb_view_pref_.set_width(1000); @@ -211,12 +215,21 @@ class BookmarkBarViewEventTestBase : public ViewEventTestBase { bb_view_->Layout(); } - tmp_parent.RemoveChildView(bb_view_); + tmp_parent.RemoveChildView(bb_view_.get()); ViewEventTestBase::SetUp(); } virtual void TearDown() { + // Destroy everything, then run the message loop to ensure we delete all + // Tasks and fully shut down. + browser_->CloseAllTabs(); + bb_view_.reset(); + browser_.reset(); + profile_.reset(); + MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); + MessageLoop::current()->Run(); + ViewEventTestBase::TearDown(); BookmarkBarView::testing_ = false; views::ViewsDelegate::views_delegate = NULL; @@ -228,7 +241,7 @@ class BookmarkBarViewEventTestBase : public ViewEventTestBase { } virtual views::View* CreateContentsView() { - return bb_view_; + return bb_view_.get(); } virtual gfx::Size GetPreferredSize() { return bb_view_pref_; } @@ -241,7 +254,7 @@ class BookmarkBarViewEventTestBase : public ViewEventTestBase { virtual bool CreateBigMenu() { return false; } BookmarkModel* model_; - BookmarkBarView* bb_view_; + scoped_ptr<BookmarkBarView> bb_view_; TestingPageNavigator navigator_; private: @@ -275,7 +288,9 @@ class BookmarkBarViewEventTestBase : public ViewEventTestBase { } gfx::Size bb_view_pref_; + ScopedTestingBrowserProcess testing_browser_process_; scoped_ptr<TestingProfile> profile_; + scoped_ptr<Browser> browser_; BrowserThread ui_thread_; BrowserThread file_thread_; ViewsDelegateImpl views_delegate_; @@ -358,7 +373,7 @@ class BookmarkBarViewTest2 : public BookmarkBarViewEventTestBase { // true. If that changes, this code will need to find another empty space // to press the mouse on. gfx::Point mouse_loc; - views::View::ConvertPointToScreen(bb_view_, &mouse_loc); + views::View::ConvertPointToScreen(bb_view_.get(), &mouse_loc); ui_controls::SendMouseMove(0, 0); ui_controls::SendMouseEventsNotifyWhenDone( ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, @@ -1043,7 +1058,7 @@ class BookmarkBarViewTest11 : public BookmarkBarViewEventTestBase { // Now click on empty space. gfx::Point mouse_loc; - views::View::ConvertPointToScreen(bb_view_, &mouse_loc); + views::View::ConvertPointToScreen(bb_view_.get(), &mouse_loc); ui_controls::SendMouseMove(mouse_loc.x(), mouse_loc.y()); ui_controls::SendMouseEventsNotifyWhenDone( ui_controls::LEFT, ui_controls::UP | ui_controls::DOWN, diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc deleted file mode 100644 index 6c6478d..0000000 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2011 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/utf_string_conversions.h" -#include "chrome/browser/bookmarks/bookmark_model.h" -#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" -#include "chrome/test/base/browser_with_test_window_test.h" -#include "chrome/test/base/testing_profile.h" -#include "content/browser/browser_thread.h" - -typedef BrowserWithTestWindowTest BookmarkBarViewTest; - -TEST_F(BookmarkBarViewTest, SwitchProfile) { - profile()->CreateBookmarkModel(true); - profile()->BlockUntilBookmarkModelLoaded(); - - profile()->GetBookmarkModel()->AddURL( - profile()->GetBookmarkModel()->bookmark_bar_node(), - 0, - ASCIIToUTF16("blah"), - GURL("http://www.google.com")); - - BookmarkBarView bookmark_bar(profile(), browser()); - - EXPECT_EQ(1, bookmark_bar.GetBookmarkButtonCount()); - - TestingProfile profile2; - profile2.CreateBookmarkModel(true); - profile2.BlockUntilBookmarkModelLoaded(); - - bookmark_bar.SetProfile(&profile2); - - EXPECT_EQ(0, bookmark_bar.GetBookmarkButtonCount()); - - bookmark_bar.SetProfile(profile()); - EXPECT_EQ(1, bookmark_bar.GetBookmarkButtonCount()); -} diff --git a/chrome/browser/ui/views/compact_nav/compact_location_bar_view.cc b/chrome/browser/ui/views/compact_nav/compact_location_bar_view.cc index 6375c5e..98185e8 100644 --- a/chrome/browser/ui/views/compact_nav/compact_location_bar_view.cc +++ b/chrome/browser/ui/views/compact_nav/compact_location_bar_view.cc @@ -110,7 +110,6 @@ void CompactLocationBarView::Init() { // Location bar. location_bar_view_ = new LocationBarView( - browser()->profile(), browser(), browser()->toolbar_model(), clb_host(), diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 8adde3b..3085aed 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -2094,8 +2094,7 @@ bool BrowserView::MaybeShowBookmarkBar(TabContentsWrapper* contents) { if (browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR) && contents) { if (!bookmark_bar_view_.get()) { - bookmark_bar_view_.reset(new BookmarkBarView(contents->profile(), - browser_.get())); + bookmark_bar_view_.reset(new BookmarkBarView(browser_.get())); bookmark_bar_view_->set_parent_owned(false); bookmark_bar_view_->set_background( new BookmarkExtensionBackground(this, bookmark_bar_view_.get(), @@ -2103,8 +2102,6 @@ bool BrowserView::MaybeShowBookmarkBar(TabContentsWrapper* contents) { bookmark_bar_view_->SetBookmarkBarState( browser_->bookmark_bar_state(), BookmarkBar::DONT_ANIMATE_STATE_CHANGE); - } else { - bookmark_bar_view_->SetProfile(contents->profile()); } bookmark_bar_view_->SetPageNavigator(contents->tab_contents()); new_bookmark_bar_view = bookmark_bar_view_.get(); @@ -2644,7 +2641,7 @@ void BrowserView::SetToolbar(ToolbarView* toolbar) { toolbar_ = toolbar; if (toolbar) { AddChildView(toolbar_); - toolbar_->Init(browser_->profile()); + toolbar_->Init(); } } diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc index d7220b4..3123709 100644 --- a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc +++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc @@ -6,6 +6,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" +#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" #include "chrome/browser/ui/content_settings/content_setting_image_model.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" @@ -45,14 +46,12 @@ const double kAnimatingFraction = kOpenTimeMs * 1.0 / kMoveTimeMs; ContentSettingImageView::ContentSettingImageView( ContentSettingsType content_type, - LocationBarView* parent, - Profile* profile) + LocationBarView* parent) : ui::LinearAnimation(kMoveTimeMs, kFrameRateHz, NULL), content_setting_image_model_( ContentSettingImageModel::CreateContentSettingImageModel( content_type)), parent_(parent), - profile_(profile), bubble_(NULL), animation_in_progress_(false), text_size_(0), @@ -136,12 +135,13 @@ void ContentSettingImageView::OnMouseReleased(const views::MouseEvent& event) { gfx::Point origin(screen_bounds.origin()); views::View::ConvertPointToScreen(this, &origin); screen_bounds.set_origin(origin); + Profile* profile = parent_->browser()->profile(); ContentSettingBubbleContents* bubble_contents = new ContentSettingBubbleContents( ContentSettingBubbleModel::CreateContentSettingBubbleModel( - parent_->browser(), tab_contents, profile_, + parent_->browser(), tab_contents, profile, content_setting_image_model_->get_content_settings_type()), - profile_, tab_contents->tab_contents()); + profile, tab_contents->tab_contents()); bubble_ = Bubble::Show(GetWidget(), screen_bounds, BubbleBorder::TOP_RIGHT, bubble_contents, this); bubble_contents->set_bubble(bubble_); diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.h b/chrome/browser/ui/views/location_bar/content_setting_image_view.h index e500b90..3a948dd 100644 --- a/chrome/browser/ui/views/location_bar/content_setting_image_view.h +++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.h @@ -16,7 +16,6 @@ class ContentSettingImageModel; class Bubble; class LocationBarView; -class Profile; class TabContents; namespace views { @@ -28,11 +27,9 @@ class ContentSettingImageView : public views::ImageView, public ui::LinearAnimation { public: ContentSettingImageView(ContentSettingsType content_type, - LocationBarView* parent, - Profile* profile); + LocationBarView* parent); virtual ~ContentSettingImageView(); - void set_profile(Profile* profile) { profile_ = profile; } // |new_navigation| true if this is a new navigation, false if the tab was // just switched to. void UpdateFromTabContents(TabContents* tab_contents); @@ -61,9 +58,6 @@ class ContentSettingImageView : public views::ImageView, // The owning LocationBarView. LocationBarView* parent_; - // The currently active profile. - Profile* profile_; - // The currently shown info bubble if any. Bubble* bubble_; diff --git a/chrome/browser/ui/views/location_bar/keyword_hint_view.h b/chrome/browser/ui/views/location_bar/keyword_hint_view.h index e0a3858..0658f43 100644 --- a/chrome/browser/ui/views/location_bar/keyword_hint_view.h +++ b/chrome/browser/ui/views/location_bar/keyword_hint_view.h @@ -45,8 +45,6 @@ class KeywordHintView : public views::View { virtual gfx::Size GetMinimumSize(); virtual void Layout(); - void set_profile(Profile* profile) { profile_ = profile; } - private: views::Label* leading_label_; views::Label* trailing_label_; diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc index 34069d2..b9af06f 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc @@ -102,13 +102,11 @@ static const int kNormalModeBackgroundImages[] = { // LocationBarView ----------------------------------------------------------- -LocationBarView::LocationBarView(Profile* profile, - Browser* browser, +LocationBarView::LocationBarView(Browser* browser, ToolbarModel* model, Delegate* delegate, Mode mode) - : profile_(profile), - browser_(browser), + : browser_(browser), model_(model), delegate_(delegate), disposition_(CURRENT_TAB), @@ -127,7 +125,6 @@ LocationBarView::LocationBarView(Profile* profile, bubble_type_(FirstRun::MINIMAL_BUBBLE), template_url_service_(NULL), animation_offset_(0) { - DCHECK(profile_); set_id(VIEW_ID_LOCATION_BAR); set_focusable(true); @@ -135,7 +132,7 @@ LocationBarView::LocationBarView(Profile* profile, painter_.reset(new views::HorizontalPainter(kNormalModeBackgroundImages)); edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, - profile_->GetPrefs(), this); + browser_->profile()->GetPrefs(), this); } LocationBarView::~LocationBarView() { @@ -173,20 +170,20 @@ void LocationBarView::Init() { // URL edit field. // View container for URL edit field. + Profile* profile = browser_->profile(); #if defined(OS_WIN) if (views::Widget::IsPureViews()) { - OmniboxViewViews* omnibox_view = - new OmniboxViewViews(this, model_, profile_, - browser_->command_updater(), mode_ == POPUP, this); + OmniboxViewViews* omnibox_view = new OmniboxViewViews(this, model_, profile, + browser_->command_updater(), mode_ == POPUP, this); omnibox_view->Init(); location_entry_.reset(omnibox_view); } else { location_entry_.reset(new OmniboxViewWin(font_, this, model_, this, - GetWidget()->GetNativeView(), profile_, browser_->command_updater(), + GetWidget()->GetNativeView(), browser_->command_updater(), mode_ == POPUP, this)); } #else - location_entry_.reset(OmniboxViewGtk::Create(this, model_, profile_, + location_entry_.reset(OmniboxViewGtk::Create(this, model_, profile, browser_->command_updater(), mode_ == POPUP, this)); #endif @@ -195,22 +192,22 @@ void LocationBarView::Init() { selected_keyword_view_ = new SelectedKeywordView( kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, - GetColor(ToolbarModel::NONE, TEXT), profile_), + GetColor(ToolbarModel::NONE, TEXT), profile); AddChildView(selected_keyword_view_); selected_keyword_view_->SetFont(font_); selected_keyword_view_->SetVisible(false); SkColor dimmed_text = GetColor(ToolbarModel::NONE, DEEMPHASIZED_TEXT); - keyword_hint_view_ = new KeywordHintView(profile_); + keyword_hint_view_ = new KeywordHintView(profile); AddChildView(keyword_hint_view_); keyword_hint_view_->SetVisible(false); keyword_hint_view_->SetFont(font_); keyword_hint_view_->SetColor(dimmed_text); for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { - ContentSettingImageView* content_blocked_view = new ContentSettingImageView( - static_cast<ContentSettingsType>(i), this, profile_); + ContentSettingImageView* content_blocked_view = + new ContentSettingImageView(static_cast<ContentSettingsType>(i), this); content_setting_views_.push_back(content_blocked_view); AddChildView(content_blocked_view); content_blocked_view->SetVisible(false); @@ -347,19 +344,6 @@ void LocationBarView::OnFocus() { this, ui::AccessibilityTypes::EVENT_FOCUS, true); } -void LocationBarView::SetProfile(Profile* profile) { - DCHECK(profile); - if (profile_ != profile) { - profile_ = profile; - location_entry_->model()->SetProfile(profile); - selected_keyword_view_->set_profile(profile); - keyword_hint_view_->set_profile(profile); - for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); - i != content_setting_views_.end(); ++i) - (*i)->set_profile(profile); - } -} - void LocationBarView::SetPreviewEnabledPageAction(ExtensionAction* page_action, bool preview_enabled) { if (mode_ != NORMAL) @@ -406,7 +390,7 @@ void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) { views::View::ConvertPointToScreen(star_view_, &origin); screen_bounds.set_origin(origin); browser::ShowBookmarkBubbleView(GetWidget(), screen_bounds, star_view_, - profile_, url, newly_bookmarked); + browser_->profile(), url, newly_bookmarked); } gfx::Point LocationBarView::GetLocationEntryOrigin() const { @@ -572,12 +556,13 @@ void LocationBarView::Layout() { if (show_selected_keyword) { if (selected_keyword_view_->keyword() != keyword) { selected_keyword_view_->SetKeyword(keyword); + Profile* profile = browser_->profile(); const TemplateURL* template_url = - TemplateURLServiceFactory::GetForProfile(profile_)-> + TemplateURLServiceFactory::GetForProfile(profile)-> GetTemplateURLForKeyword(keyword); if (template_url && template_url->IsExtensionKeyword()) { - const SkBitmap& bitmap = profile_->GetExtensionService()-> - GetOmniboxIcon(template_url->GetExtensionId()); + const SkBitmap& bitmap = profile->GetExtensionService()->GetOmniboxIcon( + template_url->GetExtensionId()); selected_keyword_view_->SetImage(bitmap); selected_keyword_view_->set_is_extension_icon(true); } else { @@ -937,7 +922,7 @@ void LocationBarView::RefreshPageActionViews() { if (mode_ != NORMAL) return; - ExtensionService* service = profile_->GetExtensionService(); + ExtensionService* service = browser_->profile()->GetExtensionService(); if (!service) return; @@ -965,7 +950,7 @@ void LocationBarView::RefreshPageActionViews() { // inserted in left-to-right order for accessibility. for (int i = page_actions.size() - 1; i >= 0; --i) { page_action_views_[i] = new PageActionWithBadgeView( - new PageActionImageView(this, profile_, page_actions[i])); + new PageActionImageView(this, page_actions[i])); page_action_views_[i]->SetVisible(false); AddChildViewAt(page_action_views_[i], GetIndexOf(star_view_)); } @@ -1021,8 +1006,8 @@ void LocationBarView::ShowFirstRunBubbleInternal( if (base::i18n::IsRTL()) origin.set_x(width() - origin.x()); views::View::ConvertPointToScreen(this, &origin); - FirstRunBubble::Show(profile_, GetWidget(), gfx::Rect(origin, gfx::Size()), - BubbleBorder::TOP_LEFT, bubble_type); + FirstRunBubble::Show(browser_->profile(), GetWidget(), + gfx::Rect(origin, gfx::Size()), BubbleBorder::TOP_LEFT, bubble_type); #endif } @@ -1115,7 +1100,7 @@ bool LocationBarView::CanStartDragForView(View* sender, void LocationBarView::ShowFirstRunBubble(FirstRun::BubbleType bubble_type) { // Wait until search engines have loaded to show the first run bubble. TemplateURLService* url_service = - TemplateURLServiceFactory::GetForProfile(profile_); + TemplateURLServiceFactory::GetForProfile(browser_->profile()); if (!url_service->loaded()) { bubble_type_ = bubble_type; template_url_service_ = url_service; diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.h b/chrome/browser/ui/views/location_bar/location_bar_view.h index 6542df8..6104f2e 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.h +++ b/chrome/browser/ui/views/location_bar/location_bar_view.h @@ -41,7 +41,6 @@ class InstantController; class KeywordHintView; class LocationIconView; class PageActionWithBadgeView; -class Profile; class SelectedKeywordView; class StarView; class TabContents; @@ -118,8 +117,7 @@ class LocationBarView : public LocationBar, APP_LAUNCHER }; - LocationBarView(Profile* profile, - Browser* browser, + LocationBarView(Browser* browser, ToolbarModel* model, Delegate* delegate, Mode mode); @@ -141,8 +139,6 @@ class LocationBarView : public LocationBar, // saved state that the tab holds. void Update(const TabContents* tab_for_state_restoring); - void SetProfile(Profile* profile); - Profile* profile() const { return profile_; } Browser* browser() const { return browser_; } // Sets |preview_enabled| for the PageAction View associated with this @@ -339,9 +335,6 @@ class LocationBarView : public LocationBar, // Helper to show the first run info bubble. void ShowFirstRunBubbleInternal(FirstRun::BubbleType bubble_type); - // Current profile. Not owned by us. - Profile* profile_; - // The Autocomplete Edit field. scoped_ptr<OmniboxView> location_entry_; diff --git a/chrome/browser/ui/views/location_bar/page_action_image_view.cc b/chrome/browser/ui/views/location_bar/page_action_image_view.cc index f8168f4..36e1761 100644 --- a/chrome/browser/ui/views/location_bar/page_action_image_view.cc +++ b/chrome/browser/ui/views/location_bar/page_action_image_view.cc @@ -19,17 +19,16 @@ #include "views/controls/menu/menu_model_adapter.h" PageActionImageView::PageActionImageView(LocationBarView* owner, - Profile* profile, ExtensionAction* page_action) : owner_(owner), - profile_(profile), page_action_(page_action), ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)), current_tab_id_(-1), preview_enabled_(false), popup_(NULL) { - const Extension* extension = profile->GetExtensionService()-> - GetExtensionById(page_action->extension_id(), false); + const Extension* extension = owner_->browser()->profile()-> + GetExtensionService()->GetExtensionById(page_action->extension_id(), + false); DCHECK(extension); // Load all the icons declared in the manifest. This is the contents of the @@ -62,15 +61,6 @@ void PageActionImageView::ExecuteAction(int button, } if (page_action_->HasPopup(current_tab_id_)) { - // In tests, GetLastActive could return NULL, so we need to have - // a fallback. - // TODO(erikkay): Find a better way to get the Browser that this - // button is in. - Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); - if (!browser) - browser = BrowserList::FindBrowserWithProfile(profile_); - DCHECK(browser); - bool popup_showing = popup_ != NULL; // Always hide the current popup. Only one popup at a time. @@ -90,15 +80,16 @@ void PageActionImageView::ExecuteAction(int button, popup_ = ExtensionPopup::Show( page_action_->GetPopupUrl(current_tab_id_), - browser, + owner_->browser(), screen_bounds, arrow_location, inspect_with_devtools, this); // ExtensionPopup::Observer } else { - ExtensionService* service = profile_->GetExtensionService(); + Profile* profile = owner_->browser()->profile(); + ExtensionService* service = profile->GetExtensionService(); service->browser_event_router()->PageActionExecuted( - profile_, page_action_->extension_id(), page_action_->id(), + profile, page_action_->extension_id(), page_action_->id(), current_tab_id_, current_url_.spec(), button); } } @@ -143,23 +134,21 @@ bool PageActionImageView::OnKeyPressed(const views::KeyEvent& event) { void PageActionImageView::ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) { - const Extension* extension = profile_->GetExtensionService()-> - GetExtensionById(page_action()->extension_id(), false); + const Extension* extension = owner_->browser()->profile()-> + GetExtensionService()->GetExtensionById(page_action()->extension_id(), + false); if (!extension->ShowConfigureContextMenus()) return; - Browser* browser = BrowserView::GetBrowserViewForNativeWindow( - platform_util::GetTopLevel(GetWidget()->GetNativeView()))->browser(); - scoped_refptr<ExtensionContextMenuModel> context_menu_model( - new ExtensionContextMenuModel(extension, browser, this)); + new ExtensionContextMenuModel(extension, owner_->browser(), this)); views::MenuModelAdapter menu_model_adapter(context_menu_model.get()); views::MenuItemView menu(&menu_model_adapter); menu_model_adapter.BuildMenu(&menu); gfx::Point screen_loc; views::View::ConvertPointToScreen(this, &screen_loc); - menu.RunMenuAt(GetWidget(), NULL, gfx::Rect(screen_loc ,size()), + menu.RunMenuAt(GetWidget(), NULL, gfx::Rect(screen_loc, size()), views::MenuItemView::TOPLEFT, true); } diff --git a/chrome/browser/ui/views/location_bar/page_action_image_view.h b/chrome/browser/ui/views/location_bar/page_action_image_view.h index a594f11..5b045b2 100644 --- a/chrome/browser/ui/views/location_bar/page_action_image_view.h +++ b/chrome/browser/ui/views/location_bar/page_action_image_view.h @@ -25,7 +25,6 @@ class PageActionImageView : public views::ImageView, public ExtensionPopup::Observer { public: PageActionImageView(LocationBarView* owner, - Profile* profile, ExtensionAction* page_action); virtual ~PageActionImageView(); @@ -71,9 +70,6 @@ class PageActionImageView : public views::ImageView, // The location bar view that owns us. LocationBarView* owner_; - // The current profile (not owned by us). - Profile* profile_; - // The PageAction that this view represents. The PageAction is not owned by // us, it resides in the extension of this particular profile. ExtensionAction* page_action_; diff --git a/chrome/browser/ui/views/location_bar/selected_keyword_view.h b/chrome/browser/ui/views/location_bar/selected_keyword_view.h index 2e0c530..d4b714a 100644 --- a/chrome/browser/ui/views/location_bar/selected_keyword_view.h +++ b/chrome/browser/ui/views/location_bar/selected_keyword_view.h @@ -36,8 +36,6 @@ class SelectedKeywordView : public IconLabelBubbleView { void SetKeyword(const string16& keyword); string16 keyword() const { return keyword_; } - void set_profile(Profile* profile) { profile_ = profile; } - private: // The keyword we're showing. If empty, no keyword is selected. // NOTE: we don't cache the TemplateURL as it is possible for it to get diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc index 4477bb0..925ae2a 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc @@ -12,8 +12,6 @@ #include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/autocomplete/autocomplete_popup_model.h" #include "chrome/browser/command_updater.h" -#include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h" -#include "chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.h" #include "chrome/browser/ui/views/location_bar/location_bar_view.h" #include "chrome/common/chrome_notification_types.h" #include "content/browser/tab_contents/tab_contents.h" @@ -32,6 +30,12 @@ #include "views/controls/textfield/textfield.h" #include "views/layout/fill_layout.h" +#if defined(TOUCH_UI) +#include "chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.h" +#else +#include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h" +#endif + namespace { // Textfield for autocomplete that intercepts events that are necessary @@ -696,6 +700,6 @@ AutocompletePopupView* OmniboxViewViews::CreatePopupView( #else typedef AutocompletePopupContentsView AutocompleteContentsView; #endif - return new AutocompleteContentsView( - gfx::Font(), this, model_.get(), profile, location_bar); + return new AutocompleteContentsView(gfx::Font(), this, model_.get(), + location_bar); } diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc index 3d5f4ab..d2a97b8 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc @@ -28,6 +28,7 @@ #include "chrome/browser/command_updater.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/views/location_bar/location_bar_view.h" #include "chrome/common/chrome_notification_types.h" #include "content/browser/tab_contents/tab_contents.h" @@ -395,13 +396,13 @@ OmniboxViewWin::OmniboxViewWin(const gfx::Font& font, ToolbarModel* toolbar_model, LocationBarView* parent_view, HWND hwnd, - Profile* profile, CommandUpdater* command_updater, bool popup_window_mode, views::View* location_bar) - : model_(new AutocompleteEditModel(this, controller, profile)), + : model_(new AutocompleteEditModel(this, controller, + parent_view->browser()->profile())), popup_view_(new AutocompletePopupContentsView(font, this, model_.get(), - profile, location_bar)), + location_bar)), controller_(controller), parent_view_(parent_view), toolbar_model_(toolbar_model), diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.h b/chrome/browser/ui/views/omnibox/omnibox_view_win.h index dae9139..7542173 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_win.h +++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.h @@ -29,7 +29,6 @@ class AutocompleteEditController; class AutocompleteEditModel; class AutocompletePopupView; class LocationBarView; -class Profile; class TabContents; namespace views { @@ -66,7 +65,6 @@ class OmniboxViewWin ToolbarModel* toolbar_model, LocationBarView* parent_view, HWND hwnd, - Profile* profile, CommandUpdater* command_updater, bool popup_window_mode, views::View* location_bar); diff --git a/chrome/browser/ui/views/toolbar_view.cc b/chrome/browser/ui/views/toolbar_view.cc index e9159b6..1452c96 100644 --- a/chrome/browser/ui/views/toolbar_view.cc +++ b/chrome/browser/ui/views/toolbar_view.cc @@ -87,7 +87,6 @@ ToolbarView::ToolbarView(Browser* browser) location_bar_(NULL), browser_actions_(NULL), app_menu_(NULL), - profile_(NULL), browser_(browser), profiles_menu_contents_(NULL) { set_id(VIEW_ID_TOOLBAR); @@ -117,7 +116,7 @@ ToolbarView::~ToolbarView() { // already gone. } -void ToolbarView::Init(Profile* profile) { +void ToolbarView::Init() { back_menu_model_.reset(new BackForwardMenuModel( browser_, BackForwardMenuModel::BACKWARD_MENU)); forward_menu_model_.reset(new BackForwardMenuModel( @@ -144,8 +143,8 @@ void ToolbarView::Init(Profile* profile) { forward_->set_id(VIEW_ID_FORWARD_BUTTON); // Have to create this before |reload_| as |reload_|'s constructor needs it. - location_bar_ = new LocationBarView(profile, browser_, - model_, this, (display_mode_ == DISPLAYMODE_LOCATION) ? + location_bar_ = new LocationBarView(browser_, model_, this, + (display_mode_ == DISPLAYMODE_LOCATION) ? LocationBarView::POPUP : LocationBarView::NORMAL); reload_ = new ReloadButton(location_bar_, browser_); @@ -197,11 +196,10 @@ void ToolbarView::Init(Profile* profile) { AddChildView(app_menu_); location_bar_->Init(); - show_home_button_.Init(prefs::kShowHomeButton, profile->GetPrefs(), this); + show_home_button_.Init(prefs::kShowHomeButton, + browser_->profile()->GetPrefs(), this); browser_actions_->Init(); - SetProfile(profile); - // Accessibility specific tooltip text. if (BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser()) { back_->SetTooltipText( @@ -211,13 +209,6 @@ void ToolbarView::Init(Profile* profile) { } } -void ToolbarView::SetProfile(Profile* profile) { - if (profile != profile_) { - profile_ = profile; - location_bar_->SetProfile(profile); - } -} - void ToolbarView::Update(TabContents* tab, bool should_restore_state) { if (location_bar_) location_bar_->Update(should_restore_state ? tab : NULL); diff --git a/chrome/browser/ui/views/toolbar_view.h b/chrome/browser/ui/views/toolbar_view.h index 4874dfb..fd0a83c 100644 --- a/chrome/browser/ui/views/toolbar_view.h +++ b/chrome/browser/ui/views/toolbar_view.h @@ -46,11 +46,7 @@ class ToolbarView : public AccessiblePaneView, virtual ~ToolbarView(); // Create the contents of the Browser Toolbar - void Init(Profile* profile); - - // Sets the profile which is active on the currently-active tab. - void SetProfile(Profile* profile); - Profile* profile() { return profile_; } + void Init(); // Updates the toolbar (and transitively the location bar) with the states of // the specified |tab|. If |should_restore_state| is true, we're switching @@ -191,7 +187,6 @@ class ToolbarView : public AccessiblePaneView, LocationBarView* location_bar_; BrowserActionsContainer* browser_actions_; views::MenuButton* app_menu_; - Profile* profile_; Browser* browser_; // Contents of the profiles menu to populate with profile names. |