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

Side by Side Diff: chrome/browser/ui/views/search_view_controller.cc

Issue 11091050: InstantExtended: Add js api for custom logo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/search_view_controller.h" 5 #include "chrome/browser/ui/views/search_view_controller.h"
6 6
7 #include "chrome/browser/instant/instant_controller.h" 7 #include "chrome/browser/instant/instant_controller.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/search_engines/search_engine_type.h" 9 #include "chrome/browser/search_engines/search_engine_type.h"
10 #include "chrome/browser/search_engines/template_url.h" 10 #include "chrome/browser/search_engines/template_url.h"
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 : browser_context_(browser_context), 242 : browser_context_(browser_context),
243 contents_container_(contents_container), 243 contents_container_(contents_container),
244 toolbar_search_animator_(toolbar_search_animator), 244 toolbar_search_animator_(toolbar_search_animator),
245 toolbar_view_(toolbar_view), 245 toolbar_view_(toolbar_view),
246 location_bar_container_(NULL), 246 location_bar_container_(NULL),
247 state_(STATE_NOT_VISIBLE), 247 state_(STATE_NOT_VISIBLE),
248 tab_contents_(NULL), 248 tab_contents_(NULL),
249 search_container_(NULL), 249 search_container_(NULL),
250 ntp_container_(NULL), 250 ntp_container_(NULL),
251 content_view_(NULL), 251 content_view_(NULL),
252 omnibox_popup_parent_(NULL) { 252 omnibox_popup_parent_(NULL),
253 instant_has_custom_logo_(false) {
253 omnibox_popup_parent_ = new internal::OmniboxPopupContainer(this); 254 omnibox_popup_parent_ = new internal::OmniboxPopupContainer(this);
254 } 255 }
255 256
256 SearchViewController::~SearchViewController() { 257 SearchViewController::~SearchViewController() {
257 if (search_model()) 258 if (search_model())
258 search_model()->RemoveObserver(this); 259 search_model()->RemoveObserver(this);
259 260
260 // If the |omnibox_popup_view_| isn't parented, delete it. Otherwise it'll be 261 // If the |omnibox_popup_view_| isn't parented, delete it. Otherwise it'll be
261 // deleted by its parent. 262 // deleted by its parent.
262 if (!omnibox_popup_parent_->parent()) 263 if (!omnibox_popup_parent_->parent())
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 int omnibox_x = (ntp_container_->bounds().width() - omnibox_width) / 2; 333 int omnibox_x = (ntp_container_->bounds().width() - omnibox_width) / 2;
333 gfx::Point omnibox_origin(omnibox_x, 334 gfx::Point omnibox_origin(omnibox_x,
334 GetLogoView()->bounds().bottom() + 335 GetLogoView()->bounds().bottom() +
335 chrome::search::kLogoBottomGap); 336 chrome::search::kLogoBottomGap);
336 views::View::ConvertPointToTarget(ntp_container_, destination, 337 views::View::ConvertPointToTarget(ntp_container_, destination,
337 &omnibox_origin); 338 &omnibox_origin);
338 return gfx::Rect(omnibox_origin.x(), omnibox_origin.y(), 339 return gfx::Rect(omnibox_origin.x(), omnibox_origin.y(),
339 omnibox_width, chrome::search::kNTPOmniboxHeight); 340 omnibox_width, chrome::search::kNTPOmniboxHeight);
340 } 341 }
341 342
343 void SearchViewController::SetInstantHasCustomLogo(bool has_logo) {
344 instant_has_custom_logo_ = has_logo;
345 }
346
342 void SearchViewController::OnImplicitAnimationsCompleted() { 347 void SearchViewController::OnImplicitAnimationsCompleted() {
343 DCHECK_EQ(STATE_NTP_ANIMATING, state_); 348 DCHECK_EQ(STATE_NTP_ANIMATING, state_);
344 state_ = STATE_SUGGESTIONS; 349 state_ = STATE_SUGGESTIONS;
345 ntp_container_->SetVisible(false); 350 ntp_container_->SetVisible(false);
346 MaybeHideOverlay(); 351 MaybeHideOverlay();
347 // While |ntp_container_| was fading out, location bar was animating from the 352 // While |ntp_container_| was fading out, location bar was animating from the
348 // middle of the NTP page to the top toolbar, at the same rate. 353 // middle of the NTP page to the top toolbar, at the same rate.
349 // Suggestions need to be aligned with the final location of the location bar. 354 // Suggestions need to be aligned with the final location of the location bar.
350 // So if omnibox popup view (InlineOmniboxPopupView) is visible, force a 355 // So if omnibox popup view (InlineOmniboxPopupView) is visible, force a
351 // re-layout of its children (i.e. the suggestions) to align with the location 356 // re-layout of its children (i.e. the suggestions) to align with the location
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 ntp_container_->layer()->SetMasksToBounds(true); 498 ntp_container_->layer()->SetMasksToBounds(true);
494 499
495 const TemplateURL* default_provider = 500 const TemplateURL* default_provider =
496 TemplateURLServiceFactory::GetForProfile( 501 TemplateURLServiceFactory::GetForProfile(
497 Profile::FromBrowserContext(browser_context_))-> 502 Profile::FromBrowserContext(browser_context_))->
498 GetDefaultSearchProvider(); 503 GetDefaultSearchProvider();
499 504
500 if (default_provider && 505 if (default_provider &&
501 InstantUI::ShouldShowSearchProviderLogo(browser_context_) && 506 InstantUI::ShouldShowSearchProviderLogo(browser_context_) &&
502 (TemplateURLPrepopulateData::GetEngineType(default_provider->url()) == 507 (TemplateURLPrepopulateData::GetEngineType(default_provider->url()) ==
503 SEARCH_ENGINE_GOOGLE)) { 508 SEARCH_ENGINE_GOOGLE) &&
509 !instant_has_custom_logo_) {
504 default_provider_logo_.reset(new views::ImageView()); 510 default_provider_logo_.reset(new views::ImageView());
505 default_provider_logo_->set_owned_by_client(); 511 default_provider_logo_->set_owned_by_client();
506 default_provider_logo_->SetImage(ui::ResourceBundle::GetSharedInstance(). 512 default_provider_logo_->SetImage(ui::ResourceBundle::GetSharedInstance().
507 GetImageSkiaNamed(IDR_GOOGLE_LOGO_LG)); 513 GetImageSkiaNamed(IDR_GOOGLE_LOGO_LG));
508 default_provider_logo_->SetPaintToLayer(true); 514 default_provider_logo_->SetPaintToLayer(true);
509 default_provider_logo_->SetFillsBoundsOpaquely(false); 515 default_provider_logo_->SetFillsBoundsOpaquely(false);
510 } 516 }
511 517
512 if (!default_provider_logo_.get()) { 518 if (!default_provider_logo_.get()) {
513 default_provider_name_.reset(new views::Label( 519 default_provider_name_.reset(new views::Label(
514 default_provider ? default_provider->short_name() : string16())); 520 default_provider && !instant_has_custom_logo_ ?
521 default_provider->short_name() : string16()));
515 default_provider_name_->set_owned_by_client(); 522 default_provider_name_->set_owned_by_client();
516 // TODO(msw): Use a transparent background color as a workaround to support 523 // TODO(msw): Use a transparent background color as a workaround to support
517 // using Labels' view layers via gfx::Canvas::NO_SUBPIXEL_RENDERING. 524 // using Labels' view layers via gfx::Canvas::NO_SUBPIXEL_RENDERING.
518 default_provider_name_->SetBackgroundColor(0x00000000); 525 default_provider_name_->SetBackgroundColor(0x00000000);
519 default_provider_name_->set_background( 526 if (!instant_has_custom_logo_) {
520 views::Background::CreateSolidBackground(SK_ColorRED)); 527 default_provider_name_->set_background(
521 default_provider_name_->SetEnabledColor(SK_ColorRED); 528 views::Background::CreateSolidBackground(SK_ColorRED));
529 default_provider_name_->SetEnabledColor(SK_ColorRED);
530 }
522 default_provider_name_->SetFont( 531 default_provider_name_->SetFont(
523 default_provider_name_->font().DeriveFont(75, gfx::Font::BOLD)); 532 default_provider_name_->font().DeriveFont(75, gfx::Font::BOLD));
524 default_provider_name_->SetPaintToLayer(true); 533 default_provider_name_->SetPaintToLayer(true);
525 default_provider_name_->SetFillsBoundsOpaquely(false); 534 default_provider_name_->SetFillsBoundsOpaquely(false);
526 } 535 }
527 536
528 // Reparent the main web contents view out of |contents_container_| and 537 // Reparent the main web contents view out of |contents_container_| and
529 // in to |ntp_container_| below. Reparent back in destructor. 538 // in to |ntp_container_| below. Reparent back in destructor.
530 content_view_ = contents_container_->active(); 539 content_view_ = contents_container_->active();
531 DCHECK(content_view_); 540 DCHECK(content_view_);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 635
627 chrome::search::SearchModel* SearchViewController::search_model() { 636 chrome::search::SearchModel* SearchViewController::search_model() {
628 return tab_contents_ ? chrome::search::SearchTabHelper::FromWebContents( 637 return tab_contents_ ? chrome::search::SearchTabHelper::FromWebContents(
629 tab_contents_->web_contents())->model() 638 tab_contents_->web_contents())->model()
630 : NULL; 639 : NULL;
631 } 640 }
632 641
633 content::WebContents* SearchViewController::web_contents() { 642 content::WebContents* SearchViewController::web_contents() {
634 return tab_contents_ ? tab_contents_->web_contents() : NULL; 643 return tab_contents_ ? tab_contents_->web_contents() : NULL;
635 } 644 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698