Index: chrome/browser/ui/views/location_bar/location_bar_view.cc |
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 0138a17189fde707181a96f610ec52dfa9dab656..cfc627e3c733d6fda99d07d3d198ec981078eda2 100644 |
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc |
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
@@ -115,11 +115,13 @@ static const int kBorderRoundCornerWidth = 5; |
// LocationBarView ----------------------------------------------------------- |
-LocationBarView::LocationBarView(Browser* browser, |
+LocationBarView::LocationBarView(Profile* profile, |
+ CommandUpdater* command_updater, |
ToolbarModel* model, |
Delegate* delegate, |
Mode mode) |
- : browser_(browser), |
+ : profile_(profile), |
+ command_updater_(command_updater), |
model_(model), |
delegate_(delegate), |
disposition_(CURRENT_TAB), |
@@ -152,7 +154,7 @@ LocationBarView::LocationBarView(Browser* browser, |
} |
edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, |
- browser_->profile()->GetPrefs(), this); |
+ profile_->GetPrefs(), this); |
} |
LocationBarView::~LocationBarView() { |
@@ -190,12 +192,11 @@ void LocationBarView::Init() { |
// URL edit field. |
// View container for URL edit field. |
- Profile* profile = browser_->profile(); |
location_entry_.reset(OmniboxView::CreateOmniboxView( |
this, |
model_, |
- profile, |
- browser_->command_updater(), |
+ profile_, |
+ command_updater_, |
mode_ == POPUP, |
this)); |
SetLocationEntryFocusable(true); |
@@ -205,19 +206,21 @@ 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); |
- 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_); |
for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
ContentSettingImageView* content_blocked_view = |
- new ContentSettingImageView(static_cast<ContentSettingsType>(i), this); |
+ new ContentSettingImageView( |
+ static_cast<ContentSettingsType>(i), |
+ this); |
content_setting_views_.push_back(content_blocked_view); |
AddChildView(content_blocked_view); |
content_blocked_view->SetVisible(false); |
@@ -225,7 +228,7 @@ void LocationBarView::Init() { |
// The star is not visible in popups and in the app launcher. |
if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { |
- star_view_ = new StarView(browser_->command_updater()); |
+ star_view_ = new StarView(command_updater_); |
AddChildView(star_view_); |
star_view_->SetVisible(true); |
} |
@@ -302,7 +305,7 @@ void LocationBarView::SetAnimationOffset(int offset) { |
void LocationBarView::Update(const WebContents* tab_for_state_restoring) { |
bool star_enabled = star_view_ && !model_->input_in_progress() && |
edit_bookmarks_enabled_.GetValue(); |
- browser_->command_updater()->UpdateCommandEnabled( |
+ command_updater_->UpdateCommandEnabled( |
IDC_BOOKMARK_PAGE, star_enabled); |
if (star_view_) |
star_view_->SetVisible(star_enabled); |
@@ -398,7 +401,7 @@ void LocationBarView::SetStarToggled(bool on) { |
} |
void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) { |
- browser::ShowBookmarkBubbleView(star_view_, browser_->profile(), url, |
+ browser::ShowBookmarkBubbleView(star_view_, profile_, url, |
newly_bookmarked); |
} |
@@ -564,13 +567,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 { |
@@ -818,16 +821,16 @@ void LocationBarView::OnAutocompleteAccept( |
transition_ = content::PageTransitionFromInt( |
transition | content::PAGE_TRANSITION_FROM_ADDRESS_BAR); |
- if (browser_->command_updater()) { |
+ if (command_updater_) { |
if (!alternate_nav_url.is_valid()) { |
- browser_->command_updater()->ExecuteCommand(IDC_OPEN_CURRENT_URL); |
+ command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL); |
} else { |
AlternateNavURLFetcher* fetcher = |
new AlternateNavURLFetcher(alternate_nav_url); |
// The AlternateNavURLFetcher will listen for the pending navigation |
// notification that will be issued as a result of the "open URL." It |
// will automatically install itself into that navigation controller. |
- browser_->command_updater()->ExecuteCommand(IDC_OPEN_CURRENT_URL); |
+ command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL); |
if (fetcher->state() == AlternateNavURLFetcher::NOT_STARTED) { |
// I'm not sure this should be reachable, but I'm not also sure enough |
// that it shouldn't to stick in a NOTREACHED(). In any case, this is |
@@ -934,7 +937,7 @@ void LocationBarView::RefreshPageActionViews() { |
if (mode_ != NORMAL) |
return; |
- ExtensionService* service = browser_->profile()->GetExtensionService(); |
+ ExtensionService* service = profile_->GetExtensionService(); |
if (!service) |
return; |
@@ -963,7 +966,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, page_actions[i])); |
+ delegate_->CreatePageActionImageView(this, page_actions[i])); |
page_action_views_[i]->SetVisible(false); |
AddChildViewAt(page_action_views_[i], GetIndexOf(star_view_)); |
} |
@@ -1006,7 +1009,7 @@ void LocationBarView::OnMouseEvent(const views::MouseEvent& event, UINT msg) { |
void LocationBarView::ShowFirstRunBubbleInternal() { |
#if !defined(OS_CHROMEOS) |
// First run bubble doesn't make sense for Chrome OS. |
- FirstRunBubble::ShowBubble(browser_->profile(), location_icon_view_); |
+ FirstRunBubble::ShowBubble(profile_, location_icon_view_); |
#endif |
} |
@@ -1096,7 +1099,7 @@ bool LocationBarView::CanStartDragForView(View* sender, |
void LocationBarView::ShowFirstRunBubble() { |
// Wait until search engines have loaded to show the first run bubble. |
TemplateURLService* url_service = |
- TemplateURLServiceFactory::GetForProfile(browser_->profile()); |
+ TemplateURLServiceFactory::GetForProfile(profile_); |
if (!url_service->loaded()) { |
template_url_service_ = url_service; |
template_url_service_->AddObserver(this); |