summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/autocomplete/autocomplete.cc15
-rw-r--r--chrome/browser/autocomplete/autocomplete.h9
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit.cc9
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit.h3
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_model.cc19
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_model.h13
-rw-r--r--chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h3
-rw-r--r--chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm12
-rw-r--r--chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc135
-rw-r--r--chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h23
-rw-r--r--chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc2
-rw-r--r--chrome/browser/ui/gtk/browser_toolbar_gtk.cc31
-rw-r--r--chrome/browser/ui/gtk/browser_toolbar_gtk.h7
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.cc7
-rw-r--r--chrome/browser/ui/gtk/location_bar_view_gtk.cc91
-rw-r--r--chrome/browser/ui/gtk/location_bar_view_gtk.h19
-rw-r--r--chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc5
-rw-r--r--chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h4
-rw-r--r--chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc2
-rw-r--r--chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc10
-rw-r--r--chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h3
-rw-r--r--chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.cc4
-rw-r--r--chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.h2
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc123
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_view.h10
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc29
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc38
-rw-r--r--chrome/browser/ui/views/compact_nav/compact_location_bar_view.cc1
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc7
-rw-r--r--chrome/browser/ui/views/location_bar/content_setting_image_view.cc10
-rw-r--r--chrome/browser/ui/views/location_bar/content_setting_image_view.h8
-rw-r--r--chrome/browser/ui/views/location_bar/keyword_hint_view.h2
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.cc59
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.h9
-rw-r--r--chrome/browser/ui/views/location_bar/page_action_image_view.cc35
-rw-r--r--chrome/browser/ui/views/location_bar/page_action_image_view.h4
-rw-r--r--chrome/browser/ui/views/location_bar/selected_keyword_view.h2
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_view_views.cc12
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_view_win.cc7
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_view_win.h2
-rw-r--r--chrome/browser/ui/views/toolbar_view.cc19
-rw-r--r--chrome/browser/ui/views/toolbar_view.h7
-rw-r--r--chrome/chrome_tests.gypi1
43 files changed, 286 insertions, 527 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc
index 6a87b83..b56c1bf 100644
--- a/chrome/browser/autocomplete/autocomplete.cc
+++ b/chrome/browser/autocomplete/autocomplete.cc
@@ -503,12 +503,6 @@ AutocompleteProvider::AutocompleteProvider(ACProviderListener* listener,
name_(name) {
}
-void AutocompleteProvider::SetProfile(Profile* profile) {
- DCHECK(profile);
- DCHECK(done_); // The controller should have already stopped us.
- profile_ = profile;
-}
-
void AutocompleteProvider::Stop() {
done_ = true;
}
@@ -835,15 +829,6 @@ AutocompleteController::~AutocompleteController() {
providers_.clear(); // Not really necessary.
}
-void AutocompleteController::SetProfile(Profile* profile) {
- Stop(true);
- for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); ++i)
- (*i)->SetProfile(profile);
- input_.Clear(); // Ensure we don't try to do a "minimal_changes" query on a
- // different profile.
- profile_ = profile;
-}
-
void AutocompleteController::Start(
const string16& text,
const string16& desired_tld,
diff --git a/chrome/browser/autocomplete/autocomplete.h b/chrome/browser/autocomplete/autocomplete.h
index 487e8bc..11ab0b7 100644
--- a/chrome/browser/autocomplete/autocomplete.h
+++ b/chrome/browser/autocomplete/autocomplete.h
@@ -359,11 +359,6 @@ class AutocompleteProvider
Profile* profile,
const char* name);
- // Invoked when the profile changes.
- // NOTE: Do not access any previous Profile* at this point as it may have
- // already been deleted.
- void SetProfile(Profile* profile);
-
// Called to start an autocomplete query. The provider is responsible for
// tracking its matches for this query and whether it is done processing the
// query. When new matches are available or the provider finishes, it
@@ -611,10 +606,6 @@ class AutocompleteController : public ACProviderListener {
#endif
~AutocompleteController();
- // Invoked when the profile changes. This forwards the call down to all
- // the AutocompleteProviders.
- void SetProfile(Profile* profile);
-
// Starts an autocomplete query, which continues until all providers are
// done or the query is Stop()ed. It is safe to Start() a new query without
// Stop()ing the previous one.
diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc
index 3d1d19e..f015a46 100644
--- a/chrome/browser/autocomplete/autocomplete_edit.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit.cc
@@ -89,13 +89,6 @@ AutocompleteEditModel::AutocompleteEditModel(
AutocompleteEditModel::~AutocompleteEditModel() {
}
-void AutocompleteEditModel::SetProfile(Profile* profile) {
- DCHECK(profile);
- profile_ = profile;
- autocomplete_controller_->SetProfile(profile);
- popup_->set_profile(profile);
-}
-
const AutocompleteEditModel::State
AutocompleteEditModel::GetStateForTabSwitch() {
// Like typing, switching tabs "accepts" the temporary text as the user
@@ -236,7 +229,7 @@ void AutocompleteEditModel::OnChanged() {
// Start Prerender of this page instead.
CHECK(tab->tab_contents());
prerender::PrerenderManager* prerender_manager =
- tab->profile()->GetPrerenderManager();
+ profile_->GetPrerenderManager();
if (prerender_manager) {
prerender_manager->AddPrerenderFromOmnibox(
CurrentMatch().destination_url);
diff --git a/chrome/browser/autocomplete/autocomplete_edit.h b/chrome/browser/autocomplete/autocomplete_edit.h
index 5bd9ce2..44a65bf 100644
--- a/chrome/browser/autocomplete/autocomplete_edit.h
+++ b/chrome/browser/autocomplete/autocomplete_edit.h
@@ -119,9 +119,6 @@ class AutocompleteEditModel : public AutocompleteControllerDelegate {
AutocompleteEditController* controller() const { return controller_; }
- // Invoked when the profile has changed.
- void SetProfile(Profile* profile);
-
Profile* profile() const { return profile_; }
// Returns the current state. This assumes we are switching tabs, and changes
diff --git a/chrome/browser/autocomplete/autocomplete_popup_model.cc b/chrome/browser/autocomplete/autocomplete_popup_model.cc
index 459560f..041e1f0 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_model.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup_model.cc
@@ -25,11 +25,9 @@
AutocompletePopupModel::AutocompletePopupModel(
AutocompletePopupView* popup_view,
- AutocompleteEditModel* edit_model,
- Profile* profile)
+ AutocompleteEditModel* edit_model)
: view_(popup_view),
edit_model_(edit_model),
- profile_(profile),
hovered_line_(kNoMatch),
selected_line_(kNoMatch) {
edit_model->set_popup_model(this);
@@ -136,7 +134,7 @@ bool AutocompletePopupModel::GetKeywordForMatch(const AutocompleteMatch& match,
if (match.template_url) {
TemplateURLService* url_service =
- TemplateURLServiceFactory::GetForProfile(profile_);
+ TemplateURLServiceFactory::GetForProfile(edit_model_->profile());
if (!url_service)
return false;
@@ -171,8 +169,9 @@ bool AutocompletePopupModel::GetKeywordForText(const string16& text,
if (keyword_hint.empty())
return false;
+ Profile* profile = edit_model_->profile();
TemplateURLService* url_service =
- TemplateURLServiceFactory::GetForProfile(profile_);
+ TemplateURLServiceFactory::GetForProfile(profile);
if (!url_service)
return false;
url_service->Load();
@@ -185,12 +184,10 @@ bool AutocompletePopupModel::GetKeywordForText(const string16& text,
// Don't provide a hint for inactive/disabled extension keywords.
if (template_url->IsExtensionKeyword()) {
- const Extension* extension = profile_->GetExtensionService()->
+ const Extension* extension = profile->GetExtensionService()->
GetExtensionById(template_url->GetExtensionId(), false);
- if (!extension ||
- (profile_->IsOffTheRecord() &&
- !profile_->GetExtensionService()->
- IsIncognitoEnabled(extension->id())))
+ if (!extension || (profile->IsOffTheRecord() &&
+ !profile->GetExtensionService()->IsIncognitoEnabled(extension->id())))
return false;
}
@@ -250,7 +247,7 @@ const SkBitmap* AutocompletePopupModel::GetIconIfExtensionMatch(
if (!match.template_url || !match.template_url->IsExtensionKeyword())
return NULL;
- return &profile_->GetExtensionService()->GetOmniboxPopupIcon(
+ return &edit_model_->profile()->GetExtensionService()->GetOmniboxPopupIcon(
match.template_url->GetExtensionId());
}
diff --git a/chrome/browser/autocomplete/autocomplete_popup_model.h b/chrome/browser/autocomplete/autocomplete_popup_model.h
index fc971aa..173800a 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_model.h
+++ b/chrome/browser/autocomplete/autocomplete_popup_model.h
@@ -11,22 +11,14 @@
#include "chrome/browser/autocomplete/autocomplete_edit.h"
class AutocompletePopupView;
-class Profile;
class SkBitmap;
class AutocompletePopupModel {
public:
AutocompletePopupModel(AutocompletePopupView* popup_view,
- AutocompleteEditModel* edit_model,
- Profile* profile);
+ AutocompleteEditModel* edit_model);
~AutocompletePopupModel();
- // Invoked when the profile has changed.
- void set_profile(Profile* profile) { profile_ = profile; }
-
- // TODO(sky): see about removing this.
- Profile* profile() const { return profile_; }
-
// Returns true if the popup is currently open.
bool IsOpen() const;
@@ -115,9 +107,6 @@ class AutocompletePopupModel {
AutocompleteEditModel* edit_model_;
- // Profile for current tab.
- Profile* profile_;
-
// The line that's currently hovered. If we're not drawing a hover rect,
// this will be kNoMatch, even if the cursor is over the popup contents.
size_t hovered_line_;
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h
index c46133d..3e585ad 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h
@@ -135,8 +135,9 @@ class OmniboxPopupViewMac : public AutocompletePopupView,
// Returns whether or not to show the instant opt-in prompt.
bool ShouldShowInstantOptIn();
- scoped_ptr<AutocompletePopupModel> model_;
OmniboxViewMac* omnibox_view_;
+ scoped_ptr<AutocompletePopupModel> model_;
+ Profile* profile_;
NSTextField* field_; // owned by tab controller
// Child window containing a matrix which implements the popup.
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm
index 984f66c..f73d25c 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm
@@ -284,8 +284,9 @@ OmniboxPopupViewMac::OmniboxPopupViewMac(OmniboxViewMac* omnibox_view,
AutocompleteEditModel* edit_model,
Profile* profile,
NSTextField* field)
- : model_(new AutocompletePopupModel(this, edit_model, profile)),
- omnibox_view_(omnibox_view),
+ : omnibox_view_(omnibox_view),
+ model_(new AutocompletePopupModel(this, edit_model)),
+ profile_(profile),
field_(field),
popup_(nil),
opt_in_controller_(nil),
@@ -549,12 +550,11 @@ void OmniboxPopupViewMac::OpenURLForRow(int row, bool force_background) {
}
void OmniboxPopupViewMac::UserPressedOptIn(bool opt_in) {
- PromoCounter* counter = model_->profile()->GetInstantPromoCounter();
+ PromoCounter* counter = profile_->GetInstantPromoCounter();
DCHECK(counter);
counter->Hide();
if (opt_in) {
- browser::ShowInstantConfirmDialogIfNecessary([field_ window],
- model_->profile());
+ browser::ShowInstantConfirmDialogIfNecessary([field_ window], profile_);
}
// This call will remove and delete |opt_in_controller_|.
@@ -562,7 +562,7 @@ void OmniboxPopupViewMac::UserPressedOptIn(bool opt_in) {
}
bool OmniboxPopupViewMac::ShouldShowInstantOptIn() {
- PromoCounter* counter = model_->profile()->GetInstantPromoCounter();
+ PromoCounter* counter = profile_->GetInstantPromoCounter();
return (counter && counter->ShouldShow(base::Time::Now()));
}
diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc
index b53e9c5..98639f8 100644
--- a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc
+++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc
@@ -121,10 +121,9 @@ void RecordAppLaunch(Profile* profile, const GURL& url) {
const int BookmarkBarGtk::kBookmarkBarNTPHeight = 57;
BookmarkBarGtk::BookmarkBarGtk(BrowserWindowGtk* window,
- Profile* profile, Browser* browser,
+ Browser* browser,
TabstripOriginProvider* tabstrip_origin_provider)
- : profile_(NULL),
- page_navigator_(NULL),
+ : page_navigator_(NULL),
browser_(browser),
window_(window),
tabstrip_origin_provider_(tabstrip_origin_provider),
@@ -134,7 +133,7 @@ BookmarkBarGtk::BookmarkBarGtk(BrowserWindowGtk* window,
dragged_node_(NULL),
drag_icon_(NULL),
toolbar_drop_item_(NULL),
- theme_service_(GtkThemeService::GetFrom(profile)),
+ theme_service_(GtkThemeService::GetFrom(browser->profile())),
show_instructions_(true),
menu_bar_helper_(this),
slide_animation_(this),
@@ -142,6 +141,7 @@ BookmarkBarGtk::BookmarkBarGtk(BrowserWindowGtk* window,
throbbing_widget_(NULL),
method_factory_(this),
bookmark_bar_state_(BookmarkBar::DETACHED) {
+ Profile* profile = browser->profile();
if (profile->GetProfileSyncService()) {
// Obtain a pointer to the profile sync service and add our instance as an
// observer.
@@ -149,8 +149,7 @@ BookmarkBarGtk::BookmarkBarGtk(BrowserWindowGtk* window,
sync_service_->AddObserver(this);
}
- Init(profile);
- SetProfile(profile);
+ Init();
// Force an update by simulating being in the wrong state.
// BrowserWindowGtk sets our true state after we're created.
SetBookmarkBarState(BookmarkBar::SHOW,
@@ -160,44 +159,21 @@ BookmarkBarGtk::BookmarkBarGtk(BrowserWindowGtk* window,
Source<ThemeService>(theme_service_));
edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled,
- profile_->GetPrefs(), this);
+ profile->GetPrefs(), this);
OnEditBookmarksEnabledChanged();
}
BookmarkBarGtk::~BookmarkBarGtk() {
- RemoveAllBookmarkButtons();
+ RemoveAllButtons();
bookmark_toolbar_.Destroy();
event_box_.Destroy();
}
-void BookmarkBarGtk::SetProfile(Profile* profile) {
- DCHECK(profile);
- if (profile_ == profile)
- return;
-
- RemoveAllBookmarkButtons();
-
- profile_ = profile;
-
- if (model_)
- model_->RemoveObserver(this);
-
- // TODO(erg): Handle extensions
-
- model_ = profile_->GetBookmarkModel();
- 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 BookmarkBarGtk::SetPageNavigator(PageNavigator* navigator) {
page_navigator_ = navigator;
}
-void BookmarkBarGtk::Init(Profile* profile) {
+void BookmarkBarGtk::Init() {
event_box_.Own(gtk_event_box_new());
g_signal_connect(event_box_.get(), "destroy",
G_CALLBACK(&OnEventBoxDestroyThunk), this);
@@ -221,6 +197,7 @@ void BookmarkBarGtk::Init(Profile* profile) {
instructions_ = gtk_alignment_new(0, 0, 1, 1);
gtk_alignment_set_padding(GTK_ALIGNMENT(instructions_), 0, 0,
kInstructionsPadding, 0);
+ Profile* profile = browser_->profile();
instructions_gtk_.reset(new BookmarkBarInstructionsGtk(this, profile));
gtk_container_add(GTK_CONTAINER(instructions_), instructions_gtk_->widget());
gtk_box_pack_start(GTK_BOX(bookmark_hbox_), instructions_,
@@ -310,6 +287,15 @@ void BookmarkBarGtk::Init(Profile* profile) {
gtk_widget_show_all(widget());
gtk_widget_hide(widget());
+
+ AddCoreButtons();
+ // TODO(erg): Handle extensions
+ model_ = profile->GetBookmarkModel();
+ 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 BookmarkBarGtk::SetBookmarkBarState(
@@ -398,7 +384,7 @@ void BookmarkBarGtk::PopupForButton(GtkWidget* button) {
}
current_menu_.reset(
- new BookmarkMenuController(browser_, profile_, page_navigator_,
+ new BookmarkMenuController(browser_, browser_->profile(), page_navigator_,
GTK_WINDOW(gtk_widget_get_toplevel(button)),
node,
button == overflow_button_ ?
@@ -506,26 +492,6 @@ void BookmarkBarGtk::Hide(BookmarkBar::State old_state,
}
}
-void BookmarkBarGtk::CreateAllBookmarkButtons() {
- const BookmarkNode* bar = model_->bookmark_bar_node();
- DCHECK(bar && model_->other_node());
-
- // Create a button for each of the children on the bookmark bar.
- for (int i = 0; i < bar->child_count(); ++i) {
- const BookmarkNode* node = bar->GetChild(i);
- GtkToolItem* item = CreateBookmarkToolItem(node);
- gtk_toolbar_insert(GTK_TOOLBAR(bookmark_toolbar_.get()), item, -1);
- if (node->is_folder())
- menu_bar_helper_.Add(gtk_bin_get_child(GTK_BIN(item)));
- }
-
- bookmark_utils::ConfigureButtonForNode(model_->other_node(),
- model_, other_bookmarks_button_, theme_service_);
-
- SetInstructionState();
- SetChevronState();
-}
-
void BookmarkBarGtk::SetInstructionState() {
if (model_)
show_instructions_ = model_->bookmark_bar_node()->empty();
@@ -563,13 +529,39 @@ void BookmarkBarGtk::UpdateOtherBookmarksVisibility() {
gtk_widget_set_visible(other_bookmarks_separator_, has_other_children);
}
-void BookmarkBarGtk::RemoveAllBookmarkButtons() {
+void BookmarkBarGtk::RemoveAllButtons() {
gtk_util::RemoveAllChildren(bookmark_toolbar_.get());
menu_bar_helper_.Clear();
+}
+
+void BookmarkBarGtk::AddCoreButtons() {
menu_bar_helper_.Add(other_bookmarks_button_);
menu_bar_helper_.Add(overflow_button_);
}
+void BookmarkBarGtk::ResetButtons() {
+ RemoveAllButtons();
+ AddCoreButtons();
+
+ const BookmarkNode* bar = model_->bookmark_bar_node();
+ DCHECK(bar && model_->other_node());
+
+ // Create a button for each of the children on the bookmark bar.
+ for (int i = 0; i < bar->child_count(); ++i) {
+ const BookmarkNode* node = bar->GetChild(i);
+ GtkToolItem* item = CreateBookmarkToolItem(node);
+ gtk_toolbar_insert(GTK_TOOLBAR(bookmark_toolbar_.get()), item, -1);
+ if (node->is_folder())
+ menu_bar_helper_.Add(gtk_bin_get_child(GTK_BIN(item)));
+ }
+
+ bookmark_utils::ConfigureButtonForNode(model_->other_node(),
+ model_, other_bookmarks_button_, theme_service_);
+
+ SetInstructionState();
+ SetChevronState();
+}
+
int BookmarkBarGtk::GetBookmarkButtonCount() {
GList* children = gtk_container_get_children(
GTK_CONTAINER(bookmark_toolbar_.get()));
@@ -853,8 +845,7 @@ void BookmarkBarGtk::Loaded(BookmarkModel* model, bool ids_reassigned) {
return;
UpdateOtherBookmarksVisibility();
- RemoveAllBookmarkButtons();
- CreateAllBookmarkButtons();
+ ResetButtons();
}
void BookmarkBarGtk::BookmarkModelBeingDeleted(BookmarkModel* model) {
@@ -949,9 +940,7 @@ void BookmarkBarGtk::BookmarkNodeChildrenReordered(BookmarkModel* model,
if (node != model_->bookmark_bar_node())
return; // We only care about reordering of the bookmark bar node.
- // Purge and rebuild the bar.
- RemoveAllBookmarkButtons();
- CreateAllBookmarkButtons();
+ ResetButtons();
}
void BookmarkBarGtk::Observe(int type,
@@ -961,8 +950,7 @@ void BookmarkBarGtk::Observe(int type,
if (model_ && model_->IsLoaded()) {
// Regenerate the bookmark bar with all new objects with their theme
// properties set correctly for the new theme.
- RemoveAllBookmarkButtons();
- CreateAllBookmarkButtons();
+ ResetButtons();
}
// Resize the bookmark bar since the target height may have changed.
@@ -1119,7 +1107,7 @@ void BookmarkBarGtk::PopupMenuForNode(GtkWidget* sender,
GtkWindow* window = GTK_WINDOW(gtk_widget_get_toplevel(sender));
current_context_menu_controller_.reset(
new BookmarkContextMenuController(
- window, this, profile_, page_navigator_, parent, nodes));
+ window, this, browser_->profile(), page_navigator_, parent, nodes));
current_context_menu_.reset(
new MenuGtk(NULL, current_context_menu_controller_->menu_model()));
current_context_menu_->PopupAsContext(
@@ -1157,10 +1145,10 @@ void BookmarkBarGtk::OnClicked(GtkWidget* sender) {
DCHECK(node->is_url());
DCHECK(page_navigator_);
- RecordAppLaunch(profile_, node->url());
- bookmark_utils::OpenAll(window_->GetNativeHandle(),
- profile_, page_navigator_, node,
- gtk_util::DispositionForCurrentButtonPressEvent());
+ Profile* profile = browser_->profile();
+ RecordAppLaunch(profile, node->url());
+ bookmark_utils::OpenAll(window_->GetNativeHandle(), profile, page_navigator_,
+ node, gtk_util::DispositionForCurrentButtonPressEvent());
UserMetrics::RecordAction(UserMetricsAction("ClickedBookmarkBarURLButton"));
}
@@ -1220,12 +1208,14 @@ void BookmarkBarGtk::OnButtonDragEnd(GtkWidget* button,
g_object_unref(button->parent);
}
-void BookmarkBarGtk::OnButtonDragGet(GtkWidget* widget, GdkDragContext* context,
+void BookmarkBarGtk::OnButtonDragGet(GtkWidget* widget,
+ GdkDragContext* context,
GtkSelectionData* selection_data,
- guint target_type, guint time) {
+ guint target_type,
+ guint time) {
const BookmarkNode* node = bookmark_utils::BookmarkNodeForWidget(widget);
bookmark_utils::WriteBookmarkToSelection(node, selection_data, target_type,
- profile_);
+ browser_->profile());
}
void BookmarkBarGtk::OnFolderClicked(GtkWidget* sender) {
@@ -1240,9 +1230,8 @@ void BookmarkBarGtk::OnFolderClicked(GtkWidget* sender) {
PopupForButton(sender);
} else if (event->button.button == 2) {
const BookmarkNode* node = GetNodeForToolButton(sender);
- bookmark_utils::OpenAll(window_->GetNativeHandle(),
- profile_, page_navigator_,
- node, NEW_BACKGROUND_TAB);
+ bookmark_utils::OpenAll(window_->GetNativeHandle(), browser_->profile(),
+ page_navigator_, node, NEW_BACKGROUND_TAB);
}
}
@@ -1304,7 +1293,7 @@ void BookmarkBarGtk::OnDragReceived(GtkWidget* widget,
std::vector<const BookmarkNode*> nodes =
bookmark_utils::GetNodesFromSelection(context, selection_data,
target_type,
- profile_,
+ browser_->profile(),
&delete_selection_data,
&dnd_success);
DCHECK(!nodes.empty());
diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h
index 0f4851c..245166a 100644
--- a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h
+++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h
@@ -37,7 +37,6 @@ class CustomContainerButton;
class GtkThemeService;
class MenuGtk;
class PageNavigator;
-class Profile;
class TabstripOriginProvider;
class BookmarkBarGtk : public ui::AnimationDelegate,
@@ -52,18 +51,10 @@ class BookmarkBarGtk : public ui::AnimationDelegate,
static const int kBookmarkBarNTPHeight;
BookmarkBarGtk(BrowserWindowGtk* window,
- Profile* profile,
Browser* browser,
TabstripOriginProvider* tabstrip_origin_provider);
virtual ~BookmarkBarGtk();
- // Resets the profile. This removes any buttons for the current profile and
- // recreates the models.
- void SetProfile(Profile* profile);
-
- // Returns the current profile.
- Profile* GetProfile() { return profile_; }
-
// Returns the current browser.
Browser* browser() const { return browser_; }
@@ -75,7 +66,7 @@ class BookmarkBarGtk : public ui::AnimationDelegate,
void SetPageNavigator(PageNavigator* navigator);
// Create the contents of the bookmark bar.
- void Init(Profile* profile);
+ void Init();
// Changes the state of the bookmark bar.
void SetBookmarkBarState(BookmarkBar::State state,
@@ -134,8 +125,14 @@ class BookmarkBarGtk : public ui::AnimationDelegate,
// bookmarks in it.
void UpdateOtherBookmarksVisibility();
- // Helper function which destroys all the bookmark buttons in the GtkToolbar.
- void RemoveAllBookmarkButtons();
+ // Destroys all the bookmark buttons in the GtkToolbar.
+ void RemoveAllButtons();
+
+ // Adds the "other bookmarks" and overflow buttons.
+ void AddCoreButtons();
+
+ // Removes and recreates all buttons in the bar.
+ void ResetButtons();
// Returns the number of buttons corresponding to starred urls/folders. This
// is equivalent to the number of children the bookmark bar node from the
@@ -302,8 +299,6 @@ class BookmarkBarGtk : public ui::AnimationDelegate,
// Updates the drag&drop state when |edit_bookmarks_enabled_| changes.
void OnEditBookmarksEnabledChanged();
- Profile* profile_;
-
// Used for opening urls.
PageNavigator* page_navigator_;
diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc
index ea18968..030ab1e 100644
--- a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc
+++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc
@@ -37,7 +37,7 @@ class BookmarkBarGtkUnittest : public TestingBrowserProcessTest {
browser_.reset(new Browser(Browser::TYPE_TABBED, profile_.get()));
origin_provider_.reset(new EmptyTabstripOriginProvider);
- bookmark_bar_.reset(new BookmarkBarGtk(NULL, profile_.get(), browser_.get(),
+ bookmark_bar_.reset(new BookmarkBarGtk(NULL, browser_.get(),
origin_provider_.get()));
}
diff --git a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc
index 276fe06..09e6285 100644
--- a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc
@@ -89,8 +89,7 @@ BrowserToolbarGtk::BrowserToolbarGtk(Browser* browser, BrowserWindowGtk* window)
model_(browser->toolbar_model()),
wrench_menu_model_(this, browser),
browser_(browser),
- window_(window),
- profile_(NULL) {
+ window_(window) {
browser_->command_updater()->AddCommandObserver(IDC_BACK, this);
browser_->command_updater()->AddCommandObserver(IDC_FORWARD, this);
browser_->command_updater()->AddCommandObserver(IDC_HOME, this);
@@ -112,11 +111,8 @@ BrowserToolbarGtk::~BrowserToolbarGtk() {
wrench_menu_.reset();
}
-void BrowserToolbarGtk::Init(Profile* profile,
- GtkWindow* top_level_window) {
- // Make sure to tell the location bar the profile before calling its Init.
- SetProfile(profile);
-
+void BrowserToolbarGtk::Init(GtkWindow* top_level_window) {
+ Profile* profile = browser_->profile();
theme_service_ = GtkThemeService::GetFrom(profile);
registrar_.Add(this,
chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
@@ -165,9 +161,8 @@ void BrowserToolbarGtk::Init(Profile* profile,
gtk_box_pack_start(GTK_BOX(toolbar_left_), reload_->widget(), FALSE, FALSE,
0);
- home_.reset(new CustomDrawButton(GtkThemeService::GetFrom(profile_),
- IDR_HOME, IDR_HOME_P, IDR_HOME_H, 0, GTK_STOCK_HOME,
- GTK_ICON_SIZE_SMALL_TOOLBAR));
+ home_.reset(new CustomDrawButton(theme_service_, IDR_HOME, IDR_HOME_P,
+ IDR_HOME_H, 0, GTK_STOCK_HOME, GTK_ICON_SIZE_SMALL_TOOLBAR));
gtk_widget_set_tooltip_text(home_->widget(),
l10n_util::GetStringUTF8(IDS_TOOLTIP_HOME).c_str());
g_signal_connect(home_->widget(), "clicked",
@@ -200,10 +195,8 @@ void BrowserToolbarGtk::Init(Profile* profile,
wrench_menu_image_ = gtk_image_new_from_pixbuf(
theme_service_->GetRTLEnabledPixbufNamed(IDR_TOOLS));
- wrench_menu_button_.reset(new CustomDrawButton(
- GtkThemeService::GetFrom(profile_),
- IDR_TOOLS, IDR_TOOLS_P, IDR_TOOLS_H, 0,
- wrench_menu_image_));
+ wrench_menu_button_.reset(new CustomDrawButton(theme_service_, IDR_TOOLS,
+ IDR_TOOLS_P, IDR_TOOLS_H, 0, wrench_menu_image_));
GtkWidget* wrench_button = wrench_menu_button_->widget();
gtk_widget_set_tooltip_text(
@@ -224,7 +217,7 @@ void BrowserToolbarGtk::Init(Profile* profile,
wrench_menu_.reset(new MenuGtk(this, &wrench_menu_model_));
registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
- Source<HostZoomMap>(browser_->profile()->GetHostZoomMap()));
+ Source<HostZoomMap>(profile->GetHostZoomMap()));
if (ShouldOnlyShowLocation()) {
gtk_widget_show(event_box_);
@@ -399,14 +392,6 @@ void BrowserToolbarGtk::Observe(int type,
// BrowserToolbarGtk, public ---------------------------------------------------
-void BrowserToolbarGtk::SetProfile(Profile* profile) {
- if (profile == profile_)
- return;
-
- profile_ = profile;
- location_bar_->SetProfile(profile);
-}
-
void BrowserToolbarGtk::UpdateTabContents(TabContents* contents,
bool should_restore_state) {
location_bar_->Update(should_restore_state ? contents : NULL);
diff --git a/chrome/browser/ui/gtk/browser_toolbar_gtk.h b/chrome/browser/ui/gtk/browser_toolbar_gtk.h
index cd5d864..00e14d9 100644
--- a/chrome/browser/ui/gtk/browser_toolbar_gtk.h
+++ b/chrome/browser/ui/gtk/browser_toolbar_gtk.h
@@ -31,7 +31,6 @@ class CustomDrawButton;
class GtkThemeService;
class LocationBar;
class LocationBarViewGtk;
-class Profile;
class ReloadButtonGtk;
class TabContents;
class ToolbarModel;
@@ -48,7 +47,7 @@ class BrowserToolbarGtk : public CommandUpdater::CommandObserver,
// Create the contents of the toolbar. |top_level_window| is the GtkWindow
// to which we attach our accelerators.
- void Init(Profile* profile, GtkWindow* top_level_window);
+ void Init(GtkWindow* top_level_window);
// Set the various widgets' ViewIDs.
void SetViewIDs();
@@ -101,9 +100,6 @@ class BrowserToolbarGtk : public CommandUpdater::CommandObserver,
const NotificationSource& source,
const NotificationDetails& details);
- Profile* profile() { return profile_; }
- void SetProfile(Profile* profile);
-
// Message that we should react to a state change.
void UpdateTabContents(TabContents* contents, bool should_restore_state);
@@ -194,7 +190,6 @@ class BrowserToolbarGtk : public CommandUpdater::CommandObserver,
Browser* browser_;
BrowserWindowGtk* window_;
- Profile* profile_;
// Controls whether or not a home button should be shown on the toolbar.
BooleanPrefMember show_home_button_;
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc
index 6320fcb..292ff4b 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_window_gtk.cc
@@ -1302,10 +1302,8 @@ void BrowserWindowGtk::MaybeShowBookmarkBar(bool animate) {
TabContentsWrapper* tab = GetDisplayedTab();
- if (tab) {
- bookmark_bar_->SetProfile(tab->profile());
+ if (tab)
bookmark_bar_->SetPageNavigator(browser_.get());
- }
BookmarkBar::State state = browser_->bookmark_bar_state();
if (contents_container_->HasPreview() && state == BookmarkBar::DETACHED)
@@ -1684,7 +1682,7 @@ void BrowserWindowGtk::InitWidgets() {
0);
toolbar_.reset(new BrowserToolbarGtk(browser_.get(), this));
- toolbar_->Init(browser_->profile(), window_);
+ toolbar_->Init(window_);
gtk_box_pack_start(GTK_BOX(window_vbox_), toolbar_->widget(),
FALSE, FALSE, 0);
g_signal_connect_after(toolbar_->widget(), "expose-event",
@@ -1750,7 +1748,6 @@ void BrowserWindowGtk::InitWidgets() {
if (IsBookmarkBarSupported()) {
bookmark_bar_.reset(new BookmarkBarGtk(this,
- browser_->profile(),
browser_.get(),
tabstrip_.get()));
PlaceBookmarkBar(false);
diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
index 10fc40d..5b32b01 100644
--- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
@@ -161,7 +161,6 @@ LocationBarViewGtk::LocationBarViewGtk(Browser* browser)
tab_to_search_hint_leading_label_(NULL),
tab_to_search_hint_icon_(NULL),
tab_to_search_hint_trailing_label_(NULL),
- profile_(NULL),
command_updater_(browser->command_updater()),
toolbar_model_(browser->toolbar_model()),
browser_(browser),
@@ -187,7 +186,8 @@ LocationBarViewGtk::~LocationBarViewGtk() {
void LocationBarViewGtk::Init(bool popup_window_mode) {
popup_window_mode_ = popup_window_mode;
- theme_service_ = GtkThemeService::GetFrom(profile_);
+ Profile* profile = browser_->profile();
+ theme_service_ = GtkThemeService::GetFrom(profile);
// Create the widget first, so we can pass it to the OmniboxViewGtk.
hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding));
@@ -199,12 +199,8 @@ void LocationBarViewGtk::Init(bool popup_window_mode) {
gtk_widget_set_redraw_on_allocate(hbox_.get(), TRUE);
// Now initialize the OmniboxViewGtk.
- location_entry_.reset(new OmniboxViewGtk(this,
- toolbar_model_,
- profile_,
- command_updater_,
- popup_window_mode_,
- hbox_.get()));
+ location_entry_.reset(new OmniboxViewGtk(this, toolbar_model_, profile,
+ command_updater_, popup_window_mode_, hbox_.get()));
location_entry_->Init();
g_signal_connect(hbox_.get(), "expose-event",
@@ -313,7 +309,7 @@ void LocationBarViewGtk::Init(bool popup_window_mode) {
for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
ContentSettingImageViewGtk* content_setting_view =
new ContentSettingImageViewGtk(
- static_cast<ContentSettingsType>(i), this, profile_);
+ static_cast<ContentSettingsType>(i), this);
content_setting_views_.push_back(content_setting_view);
gtk_box_pack_end(GTK_BOX(content_setting_hbox_.get()),
content_setting_view->widget(), FALSE, FALSE, 0);
@@ -335,7 +331,7 @@ void LocationBarViewGtk::Init(bool popup_window_mode) {
chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
Source<ThemeService>(theme_service_));
edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled,
- profile_->GetPrefs(), this);
+ profile->GetPrefs(), this);
theme_service_->InitThemesFor(this);
}
@@ -414,10 +410,6 @@ void LocationBarViewGtk::SetSiteTypeDragSource() {
ui::CHROME_NAMED_URL);
}
-void LocationBarViewGtk::SetProfile(Profile* profile) {
- profile_ = profile;
-}
-
TabContents* LocationBarViewGtk::GetTabContents() const {
return browser_->GetSelectedTabContents();
}
@@ -554,14 +546,12 @@ void LocationBarViewGtk::OnKillFocus() {
}
void LocationBarViewGtk::OnSetFocus() {
- AccessibilityTextBoxInfo info(
- profile_,
- l10n_util::GetStringUTF8(IDS_ACCNAME_LOCATION).c_str(),
- false);
+ Profile* profile = browser_->profile();
+ AccessibilityTextBoxInfo info(profile,
+ l10n_util::GetStringUTF8(IDS_ACCNAME_LOCATION), false);
NotificationService::current()->Notify(
chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED,
- Source<Profile>(profile_),
- Details<AccessibilityTextBoxInfo>(&info));
+ Source<Profile>(profile), Details<AccessibilityTextBoxInfo>(&info));
// Update the keyword and search hint states.
OnChanged();
@@ -641,7 +631,7 @@ void LocationBarViewGtk::UpdateContentSettingsIcons() {
void LocationBarViewGtk::UpdatePageActions() {
std::vector<ExtensionAction*> page_actions;
- ExtensionService* service = profile_->GetExtensionService();
+ ExtensionService* service = browser_->profile()->GetExtensionService();
if (!service)
return;
@@ -658,7 +648,7 @@ void LocationBarViewGtk::UpdatePageActions() {
for (size_t i = 0; i < page_actions.size(); ++i) {
page_action_views_.push_back(
- new PageActionViewGtk(this, profile_, page_actions[i]));
+ new PageActionViewGtk(this, page_actions[i]));
gtk_box_pack_end(GTK_BOX(page_action_hbox_.get()),
page_action_views_[i]->widget(), FALSE, FALSE, 0);
}
@@ -824,8 +814,7 @@ gboolean LocationBarViewGtk::HandleExpose(GtkWidget* widget,
GdkEventExpose* event) {
// If we're not using GTK theming, draw our own border over the edge pixels
// of the background.
- if (!profile_ ||
- !GtkThemeService::GetFrom(profile_)->UsingNativeTheme()) {
+ if (!GtkThemeService::GetFrom(browser_->profile())->UsingNativeTheme()) {
int left, center, right;
if (popup_window_mode_) {
left = right = IDR_LOCATIONBG_POPUPMODE_EDGE;
@@ -935,9 +924,9 @@ void LocationBarViewGtk::SetKeywordLabel(const string16& keyword) {
if (keyword.empty())
return;
- DCHECK(profile_);
+ Profile* profile = browser_->profile();
TemplateURLService* template_url_service =
- TemplateURLServiceFactory::GetForProfile(profile_);
+ TemplateURLServiceFactory::GetForProfile(profile);
if (!template_url_service)
return;
@@ -963,7 +952,7 @@ void LocationBarViewGtk::SetKeywordLabel(const string16& keyword) {
if (is_extension_keyword) {
const TemplateURL* template_url =
template_url_service->GetTemplateURLForKeyword(keyword);
- const SkBitmap& bitmap = profile_->GetExtensionService()->
+ const SkBitmap& bitmap = profile->GetExtensionService()->
GetOmniboxIcon(template_url->GetExtensionId());
GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap);
gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), pixbuf);
@@ -980,9 +969,8 @@ void LocationBarViewGtk::SetKeywordHintLabel(const string16& keyword) {
if (keyword.empty())
return;
- DCHECK(profile_);
TemplateURLService* template_url_service =
- TemplateURLServiceFactory::GetForProfile(profile_);
+ TemplateURLServiceFactory::GetForProfile(browser_->profile());
if (!template_url_service)
return;
@@ -1021,7 +1009,8 @@ void LocationBarViewGtk::ShowFirstRunBubbleInternal(
gfx::Rect bounds = gtk_util::WidgetBounds(location_icon_image_);
bounds.set_x(bounds.x() + kFirstRunBubbleLeftSpacing);
- FirstRunBubble::Show(profile_, location_icon_image_, bounds, bubble_type);
+ FirstRunBubble::Show(browser_->profile(), location_icon_image_, bounds,
+ bubble_type);
}
gboolean LocationBarViewGtk::OnIconReleased(GtkWidget* sender,
@@ -1056,7 +1045,7 @@ gboolean LocationBarViewGtk::OnIconReleased(GtkWidget* sender,
}
GURL url;
- if (!gtk_util::URLFromPrimarySelection(profile_, &url))
+ if (!gtk_util::URLFromPrimarySelection(browser_->profile(), &url))
return FALSE;
tab->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED);
@@ -1125,7 +1114,8 @@ void LocationBarViewGtk::ShowStarBubble(const GURL& url,
if (!star_.get())
return;
- BookmarkBubbleGtk::Show(star_.get(), profile_, url, newly_bookmarked);
+ BookmarkBubbleGtk::Show(star_.get(), browser_->profile(), url,
+ newly_bookmarked);
}
void LocationBarViewGtk::SetStarred(bool starred) {
@@ -1222,8 +1212,7 @@ void LocationBarViewGtk::AdjustChildrenVisibility() {
// LocationBarViewGtk::ContentSettingImageViewGtk
LocationBarViewGtk::ContentSettingImageViewGtk::ContentSettingImageViewGtk(
ContentSettingsType content_type,
- const LocationBarViewGtk* parent,
- Profile* profile)
+ const LocationBarViewGtk* parent)
: content_setting_image_model_(
ContentSettingImageModel::CreateContentSettingImageModel(
content_type)),
@@ -1233,7 +1222,6 @@ LocationBarViewGtk::ContentSettingImageViewGtk::ContentSettingImageViewGtk(
image_(gtk_image_new()),
label_(gtk_label_new(NULL)),
parent_(parent),
- profile_(profile),
content_setting_bubble_(NULL),
animation_(this),
method_factory_(this) {
@@ -1284,7 +1272,7 @@ void LocationBarViewGtk::ContentSettingImageViewGtk::UpdateFromTabContents(
}
gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()),
- GtkThemeService::GetFrom(profile_)->GetPixbufNamed(
+ GtkThemeService::GetFrom(parent_->browser()->profile())->GetPixbufNamed(
content_setting_image_model_->get_icon()));
gtk_widget_set_tooltip_text(widget(),
@@ -1368,12 +1356,13 @@ gboolean LocationBarViewGtk::ContentSettingImageViewGtk::OnButtonPressed(
TabContentsWrapper* tab_contents = parent_->GetTabContentsWrapper();
if (!tab_contents)
return TRUE;
+ Profile* profile = parent_->browser()->profile();
content_setting_bubble_ = new ContentSettingBubbleGtk(
sender, this,
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());
return TRUE;
}
@@ -1416,10 +1405,9 @@ void LocationBarViewGtk::ContentSettingImageViewGtk::BubbleClosing(
// LocationBarViewGtk::PageActionViewGtk
LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk(
- LocationBarViewGtk* owner, Profile* profile,
+ LocationBarViewGtk* owner,
ExtensionAction* page_action)
: owner_(NULL),
- profile_(profile),
page_action_(page_action),
last_icon_pixbuf_(NULL),
tracker_(this),
@@ -1439,8 +1427,9 @@ LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk(
image_.Own(gtk_image_new());
gtk_container_add(GTK_CONTAINER(event_box_.get()), image_.get());
- 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
@@ -1596,19 +1585,16 @@ bool LocationBarViewGtk::PageActionViewGtk::ShowPopup(bool devtools) {
gboolean LocationBarViewGtk::PageActionViewGtk::OnButtonPressed(
GtkWidget* sender,
GdkEventButton* event) {
+ Profile* profile = owner_->browser()->profile();
if (event->button != 3) {
if (!ShowPopup(false)) {
- ExtensionService* service = profile_->GetExtensionService();
- service->browser_event_router()->PageActionExecuted(
- profile_,
- page_action_->extension_id(),
- page_action_->id(),
- current_tab_id_,
- current_url_.spec(),
- event->button);
+ ExtensionService* service = profile->GetExtensionService();
+ service->browser_event_router()->PageActionExecuted(profile,
+ page_action_->extension_id(), page_action_->id(), current_tab_id_,
+ current_url_.spec(), event->button);
}
} else {
- const Extension* extension = profile_->GetExtensionService()->
+ const Extension* extension = profile->GetExtensionService()->
GetExtensionById(page_action()->extension_id(), false);
if (extension->ShowConfigureContextMenus()) {
@@ -1624,7 +1610,8 @@ gboolean LocationBarViewGtk::PageActionViewGtk::OnButtonPressed(
}
gboolean LocationBarViewGtk::PageActionViewGtk::OnExposeEvent(
- GtkWidget* widget, GdkEventExpose* event) {
+ GtkWidget* widget,
+ GdkEventExpose* event) {
TabContents* contents = owner_->GetTabContents();
if (!contents)
return FALSE;
diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.h b/chrome/browser/ui/gtk/location_bar_view_gtk.h
index 837eb16..f18ed96 100644
--- a/chrome/browser/ui/gtk/location_bar_view_gtk.h
+++ b/chrome/browser/ui/gtk/location_bar_view_gtk.h
@@ -41,7 +41,6 @@ class ContentSettingImageModel;
class ContentSettingBubbleGtk;
class ExtensionAction;
class GtkThemeService;
-class Profile;
class SkBitmap;
class TabContents;
class ToolbarModel;
@@ -56,8 +55,6 @@ class LocationBarViewGtk : public AutocompleteEditController,
void Init(bool popup_window_mode);
- void SetProfile(Profile* profile);
-
// Returns the widget the caller should host. You must call Init() first.
GtkWidget* widget() { return hbox_.get(); }
@@ -149,14 +146,11 @@ class LocationBarViewGtk : public AutocompleteEditController,
public ui::AnimationDelegate {
public:
ContentSettingImageViewGtk(ContentSettingsType content_type,
- const LocationBarViewGtk* parent,
- Profile* profile);
+ const LocationBarViewGtk* parent);
virtual ~ContentSettingImageViewGtk();
GtkWidget* widget() { return alignment_.get(); }
- void set_profile(Profile* profile) { profile_ = profile; }
-
bool IsVisible();
void UpdateFromTabContents(TabContents* tab_contents);
@@ -195,9 +189,6 @@ class LocationBarViewGtk : public AutocompleteEditController,
// The owning LocationBarViewGtk.
const LocationBarViewGtk* parent_;
- // The currently active profile.
- Profile* profile_;
-
// The currently shown bubble if any.
ContentSettingBubbleGtk* content_setting_bubble_;
@@ -215,9 +206,7 @@ class LocationBarViewGtk : public AutocompleteEditController,
class PageActionViewGtk : public ImageLoadingTracker::Observer,
public ExtensionContextMenuModel::PopupDelegate {
public:
- PageActionViewGtk(
- LocationBarViewGtk* owner, Profile* profile,
- ExtensionAction* page_action);
+ PageActionViewGtk(LocationBarViewGtk* owner, ExtensionAction* page_action);
virtual ~PageActionViewGtk();
GtkWidget* widget() { return event_box_.get(); }
@@ -258,9 +247,6 @@ class LocationBarViewGtk : public AutocompleteEditController,
// The location bar view that owns us.
LocationBarViewGtk* 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_;
@@ -410,7 +396,6 @@ class LocationBarViewGtk : public AutocompleteEditController,
// Alignment used to wrap |location_entry_|.
GtkWidget* location_entry_alignment_;
- Profile* profile_;
CommandUpdater* command_updater_;
ToolbarModel* toolbar_model_;
Browser* browser_;
diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc
index ee77e01..a3a85ed 100644
--- a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc
+++ b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc
@@ -270,14 +270,13 @@ void OmniboxPopupViewGtk::SetupLayoutForMatch(
OmniboxPopupViewGtk::OmniboxPopupViewGtk(const gfx::Font& font,
OmniboxView* omnibox_view,
AutocompleteEditModel* edit_model,
- Profile* profile,
GtkWidget* location_bar)
- : model_(new AutocompletePopupModel(this, edit_model, profile)),
+ : model_(new AutocompletePopupModel(this, edit_model)),
omnibox_view_(omnibox_view),
location_bar_(location_bar),
window_(gtk_window_new(GTK_WINDOW_POPUP)),
layout_(NULL),
- theme_service_(GtkThemeService::GetFrom(profile)),
+ theme_service_(GtkThemeService::GetFrom(edit_model->profile())),
font_(font.DeriveFont(kEditFontAdjust)),
ignore_mouse_drag_(false),
opened_(false) {
diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h
index 025e432..5903116 100644
--- a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h
+++ b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h
@@ -25,16 +25,14 @@ class AutocompleteEditModel;
class AutocompletePopupModel;
class GtkThemeService;
class OmniboxView;
-class Profile;
class SkBitmap;
class OmniboxPopupViewGtk : public AutocompletePopupView,
- public NotificationObserver {
+ public NotificationObserver {
public:
OmniboxPopupViewGtk(const gfx::Font& font,
OmniboxView* omnibox_view,
AutocompleteEditModel* edit_model,
- Profile* profile,
GtkWidget* location_bar);
virtual ~OmniboxPopupViewGtk();
diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc
index 838ed9f..3f57d3e 100644
--- a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc
+++ b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc
@@ -209,7 +209,7 @@ OmniboxViewGtk::OmniboxViewGtk(
#else
new OmniboxPopupViewGtk
#endif
- (GetFont(), this, model_.get(), profile, location_bar));
+ (GetFont(), this, model_.get(), location_bar));
}
OmniboxViewGtk::~OmniboxViewGtk() {
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.
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 5fc5265..2d0745d 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1878,7 +1878,6 @@
'browser/ui/toolbar/wrench_menu_model_unittest.cc',
'browser/ui/touch/tabs/touch_tab_strip_unittest.cc',
'browser/ui/views/accessibility_event_router_views_unittest.cc',
- 'browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc',
'browser/ui/views/bookmarks/bookmark_context_menu_test.cc',
'browser/ui/views/bookmarks/bookmark_editor_view_unittest.cc',
'browser/ui/views/bubble/border_contents_unittest.cc',