| 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/gtk/first_run_bubble.h" | 5 #include "chrome/browser/ui/gtk/first_run_bubble.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/metrics/histogram.h" |
| 10 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/first_run/first_run.h" |
| 11 #include "chrome/browser/search_engines/util.h" | 13 #include "chrome/browser/search_engines/util.h" |
| 12 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_list.h" |
| 13 #include "chrome/browser/ui/gtk/theme_service_gtk.h" | 15 #include "chrome/browser/ui/gtk/theme_service_gtk.h" |
| 14 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 15 #include "ui/base/gtk/gtk_hig_constants.h" | 17 #include "ui/base/gtk/gtk_hig_constants.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 17 | 19 |
| 18 namespace { | 20 namespace { |
| 19 // Markup for the text of the Omnibox search label | 21 // Markup for the text of the Omnibox search label |
| 20 const char kSearchLabelMarkup[] = "<big><b>%s</b></big>"; | 22 const char kSearchLabelMarkup[] = "<big><b>%s</b></big>"; |
| 21 | 23 |
| 22 // Padding between content and edge of bubble. | 24 // Padding between content and edge of bubble. |
| 23 const int kContentBorder = 7; | 25 const int kContentBorder = 7; |
| 24 | 26 |
| 25 // Vertical spacing between labels. | 27 // Vertical spacing between labels. |
| 26 const int kInterLineSpacing = 5; | 28 const int kInterLineSpacing = 5; |
| 27 | 29 |
| 28 } // namespace | 30 } // namespace |
| 29 | 31 |
| 30 // static | 32 // static |
| 31 void FirstRunBubble::Show(Profile* profile, | 33 void FirstRunBubble::Show(Profile* profile, |
| 32 GtkWidget* anchor, | 34 GtkWidget* anchor, |
| 33 const gfx::Rect& rect) { | 35 const gfx::Rect& rect) { |
| 36 HISTOGRAM_ENUMERATION("FirstRun.SearchEngineBubble", |
| 37 first_run::FIRST_RUN_BUBBLE_SHOWN, |
| 38 first_run::NUM_FIRST_RUN_BUBBLE_METRICS); |
| 39 |
| 34 new FirstRunBubble(profile, anchor, rect); | 40 new FirstRunBubble(profile, anchor, rect); |
| 35 } | 41 } |
| 36 | 42 |
| 37 void FirstRunBubble::BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) { | 43 void FirstRunBubble::BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) { |
| 38 // TODO(port): Enable parent window | 44 // TODO(port): Enable parent window |
| 39 } | 45 } |
| 40 | 46 |
| 41 FirstRunBubble::FirstRunBubble(Profile* profile, | 47 FirstRunBubble::FirstRunBubble(Profile* profile, |
| 42 GtkWidget* anchor, | 48 GtkWidget* anchor, |
| 43 const gfx::Rect& rect) | 49 const gfx::Rect& rect) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } | 82 } |
| 77 | 83 |
| 78 FirstRunBubble::~FirstRunBubble() { | 84 FirstRunBubble::~FirstRunBubble() { |
| 79 } | 85 } |
| 80 | 86 |
| 81 void FirstRunBubble::HandleDestroy(GtkWidget* sender) { | 87 void FirstRunBubble::HandleDestroy(GtkWidget* sender) { |
| 82 delete this; | 88 delete this; |
| 83 } | 89 } |
| 84 | 90 |
| 85 void FirstRunBubble::HandleChangeLink(GtkWidget* sender) { | 91 void FirstRunBubble::HandleChangeLink(GtkWidget* sender) { |
| 92 HISTOGRAM_ENUMERATION("FirstRun.SearchEngineBubble", |
| 93 first_run::FIRST_RUN_BUBBLE_CHANGE_SEARCH_INVOKED, |
| 94 first_run::NUM_FIRST_RUN_BUBBLE_METRICS); |
| 95 |
| 86 // Get |profile_|'s browser before closing the bubble, which deletes |this|. | 96 // Get |profile_|'s browser before closing the bubble, which deletes |this|. |
| 87 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); | 97 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); |
| 88 bubble_->Close(); | 98 bubble_->Close(); |
| 89 if (browser) | 99 if (browser) |
| 90 browser->OpenSearchEngineOptionsDialog(); | 100 browser->OpenSearchEngineOptionsDialog(); |
| 91 } | 101 } |
| OLD | NEW |