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

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

Issue 10830254: views: Pass only Browser pointer to FirstRunBubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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/first_run_bubble.h" 5 #include "chrome/browser/ui/views/first_run_bubble.h"
6 6
7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/first_run/first_run.h" 7 #include "chrome/browser/first_run/first_run.h"
9 #include "chrome/browser/search_engines/util.h" 8 #include "chrome/browser/search_engines/util.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/chrome_pages.h" 10 #include "chrome/browser/ui/chrome_pages.h"
11 #include "grit/generated_resources.h" 11 #include "grit/generated_resources.h"
12 #include "ui/base/l10n/l10n_util.h" 12 #include "ui/base/l10n/l10n_util.h"
13 #include "ui/base/resource/resource_bundle.h" 13 #include "ui/base/resource/resource_bundle.h"
14 #include "ui/views/controls/label.h" 14 #include "ui/views/controls/label.h"
15 #include "ui/views/controls/link.h" 15 #include "ui/views/controls/link.h"
16 #include "ui/views/layout/grid_layout.h" 16 #include "ui/views/layout/grid_layout.h"
17 #include "ui/views/layout/layout_constants.h" 17 #include "ui/views/layout/layout_constants.h"
18 #include "ui/views/widget/widget.h" 18 #include "ui/views/widget/widget.h"
19 19
20 namespace { 20 namespace {
21 const int kAnchorVerticalInset = 5; 21 const int kAnchorVerticalInset = 5;
22 const int kTopInset = 1; 22 const int kTopInset = 1;
23 const int kLeftInset = 2; 23 const int kLeftInset = 2;
24 const int kBottomInset = 7; 24 const int kBottomInset = 7;
25 const int kRightInset = 2; 25 const int kRightInset = 2;
26 } // namespace 26 } // namespace
27 27
28 namespace first_run { 28 namespace first_run {
29 void ShowFirstRunDialog(Profile* profile) {} 29 void ShowFirstRunDialog(Profile* profile) {}
30 } // namespace first_run 30 } // namespace first_run
31 31
32 // static 32 // static
33 FirstRunBubble* FirstRunBubble::ShowBubble(Browser* browser, 33 FirstRunBubble* FirstRunBubble::ShowBubble(Browser* browser,
34 Profile* profile,
35 views::View* anchor_view) { 34 views::View* anchor_view) {
36 first_run::LogFirstRunMetric(first_run::FIRST_RUN_BUBBLE_SHOWN); 35 first_run::LogFirstRunMetric(first_run::FIRST_RUN_BUBBLE_SHOWN);
37 36
38 FirstRunBubble* delegate = new FirstRunBubble(browser, profile, anchor_view); 37 FirstRunBubble* delegate = new FirstRunBubble(browser, anchor_view);
39 views::BubbleDelegateView::CreateBubble(delegate); 38 views::BubbleDelegateView::CreateBubble(delegate);
40 delegate->StartFade(true); 39 delegate->StartFade(true);
41 return delegate; 40 return delegate;
42 } 41 }
43 42
44 void FirstRunBubble::Init() { 43 void FirstRunBubble::Init() {
45 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 44 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
46 const gfx::Font& original_font = rb.GetFont(ui::ResourceBundle::MediumFont); 45 const gfx::Font& original_font = rb.GetFont(ui::ResourceBundle::MediumFont);
47 46
47 string16 search_engine_name;
48 if (browser_)
49 search_engine_name = GetDefaultSearchEngineName(browser_->profile());
50
48 views::Label* title = new views::Label(l10n_util::GetStringFUTF16( 51 views::Label* title = new views::Label(l10n_util::GetStringFUTF16(
49 IDS_FR_BUBBLE_TITLE, GetDefaultSearchEngineName(profile_))); 52 IDS_FR_BUBBLE_TITLE, search_engine_name));
Peter Kasting 2012/08/11 22:52:40 Nit: If you inline, you can avoid the temp above:
50 title->SetFont(original_font.DeriveFont(2, gfx::Font::BOLD)); 53 title->SetFont(original_font.DeriveFont(2, gfx::Font::BOLD));
51 54
52 views::Link* change = 55 views::Link* change =
53 new views::Link(l10n_util::GetStringUTF16(IDS_FR_BUBBLE_CHANGE)); 56 new views::Link(l10n_util::GetStringUTF16(IDS_FR_BUBBLE_CHANGE));
54 change->SetFont(original_font); 57 change->SetFont(original_font);
55 change->set_listener(this); 58 change->set_listener(this);
56 59
57 views::Label* subtext = 60 views::Label* subtext =
58 new views::Label(l10n_util::GetStringUTF16(IDS_FR_BUBBLE_SUBTEXT)); 61 new views::Label(l10n_util::GetStringUTF16(IDS_FR_BUBBLE_SUBTEXT));
59 subtext->SetFont(original_font); 62 subtext->SetFont(original_font);
(...skipping 18 matching lines...) Expand all
78 layout->AddView(subtext, columns->num_columns(), 1); 81 layout->AddView(subtext, columns->num_columns(), 1);
79 } 82 }
80 83
81 gfx::Rect FirstRunBubble::GetAnchorRect() { 84 gfx::Rect FirstRunBubble::GetAnchorRect() {
82 // Compensate for padding in anchor. 85 // Compensate for padding in anchor.
83 gfx::Rect rect(BubbleDelegateView::GetAnchorRect()); 86 gfx::Rect rect(BubbleDelegateView::GetAnchorRect());
84 rect.Inset(0, anchor_view() ? kAnchorVerticalInset : 0); 87 rect.Inset(0, anchor_view() ? kAnchorVerticalInset : 0);
85 return rect; 88 return rect;
86 } 89 }
87 90
88 FirstRunBubble::FirstRunBubble(Browser* browser, 91 FirstRunBubble::FirstRunBubble(Browser* browser, views::View* anchor_view)
89 Profile* profile,
90 views::View* anchor_view)
91 : views::BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), 92 : views::BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT),
92 browser_(browser), 93 browser_(browser) {
93 profile_(profile) {
94 } 94 }
95 95
96 FirstRunBubble::~FirstRunBubble() { 96 FirstRunBubble::~FirstRunBubble() {
97 } 97 }
98 98
99 void FirstRunBubble::LinkClicked(views::Link* source, int event_flags) { 99 void FirstRunBubble::LinkClicked(views::Link* source, int event_flags) {
100 first_run::LogFirstRunMetric(first_run::FIRST_RUN_BUBBLE_CHANGE_INVOKED); 100 first_run::LogFirstRunMetric(first_run::FIRST_RUN_BUBBLE_CHANGE_INVOKED);
101 101
102 GetWidget()->Close(); 102 GetWidget()->Close();
103 if (browser_) 103 if (browser_)
104 chrome::ShowSearchEngineSettings(browser_); 104 chrome::ShowSearchEngineSettings(browser_);
105 } 105 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/first_run_bubble.h ('k') | chrome/browser/ui/views/first_run_bubble_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698