OLD | NEW |
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/extensions/extension_installed_bubble.h" | 5 #include "chrome/browser/ui/views/extensions/extension_installed_bubble.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 // Loop through the lines, creating a renderer for each. | 363 // Loop through the lines, creating a renderer for each. |
364 for (std::vector<string16>::const_iterator it = lines.begin(); | 364 for (std::vector<string16>::const_iterator it = lines.begin(); |
365 it != lines.end(); ++it) { | 365 it != lines.end(); ++it) { |
366 gfx::RenderText* line = gfx::RenderText::CreateInstance(); | 366 gfx::RenderText* line = gfx::RenderText::CreateInstance(); |
367 line->SetDirectionalityMode(gfx::DIRECTIONALITY_FROM_UI); | 367 line->SetDirectionalityMode(gfx::DIRECTIONALITY_FROM_UI); |
368 line->SetText(*it); | 368 line->SetText(*it); |
369 const gfx::Size size(contents_area.width(), | 369 const gfx::Size size(contents_area.width(), |
370 line->GetStringSize().height()); | 370 line->GetStringSize().height()); |
371 line->SetDisplayRect(gfx::Rect(position, size)); | 371 line->SetDisplayRect(gfx::Rect(position, size)); |
372 position.set_y(position.y() + size.height()); | 372 position.set_y(position.y() + size.height()); |
373 | |
374 // The link is always first in the text and is assumed to not be long | |
375 // enough to wrap to the next line. | |
376 if (it == lines.begin()) { | |
377 // First line we treat specially, because we will draw the link on its | |
378 // own, so we don't want to draw the text for the link twice. We | |
379 // therefore set it to transparent. | |
380 gfx::StyleRange link_text_style(line->default_style()); | |
381 link_text_style.foreground = SK_ColorTRANSPARENT; | |
382 link_text_style.range = ui::Range(0, signin_promo_link_text_.size()); | |
383 line->ApplyStyleRange(link_text_style); | |
384 } | |
385 | |
386 sign_in_promo_lines_.push_back(line); | 373 sign_in_promo_lines_.push_back(line); |
387 height += size.height(); | 374 height += size.height(); |
388 } | 375 } |
389 | 376 |
| 377 // The link is drawn separately; make it transparent here to only draw once. |
| 378 // The link always leads other text and is assumed to fit on the first line. |
| 379 sign_in_promo_lines_.front()->ApplyColor(SK_ColorTRANSPARENT, |
| 380 ui::Range(0, signin_promo_link_text_.size())); |
| 381 |
390 return height; | 382 return height; |
391 } | 383 } |
392 | 384 |
393 virtual gfx::Size GetPreferredSize() { | 385 virtual gfx::Size GetPreferredSize() { |
394 int width = kHorizOuterMargin; | 386 int width = kHorizOuterMargin; |
395 width += kIconSize; | 387 width += kIconSize; |
396 width += views::kPanelHorizMargin; | 388 width += views::kPanelHorizMargin; |
397 width += kRightColumnWidth; | 389 width += kRightColumnWidth; |
398 width += 2 * views::kPanelHorizMargin; | 390 width += 2 * views::kPanelHorizMargin; |
399 width += kHorizOuterMargin; | 391 width += kHorizOuterMargin; |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 | 658 |
667 void ExtensionInstalledBubble::WindowClosing() { | 659 void ExtensionInstalledBubble::WindowClosing() { |
668 if (extension_ && type_ == PAGE_ACTION) { | 660 if (extension_ && type_ == PAGE_ACTION) { |
669 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); | 661 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); |
670 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( | 662 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( |
671 extensions::ExtensionActionManager::Get(browser_->profile())-> | 663 extensions::ExtensionActionManager::Get(browser_->profile())-> |
672 GetPageAction(*extension_), | 664 GetPageAction(*extension_), |
673 false); // preview_enabled | 665 false); // preview_enabled |
674 } | 666 } |
675 } | 667 } |
OLD | NEW |