Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(644)

Unified Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 9703099: Revert 126959 - Re-factor location bar/toolbar code to get rid of the browser dependency. This CL i… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/location_bar/location_bar_view.cc
===================================================================
--- chrome/browser/ui/views/location_bar/location_bar_view.cc (revision 127082)
+++ chrome/browser/ui/views/location_bar/location_bar_view.cc (working copy)
@@ -139,13 +139,11 @@
// LocationBarView -----------------------------------------------------------
-LocationBarView::LocationBarView(Profile* profile,
- CommandUpdater* command_updater,
+LocationBarView::LocationBarView(Browser* browser,
ToolbarModel* model,
Delegate* delegate,
Mode mode)
- : profile_(profile),
- command_updater_(command_updater),
+ : browser_(browser),
model_(model),
delegate_(delegate),
disposition_(CURRENT_TAB),
@@ -179,7 +177,7 @@
}
edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled,
- profile_->GetPrefs(), this);
+ browser_->profile()->GetPrefs(), this);
}
LocationBarView::~LocationBarView() {
@@ -217,11 +215,12 @@
// URL edit field.
// View container for URL edit field.
+ Profile* profile = browser_->profile();
location_entry_.reset(OmniboxView::CreateOmniboxView(
this,
model_,
- profile_,
- command_updater_,
+ profile,
+ browser_->command_updater(),
mode_ == POPUP,
this));
SetLocationEntryFocusable(true);
@@ -231,12 +230,12 @@
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_);
@@ -251,17 +250,18 @@
// Hide the star and Chrome To Mobile icons in popups and in the app launcher.
if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) {
- star_view_ = new StarView(command_updater_);
+ star_view_ = new StarView(browser_->command_updater());
AddChildView(star_view_);
star_view_->SetVisible(true);
// Also disable Chrome To Mobile for off-the-record and non-synced profiles.
- if (!profile_->IsOffTheRecord() && profile_->IsSyncAccessible()) {
+ Profile* profile = browser_->profile();
+ if (!profile->IsOffTheRecord() && profile->IsSyncAccessible()) {
chrome_to_mobile_view_ =
- new ChromeToMobileView(this, command_updater_);
+ new ChromeToMobileView(this, browser_->command_updater());
AddChildView(chrome_to_mobile_view_);
ChromeToMobileService* service =
- ChromeToMobileServiceFactory::GetForProfile(profile_);
+ ChromeToMobileServiceFactory::GetForProfile(browser_->profile());
service->RequestMobileListUpdate();
chrome_to_mobile_view_->SetVisible(!service->mobiles().empty());
}
@@ -339,15 +339,17 @@
void LocationBarView::Update(const WebContents* tab_for_state_restoring) {
bool star_enabled = star_view_ && !model_->input_in_progress() &&
edit_bookmarks_enabled_.GetValue();
- command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled);
+ CommandUpdater* command_updater = browser_->command_updater();
+ command_updater->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled);
if (star_view_)
star_view_->SetVisible(star_enabled);
+ Profile* profile = browser_->profile();
bool chrome_to_mobile_enabled = chrome_to_mobile_view_ &&
- !model_->input_in_progress() && profile_->IsSyncAccessible() &&
- !ChromeToMobileServiceFactory::GetForProfile(profile_)->mobiles().empty();
- command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE,
- chrome_to_mobile_enabled);
+ !model_->input_in_progress() && profile->IsSyncAccessible() &&
+ !ChromeToMobileServiceFactory::GetForProfile(profile)->mobiles().empty();
+ command_updater->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE,
+ chrome_to_mobile_enabled);
RefreshContentSettingViews();
RefreshPageActionViews();
@@ -441,15 +443,15 @@
}
void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) {
- browser::ShowBookmarkBubbleView(star_view_, profile_, url,
+ browser::ShowBookmarkBubbleView(star_view_, browser_->profile(), url,
newly_bookmarked);
}
void LocationBarView::ShowChromeToMobileBubble() {
- ChromeToMobileServiceFactory::GetForProfile(profile_)->
+ ChromeToMobileServiceFactory::GetForProfile(browser_->profile())->
RequestMobileListUpdate();
browser::ShowChromeToMobileBubbleView(chrome_to_mobile_view_,
- profile_);
+ browser_->profile());
}
gfx::Point LocationBarView::GetLocationEntryOrigin() const {
@@ -617,13 +619,13 @@
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 {
@@ -884,16 +886,16 @@
transition_ = content::PageTransitionFromInt(
transition | content::PAGE_TRANSITION_FROM_ADDRESS_BAR);
- if (command_updater_) {
+ if (browser_->command_updater()) {
if (!alternate_nav_url.is_valid()) {
- command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL);
+ browser_->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.
- command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL);
+ browser_->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
@@ -1000,7 +1002,7 @@
if (mode_ != NORMAL)
return;
- ExtensionService* service = profile_->GetExtensionService();
+ ExtensionService* service = browser_->profile()->GetExtensionService();
if (!service)
return;
@@ -1031,7 +1033,7 @@
// inserted in left-to-right order for accessibility.
for (int i = page_actions.size() - 1; i >= 0; --i) {
page_action_views_[i] = new PageActionWithBadgeView(
- delegate_->CreatePageActionImageView(this, page_actions[i]));
+ new PageActionImageView(this, page_actions[i]));
page_action_views_[i]->SetVisible(false);
AddChildViewAt(page_action_views_[i], GetIndexOf(view));
}
@@ -1074,7 +1076,7 @@
void LocationBarView::ShowFirstRunBubbleInternal() {
#if !defined(OS_CHROMEOS)
// First run bubble doesn't make sense for Chrome OS.
- FirstRunBubble::ShowBubble(profile_, location_icon_view_);
+ FirstRunBubble::ShowBubble(browser_->profile(), location_icon_view_);
#endif
}
@@ -1164,7 +1166,7 @@
void LocationBarView::ShowFirstRunBubble() {
// 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()) {
template_url_service_ = url_service;
template_url_service_->AddObserver(this);

Powered by Google App Engine
This is Rietveld 408576698