| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ime/ime_warning_bubble_view.h" | 5 #include "chrome/browser/ui/views/ime/ime_warning_bubble_view.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "chrome/browser/extensions/api/input_ime/input_ime_api_nonchromeos.h" | 10 #include "chrome/browser/extensions/api/input_ime/input_ime_api_nonchromeos.h" |
| 11 #include "chrome/browser/platform_util.h" | 11 #include "chrome/browser/platform_util.h" |
| 12 #include "chrome/browser/ui/browser_dialogs.h" | 12 #include "chrome/browser/ui/browser_dialogs.h" |
| 13 #include "chrome/browser/ui/browser_list.h" | 13 #include "chrome/browser/ui/browser_list.h" |
| 14 #include "chrome/browser/ui/views/frame/browser_view.h" | 14 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 15 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" |
| 15 #include "chrome/browser/ui/views/harmony/chrome_typography.h" | 16 #include "chrome/browser/ui/views/harmony/chrome_typography.h" |
| 16 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" | 17 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" |
| 17 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" | 18 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" |
| 18 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 19 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 19 #include "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.h" |
| 20 #include "extensions/common/feature_switch.h" | 21 #include "extensions/common/feature_switch.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 22 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
| 23 #include "ui/views/controls/button/checkbox.h" | 24 #include "ui/views/controls/button/checkbox.h" |
| 24 #include "ui/views/layout/layout_constants.h" | |
| 25 | 25 |
| 26 using extensions::Extension; | 26 using extensions::Extension; |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 // The column width of the warning bubble. | 30 // The column width of the warning bubble. |
| 31 const int kColumnWidth = 285; | 31 const int kColumnWidth = 285; |
| 32 | 32 |
| 33 views::Label* CreateExtensionNameLabel(const base::string16& text) { | 33 views::Label* CreateExtensionNameLabel(const base::string16& text) { |
| 34 views::Label* label = new views::Label(text, CONTEXT_BODY_TEXT_SMALL); | 34 views::Label* label = new views::Label(text, CONTEXT_BODY_TEXT_SMALL); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 views::GridLayout* layout = new views::GridLayout(this); | 167 views::GridLayout* layout = new views::GridLayout(this); |
| 168 SetLayoutManager(layout); | 168 SetLayoutManager(layout); |
| 169 | 169 |
| 170 int cs_id = 0; | 170 int cs_id = 0; |
| 171 | 171 |
| 172 views::ColumnSet* main_cs = layout->AddColumnSet(cs_id); | 172 views::ColumnSet* main_cs = layout->AddColumnSet(cs_id); |
| 173 // The first row which shows the warning info. | 173 // The first row which shows the warning info. |
| 174 main_cs->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING, 0, | 174 main_cs->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING, 0, |
| 175 views::GridLayout::FIXED, kColumnWidth, 0); | 175 views::GridLayout::FIXED, kColumnWidth, 0); |
| 176 | 176 |
| 177 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); |
| 178 const int vertical_spacing = |
| 179 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL); |
| 177 layout->StartRow(0, cs_id); | 180 layout->StartRow(0, cs_id); |
| 178 base::string16 extension_name = base::UTF8ToUTF16(extension_->name()); | 181 base::string16 extension_name = base::UTF8ToUTF16(extension_->name()); |
| 179 base::i18n::AdjustStringForLocaleDirection(&extension_name); | 182 base::i18n::AdjustStringForLocaleDirection(&extension_name); |
| 180 views::Label* warning = CreateExtensionNameLabel(l10n_util::GetStringFUTF16( | 183 views::Label* warning = CreateExtensionNameLabel(l10n_util::GetStringFUTF16( |
| 181 IDS_IME_API_ACTIVATED_WARNING, extension_name)); | 184 IDS_IME_API_ACTIVATED_WARNING, extension_name)); |
| 182 layout->AddView(warning); | 185 layout->AddView(warning); |
| 183 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 186 layout->AddPaddingRow(0, vertical_spacing); |
| 184 | 187 |
| 185 // The seconde row which shows the check box. | 188 // The seconde row which shows the check box. |
| 186 layout->StartRow(0, cs_id); | 189 layout->StartRow(0, cs_id); |
| 187 never_show_checkbox_ = | 190 never_show_checkbox_ = |
| 188 new views::Checkbox(l10n_util::GetStringUTF16(IDS_IME_API_NEVER_SHOW)); | 191 new views::Checkbox(l10n_util::GetStringUTF16(IDS_IME_API_NEVER_SHOW)); |
| 189 layout->AddView(never_show_checkbox_); | 192 layout->AddView(never_show_checkbox_); |
| 190 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 193 layout->AddPaddingRow(0, vertical_spacing); |
| 191 } | 194 } |
| 192 | 195 |
| 193 bool ImeWarningBubbleView::IsToolbarAnimating() { | 196 bool ImeWarningBubbleView::IsToolbarAnimating() { |
| 194 return anchor_to_browser_action_ && container_->animating(); | 197 return anchor_to_browser_action_ && container_->animating(); |
| 195 } | 198 } |
| OLD | NEW |