text:
using content::WebContents;
using views::View;

namespace {

WebContents* GetWebContentsFromDelegate(LocationBarView::Delegate* delegate) {
  const TabContents* tab_contents = delegate->GetTabContents();
  return tab_contents ? tab_contents->web_contents() : NULL;
}

Browser* GetBrowserFromDelegate(LocationBarView::Delegate* delegate) {
  WebContents* contents = GetWebContentsFromDelegate(delegate);
  return browser::FindBrowserWithWebContents(contents);
}

// Height of the location bar's round corner region.
const int kBorderRoundCornerHeight = 5;
// Width of location bar's round corner region.
const int kBorderRoundCornerWidth = 4;
// Radius of the round corners inside the location bar.
const int kBorderCornerRadius = 2;

const int kDesktopItemPadding = 3;
const int kDesktopEdgeItemPadding = kDesktopItemPadding;

const int kTouchItemPadding = 8;
const int kTouchEdgeItemPadding = kTouchItemPadding;

// Extra padding for the height of the omnibox in search mode.
const int kSearchEditHeightPadding = 2;

}  // namespace

// static
const int LocationBarView::kNormalHorizontalEdgeThickness = 2;
const int LocationBarView::kVerticalEdgeThickness = 3;
const int LocationBarView::kIconInternalPadding = 2;
const int LocationBarView::kBubbleHorizontalPadding = 1;
const char LocationBarView::kViewClassName[] =
    "browser/ui/views/location_bar/LocationBarView";

static const int kEVBubbleBackgroundImages[] = {
  IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_L,
  IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_C,
  IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_R,
};

static const int kSelectedKeywordBackgroundImages[] = {
  IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_L,
  IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_C,
  IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_R,
};

#if defined(USE_AURA)
LocationBarView::FadeAnimationObserver::FadeAnimationObserver(
    LocationBarView* location_bar_view)
    : location_bar_view_(location_bar_view) {
}

LocationBarView::FadeAnimationObserver::~FadeAnimationObserver() {
}

void LocationBarView::FadeAnimationObserver::OnImplicitAnimationsCompleted() {
  location_bar_view_->CleanupFadeAnimation();
}
#endif  // USE_AURA

// LocationBarView -----------------------------------------------------------

LocationBarView::LocationBarView(Profile* profile,
                                 CommandUpdater* command_updater,
                                 ToolbarModel* model,
                                 Delegate* delegate,
                                 chrome::search::SearchModel* search_model,
                                 Mode mode)
    : profile_(profile),
      command_updater_(command_updater),
      model_(model),
      delegate_(delegate),
      search_model_(search_model),
      disposition_(CURRENT_TAB),
      transition_(content::PageTransitionFromInt(
          content::PAGE_TRANSITION_TYPED |
          content::PAGE_TRANSITION_FROM_ADDRESS_BAR)),
      location_icon_view_(NULL),
      ev_bubble_view_(NULL),
      location_entry_view_(NULL),
      selected_keyword_view_(NULL),
      suggested_text_view_(NULL),
      keyword_hint_view_(NULL),
      zoom_view_(NULL),
      star_view_(NULL),
      action_box_button_view_(NULL),
      chrome_to_mobile_view_(NULL),
      mode_(mode),
      show_focus_rect_(false),
      template_url_service_(NULL),
      animation_offset_(0),
      ALLOW_THIS_IN_INITIALIZER_LIST(view_to_focus_(this)) {
  set_id(VIEW_ID_LOCATION_BAR);

  if (mode_ == NORMAL) {
    painter_.reset(
        views::Painter::CreateImagePainter(
            *ui::ResourceBundle::GetSharedInstance().GetImageNamed(
                IDR_LOCATION_BAR_BORDER).ToImageSkia(),
            gfx::Insets(kBorderRoundCornerHeight, kBorderRoundCornerWidth,
                kBorderRoundCornerHeight, kBorderRoundCornerWidth),
            true));
  }

  edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled,
                               profile_->GetPrefs(), this);

  if (search_model_)
    search_model_->AddObserver(this);
}

LocationBarView::~LocationBarView() {
  if (template_url_service_)
    template_url_service_->RemoveObserver(this);

  if (search_model_)
    search_model_->RemoveObserver(this);
}

void LocationBarView::Init(views::View* popup_parent_view) {
  ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
  if (mode_ == POPUP) {
    font_ = rb.GetFont(ui::ResourceBundle::BaseFont);
  } else {
    // Use a larger version of the system font.
    font_ = rb.GetFont(ui::ResourceBundle::MediumFont);
  }

  // If this makes the font too big, try to make it smaller so it will fit.
  const int height = GetInternalHeight(true);
  while ((font_.GetHeight() > height) && (font_.GetFontSize() > 1))
    font_ = font_.DeriveFont(-1);

  location_icon_view_ = new LocationIconView(this);
  AddChildView(location_icon_view_);
  location_icon_view_->SetVisible(true);
  location_icon_view_->set_drag_controller(this);

  ev_bubble_view_ =
      new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID,
                       GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), this);
  AddChildView(ev_bubble_view_);
  ev_bubble_view_->SetVisible(false);
  ev_bubble_view_->set_drag_controller(this);

  // URL edit field.
  // View container for URL edit field.
  location_entry_.reset(CreateOmniboxView(this, model_, profile_,
      command_updater_, mode_ == POPUP, this, popup_parent_view));
  SetLocationEntryFocusable(true);

  location_entry_view_ = location_entry_->AddToView(this);
  location_entry_view_->set_id(VIEW_ID_AUTOCOMPLETE);

  selected_keyword_view_ = new SelectedKeywordView(
      kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER,
      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_);
  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);
    content_setting_views_.push_back(content_blocked_view);
    AddChildView(content_blocked_view);
    content_blocked_view->SetVisible(false);
  }

  zoom_view_ = new ZoomView(model_);
  AddChildView(zoom_view_);

  if (extensions::switch_utils::IsActionBoxEnabled()) {
    action_box_button_view_ = new ActionBoxButtonView(
        extensions::ExtensionSystem::Get(profile_)->extension_service());
    AddChildView(action_box_button_view_);
  } else if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) {
    // Note: condition above means that the star and ChromeToMobile icons are
    // hidden in popups and in the app launcher.
    star_view_ = new StarView(command_updater_);
    AddChildView(star_view_);
    star_view_->SetVisible(true);

    // Also disable Chrome To Mobile for off-the-record and non-synced profiles,
    // or if the feature is disabled by a command line flag or chrome://flags.
    if (!profile_->IsOffTheRecord() && profile_->IsSyncAccessible() &&
        ChromeToMobileService::IsChromeToMobileEnabled()) {
      chrome_to_mobile_view_ = new ChromeToMobileView(this, command_updater_);
      AddChildView(chrome_to_mobile_view_);
      ChromeToMobileService* service =
          ChromeToMobileServiceFactory::GetForProfile(profile_);
      service->RequestMobileListUpdate();
      chrome_to_mobile_view_->SetVisible(service->HasDevices());
    }
  }

  registrar_.Add(this,
                 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED,
                 content::Source<Profile>(profile_));

  // Initialize the location entry. We do this to avoid a black flash which is
  // visible when the location entry has just been initialized.
  Update(NULL);

  OnChanged();
}

bool LocationBarView::IsInitialized() const {
  return location_entry_view_ != NULL;
}

// static
SkColor LocationBarView::GetColor(ToolbarModel::SecurityLevel security_level,
                                  ColorKind kind) {
  switch (kind) {
#if defined(OS_WIN)
    case BACKGROUND:    return color_utils::GetSysSkColor(COLOR_WINDOW);
    case TEXT:          return color_utils::GetSysSkColor(COLOR_WINDOWTEXT);
    case SELECTED_TEXT: return color_utils::GetSysSkColor(COLOR_HIGHLIGHTTEXT);
#else
    // TODO(beng): source from theme provider.
    case BACKGROUND:    return SK_ColorWHITE;
    case TEXT:          return SK_ColorBLACK;
    case SELECTED_TEXT: return SK_ColorWHITE;
#endif

    case DEEMPHASIZED_TEXT:
      return color_utils::AlphaBlend(GetColor(security_level, TEXT),
                                     GetColor(security_level, BACKGROUND), 128);

    case SECURITY_TEXT: {
      SkColor color;
      switch (security_level) {
        case ToolbarModel::EV_SECURE:
        case ToolbarModel::SECURE:
          color = SkColorSetRGB(7, 149, 0);
          break;

        case ToolbarModel::SECURITY_WARNING:
          return GetColor(security_level, DEEMPHASIZED_TEXT);
          break;

        case ToolbarModel::SECURITY_ERROR:
          color = SkColorSetRGB(162, 0, 0);
          break;

        default:
          NOTREACHED();
          return GetColor(security_level, TEXT);
      }
      return color_utils::GetReadableColor(color, GetColor(security_level,
                                                           BACKGROUND));
    }

    default:
      NOTREACHED();
      return GetColor(security_level, TEXT);
  }
}

// static
int LocationBarView::GetItemPadding() {
  return (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) ?
      kTouchItemPadding : kDesktopItemPadding;
}

// static
int LocationBarView::GetEdgeItemPadding() {
  return (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) ?
      kTouchEdgeItemPadding : kDesktopEdgeItemPadding;
}

// DropdownBarHostDelegate
void LocationBarView::SetFocusAndSelection(bool select_all) {
  FocusLocation(select_all);
}

void LocationBarView::SetAnimationOffset(int offset) {
  animation_offset_ = offset;
}

void LocationBarView::ModeChanged(const chrome::search::Mode& mode) {
#if defined(USE_AURA)
  if (mode.is_search() && mode.animate) {
    // Fade in so the icons don't pop.
    StartFadeAnimation();
  } else {
    // Cancel any pending animations; switch to the final state immediately.
    StopFadeAnimation();
  }
#endif
}

void LocationBarView::Update(const WebContents* tab_for_state_restoring) {
  RefreshContentSettingViews();
  zoom_view_->Update();
  RefreshPageActionViews();

  bool star_enabled = star_view_ && !model_->input_in_progress() &&
                      edit_bookmarks_enabled_.GetValue();

  command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled);
  if (star_view_)
    star_view_->SetVisible(star_enabled);

  bool enabled = chrome_to_mobile_view_ && !model_->input_in_progress() &&
      ChromeToMobileServiceFactory::GetForProfile(profile_)->HasDevices();
  command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, enabled);

  // Don't Update in app launcher mode so that the location entry does not show
  // a URL or security background.
  if (mode_ != APP_LAUNCHER)
    location_entry_->Update(tab_for_state_restoring);
  OnChanged();
}

void LocationBarView::UpdateContentSettingsIcons() {
  RefreshContentSettingViews();

  Layout();
  SchedulePaint();
}

void LocationBarView::UpdatePageActions() {
  size_t count_before = page_action_views_.size();
  RefreshPageActionViews();
  if (page_action_views_.size() != count_before) {
    content::NotificationService::current()->Notify(
        chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED,
        content::Source<LocationBar>(this),
        content::NotificationService::NoDetails());
  }

  Layout();
  SchedulePaint();
}

void LocationBarView::InvalidatePageActions() {
  size_t count_before = page_action_views_.size();
  DeletePageActionViews();
  if (page_action_views_.size() != count_before) {
    content::NotificationService::current()->Notify(
        chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED,
        content::Source<LocationBar>(this),
        content::NotificationService::NoDetails());
  }
}

void LocationBarView::OnFocus() {
  // Focus the view widget first which implements accessibility for
  // Chrome OS.  It is noop on Win. This should be removed once
  // Chrome OS migrates to aura, which uses Views' textfield that receives
  // focus. See crbug.com/106428.
  GetWidget()->NotifyAccessibilityEvent(
      this, ui::AccessibilityTypes::EVENT_FOCUS, false);

  // Then focus the native location view which implements accessibility for
  // Windows.
  location_entry_->SetFocus();
}

void LocationBarView::SetPreviewEnabledPageAction(ExtensionAction* page_action,
                                                  bool preview_enabled) {
  if (mode_ != NORMAL)
    return;

  DCHECK(page_action);
  WebContents* contents = GetWebContentsFromDelegate(delegate_);

  RefreshPageActionViews();
  PageActionWithBadgeView* page_action_view =
      static_cast<PageActionWithBadgeView*>(GetPageActionView(page_action));
  DCHECK(page_action_view);
  if (!page_action_view)
    return;

  page_action_view->image_view()->set_preview_enabled(preview_enabled);
  page_action_view->UpdateVisibility(contents, GURL(model_->GetText()));
  Layout();
  SchedulePaint();
}

views::View* LocationBarView::GetPageActionView(ExtensionAction *page_action) {
  DCHECK(page_action);
  for (PageActionViews::const_iterator i(page_action_views_.begin());
       i != page_action_views_.end(); ++i) {
    if ((*i)->image_view()->page_action() == page_action)
      return *i;
  }
  return NULL;
}

void LocationBarView::SetStarToggled(bool on) {
  if (star_view_)
    star_view_->SetToggled(on);
}

void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) {
  chrome::ShowBookmarkBubbleView(star_view_, profile_, url, newly_bookmarked);
}

void LocationBarView::SetZoomIconTooltipPercent(int zoom_percent) {
  zoom_view_->SetZoomIconTooltipPercent(zoom_percent);
}

void LocationBarView::SetZoomIconState(
    ZoomController::ZoomIconState zoom_icon_state) {
  zoom_view_->SetZoomIconState(zoom_icon_state);

  Layout();
  SchedulePaint();
}

void LocationBarView::ShowZoomBubble(int zoom_percent) {
  ZoomBubbleView::ShowBubble(zoom_view_, zoom_percent, true);
}

void LocationBarView::ShowChromeToMobileBubble() {
  Browser* browser = GetBrowserFromDelegate(delegate_);
  chrome::ShowChromeToMobileBubbleView(chrome_to_mobile_view_, browser);
}

gfx::Point LocationBarView::GetLocationEntryOrigin() const {
  gfx::Point origin(location_entry_view_->bounds().origin());
  // If the UI layout is RTL, the coordinate system is not transformed and
  // therefore we need to adjust the X coordinate so that bubble appears on the
  // right hand side of the location bar.
  if (base::i18n::IsRTL())
    origin.set_x(width() - origin.x());
  views::View::ConvertPointToScreen(this, &origin);
  return origin;
}

void LocationBarView::SetInstantSuggestion(const string16& text,
                                           bool animate_to_complete) {
  // Don't show the suggested text if inline autocomplete is prevented.
  if (!text.empty()) {
    if (!suggested_text_view_) {
      suggested_text_view_ = new SuggestedTextView(location_entry_->model());
      suggested_text_view_->SetText(text);
      suggested_text_view_->SetFont(location_entry_->GetFont());
      AddChildView(suggested_text_view_);
    } else if (suggested_text_view_->text() != text) {
      suggested_text_view_->SetText(text);
    }
    if (animate_to_complete && !location_entry_->IsImeComposing())
      suggested_text_view_->StartAnimation();
  } else if (suggested_text_view_) {
    delete suggested_text_view_;
    suggested_text_view_ = NULL;
  } else {
    return;
  }

  Layout();
  SchedulePaint();
}

string16 LocationBarView::GetInstantSuggestion() const {
  return HasValidSuggestText() ? suggested_text_view_->text() : string16();
}

void LocationBarView::SetLocationEntryFocusable(bool focusable) {
  OmniboxViewViews* omnibox_views = GetOmniboxViewViews(location_entry_.get());
  if (omnibox_views)
    omnibox_views->SetLocationEntryFocusable(focusable);
  else
    view_to_focus_->set_focusable(focusable);
}

bool LocationBarView::IsLocationEntryFocusableInRootView() const {
  OmniboxViewViews* omnibox_views = GetOmniboxViewViews(location_entry_.get());
  if (omnibox_views)
    return omnibox_views->IsLocationEntryFocusableInRootView();
  return view_to_focus_->IsFocusable();
}

gfx::Size LocationBarView::GetPreferredSize() {
  if (search_model_ && search_model_->mode().is_ntp())
    return gfx::Size(0, chrome::search::GetNTPOmniboxHeight(
        location_entry_->GetFont()));
  int delta = chrome::search::IsInstantExtendedAPIEnabled(profile_) ?
      kSearchEditHeightPadding : 0;
  return gfx::Size(0, GetThemeProvider()->GetImageSkiaNamed(mode_ == POPUP ?
      IDR_LOCATIONBG_POPUPMODE_CENTER : IDR_LOCATIONBG_C)->height() + delta);
}

void LocationBarView::Layout() {
  if (!location_entry_.get())
    return;

  // TODO(jhawkins): Remove once crbug.com/101994 is fixed.
  CHECK(location_icon_view_);

  // TODO(sky): baseline layout.
  int location_y = kVerticalEdgeThickness;
  // In some cases (e.g. fullscreen mode) we may have 0 height.  We still want
  // to position our child views in this case, because other things may be
  // positioned relative to them (e.g. the "bookmark added" bubble if the user
  // hits ctrl-d).
  int location_height = GetInternalHeight(false);

  // In NTP mode, hide all location bar decorations.
  if (search_model_ && search_model_->mode().is_ntp()) {
    gfx::Rect location_bounds(0, location_y, width(), location_height);
    location_entry_view_->SetBoundsRect(location_bounds);
    for (int i = 0; i < child_count(); ++i)
      if (child_at(i) != location_entry_view_)
        child_at(i)->SetVisible(false);
    return;
  }

  // The edge stroke is 1 px thick.  In popup mode, the edges are drawn by the
  // omnibox' parent, so there isn't any edge to account for at all.
  const int kEdgeThickness = (mode_ == NORMAL) ?
      kNormalHorizontalEdgeThickness : 0;
  // The edit has 1 px of horizontal whitespace inside it before the text.
  const int kEditInternalSpace = 1;
  // The space between an item and the edit is the normal item space, minus the
  // edit's built-in space (so the apparent space will be the same).
  const int kItemEditPadding = GetItemPadding() - kEditInternalSpace;
  const int kEdgeEditPadding = GetEdgeItemPadding() - kEditInternalSpace;
  const int kBubbleVerticalPadding = (mode_ == POPUP) ?
      -1 : kBubbleHorizontalPadding;

  // Start by reserving the padding at the right edge.
  int entry_width = width() - kEdgeThickness - GetEdgeItemPadding();

  // |location_icon_view_| is visible except when |ev_bubble_view_| or
  // |selected_keyword_view_| are visible.
  int location_icon_width = 0;
  int ev_bubble_width = 0;
  location_icon_view_->SetVisible(false);
  ev_bubble_view_->SetVisible(false);

  const string16 keyword(location_entry_->model()->keyword());
  const bool is_keyword_hint(location_entry_->model()->is_keyword_hint());
  const bool show_selected_keyword = !keyword.empty() && !is_keyword_hint;
  if (show_selected_keyword) {
    // Assume the keyword might be hidden.
    entry_width -= (kEdgeThickness + kEdgeEditPadding);
  } else if (model_->GetSecurityLevel() == ToolbarModel::EV_SECURE) {
    ev_bubble_view_->SetVisible(true);
    ev_bubble_view_->SetLabel(model_->GetEVCertName());
    ev_bubble_width = ev_bubble_view_->GetPreferredSize().width();
    // We'll adjust this width and take it out of |entry_width| below.
  } else {
    location_icon_view_->SetVisible(true);
    location_icon_width = location_icon_view_->GetPreferredSize().width();
    entry_width -= (kEdgeThickness + GetEdgeItemPadding() +
                    location_icon_width + kItemEditPadding);
  }

  if (star_view_ && star_view_->visible())
    entry_width -= star_view_->GetPreferredSize().width() + GetItemPadding();
  if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) {
    entry_width -= chrome_to_mobile_view_->GetPreferredSize().width() +
        GetItemPadding();
  }
  int action_box_button_width = location_height;
  if (action_box_button_view_)
    entry_width -= action_box_button_width + GetItemPadding();
  for (PageActionViews::const_iterator i(page_action_views_.begin());
       i != page_action_views_.end(); ++i) {
    if ((*i)->visible())
      entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding());
  }
  if (zoom_view_->visible())
    entry_width -= zoom_view_->GetPreferredSize().width() + GetItemPadding();
  for (ContentSettingViews::const_iterator i(content_setting_views_.begin());
       i != content_setting_views_.end(); ++i) {
    if ((*i)->visible())
      entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding());
  }
  // The gap between the edit and whatever is to its right is shortened.
  entry_width += kEditInternalSpace;

  // Size the EV bubble after taking star/ChromeToMobile/page actions/content
  // settings out of |entry_width| so we won't take too much space.
  if (ev_bubble_width) {
    // Try to elide the bubble to be no larger than half the total available
    // space, but never elide it any smaller than 150 px.
    static const int kMinElidedBubbleWidth = 150;
    static const double kMaxBubbleFraction = 0.5;
    const int total_padding =
        kEdgeThickness + kBubbleHorizontalPadding + kItemEditPadding;
    ev_bubble_width = std::min(ev_bubble_width, std::max(kMinElidedBubbleWidth,
        static_cast<int>((entry_width - total_padding) * kMaxBubbleFraction)));
    entry_width -= (total_padding + ev_bubble_width);
  }

  int max_edit_width = location_entry_->GetMaxEditWidth(entry_width);
  if (max_edit_width < 0)
    return;
  const int available_width = AvailableWidth(max_edit_width);

  const bool show_keyword_hint = !keyword.empty() && is_keyword_hint;
  selected_keyword_view_->SetVisible(show_selected_keyword);
  keyword_hint_view_->SetVisible(show_keyword_hint);
  if (show_selected_keyword) {
    if (selected_keyword_view_->keyword() != keyword) {
      selected_keyword_view_->SetKeyword(keyword);
      const TemplateURL* template_url =
          TemplateURLServiceFactory::GetForProfile(profile_)->
          GetTemplateURLForKeyword(keyword);
      if (template_url && template_url->IsExtensionKeyword()) {
        const SkBitmap& bitmap =
            profile_->GetExtensionService()->GetOmniboxIcon(
                template_url->GetExtensionId());
        selected_keyword_view_->SetImage(bitmap);
        selected_keyword_view_->set_is_extension_icon(true);
      } else {
        ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
        selected_keyword_view_->SetImage(
            *rb.GetImageSkiaNamed(IDR_OMNIBOX_SEARCH));
        selected_keyword_view_->set_is_extension_icon(false);
      }
    }
  } else if (show_keyword_hint) {
    if (keyword_hint_view_->keyword() != keyword)
      keyword_hint_view_->SetKeyword(keyword);
  }

  // Lay out items to the right of the edit field.
  int offset = width() - kEdgeThickness;
  if (action_box_button_view_) {
    offset -= action_box_button_width;
    action_box_button_view_->SetBounds(offset, location_y,
                                       action_box_button_width,
                                       location_height);
    offset -= GetItemPadding();
  } else {
    offset -= GetEdgeItemPadding();
  }

  if (star_view_ && star_view_->visible()) {
    offset += star_view_->GetBuiltInHorizontalPadding();
    int star_width = star_view_->GetPreferredSize().width();
    offset -= star_width;
    star_view_->SetBounds(offset, location_y, star_width, location_height);
    offset -= GetItemPadding() - star_view_->GetBuiltInHorizontalPadding();
  }

  if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) {
    offset += chrome_to_mobile_view_->GetBuiltInHorizontalPadding();
    int icon_width = chrome_to_mobile_view_->GetPreferredSize().width();
    offset -= icon_width;
    chrome_to_mobile_view_->SetBounds(offset, location_y,
                                      icon_width, location_height);
    offset -= GetItemPadding() -
        chrome_to_mobile_view_->GetBuiltInHorizontalPadding();
  }

  for (PageActionViews::const_iterator i(page_action_views_.begin());
       i != page_action_views_.end(); ++i) {
    if ((*i)->visible()) {
      offset += (*i)->GetBuiltInHorizontalPadding();
      int page_action_width = (*i)->GetPreferredSize().width();
      offset -= page_action_width;
      (*i)->SetBounds(offset, location_y, page_action_width, location_height);
      offset -= GetItemPadding() - (*i)->GetBuiltInHorizontalPadding();
    }
  }

  if (zoom_view_->visible()) {
    int zoom_width = zoom_view_->GetPreferredSize().width();
    offset -= zoom_width;
    zoom_view_->SetBounds(offset, location_y, zoom_width, location_height);
    offset -= GetItemPadding();
  }

  // We use a reverse_iterator here because we're laying out the views from
  // right to left but in the vector they're ordered left to right.
  for (ContentSettingViews::const_reverse_iterator
       i(content_setting_views_.rbegin()); i != content_setting_views_.rend();
       ++i) {
    if ((*i)->visible()) {
      offset += (*i)->GetBuiltInHorizontalPadding();
      int content_blocked_width = (*i)->GetPreferredSize().width();
      offset -= content_blocked_width;
      (*i)->SetBounds(offset, location_y, content_blocked_width,
                      location_height);
      offset -= GetItemPadding() - (*i)->GetBuiltInHorizontalPadding();
    }
  }

  // Now lay out items to the left of the edit field.
  if (location_icon_view_->visible()) {
    location_icon_view_->SetBounds(
        kEdgeThickness + GetEdgeItemPadding() -
        location_icon_view_->GetBuiltInHorizontalPadding(),
        location_y, location_icon_width, location_height);
    offset = location_icon_view_->bounds().right() + kItemEditPadding -
        location_icon_view_->GetBuiltInHorizontalPadding();
  } else if (ev_bubble_view_->visible()) {
    ev_bubble_view_->SetBounds(kEdgeThickness + kBubbleHorizontalPadding,
        location_y + kBubbleVerticalPadding, ev_bubble_width,
        ev_bubble_view_->GetPreferredSize().height());
    offset = ev_bubble_view_->bounds().right() + kItemEditPadding;
  } else {
    offset = kEdgeThickness +
        (show_selected_keyword ? kBubbleHorizontalPadding : kEdgeEditPadding);
  }

  // Now lay out the edit field and views that autocollapse to give it more
  // room.
  gfx::Rect location_bounds(offset, location_y, entry_width, location_height);
  if (show_selected_keyword) {
    selected_keyword_view_->SetBounds(0, location_y + kBubbleVerticalPadding,
        0, selected_keyword_view_->GetPreferredSize().height());
    LayoutView(selected_keyword_view_, kItemEditPadding, available_width,
               true, &location_bounds);
    location_bounds.set_x(selected_keyword_view_->visible() ?
        (offset + selected_keyword_view_->width() + kItemEditPadding) :
        (kEdgeThickness + kEdgeEditPadding));
  } else if (show_keyword_hint) {
    keyword_hint_view_->SetBounds(0, location_y, 0, location_height);
    // Tricky: |entry_width| has already been enlarged by |kEditInternalSpace|.
    // But if we add a trailing view, it needs to have that enlargement be to
    // its left.  So we undo the enlargement, then include it in the padding for
    // the added view.
    location_bounds.Inset(0, 0, kEditInternalSpace, 0);
    LayoutView(keyword_hint_view_, kItemEditPadding, available_width, false,
               &location_bounds);
    if (!keyword_hint_view_->visible()) {
      // Put back the enlargement that we undid above.
      location_bounds.Inset(0, 0, -kEditInternalSpace, 0);
    }
  }

  // Layout out the suggested text view right aligned to the location
  // entry. Only show the suggested text if we can fit the text from one
  // character before the end of the selection to the end of the text and the
  // suggested text. If we can't it means either the suggested text is too big,
  // or the user has scrolled.

  // TODO(sky): We could potentially combine this with the previous step to
  // force using minimum size if necessary, but currently the chance of showing
  // keyword hints and suggested text is minimal and we're not confident this
  // is the right approach for suggested text.
  if (suggested_text_view_) {
    // TODO(sky): need to layout when the user changes caret position.
    int suggested_text_width =
        suggested_text_view_->GetPreferredSize().width();
    int vis_text_width = location_entry_->WidthOfTextAfterCursor();
    if (vis_text_width + suggested_text_width > entry_width) {
      // Hide the suggested text if the user has scrolled or we can't fit all
      // the suggested text.
      suggested_text_view_->SetBounds(0, 0, 0, 0);
    } else {
      int location_needed_width = location_entry_->TextWidth();
#if defined(USE_AURA)
      // TODO(sky): fix this. The +1 comes from the width of the cursor, without
      // the text ends up shifting to the left.
      location_needed_width++;
#endif
      location_bounds.set_width(std::min(location_needed_width,
                                         entry_width - suggested_text_width));
      // TODO(sky): figure out why this needs the -1.
      suggested_text_view_->SetBounds(location_bounds.right() - 1,
                                      location_bounds.y(),
                                      suggested_text_width,
                                      location_bounds.height());
    }
  }

  location_entry_view_->SetBoundsRect(location_bounds);
}

void LocationBarView::OnPaint(gfx::Canvas* canvas) {
  View::OnPaint(canvas);

  if (painter_.get()) {
    painter_->Paint(canvas, size());
  } else if (mode_ == POPUP) {
    canvas->TileImageInt(*GetThemeProvider()->GetImageSkiaNamed(
        IDR_LOCATIONBG_POPUPMODE_CENTER), 0, 0, 0, 0, width(), height());
  }
  // When used in the app launcher, don't draw a border, the LocationBarView has
  // its own views::Border.

  // Draw the background color so that the graphical elements at the edges
  // appear over the correct color.  (The edit draws its own background, so this
  // isn't important for that.)
  // TODO(pkasting): We need images that are transparent in the middle, so we
  // can draw the border images over the background color instead of the
  // reverse; this antialiases better (see comments in
  // OmniboxPopupContentsView::OnPaint()).
  gfx::Rect bounds(GetContentsBounds());
  bounds.Inset(0, kVerticalEdgeThickness);
  SkColor color(GetColor(ToolbarModel::NONE, BACKGROUND));
  if (mode_ == NORMAL) {
    SkPaint paint;
    paint.setColor(color);
    paint.setStyle(SkPaint::kFill_Style);
    paint.setAntiAlias(true);
    // TODO(jamescook): Make the corners of the dropdown match the corners of
    // the omnibox.
    const SkScalar radius(SkIntToScalar(kBorderCornerRadius));
    bounds.Inset(kNormalHorizontalEdgeThickness, 0);
    canvas->sk_canvas()->drawRoundRect(gfx::RectToSkRect(bounds), radius,
                                       radius, paint);
    if (action_box_button_view_)
      PaintActionBoxBackground(canvas, bounds);
  } else {
    canvas->FillRect(bounds, color);
  }

  if (show_focus_rect_ && HasFocus()) {
    gfx::Rect r = location_entry_view_->bounds();
    // TODO(jamescook): Is this still needed?
#if defined(OS_WIN)
    r.Inset(-1,  -1);
#else
    r.Inset(-1, 0);
#endif
    canvas->DrawFocusRect(r);
  }
}

void LocationBarView::SetShowFocusRect(bool show) {
  show_focus_rect_ = show;
  SchedulePaint();
}

void LocationBarView::SelectAll() {
  location_entry_->SelectAll(true);
}

#if defined(OS_WIN) && !defined(USE_AURA)
bool LocationBarView::OnMousePressed(const views::MouseEvent& event) {
  UINT msg;
  if (event.IsLeftMouseButton()) {
    msg = (event.flags() & ui::EF_IS_DOUBLE_CLICK) ?
        WM_LBUTTONDBLCLK : WM_LBUTTONDOWN;
  } else if (event.IsMiddleMouseButton()) {
    msg = (event.flags() & ui::EF_IS_DOUBLE_CLICK) ?
        WM_MBUTTONDBLCLK : WM_MBUTTONDOWN;
  } else if (event.IsRightMouseButton()) {
    msg = (event.flags() & ui::EF_IS_DOUBLE_CLICK) ?
        WM_RBUTTONDBLCLK : WM_RBUTTONDOWN;
  } else {
    NOTREACHED();
    return false;
  }
  OnMouseEvent(event, msg);
  return true;
}

bool LocationBarView::OnMouseDragged(const views::MouseEvent& event) {
  OnMouseEvent(event, WM_MOUSEMOVE);
  return true;
}

void LocationBarView::OnMouseReleased(const views::MouseEvent& event) {
  UINT msg;
  if (event.IsLeftMouseButton()) {
    msg = WM_LBUTTONUP;
  } else if (event.IsMiddleMouseButton()) {
    msg = WM_MBUTTONUP;
  } else if (event.IsRightMouseButton()) {
    msg = WM_RBUTTONUP;
  } else {
    NOTREACHED();
    return;
  }
  OnMouseEvent(event, msg);
}

void LocationBarView::OnMouseCaptureLost() {
  OmniboxViewWin* omnibox_win = GetOmniboxViewWin(location_entry_.get());
  if (omnibox_win)
    omnibox_win->HandleExternalMsg(WM_CAPTURECHANGED, 0, CPoint());
}
#endif

void LocationBarView::OnAutocompleteAccept(
    const GURL& url,
    WindowOpenDisposition disposition,
    content::PageTransition transition,
    const GURL& alternate_nav_url) {
  // WARNING: don't add an early return here. The calls after the if must
  // happen.
  if (url.is_valid()) {
    location_input_ = UTF8ToUTF16(url.spec());
    disposition_ = disposition;
    transition_ = content::PageTransitionFromInt(
        transition | content::PAGE_TRANSITION_FROM_ADDRESS_BAR);

    if (command_updater_) {
      if (!alternate_nav_url.is_valid()) {
        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);
        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
          // harmless.
          delete fetcher;
        } else {
          // The navigation controller will delete the fetcher.
        }
      }
    }
  }
}

void LocationBarView::OnChanged() {
  location_icon_view_->SetImage(
      ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
          location_entry_->GetIcon()));
  location_icon_view_->ShowTooltip(!GetLocationEntry()->IsEditingOrEmpty());

  Layout();
  SchedulePaint();
}

void LocationBarView::OnSelectionBoundsChanged() {
  if (suggested_text_view_)
    suggested_text_view_->StopAnimation();
}

void LocationBarView::OnInputInProgress(bool in_progress) {
  delegate_->OnInputInProgress(in_progress);
}

void LocationBarView::OnKillFocus() {
}

void LocationBarView::OnSetFocus() {
  views::FocusManager* focus_manager = GetFocusManager();
  if (!focus_manager) {
    NOTREACHED();
    return;
  }
  focus_manager->SetFocusedView(view_to_focus_);
}

SkBitmap LocationBarView::GetFavicon() const {
  return delegate_->GetTabContents()->favicon_tab_helper()->GetFavicon();
}

string16 LocationBarView::GetTitle() const {
  return GetWebContentsFromDelegate(delegate_)->GetTitle();
}

InstantController* LocationBarView::GetInstant() {
  return delegate_->GetInstant();
}

TabContents* LocationBarView::GetTabContents() const {
  return delegate_->GetTabContents();
}

int LocationBarView::AvailableWidth(int location_bar_width) {
  return location_bar_width - location_entry_->TextWidth();
}

void LocationBarView::LayoutView(views::View* view,
                                 int padding,
                                 int available_width,
                                 bool leading,
                                 gfx::Rect* bounds) {
  DCHECK(view && bounds);
  gfx::Size view_size = view->GetPreferredSize();
  if ((view_size.width() + padding) > available_width)
    view_size = view->GetMinimumSize();
  int desired_width = view_size.width() + padding;
  view->SetVisible(desired_width < bounds->width());
  if (view->visible()) {
    view->SetBounds(
        leading ? bounds->x() : (bounds->right() - view_size.width()),
        view->y(), view_size.width(), view->height());
    bounds->set_width(bounds->width() - desired_width);
  }
}

void LocationBarView::RefreshContentSettingViews() {
  for (ContentSettingViews::const_iterator i(content_setting_views_.begin());
       i != content_setting_views_.end(); ++i) {
    (*i)->UpdateFromWebContents(model_->input_in_progress() ? NULL :
                                GetWebContentsFromDelegate(delegate_));
  }
}

void LocationBarView::DeletePageActionViews() {
  for (PageActionViews::const_iterator i(page_action_views_.begin());
       i != page_action_views_.end(); ++i)
    RemoveChildView(*i);
  STLDeleteElements(&page_action_views_);
}

void LocationBarView::RefreshPageActionViews() {
  if (mode_ != NORMAL)
    return;

  // Remember the previous visibility of the page actions so that we can
  // notify when this changes.
  std::map<ExtensionAction*, bool> old_visibility;
  for (PageActionViews::const_iterator i(page_action_views_.begin());
       i != page_action_views_.end(); ++i) {
    old_visibility[(*i)->image_view()->page_action()] = (*i)->visible();
  }

  std::vector<ExtensionAction*> new_page_actions;

  TabContents* tab_contents = GetTabContents();
  if (tab_contents) {
    extensions::LocationBarController* controller =
        tab_contents->extension_tab_helper()->location_bar_controller();
    new_page_actions = controller->GetCurrentActions();
  }

  // On startup we sometimes haven't loaded any extensions. This makes sure
  // we catch up when the extensions (and any page actions) load.
  if (page_actions_ != new_page_actions) {
    page_actions_.swap(new_page_actions);
    DeletePageActionViews();  // Delete the old views (if any).

    page_action_views_.resize(page_actions_.size());
    View* right_anchor = chrome_to_mobile_view_;
    if (!right_anchor)
      right_anchor = star_view_;
    if (!right_anchor)
      right_anchor = action_box_button_view_;
    DCHECK(right_anchor);

    // Add the page actions in reverse order, so that the child views are
    // 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]));
      page_action_views_[i]->SetVisible(false);
      AddChildViewAt(page_action_views_[i], GetIndexOf(right_anchor));
    }
  }

  WebContents* contents = GetWebContentsFromDelegate(delegate_);
  if (!page_action_views_.empty() && contents) {
    Browser* browser = browser::FindBrowserWithWebContents(contents);
    GURL url = chrome::GetActiveWebContents(browser)->GetURL();

    for (PageActionViews::const_iterator i(page_action_views_.begin());
         i != page_action_views_.end(); ++i) {
      (*i)->UpdateVisibility(model_->input_in_progress() ? NULL : contents,
                             url);

      // Check if the visibility of the action changed and notify if it did.
      ExtensionAction* action = (*i)->image_view()->page_action();
      if (old_visibility.find(action) == old_visibility.end() ||
          old_visibility[action] != (*i)->visible()) {
        content::NotificationService::current()->Notify(
            chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED,
            content::Source<ExtensionAction>(action),
            content::Details<WebContents>(contents));
      }
    }
  }
}

#if defined(OS_WIN) && !defined(USE_AURA)
void LocationBarView::OnMouseEvent(const views::MouseEvent& event, UINT msg) {
  OmniboxViewWin* omnibox_win = GetOmniboxViewWin(location_entry_.get());
  if (omnibox_win) {
    UINT flags = event.native_event().wParam;
    gfx::Point screen_point(event.location());
    ConvertPointToScreen(this, &screen_point);
    omnibox_win->HandleExternalMsg(msg, flags, screen_point.ToPOINT());
  }
}
#endif

void LocationBarView::ShowFirstRunBubbleInternal() {
#if !defined(OS_CHROMEOS)
  // First run bubble doesn't make sense for Chrome OS.
  Browser* browser = GetBrowserFromDelegate(delegate_);
  FirstRunBubble::ShowBubble(browser, profile_, location_icon_view_);
#endif
}

void LocationBarView::PaintActionBoxBackground(gfx::Canvas* canvas,
                                               const gfx::Rect& content_rect) {
  // Draw action box background here so we can fill it up to the right hand
  // location bar border without any gap.
  gfx::Rect bounds(content_rect);
  // Fill button rectangle.
  int action_box_button_x = action_box_button_view_->bounds().x();
  bounds.Inset(action_box_button_x - bounds.x(), 0, 0, 0);
  SkPaint paint;
  paint.setStyle(SkPaint::kFill_Style);
  paint.setAntiAlias(true);
  paint.setColor(action_box_button_view_->GetBackgroundColor());
  canvas->DrawRoundRect(bounds, kBorderCornerRadius, paint);

  // Draw over left curved corners.
  bounds.set_width(kBorderCornerRadius);
  canvas->DrawRect(bounds, paint);

  // Draw left border.
  gfx::Point line_end(bounds.origin());
  line_end.Offset(0, bounds.height());
  canvas->DrawLine(bounds.origin(), line_end,
                   action_box_button_view_->GetBorderColor());
}

std::string LocationBarView::GetClassName() const {
  return kViewClassName;
}

bool LocationBarView::SkipDefaultKeyEventProcessing(
    const views::KeyEvent& event) {
#if defined(OS_WIN)
  if (views::FocusManager::IsTabTraversalKeyEvent(event)) {
    if (location_entry_->model()->popup_model()->IsOpen()) {
      // Return true so that the edit sees the tab and moves the selection.
      return true;
    }
    if (keyword_hint_view_->visible() && !event.IsShiftDown()) {
      // Return true so the edit gets the tab event and enters keyword mode.
      return true;
    }

    // Tab while showing instant commits instant immediately.
    // Return true so that focus traversal isn't attempted. The edit ends
    // up doing nothing in this case.
    if (location_entry_->model()->AcceptCurrentInstantPreview())
      return true;
  }

#if defined(USE_AURA)
  NOTIMPLEMENTED();
  return false;
#else
  OmniboxViewWin* omnibox_win = GetOmniboxViewWin(location_entry_.get());
  if (omnibox_win)
    return omnibox_win->SkipDefaultKeyEventProcessing(event);
#endif  // USE_AURA
#endif  // OS_WIN

  // This method is not used for Linux ports. See FocusManager::OnKeyEvent() in
  // src/ui/views/focus/focus_manager.cc for details.
  return false;
}

void LocationBarView::GetAccessibleState(ui::AccessibleViewState* state) {
  state->role = ui::AccessibilityTypes::ROLE_LOCATION_BAR;
  state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_LOCATION);
  state->value = location_entry_->GetText();

  string16::size_type entry_start;
  string16::size_type entry_end;
  location_entry_->GetSelectionBounds(&entry_start, &entry_end);
  state->selection_start = entry_start;
  state->selection_end = entry_end;
}

bool LocationBarView::HasFocus() const {
  return location_entry_->model()->has_focus();
}

void LocationBarView::WriteDragDataForView(views::View* sender,
                                           const gfx::Point& press_pt,
                                           OSExchangeData* data) {
  DCHECK_NE(GetDragOperationsForView(sender, press_pt),
            ui::DragDropTypes::DRAG_NONE);

  TabContents* tab_contents = delegate_->GetTabContents();
  DCHECK(tab_contents);
  button_drag_utils::SetURLAndDragImage(
      tab_contents->web_contents()->GetURL(),
      tab_contents->web_contents()->GetTitle(),
      tab_contents->favicon_tab_helper()->GetFavicon(),
      data,
      sender->GetWidget());
}

int LocationBarView::GetDragOperationsForView(views::View* sender,
                                              const gfx::Point& p) {
  DCHECK((sender == location_icon_view_) || (sender == ev_bubble_view_));
  WebContents* web_contents = GetWebContentsFromDelegate(delegate_);
  return (web_contents && web_contents->GetURL().is_valid() &&
          !GetLocationEntry()->IsEditingOrEmpty()) ?
      (ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK) :
      ui::DragDropTypes::DRAG_NONE;
}

bool LocationBarView::CanStartDragForView(View* sender,
                                          const gfx::Point& press_pt,
                                          const gfx::Point& p) {
  return true;
}

////////////////////////////////////////////////////////////////////////////////
// LocationBarView, LocationBar implementation:

void LocationBarView::ShowFirstRunBubble() {
  // Wait until search engines have loaded to show the first run bubble.
  TemplateURLService* url_service =
      TemplateURLServiceFactory::GetForProfile(profile_);
  if (!url_service->loaded()) {
    template_url_service_ = url_service;
    template_url_service_->AddObserver(this);
    template_url_service_->Load();
    return;
  }
  ShowFirstRunBubbleInternal();
}

void LocationBarView::SetSuggestedText(const string16& text,
                                       InstantCompleteBehavior behavior) {
  location_entry_->model()->SetSuggestedText(text, behavior);
}

string16 LocationBarView::GetInputString() const {
  return location_input_;
}

WindowOpenDisposition LocationBarView::GetWindowOpenDisposition() const {
  return disposition_;
}

content::PageTransition LocationBarView::GetPageTransition() const {
  return transition_;
}

void LocationBarView::AcceptInput() {
  location_entry_->model()->AcceptInput(CURRENT_TAB, false);
}

void LocationBarView::FocusLocation(bool select_all) {
  location_entry_->SetFocus();
  if (select_all)
    location_entry_->SelectAll(true);
}

void LocationBarView::FocusSearch() {
  location_entry_->SetFocus();
  location_entry_->SetForcedQuery();
}

void LocationBarView::SaveStateToContents(WebContents* contents) {
  location_entry_->SaveStateToTab(contents);
}

void LocationBarView::Revert() {
  location_entry_->RevertAll();
}

const OmniboxView* LocationBarView::GetLocationEntry() const {
  return location_entry_.get();
}

OmniboxView* LocationBarView::GetLocationEntry() {
  return location_entry_.get();
}

LocationBarTesting* LocationBarView::GetLocationBarForTesting() {
  return this;
}

int LocationBarView::PageActionCount() {
  return page_action_views_.size();
}

int LocationBarView::PageActionVisibleCount() {
  int result = 0;
  for (size_t i = 0; i < page_action_views_.size(); i++) {
    if (page_action_views_[i]->visible())
      ++result;
  }
  return result;
}

ExtensionAction* LocationBarView::GetPageAction(size_t index) {
  if (index < page_action_views_.size())
    return page_action_views_[index]->image_view()->page_action();

  NOTREACHED();
  return NULL;
}

ExtensionAction* LocationBarView::GetVisiblePageAction(size_t index) {
  size_t current = 0;
  for (size_t i = 0; i < page_action_views_.size(); ++i) {
    if (page_action_views_[i]->visible()) {
      if (current == index)
        return page_action_views_[i]->image_view()->page_action();

      ++current;
    }
  }

  NOTREACHED();
  return NULL;
}

void LocationBarView::TestPageActionPressed(size_t index) {
  size_t current = 0;
  for (size_t i = 0; i < page_action_views_.size(); ++i) {
    if (page_action_views_[i]->visible()) {
      if (current == index) {
        const int kLeftMouseButton = 1;
        page_action_views_[i]->image_view()->ExecuteAction(kLeftMouseButton);
        return;
      }
      ++current;
    }
  }

  NOTREACHED();
}

void LocationBarView::OnTemplateURLServiceChanged() {
  template_url_service_->RemoveObserver(this);
  template_url_service_ = NULL;
  // If the browser is no longer active, let's not show the info bubble, as this
  // would make the browser the active window again.
  if (location_entry_view_ && location_entry_view_->GetWidget()->IsActive())
    ShowFirstRunBubble();
}

void LocationBarView::Observe(int type,
                              const content::NotificationSource& source,
                              const content::NotificationDetails& details) {
  switch (type) {
    case chrome::NOTIFICATION_PREF_CHANGED: {
      std::string* name = content::Details<std::string>(details).ptr();
      if (*name == prefs::kEditBookmarksEnabled)
        Update(NULL);
      break;
    }

    case chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED: {
      // Only update if the updated action box was for the active tab contents.
      TabContents* target_tab = content::Details<TabContents>(details).ptr();
      if (target_tab == GetTabContents())
        UpdatePageActions();
      break;
    }

    default:
      NOTREACHED() << "Unexpected notification.";
  }
}

int LocationBarView::GetInternalHeight(bool use_preferred_size) {
  int total_height =
      use_preferred_size ? GetPreferredSize().height() : height();
  return std::max(total_height - (kVerticalEdgeThickness * 2), 0);
}

bool LocationBarView::HasValidSuggestText() const {
  return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() &&
      !suggested_text_view_->text().empty();
}

#if defined(USE_AURA)
void LocationBarView::StartFadeAnimation() {
  // We do an opacity animation on this view, so it needs a layer.
  SetPaintToLayer(true);
  layer()->SetFillsBoundsOpaquely(false);

  // Sub-pixel text rendering doesn't work properly on top of non-opaque
  // layers, so disable it by setting a transparent background color on the
  // bubble labels.
  const SkColor kTransparentWhite = SkColorSetARGB(128, 255, 255, 255);
  ev_bubble_view_->SetLabelBackgroundColor(kTransparentWhite);
  selected_keyword_view_->SetLabelBackgroundColor(kTransparentWhite);

  // Fade in opacity from 0 to 1.
  layer()->SetOpacity(0.f);
  ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator());
  fade_animation_observer_.reset(new FadeAnimationObserver(this));
  settings.AddObserver(fade_animation_observer_.get());
  settings.SetTransitionDuration(
      base::TimeDelta::FromMilliseconds(
          200 * InstantUI::GetSlowAnimationScaleFactor()));
  settings.SetTweenType(ui::Tween::LINEAR);
  layer()->SetOpacity(1.f);
}

void LocationBarView::StopFadeAnimation() {
  if (!layer())
    return;
  // Stop all animations.
  layer()->GetAnimator()->StopAnimating();
}

void LocationBarView::CleanupFadeAnimation() {
  // Since we're no longer animating we don't need our layer.
  SetPaintToLayer(false);
  // Bubble labels don't need a transparent background anymore.
  ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE);
  selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE);
}
#endif  // USE_AURA


Sextremist FEMENism 25/07/2013 RT World Apart . Boyko interviews Inna Shevchenko.
Breasts and politics - by combining the two with daring protests, FEMEN successfully captured the world's attention in a short period of time. But do they really help the causes they represent, or are they simply provocateurs, hungry for the limelight? To lay bare these issues, Oksana Boyko is joined by Inna Shevchenko, a prominent FEMEN activist.
This entry was posted in Countries, English and tagged Boyko, inna shevchenko, world apart on July 25, 2013 by sardananico.


text:
«We Made It» — сингл американского рэпера Басты Раймса, записанный совместно с рок-группой Linkin Park в 2008 году.

Структура песни
Песня начинается с игры Майка Шиноды на пианино, после чего следуют слова Честера Беннингтона. Баста Раймс поёт первый и третий куплет, а Майк — второй. В самом конце песни можно слышать гитарные риффы из песни Papercut с альбома Hybrid Theory, который был выпущен в качестве сингла 25 сентября 2001 года.

Трек не содержит ненормативную лексику, однако в нём можно слышать лёгкие ругательства, произнесённые Бастой — nigga () и shit (). Во второй версии песни данные слова были заменены на другие. Слово nigga в припеве было немного обрезано.

Клип
Премьера видеоклипа на песню состоялась во вторник 29 апреля 2008 года на телеканале BET, в тот же день сингл «We Made It» зазвучал на всех радиостанциях мира. В клипе, режиссёром которого стал Крис Робинсон, кроме самих исполнителей также присутствуют Styles of Beyond, Bishop Lamont и Ламар Одом. На складе, на котором была снята часть клипа, ранее были созданы художественные работы к альбому Linkin Park Meteora и сделана обложка к нему.

Видео начинается с представления LP и Басты Раймса, появляется название песни.

Linkin Park находятся на большом складе, Честер Беннингтон поет, а Майк Шинода исполняет свою сольную партию и играет на чёрном рояле; Баста Раймс сидит в квартире на последнем этаже одного из нью-йоркских домов и читает рэп. Параллельно с этим показано, как Беннингтон и Шинода исполняют песню на складе вместе с Бастой Раймсом.
В это время ночью в городе начинают собираться вместе люди. Они приходят к подножию большой горы и, когда начинается дождь, начинают подниматься на её вершину, Баста Раймс им помогает.

Список композиций

Чарты

Чарты на конец года

Примечания

Ссылки

Песни 2008 года
Синглы 2008 года
Синглы Linkin Park
Песни на английском языке
Песни Linkin Park
Песни рэп-рока
Альтернативный хип-хоп
Песни Басты Раймса

redpajama_set_name: RedPajamaWikipedia


text:
Lašva Valley ethnic cleansing
The Lašva Valley ethnic cleansing campaign against Bosniak civilians planned by the Croatian Community of Herzeg-Bosnia's political and military leadership from May 1992 to March 1993 and erupting the following April, was meant to implement objectives set forth by Croat nationalists in November 1991.[22] The Lašva Valley's Bosniaks were subjected to persecution on political, racial and religious grounds[56], deliberately discriminated against in the context of a widespread attack on the region's civilian population[57] and suffered mass murder, rape, imprisonment in camps, as well as the destruction of cultural sites and private property. This was often followed by anti-Bosniak propaganda, particularly in the municipalities of Vitez, Busovaca, Novi Travnik and Kiseljak. Ahmici massacre in April 1993, was the culmination of the Lašva Valley ethnic cleansing, resulting in mass killing of Bosnian Muslim civilians just in a few hours. An estimate puts the death toll at 120. The youngest was a three-month-old baby, who was shot to death in his crib, and the oldest was a 96-year-old woman. It is the biggest massacre committed during the conflict between Croats and the Bosnian government (dominated by Bosniaks).
The International Criminal Tribunal for the Former Yugoslavia (ICTY) has ruled that these crimes amounted to crimes against humanity in numerous verdicts against Croat political and military leaders and soldiers, most notably Dario Kordic. [58] Based on the evidence of numerous HVO attacks at that time, the ICTY Trial Chamber concluded in the Kordic and Cerkez case that by April 1993 Croat leadership had a common design or plan conceived and executed to ethnically cleanse Bosniaks from the Lašva Valley. Dario Kordic, as the local political leader, was found to be the planner and instigator of this plan. [59] According to the Sarajevo-based Research and Documentation Center (IDC), around 2,000 Bosniaks from the Lašva Valley are missing or were killed during this period.[60]
1. a b c "ICTY: Blaškic verdict - A. The Lasva Valley: May 1992 – January 1993t". [22]
2. "ICTY (1995): Initial indictment for the ethnic cleansing of the Lasva Valley area - Part II". [56]
3. "ICTY: Summary of sentencing judgement for Miroslav Bralo". [57]
4. a b c "ICTY: Kordic and Cerkez verdict". [58]
5. a b "ICTY: Kordic and Cerkez verdict - IV. Attacks on towns and villages: killings - C. The April 1993 Conflagration in Vitez and the Lašva Valley - 3. The Attack on Ahmici (Paragraph 642)". [59]
6. "IDC: Victim statistics in Novi Travnik, Vitez, Kiseljak and Busovaca".[60]
Tags: Lašva Valley, Croatian aggression, Ethnic cleansing

redpajama_set_name: RedPajamaCommonCrawl


text:
Society plans 21st Annual St. Patrick's Day Parade Brunch
By Sue
Oakland County Legal News
The Incorporated Society of Irish American Lawyers invites the legal community to the 21st Annual St. Patrick's Day Parade Brunch, preceding the St. Patrick's Day Parade, on Sunday, March 12, at Mario's Restaurant. Doors open at 9:45 a.m. with program and brunch from 10 to 11:30 a.m. Mario's Restaurant is located at 4222 Second Avenue in Detroit.
The event will feature music for a sing-a-long presented by Cahill & Murphy as well as snappy commentary from the MC who will be Michigan Court of Appeals Justice and former ISIAL President Mike Riordan, former State Senator Bruce Patterson, and attorney author Fred Lauck.
A return must-see to this year's entertainment program will be the expected appearances from the Maid of Erin and the parade grand marshal. Audience participation will factor heavily into our program. The event will also feature some great prizes for the annual raffle for the scholarship fund. Also expected to attend will be plenty of lawyers, judges, elected leaders, and dignitaries from the Detroit Irish-American community.
Reservations – priced at $25 per person for ISIAL members; $30 for ISIAL non-member guests; $10 for those children 12 years old and under; and $20 for law student ISIAL members – must purchased in advance by Friday, March 10. All adult brunches will be $35 at the door without a reservation and pre-payment. Tickets can be ordered by using Paypal by going to www.irish-lawyers.org, go to the Upcoming Events
section, and follow the instructions. Reservations will be kept at the door. Payment and reservation information can also be mailed to ISIAL, 38777 Six Mile Road, Suite 300, Livonia, 48152.
ISIAL will also offer advertising and sponsorship opportunities in the brunch program. Information on these opportunities can also be found on the ISIAL website at www.irish-lawyers.org or sending an email to garybres@msn.com.
headlines Oakland County
Presidents recognized
Presidential: Attorney takes the helm of the WCBA
Nessel joins effort urging regulators to protect workers from anticompetitive labor practices
Michigan high court mulls legality of weaker wage, sick time laws in 'adopt and?amend' case
Michigan Mortgage Lenders Association hosts 'Summer Mixer in the D'
You are here: HomeOakland County > Society plans 21st Annual St. Patrick's Day Parade Brunch


Is wood a sustainable source of energy?
Hearth and Home Technologies says 100 million homes can be heated sustainably with wood pellets.
May 16, 2009, 10:18 p.m.
Is wood the greatest untapped source of renewable energy in North America?
According to the U.S. Forest Service there are approximately 360 million dry tons of wood available annually in the U.S. A typical home requires 3 tons for heating. "That means we could heat 100 millions homes in our country."
This is not a new technology. There are currently 1 million homes heated by wood pellets, a product made from wood and wood scraps. The wood fiber is compressed into small pellets that resemble hamster food, making it easy to deliver. But these little pellets pack a big BTU punch (about 350,000 BTU's per cubic foot).
According to the Pellet Fuels Institute, that makes the fuel comparable to gasoline in terms of its efficiency to deliver heat (about twice the efficiency of ethanol).
Wood pellet technology is interesting in that it is one of the few renewable sources of "clean" energy (in quotes because wood burning is only clean if highly controlled) that specifically addresses U.S. heating needs.
For the most part, heating technologies on display at events like the Sustainable Energy Expo (where I shot this video of Dan Henry) tend toward efficiency -- preheating air or water using solar, more efficiency furnaces, on-demand water heaters, etc. All of these are great and can significantly reduce our heating demand, but right now most all of our fuel stocks are non-renewable -- gas, oil, and propane.
Rarely do you see a technology that addresses the actual fuel stock for heating. In the U.S. heating of homes accounts for about 40% of total home energy consumption (electricity is about 60%). No matter how many solar panels or wind farms we get, these clean technologies will never address our massive need for heating fuel.
But if we were to begin to use our forests as a source of fuel many questions arise, I think, about our ability to manage those forests sustainably. Yes, I agree forest fires are not a good thing (they are part of nature, but we just can't afford to have such massive CO2 dumps given our current over-carbonized atmosphere). And I do think the clearing of timber for firebreaks could indeed be an excellent source of fuel.
But I wonder how quickly the "sustainable management" of a forest would get reduced to privatized land rush for the next great heating fuel. If we treated our trees the way we treat our oil, it's difficult to imagine that the forests could remain in tact for very long.


Regardless of the type of aircraft you want to fly, learning from an experienced pilot using a trainer aircraft is an important first step. Computer-based model flight simulators are another awesome tool to help you learn to operate an aircraft using a transmitter. And you can crash your virtual aircraft as much as you want without damaging a plane, a person, or your wallet!
Click and explore the types of aircraft below to help you get started!
You'll need an open space. It could be an AMA club field, your own backyard or a large indoor space (like a gymnasium)—any place that's large, legal and safe will do. Wherever you choose to fly, ensure you have permission from the property owner and that you are following local and national laws.
Whatever you fly. Wherever you are. AMA has you covered.
Enjoy your monthly issue of Model Aviation Magazine featuring how-to articles, recurring columns, product reviews, AMA member features, district and industry news and more.
Obtain privileges to compete anually in more than 2,500 national AMA sanctioned events including the National and World Aeromodeling Championships.


You reside in a location where there is limited rainfall, but you want to plant some trees around your house. That's usually where a lot of people find themselves, especially when they choose to live in the southern part of the United States. Often, people might buy trees to enhance their home without knowing how much water is required. There are trees that are able to survive with not much water, and they might be the kind you need to buy. Be sure you do not rush out and buy two or three trees without doing some research.
The least difficult type of tree to have are ones that natively grow in the area you live. They'll be able to develop well due to the fact they are already able to grow with little water. Go on a drive through undeveloped areas of your town, and see which trees are still green. Those which are green are the ones that you should have in your garden. Even though some of these trees might not be the best looking, at least you will have them.
A particular tree which can grow in almost every condition and with any amount of water is Scotch Pine. This particular sturdy tree can grow about twenty inches a year with very little water. It does not take much to plant these trees and they can grow quickly to 25 to 35 feet. Most of these trees are offered by the vast majority of nurseries, especially in areas where enough water is a problem. There are different varieties of Scotch Pine and a few of them turn to a yellowish brown color when the weather gets cold. Some individuals love this look, but some varieties don't do this.
An additionally simple to grow tree that is hardy, is the Rocky Mountain Juniper. During the winter season, the tree gets brown but becomes green again during the spring. As tough as they may be, they are frequently employed as windbreaks, and they work great if you are trying to attract birds. They already have plenty of branches to nest in, but their speed of growth is only around 10 inches a year. This is slow when compared with several other hardy trees. The Russian Olive tree is the one other popular tree that will require very little water. This is a considerably more elaborate tree compared to others and looks quite beautiful when it's all grown up. This tree is sturdy enough to grow in numerous types of soil and has berries that birds find attractive to eat.
If you're living where your water is restricted, you do have options. If you carry out the investigation, whether online or at your local nursery, you'll find something that will grow well in your yard. You can certainly get the trees that you want by simply driving around the nearby area.


Previous Post Why your typical work day might be causing you more harm than good.
It iѕs the Ƅest timе too make some plans for the fᥙture and it's time to be happy.
I have read this post and if I could I wish to suggest yօu few interesting thingѕ or aɗvice.
Perhsps you could write next articles referring to this article.
I ddesiгe to read even moгe things about it!
Definitely! I'm going to write more about this! Also you can subscribe to my blog to make sure that you get my posts the moment I publish them!


Dark rums are a popular player in cocktails, from a Mai Tai to a Zombie or the Christmas classic Eggnog. Dark rum is made from molasses and tends to retain its natural flavour - that tan is au naturel. Dark rum are generally dark, rich and has a fuller body. Dark rums are also commonly flavoured with things like spices, caramel and vanilla.


text:
Congress To Remove Bust Of Supreme Court Justice Responsible For Dred Scott Ruling
The bust of former Chief Justice Roger Taney will be removed from the Capitol building due to his involvement in the Dred Scott decision in 1857 and replaced with Justice Thurgood Marshall, according to a House Bill passed Wednesday.
Taney wrote the majority opinion for Dred Scott v. Sandford when the Supreme Court ruled that citizenship did not extend to enslaved people of African American descent. The bill was introduced to the House in 2020 by Democratic Rep. Steny Hoyer and Rep. David Trone, according to NBC News.
"The Dred Scott v. Sandford Supreme Court decision is a stain on our country's history, and it was made under the Taney Court," Trone stated in the press release for the bill. "It's time for us to remove this statue and denounce the institutions of slavery and racism once and for all. They have no place in the United States Capitol or anywhere in our country."
Taney's bust would be replaced by Justice Thurgood Marshall, the first black Supreme Court Justice to sit on the bench, according to the New York Times. Marshall, a civil rights activist who argued before the Supreme Court during Brown v. Board of Education, was nominated by President Lyndon B. Johnson to the Supreme Court in 1967.
If signed by President Biden, Capitol officials will remove Taney's bust within 45 days and replace it with Marshall's within two years, according to NBC. The bill was sponsored by Democratic Sen. Benjamin Cardin and passed the Senate a week before the House vote, according to the Times.
A statue of Taney was removed from Maryland's state House in 2017. The statue had been on the grounds since 1872 almost a decade after Taney's death.
The Supreme Court, Hoyer, Cardin and Trone did not respond to the Daily Caller News Foundation's request for comment.
All content created by the Daily Caller News Foundation, an independent and nonpartisan newswire service, is available without charge to any legitimate news publisher that can provide a large audience. All republished articles must include our logo, our reporter's byline and their DCNF affiliation. For any questions about our guidelines or partnering with us, please contact licensing@dailycallernewsfoundation.org.


Singidunum University is a higher education institution that offers its students modern curricula and teaching methods resembling those of the renowned university centers. Our goal is to empower young people to be competitive in the market and keep pace with contemporary tendencies and business trends.
Singidunum University is the first private university accredited under the new Law on Higher Education. There are currently around 12,000 students enrolled at Singidunum University. Lectures are carried out within 16,000 m² of high-quality space equipped with necessary computer and Internet infrastructure, audio-video and other word-class amenities necessary for the efficient learning and teaching process. The University disposes of 16 amphitheatres, 20 lecture halls and 9 computer rooms.
The University curricula are harmonized with the principles of the Bologna Declaration and include the European Credit Transfer System (ECTS). All our study programmes are designed to meet the needs of the modern business environment, with lectures being held in high-quality modern premises by over 300 eminent professors from the country and abroad. The University successfully cooperates with distinguished higher education institutions from the USA and Europe, as well as with the leading representatives of the Serbian business community.
The University is permanently catching up with modern scientific trends and achievements, including transmission of knowledge through modern curricula. Our principal mission is training and education of high quality personnel, experts in their respective fields who could contribute considerably to the overall social and economic development and modernization of Serbia.
Therefore, the University's mission is to allow transfer of contemporary knowledge, methods and scientific techniques, applied at prominent European University centers, taking into account all good practices of our state higher education institutions.
Singidunum University strives to educate and train personnel and provide them with relevant knowledge and skills to compete efficiently in the labor market, as well as to enable future graduates to keep pace with modern business trends without additional professional advancement.


text:
Begonia phamiana est une espèce de plantes de la famille des Begoniaceae.
L'espèce fait partie de la section Parvibegonia.
Elle a été décrite en 2007 par Ruth Kiew (1946-…).

Description

Répartition géographique
Cette espèce est originaire des pays suivants : Cambodge ; Viet Nam.

Notes et références

Liens externes

phamiana
phamiana


text:
Seldo.com
A conversation with Rick Santorum
Me: Hello, sir. I'd like to ask a fundamental question about your beliefs.
Rick: Uh, sure.
Me: I'm gay, and I'd like to get married someday. Can you tell me why you don't think that should happen?
Rick: Well, first I'd like to say that I don't discriminate against gay people. I believe they should be treated equally under the law. What I don't believe is that people should be able to change the definition of marriage, a sacred institution that has stood for thousands of years.
Me: But why shouldn't we change the definition? We changed the definition in 1967, when we said that a marriage between people of different races was okay.
Rick: That wasn't changing the definition. The Bible doesn't say anything about people of different races. What it does say is that marriage is between a man and a woman, and it has been for thousands of years.
Me: But allowing gay marriage doesn't stop straight marriages. A marriage will still be between a man and a woman, just also between two men or two women. How does changing the definition harm that?
Rick: It's not a matter of whether or not changing the definition harms anybody. Marriage is what marriage is. You can't change religion by passing a law, that tramples on religious freedoms.
Me: But marriage isn't just a religious ceremony, it's also a legal one. Is the word the problem? Would it be acceptable to give gay people Civil Unions, with all the rights of marriage but without the religious connotations?
Rick: No, I'm against that. I believe if people want those rights they can get them by forming contracts under existing contract law.
Me: But what about rights that can't be obtained by private contracts, like immigration rights, tax exemptions on inheriting property, and not being forced to testify against your spouse in court?
Rick: I believe there's something bigger at stake here. I think in the interests of children, in the interests of families, and in the interest of society, marriage should be defined as being between one man and one woman.
Me: Can you explain to me how children or society are harmed by allowing gay marriages?
Rick: The central purpose of marriage is procreation, to create children for the next generation. As we get further away from that ideal, children suffer and cultures die.
Me: Can you explain how the existence of gay couples who can't biologically have children is different from opposite-sex couples who can't? How do either of those relationships harm children?
Rick: Men and women who want to have children together should have privileged status over people who want to have a relationship together. By saying other types of relationships are okay -- I think we are harming children.
Me: Doesn't that imply you think gay relationships are not okay? That seems at odds with your statement that you don't discriminate against gay people.
Rick: I have no problem with homosexuality. I have a problem with homosexual acts. As I would with other acts outside of traditional heterosexual relationships. And that includes a variety of different acts, not just homosexual. I have absolutely nothing against anyone who's homosexual. If that's their orientation, then I accept that. The question is, do you act upon that orientation?
Me: So are gay relationships okay as long as they don't have sex? Isn't that at odds with equality under the law?
Rick: We have sodomy laws and they were there for a purpose. Because, I would argue, they undermine the basic tenets of our society and the family. And if the Supreme Court says that you have the right to consensual sex within your home, then you have the right to bigamy, you have you have the right to incest, you have the right to adultery. You have the right to anything. Does that undermine the fabric of our society? I would argue yes, it does.
Me: I think I get it.
This hypothetical conversation never happened; Mr. Santorum's answers are an amalgamation of his public statements on gay marriage and civil unions, and most of the replies are quotes from similar contexts. Sources: [1][2][3]
floof-with-border
© 2001 - 2020 Laurie Voss.
Home | About me | Archive


How do you find peace amidst earthly suffering, endless headlines, and personal anxiety?
In Take Cover: Finding Peace in God's Protection, Pastor and former police officer Philip De Courcy urges Christians to turn and take cover in God as their source of ultimate peace.
Drawing on lessons he learned in law enforcement, De Courcy offers practical advice and biblical examples to reveal that true security is not found in the absence of danger, but in the presence of God. In each chapter, Pastor Philip identifies major dangers today's Christians face and prominent spiritual threats—including crime, North Korea, Islamic terror, aggressive secularism, and spiritual warfare.
Rather than providing escapist strategies or self-help guidance, De Courcy conversationally encourages readers to take cover in God to meet life's challenges head-on—equipped with the spiritual strength only He can provide.


text:
Sexual behaviour among male methamphetamine and heroin dependents in selected areas in Malaysia
MOHD FADZLI MOHAMAD ISA1, NG, CHONG GUAN2, RUSDI ABD RASHID3, MOHD HUSSAIN HABIL4, HATTA SIDI5, MAS AYU SAID6, AHMAD HATIM SULAIMAN7.
This study aims to describe the pattern of sexual behaviour among methamphetamine and heroin users. It describes the pattern of sexual behaviour based on aspects of sex such as desire, interest, drive and obsession in relation to the drug use. A cross-sectional study was carried out among attendees of drug rehabilitation programmes in Kota Kinabalu, Kota Bharu and Kuala Lumpur. All subjects were living in the community with satisfactory psychosocial functioning. This study was primarily based on a validated sexual behaviour self-rated questionnaire followed by face-to-face interview. A total of 227 subjects were included with 124 (54.6%) using methamphetamine while 103 (45.4%) using heroin. Majority (218; 96%) were heterosexuals with 104 (45.8%) reported having been involved in high risk sexual behaviour. More methamphetamine than heroin subjects agreed that their sexual thoughts, feelings and behaviours were often associated with the drug (p<0.05). Methamphetamine subjects agreed that the use of methamphetamine caused them to be more obsessed with sex and they found themselves to be preoccupied with sexual thoughts while being under the influence of the drug (p<0.05). Heroin subjects mainly reported on negative effects of the drug on their sexual behaviour. Methamphetamine subjects reported that the use of drug had positively affected their sexual interest and drive (p<0.05). Methamphetamine subjects were also 1.97 times more likely than heroin subjects to be involved in risky sexual behaviour. The results of this study can be utilized to improve the drug treatment and rehabilitation programme. Methamphetamine subjects were more likely than heroin subjects to be involved in risky sexual behaviour.
University Malaya Centre of Addiction Sciences, Malaysia
Universiti Kebangsaan Malaysia, Malaysia
Toggle translation


text:
The Gator Nationals
After a soggy start to the weekend with a rainout on Saturday night, the Gator Nationals finally got underway on Sunday evening. Five classes of racing took to the track to do battle on this Memorial Day Weekend, and as expected the show kept fans on their feet all night.
The feature events kicked off with a 20-lap DIRTcar UMP Modified race and a $2000 winner's purse. Seth Geary started on the pole and took the early lead. Garret Stewart charged thru the pack from his seventh starting position to second, and after a caution with five to go he got his chance at Geary. On the restart Stewart pulled to the inside of Geary and the two raced side-by-side for a couple of laps, but Geary was able to pull back ahead at the white flag and went on to win the race.
In the second feature event of the evening the Thunder Stocks took the track for what would be a caution filled race. Young Bubba Roling was the early leader holding off several challenges from seasoned veterans, but on a restart on lap seven Shaun Daugharty used the inside line in turn one to take the lead and never look back. Roling held on for a second place finish, and Charlie Staats finished third.
The third feature of the night was the 602 Late Models. With $1500 on the line we all knew this would be a good race. Brenden Smith won his heat race and took the early lead in the feature, closely trailed by Mikey Kopka and Dustin Carter. As the race wound down it was clear that Brenden Smith was not going to be caught tonight. He went on to win with Kopka and Carter finishing second and third.
The ¾ Modifieds were the fourth feature of the night. Timmy Hogan took the early lead, while Wade Olmstead and Dustin Peterson put on a show behind him running side-by-side for second. With six laps to go Olmstead took the long way around turn one and two riding the cushion and taking the lead down the back stretch. A caution on the next lap tightened up the field, but once the green flag dropped it was clear Olmstead was on a mission. He went on to pick up his first feature win with Hogan and Powers rounding out the top three.
In the final feature of the night the Street Stocks took the track. An early side-by-side battle between David Showers Jr and Bubba Christian set up a very fast paced race. Christian took the lead on the third lap and never looked back notching the victory. Chris Lawrance moved up to take second, and Showers finished third.
We thank everyone who joined us this Memorial Day weekend, especially our veterans. Our next race is the Sunshine Showdown on June 12th.
PrevPreviousThe Dennis North Memorial
NextThe Sunshine ShowdownNext


The father of the telephone was born this day in 1847. He passed away in 1922, but his telephonic contribution to our society continues to be a tremendous factor in everyday life. Not as many of us realize that Mr. Bell was also considered to be influential in aeronautics as well as a founding member of the National Geographic Society.
Use that famous, historic invention of his to make a date with destiny and experience History in VogueTM for yourself.
Bring moar green chile fud. kthxbai.


text:
Q: java.lang.OutOfMemoryError on using Spring Boot WebFlux Starter I have created 2 Microservices with Spring Boot (version 1.5.1 RELEASE), Spring Cloud(Edgware.SR3), Spring Cloud Starter Config (version 1.4.3 RELEASE) and Netflix's Eureka naming server (Spring Cloud Starter Netflix Eureka Client/Server 1.4.4 RELEASE):

*

*A Eureka Server (a service meant to register microservices)

*A Eureka Client (a DB service meant for save/update operations)

Eureka Client is a simple Restful Service with a single@PostMapping annotated method which accepts a sizeable object as an argument (@RequestBody MyObject object).
Eureka client registers itself with Eureka server successfully.
Then with the help of Spring Boot Webflux, I try to access my Eureka Client with the help of class WebClient which is introduced in Spring 5 and is an improvisation on AsyncRestTemplate class. I do something like below :
WebClient webClient = WebClient.create();
reactor.core.publisher.Mono result = (Mono) webClient.post()
.uri("http://localhost:8080/eureka-client")
.body(BodyInserters.fromObject(//myComplexObject here))
.retrieve()
.bodyToMono(String.class);

result.subscribe();

On debugging, I found that I get OOM exception after last line of above code.
io.netty.handler.codec.EncoderException: java.lang.OutOfMemoryError

Full Stack Trace below :
[reactor-http-nio-4] WARN  io.netty.util.concurrent.AbstractEventExecutor  - A task raised an exception. Task: reactor.ipc.netty.channel.ContextHandler$$Lambda$401/11401686@10ae5a2

reactor.core.Exceptions$ErrorCallbackNotImplemented: io.netty.handler.codec.EncoderException: java.lang.OutOfMemoryError

Caused by: io.netty.handler.codec.EncoderException: java.lang.OutOfMemoryError

                at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:106)

                at io.netty.channel.CombinedChannelDuplexHandler.write(CombinedChannelDuplexHandler.java:348)

                at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:738)

                at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:730)

                at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:816)

                at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:723)

                at reactor.ipc.netty.channel.ChannelOperationsHandler.doWrite(ChannelOperationsHandler.java:291)

                at reactor.ipc.netty.channel.ChannelOperationsHandler.drain(ChannelOperationsHandler.java:465)

                at reactor.ipc.netty.channel.ChannelOperationsHandler.flush(ChannelOperationsHandler.java:191)

                at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776)

                at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:802)

                at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:814)

                at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:794)

                at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:831)

                at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1051)

                at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:300)

                at reactor.ipc.netty.http.HttpOperations.lambda$then$0(HttpOperations.java:135)

                at reactor.ipc.netty.FutureMono.lambda$deferFuture$0(FutureMono.java:68)

                at reactor.ipc.netty.FutureMono$DeferredFutureMono.subscribe(FutureMono.java:134)

                at reactor.core.publisher.Mono.subscribe(Mono.java:3008)

                at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:167)

                at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56)

                at reactor.core.publisher.Mono.subscribe(Mono.java:3008)

                at reactor.core.publisher.FluxConcatIterable$ConcatIterableSubscriber.onComplete(FluxConcatIterable.java:141)

                at reactor.core.publisher.FluxConcatIterable.subscribe(FluxConcatIterable.java:60)

                at reactor.core.publisher.MonoSourceFlux.subscribe(MonoSourceFlux.java:47)

                at reactor.ipc.netty.channel.ChannelOperations.applyHandler(ChannelOperations.java:380)

                at reactor.ipc.netty.http.client.HttpClientOperations.onHandlerStart(HttpClientOperations.java:501)

                at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)

                at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)

                at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463)

                at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)

                at java.lang.Thread.run(Thread.java:745)

Caused by: java.lang.OutOfMemoryError

                at sun.misc.Unsafe.allocateMemory(Native Method)

                at io.netty.util.internal.PlatformDependent0.allocateDirectNoCleaner(PlatformDependent0.java:430)

                at io.netty.util.internal.PlatformDependent.allocateDirectNoCleaner(PlatformDependent.java:596)

                at io.netty.buffer.PoolArena$DirectArena.allocateDirect(PoolArena.java:764)

                at io.netty.buffer.PoolArena$DirectArena.newChunk(PoolArena.java:740)

                at io.netty.buffer.PoolArena.allocateNormal(PoolArena.java:244)

                at io.netty.buffer.PoolArena.allocate(PoolArena.java:214)

                at io.netty.buffer.PoolArena.allocate(PoolArena.java:146)

                at io.netty.buffer.PooledByteBufAllocator.newDirectBuffer(PooledByteBufAllocator.java:324)

                at io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:185)

                at io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:176)

                at io.netty.buffer.AbstractByteBufAllocator.buffer(AbstractByteBufAllocator.java:113)

                at io.netty.handler.codec.http.HttpObjectEncoder.encode(HttpObjectEncoder.java:92)

                at io.netty.handler.codec.http.HttpClientCodec$Encoder.encode(HttpClientCodec.java:167)

                at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:88)

                ... 32 more

I have jackson library in my classpath and rely on spring to serialize my complex object while passing it to Restful service. I am not sure what may cause this. Any pointers please?

A: add this in java execution path
-Dio.netty.noPreferDirect=true

redpajama_set_name: RedPajamaStackExchange


Thinking about raising goats for milk? There are many goat milk benefits, including making goat cheese or learning how to make goat milk soap. But there are a few things to consider about raising goats for milk before you take the leap.
1. Is raising goats for milk legal in my area?
Even if you already keep backyard chickens or are raising rabbits for meat, that doesn't mean raising goats for milk is allowed. To be sure, check with your local zoning and homeowner regulations as to whether raising goats is permitted and, if so, how many you can legally have.
2. Goats are social animals.
A single goat will complain loud enough for the whole neighborhood to get the point. So plan on having at least two. They can be two does (females) or a doe and a wether (castrated male). With two does you can stagger breeding to produce milk year-round. Otherwise you will have some months of plenty and some months without any milk.
3. You need access to a buck (male).
A doe must be periodically bred to refresh her milk cycle. A buck is difficult to maintain, and is not worth the hassle or expense for just one or two does. Options include arranging with a nearby goat owner for stud service or using artificial insemination (AI). Your veterinarian should be able to help you find someone skilled at AI.
4. Does a local veterinarian treat goats?
Not all veterinarians understand goat medicine. If your local vets are not well versed in goats, at least seek an experienced goat keeper willing to help you out, should your goats ever need medical assistance.
5. Do you have, or can you provide, a goat tight fence?
Goat owners are fond of saying a fence that won't hold water won't hold a goat. Of course, that's an exaggeration, but only slightly so. Goats are Houdinis at climbing over, under, or through a less than adequate fence, to the detriment of your (or your neighbor's) garden and landscaping.
6. What will you do with the kids?
A dairy doe produces one or more kids every 15 months or so. If you try to keep them all, you'll soon be goat poor, so have a plan for dealing with those bouncing bundles of joy — and stick to it. Options include selling them or butchering them for meat. A common plan is the sell the doelings and turn the bucklings into roasts and burger. (Goat meat recipes are similar to venison recipes.) Also, learn more about managing your goat herd for optimum reproduction.
7. Milking is a daily event.
If you can't be available to milk every day, you'll need to arrange for help. If you milk twice a day, morning and evening, you'll get a little more milk than if you milk only once a day. Some goat keepers optimize milk production by milking three times daily — morning, noon, and evening.
8. What will you do with all the milk?
Depending on the breed and bloodlines, a good doe may produce as much as a gallon and a half a day soon after kidding, dwindling down to a quart or less within 9 or 10 months. Some does produce much less to start with, and their production drops quicker. Ask about the milk production of your prospective doe's dam (mother) and sire's dam (paternal grandmother).
9. There are many benefits of goat milk, but do you like it?
A lot of people, including me, like goat milk better than cow milk. The infamous off-flavor milk typically results from not caring for goats properly, such as keeping goats in filthy conditions, improper diet, or housing milkers with a buck in rut. On the other hand, the occasional doe receiving good basic care naturally produces off-flavor milk as a matter of genetics, so ask to taste your prospective doe's milk (or her dam's milk). A scant few people claim to be able to taste the active enzymes in fresh goat milk, which multiply over time to the point that nearly anyone can taste them in milk that's been stored too long.
Pasteurizing kills the enzymes, but also destroys the healthful benefits of goat milk. Further, pasteurized goat milk keeps only about half as long as raw milk, which remains tasty for up to 10 days in the fridge. But long before then, the milk from your own dairy goats will have disappeared in glasses of refreshing ice cold milk, enjoyed over breakfast cereal or made into delicious homemade yogurt and ice cream.
a, and, animals, backyard chickens, benefits, breeding, caring for goats, cheese, cold, dairy goats, does, for, fresh, garden, goat, goat meat, goat meat recipes, goat milk, goat milk benefits, goat milk soap, goats, homemade, how, how to make goat milk, how to make goat milk soap, how. to, in, keeping goats, long, make, making goat cheese, mean, meat, milk production, of, raising, raising goats, raising goats for milk, raising rabbits, raising rabbits for meat, social, that, the, to, venison, what, whole.
Properly pasteurized milk will last much longer than raw milk.
Thank you for this information. Very useful.


text:
Mark Baker is an American politician and Republican member of the Wyoming House of Representatives, representing the 60th district since January 4, 2021. Baker previously served as a representative from the 48th district from January 8, 2013, until his resignation on May 15, 2017.

Elections

2012
Challenging incumbent Democratic Representative Joseph M. Barbuto for the District 48 seat, Baker was unopposed for the August 21, 2012 Republican Primary, winning with 374 votes, and won the November 6, 2012 General election with 1,723 votes (49.5%) against Barbuto.

2014
Baker faced a rematch against former Democratic Representative Joseph M. Barbuto.  Baker ran unopposed in the Republican primary and defeated Barbuto by 27 votes, taking 50.4% of the vote.

2016
Baker ran unopposed in the Republican primary, and defeated Democratic Western Wyoming Community College administrator Jackie Freeze with 58.3% of the vote.

References

External links
Official page at the Wyoming Legislature

Place of birth missing (living people)
Year of birth missing (living people)
Living people
Republican Party members of the Wyoming House of Representatives
People from Rock Springs, Wyoming
21st-century American politicians


Crescendo Interior & Lifestyle P/L is an interior design consultancy in Singapore devoted to the creation of a unique lifestyle experience for our clients.
Our interior design firm comes with a whole team of experienced and friendly sales and design consultants which committed to providing interior design expertise and services according to the individual client's needs.
We are suitable for creating different designs for both domestic and commercial purposes, which makes us the chosen interior design consultancy for individual home, HDB and condo owners in Singapore, as well as developers constructing condominiums and office blocks, making us one of the best companies to work with, since we also manage part of our business online offering all our services and using cfo advisory services to manage our finances of all these types of clients.
We are reviewed by using their 50-Point Inspection which includes everything from checking reputation, history, complaints, ratings, nearness, satisfaction, trust and cost to the general excellence. Many office interior refurbishment agencies offer a full design and fit out service which you will get here and so much more !
"Three Best Rated® was created with a simple goal to find you the top 3 local businesses, professionals, restaurants and health care providers in your region where they offer different health treatments and information, as the 100% Organic DHEA Cream for Men and Women, which is great to improve health, although there are other measures you can take to keep your best health possible, a good diet is always involve in this, along with supplements as the patriot power greens that help with this. We display only businesses that are verified by our employees since customers deserve only the best.


Lisyanet Rodr�guez is a metaphor and rootstock maker. Her work, at ease, enjoys a double condition: on one hand, the centralization of the admitted beauty as a clear drive, and on the other hand, the ascension of strangeness turned into the space in which the fruition of the unsettling is generated. Her works reveal themselves as authentic allegoric tapestries that do not invoke fiction exactly as one might think, but instead they approach her own life as a visual biography of what her childhood once was. These works should not only be read�or at least not just�as aesthetic formalizations narrating a great technical virtuosity. They should be read as a symbolic revelation of her personal and family story, as the emphatic treaty that registers all clues and hints of a certain existence, the snapshot of a present seeking to cross paths with the past. To the same extent I worship words and invite them to be a substantial member of my world, Lisyanet�in her own way�turns the fiction of art into the essence of life. She builds a private mythology that dwells at its own will and whim. The characters that inhabit this world with her seem freed from an odd land, from an island perhaps. The silence of their spaces and blindness disclose them stripped from their competencies and powers. These characters appear to speak out against stereotyped worlds, announcing their happiness while singing their confusing bitterness. Their lives fluctuate between the trivial and the mournful, the verbal density and epiphany.
From there, perhaps, that particular magnetism crosses through her imagery turning it into an ally for remembrance. Lisyanet, who is part of a generation that shares a derivative accent bearing certain sense of constant quoting, has attained something vital for an art piece�s consolidation and prevalence: the creation of a personal style based on the postulation of a personal and unique voice. She has been able to generate poetics per se. And none of this stems from the grandiloquence of anthropological searches or trendy pseudo conceptualisms that, from time to time, result in noisy caricatures of triviality�and vanity. In Lisyanet, said finding is indeed produced through an inquiry of her life�s passages.


Multi-Comic Event featuring Madelein Smith, Linda Belt and Angel Rentas . Doors open at 6pm and show starts at 7pm.
The Kiltonic Post 72 - American Legion Centennial Gala will be held on November 9, 2019 at the Aqua Turf Club.
Multi-Comic Event featuring Jody Sloane, Steve Guilmette and Tim McKeever. Doors open at 6pm and show starts at 7pm. This promises to be a great show!
Checkout our next Comedy Night. Hosted by Ryan Dinesco with Openening Comedian Andy McDermot and Comedians Paul Schissler and Jeff Scott. This promises to be a great show!
Come check out our next Comedy Night featuring Chip Ambrogio, Regina DeCicco and John McClellan.
Chicken & Rib BBQ. Advance Tickets Required (So we have enough food). Cash Bar Available.
Includes: greens fees, cart, access to driving range, lunch, dinner & prizes.
Come check out this comedy trio that promises to be another great night!
Join us for our forth and final comedy night of 2017! 3 Headliner Act starring John McClellan, Corey Alexander & Sandy Ehlers. Doors Open at 6pm, Show Starts at 7pm.
Adam Oliensis and two other comedians will be performing our third show of 2017 on September 9th at the post hall!