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