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

Side by Side Diff: chrome/browser/ui/views/extensions/extension_installed_bubble.cc

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

Powered by Google App Engine
This is Rietveld 408576698