summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-15 16:24:24 +0000
committermukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-15 16:24:24 +0000
commitbe98edc4db0dfdc9c8b13d715c015f447b5969e2 (patch)
treea2c2a0a67877d7ddf90237c69b95bd58f5f14a2c
parent0a0012f6c1fb0d3896827987b6d9fcccdb51597e (diff)
downloadchromium_src-be98edc4db0dfdc9c8b13d715c015f447b5969e2.zip
chromium_src-be98edc4db0dfdc9c8b13d715c015f447b5969e2.tar.gz
chromium_src-be98edc4db0dfdc9c8b13d715c015f447b5969e2.tar.bz2
Moves IME's views specific code out from chrome/browser/chromeos.
Now UI code of input methods -- candidate window, infolist window, and mode indicator -- is pure views and doesn't need to be in c/b. I chose ash/ime because they are ash-specific UI, but I'm okay to move to another place. Please tell me if you have other ideas. BUG=325813 R=oshima@chromium.org, komatsu@chromium.org TEST=no functional changes, compile succeeds Review URL: https://codereview.chromium.org/132083009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244895 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/ash.gyp9
-rw-r--r--ash/ash_strings.grd4
-rw-r--r--ash/ime/OWNERS3
-rw-r--r--ash/ime/candidate_view.cc (renamed from chrome/browser/chromeos/input_method/candidate_view.cc)12
-rw-r--r--ash/ime/candidate_view.h (renamed from chrome/browser/chromeos/input_method/candidate_view.h)19
-rw-r--r--ash/ime/candidate_window_constants.h (renamed from chrome/browser/chromeos/input_method/candidate_window_constants.h)16
-rw-r--r--ash/ime/candidate_window_view.cc (renamed from chrome/browser/chromeos/input_method/candidate_window_view.cc)17
-rw-r--r--ash/ime/candidate_window_view.h (renamed from chrome/browser/chromeos/input_method/candidate_window_view.h)21
-rw-r--r--ash/ime/candidate_window_view_unittest.cc (renamed from chrome/browser/chromeos/input_method/candidate_window_view_unittest.cc)15
-rw-r--r--ash/ime/infolist_window.cc (renamed from chrome/browser/chromeos/input_method/infolist_window.cc)48
-rw-r--r--ash/ime/infolist_window.h (renamed from chrome/browser/chromeos/input_method/infolist_window.h)36
-rw-r--r--ash/ime/mode_indicator_view.cc (renamed from chrome/browser/chromeos/input_method/mode_indicator_delegate_view.cc)44
-rw-r--r--ash/ime/mode_indicator_view.h (renamed from chrome/browser/chromeos/input_method/mode_indicator_delegate_view.h)29
-rw-r--r--chrome/app/chromeos_strings.grdp3
-rw-r--r--chrome/browser/chromeos/input_method/candidate_window_controller_impl.cc49
-rw-r--r--chrome/browser/chromeos/input_method/candidate_window_controller_impl.h31
-rw-r--r--chrome/browser/chromeos/input_method/candidate_window_controller_impl_unittest.cc174
-rw-r--r--chrome/browser/chromeos/input_method/mode_indicator_controller.cc18
-rw-r--r--chrome/chrome_browser_chromeos.gypi8
-rw-r--r--chrome/chrome_tests_unit.gypi2
-rw-r--r--ui/base/ime/candidate_window.cc27
-rw-r--r--ui/base/ime/candidate_window.h6
-rw-r--r--ui/base/ime/candidate_window_unittest.cc119
-rw-r--r--ui/base/ime/ime.gypi2
-rw-r--r--ui/base/ime/infolist_entry.cc22
-rw-r--r--ui/base/ime/infolist_entry.h26
26 files changed, 372 insertions, 388 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index f18b68f..ecf4275 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -153,6 +153,14 @@
'host/root_window_host_factory.cc',
'host/root_window_host_factory.h',
'host/root_window_host_factory_win.cc',
+ 'ime/candidate_view.cc',
+ 'ime/candidate_view.h',
+ 'ime/candidate_window_view.cc',
+ 'ime/candidate_window_view.h',
+ 'ime/infolist_window.cc',
+ 'ime/infolist_window.h',
+ 'ime/mode_indicator_view.cc',
+ 'ime/mode_indicator_view.h',
'keyboard_uma_event_filter.cc',
'keyboard_uma_event_filter.h',
'launcher/launcher_types.cc',
@@ -824,6 +832,7 @@
'drag_drop/drag_drop_tracker_unittest.cc',
'extended_desktop_unittest.cc',
'focus_cycler_unittest.cc',
+ 'ime/candidate_window_view_unittest.cc',
'keyboard_overlay/keyboard_overlay_delegate_unittest.cc',
'keyboard_overlay/keyboard_overlay_view_unittest.cc',
'magnifier/magnification_controller_unittest.cc',
diff --git a/ash/ash_strings.grd b/ash/ash_strings.grd
index 8c98008..c51d882 100644
--- a/ash/ash_strings.grd
+++ b/ash/ash_strings.grd
@@ -582,6 +582,10 @@ Press Shift + Alt to switch.
Press Control Shift Q twice to quit.
</message>
+ <message name="IDS_ASH_IME_INFOLIST_WINDOW_TITLE" desc="The title of the infolist window where the meanings and the usages of words are displayed.">
+ Information
+ </message>
+
<message name="IDS_ASH_LOGOUT_CONFIRMATION_TITLE" desc="Dialog title for the logout confirmation dialog.">
Exiting Session
</message>
diff --git a/ash/ime/OWNERS b/ash/ime/OWNERS
new file mode 100644
index 0000000..7224e3b
--- /dev/null
+++ b/ash/ime/OWNERS
@@ -0,0 +1,3 @@
+komatsu@chromium.org
+mukai@chromium.org
+nona@chromium.org
diff --git a/chrome/browser/chromeos/input_method/candidate_view.cc b/ash/ime/candidate_view.cc
index e04a41d..652998a 100644
--- a/chrome/browser/chromeos/input_method/candidate_view.cc
+++ b/ash/ime/candidate_view.cc
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/chromeos/input_method/candidate_view.h"
+#include "ash/ime/candidate_view.h"
+#include "ash/ime/candidate_window_constants.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/chromeos/input_method/candidate_window_constants.h"
#include "ui/base/ime/candidate_window.h"
#include "ui/gfx/color_utils.h"
#include "ui/native_theme/native_theme.h"
@@ -14,8 +14,8 @@
#include "ui/views/controls/label.h"
#include "ui/views/widget/widget.h"
-namespace chromeos {
-namespace input_method {
+namespace ash {
+namespace ime {
namespace {
@@ -285,5 +285,5 @@ gfx::Size CandidateView::GetPreferredSize() {
return size;
}
-} // namespace input_method
-} // namespace chromeos
+} // namespace ime
+} // namespace ash
diff --git a/chrome/browser/chromeos/input_method/candidate_view.h b/ash/ime/candidate_view.h
index a0bce3e..6f58957 100644
--- a/chrome/browser/chromeos/input_method/candidate_view.h
+++ b/ash/ime/candidate_view.h
@@ -1,21 +1,22 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_VIEW_H_
-#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_VIEW_H_
+#ifndef ASH_IME_CANDIDATE_VIEW_H_
+#define ASH_IME_CANDIDATE_VIEW_H_
+#include "ash/ash_export.h"
#include "base/gtest_prod_util.h"
#include "ui/base/ime/candidate_window.h"
#include "ui/views/controls/button/custom_button.h"
#include "ui/views/controls/label.h"
#include "ui/views/view.h"
-namespace chromeos {
-namespace input_method {
+namespace ash {
+namespace ime {
// CandidateView renderes a row of a candidate.
-class CandidateView : public views::CustomButton {
+class ASH_EXPORT CandidateView : public views::CustomButton {
public:
CandidateView(views::ButtonListener* listener,
ui::CandidateWindow::Orientation orientation);
@@ -66,7 +67,7 @@ class CandidateView : public views::CustomButton {
DISALLOW_COPY_AND_ASSIGN(CandidateView);
};
-} // namespace input_method
-} // namespace chromeos
+} // namespace ime
+} // namespace ash
-#endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_VIEW_H_
+#endif // ASH_IME_CANDIDATE_VIEW_H_
diff --git a/chrome/browser/chromeos/input_method/candidate_window_constants.h b/ash/ime/candidate_window_constants.h
index 148ab65..f3ec24e 100644
--- a/chrome/browser/chromeos/input_method/candidate_window_constants.h
+++ b/ash/ime/candidate_window_constants.h
@@ -1,12 +1,12 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_CONSTANTS_H_
-#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_CONSTANTS_H_
+#ifndef ASH_IME_CANDIDATE_WINDOW_CONSTANTS_H_
+#define ASH_IME_CANDIDATE_WINDOW_CONSTANTS_H_
-namespace chromeos {
-namespace input_method {
+namespace ash {
+namespace ime {
// We'll use a bigger font size, so Chinese characters are more readable
// in the candidate window.
@@ -36,7 +36,7 @@ const int kInfolistIndicatorIconWidth = 4;
// The padding size of the infolist indicator icon in the candidate window.
const int kInfolistIndicatorIconPadding = 2;
-} // namespace input_method
-} // namespace chromeos
+} // namespace ime
+} // namespace ash
-#endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_CONSTANTS_H_
+#endif // ASH_IME_CANDIDATE_WINDOW_CONSTANTS_H_
diff --git a/chrome/browser/chromeos/input_method/candidate_window_view.cc b/ash/ime/candidate_window_view.cc
index 5848972..28de0e7 100644
--- a/chrome/browser/chromeos/input_method/candidate_window_view.cc
+++ b/ash/ime/candidate_window_view.cc
@@ -1,13 +1,14 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/chromeos/input_method/candidate_window_view.h"
+
+#include "ash/ime/candidate_window_view.h"
#include <string>
+#include "ash/ime/candidate_view.h"
+#include "ash/ime/candidate_window_constants.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/chromeos/input_method/candidate_view.h"
-#include "chrome/browser/chromeos/input_method/candidate_window_constants.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/screen.h"
#include "ui/native_theme/native_theme.h"
@@ -19,8 +20,8 @@
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
-namespace chromeos {
-namespace input_method {
+namespace ash {
+namespace ime {
namespace {
@@ -398,5 +399,5 @@ void CandidateWindowView::ButtonPressed(views::Button* sender,
}
}
-} // namespace input_method
-} // namespace chromeos
+} // namespace ime
+} // namespace ash
diff --git a/chrome/browser/chromeos/input_method/candidate_window_view.h b/ash/ime/candidate_window_view.h
index 98fcc84..34bdcf3 100644
--- a/chrome/browser/chromeos/input_method/candidate_window_view.h
+++ b/ash/ime/candidate_window_view.h
@@ -1,23 +1,24 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_VIEW_H_
-#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_VIEW_H_
+#ifndef ASH_IME_CANDIDATE_WINDOW_VIEW_H_
+#define ASH_IME_CANDIDATE_WINDOW_VIEW_H_
+#include "ash/ash_export.h"
#include "ui/base/ime/candidate_window.h"
#include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/controls/button/button.h"
-namespace chromeos {
-namespace input_method {
+namespace ash {
+namespace ime {
class CandidateView;
class InformationTextArea;
// CandidateWindowView is the main container of the candidate window UI.
-class CandidateWindowView : public views::BubbleDelegateView,
- public views::ButtonListener {
+class ASH_EXPORT CandidateWindowView : public views::BubbleDelegateView,
+ public views::ButtonListener {
public:
// The object can be monitored by the observer.
class Observer {
@@ -127,7 +128,7 @@ class CandidateWindowView : public views::BubbleDelegateView,
DISALLOW_COPY_AND_ASSIGN(CandidateWindowView);
};
-} // namespace input_method
-} // namespace chromeos
+} // namespace ime
+} // namespace ash
-#endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_VIEW_H_
+#endif // ASH_IME_CANDIDATE_WINDOW_VIEW_H_
diff --git a/chrome/browser/chromeos/input_method/candidate_window_view_unittest.cc b/ash/ime/candidate_window_view_unittest.cc
index bc4fc18..45ab518 100644
--- a/chrome/browser/chromeos/input_method/candidate_window_view_unittest.cc
+++ b/ash/ime/candidate_window_view_unittest.cc
@@ -1,20 +1,20 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/chromeos/input_method/candidate_window_view.h"
+#include "ash/ime/candidate_window_view.h"
#include <string>
+#include "ash/ime/candidate_view.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/chromeos/input_method/candidate_view.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/widget.h"
-namespace chromeos {
-namespace input_method {
+namespace ash {
+namespace ime {
namespace {
const char* kSampleCandidate[] = {
@@ -379,5 +379,6 @@ TEST_F(CandidateWindowViewTest, DoNotChangeRowHeightWithLabelSwitchTest) {
for (size_t i = 1; i < GetCandidatesSize(); ++i)
EXPECT_EQ(before_height, GetCandidateAt(i)->GetContentsBounds().height());
}
-} // namespace input_method
-} // namespace chromeos
+
+} // namespace ime
+} // namespace ash
diff --git a/chrome/browser/chromeos/input_method/infolist_window.cc b/ash/ime/infolist_window.cc
index f9e4ad5..d72eed3 100644
--- a/chrome/browser/chromeos/input_method/infolist_window.cc
+++ b/ash/ime/infolist_window.cc
@@ -1,15 +1,15 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/chromeos/input_method/infolist_window.h"
+#include "ash/ime/infolist_window.h"
#include <string>
#include <vector>
+#include "ash/ime/candidate_window_constants.h"
#include "base/logging.h"
-#include "chrome/browser/chromeos/input_method/candidate_window_constants.h"
-#include "grit/generated_resources.h"
+#include "grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/font.h"
@@ -23,8 +23,8 @@
#include "ui/views/layout/box_layout.h"
#include "ui/views/widget/widget.h"
-namespace chromeos {
-namespace input_method {
+namespace ash {
+namespace ime {
namespace {
// The width of an info-list.
@@ -86,12 +86,12 @@ gfx::Insets InfolistBorder::GetInsets() const {
// InfolistRow renderes a row of a infolist.
class InfolistEntryView : public views::View {
public:
- InfolistEntryView(const InfolistEntry& entry,
+ InfolistEntryView(const ui::InfolistEntry& entry,
const gfx::FontList& title_font,
const gfx::FontList& description_font);
virtual ~InfolistEntryView();
- void SetEntry(const InfolistEntry& entry);
+ void SetEntry(const ui::InfolistEntry& entry);
private:
// views::View implementation.
@@ -99,7 +99,7 @@ class InfolistEntryView : public views::View {
void UpdateBackground();
- InfolistEntry entry_;
+ ui::InfolistEntry entry_;
// The title label. Owned by views hierarchy.
views::Label* title_label_;
@@ -110,7 +110,7 @@ class InfolistEntryView : public views::View {
DISALLOW_COPY_AND_ASSIGN(InfolistEntryView);
};
-InfolistEntryView::InfolistEntryView(const InfolistEntry& entry,
+InfolistEntryView::InfolistEntryView(const ui::InfolistEntry& entry,
const gfx::FontList& title_font,
const gfx::FontList& description_font)
: entry_(entry) {
@@ -138,7 +138,7 @@ InfolistEntryView::InfolistEntryView(const InfolistEntry& entry,
InfolistEntryView::~InfolistEntryView() {}
-void InfolistEntryView::SetEntry(const InfolistEntry& entry) {
+void InfolistEntryView::SetEntry(const ui::InfolistEntry& entry) {
if (entry_ == entry)
return;
@@ -168,26 +168,10 @@ void InfolistEntryView::UpdateBackground() {
}
///////////////////////////////////////////////////////////////////////////////
-// InfolistEntry model
-
-InfolistEntry::InfolistEntry(const base::string16& title,
- const base::string16& body)
- : title(title), body(body), highlighted(false) {}
-
-bool InfolistEntry::operator==(const InfolistEntry& other) const {
- return title == other.title && body == other.body &&
- highlighted == other.highlighted;
-}
-
-bool InfolistEntry::operator!=(const InfolistEntry& other) const {
- return !(*this == other);
-}
-
-///////////////////////////////////////////////////////////////////////////////
// InfolistWindow
InfolistWindow::InfolistWindow(views::View* candidate_window,
- const std::vector<InfolistEntry>& entries)
+ const std::vector<ui::InfolistEntry>& entries)
: views::BubbleDelegateView(candidate_window, views::BubbleBorder::NONE),
title_font_(gfx::Font(kJapaneseFontName, kFontSizeDelta + 15)),
description_font_(gfx::Font(kJapaneseFontName, kFontSizeDelta + 11)) {
@@ -204,7 +188,7 @@ InfolistWindow::InfolistWindow(views::View* candidate_window,
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
views::Label* caption_label = new views::Label(
- l10n_util::GetStringUTF16(IDS_INPUT_METHOD_INFOLIST_WINDOW_TITLE));
+ l10n_util::GetStringUTF16(IDS_ASH_IME_INFOLIST_WINDOW_TITLE));
caption_label->SetFontList(
caption_label->font_list().DeriveFontList(kFontSizeDelta - 2));
caption_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
@@ -240,7 +224,7 @@ void InfolistWindow::InitWidget() {
SizeToContents();
}
-void InfolistWindow::Relayout(const std::vector<InfolistEntry>& entries) {
+void InfolistWindow::Relayout(const std::vector<ui::InfolistEntry>& entries) {
size_t i = 0;
for (; i < entries.size(); ++i) {
if (i < entry_views_.size()) {
@@ -294,5 +278,5 @@ void InfolistWindow::WindowClosing() {
show_hide_timer_.Stop();
}
-} // namespace input_method
-} // namespace chromeos
+} // namespace ime
+} // namespace ash
diff --git a/chrome/browser/chromeos/input_method/infolist_window.h b/ash/ime/infolist_window.h
index 4abf5e3..e7c984a 100644
--- a/chrome/browser/chromeos/input_method/infolist_window.h
+++ b/ash/ime/infolist_window.h
@@ -1,46 +1,36 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INFOLIST_WINDOW_H_
-#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INFOLIST_WINDOW_H_
+#ifndef ASH_IME_INFOLIST_WINDOW_H_
+#define ASH_IME_INFOLIST_WINDOW_H_
#include <string>
#include <vector>
+#include "ash/ash_export.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "base/timer/timer.h"
+#include "ui/base/ime/infolist_entry.h"
#include "ui/gfx/font_list.h"
#include "ui/views/bubble/bubble_delegate.h"
-namespace chromeos {
-namespace input_method {
+namespace ash {
+namespace ime {
class InfolistEntryView;
-// TODO(mukai): move this model to another place, src/chromeos/ime or
-// src/ui/base/ime.
-struct InfolistEntry {
- base::string16 title;
- base::string16 body;
- bool highlighted;
-
- InfolistEntry(const base::string16& title, const base::string16& body);
- bool operator==(const InfolistEntry& entry) const;
- bool operator!=(const InfolistEntry& entry) const;
-};
-
// A widget delegate representing the infolist window UI.
-class InfolistWindow : public views::BubbleDelegateView {
+class ASH_EXPORT InfolistWindow : public views::BubbleDelegateView {
public:
InfolistWindow(views::View* candidate_window,
- const std::vector<InfolistEntry>& entries);
+ const std::vector<ui::InfolistEntry>& entries);
virtual ~InfolistWindow();
void InitWidget();
// Updates infolist contents with |entries|.
- void Relayout(const std::vector<InfolistEntry>& entries);
+ void Relayout(const std::vector<ui::InfolistEntry>& entries);
// Show/hide itself with a delay.
void ShowWithDelay();
@@ -68,7 +58,7 @@ class InfolistWindow : public views::BubbleDelegateView {
DISALLOW_COPY_AND_ASSIGN(InfolistWindow);
};
-} // namespace input_method
-} // namespace chromeos
+} // namespace ime
+} // namespace ash
-#endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INFOLIST_WINDOW_H_
+#endif // ASH_IME_INFOLIST_WINDOW_H_
diff --git a/chrome/browser/chromeos/input_method/mode_indicator_delegate_view.cc b/ash/ime/mode_indicator_view.cc
index c9d161f..64c9b24 100644
--- a/chrome/browser/chromeos/input_method/mode_indicator_delegate_view.cc
+++ b/ash/ime/mode_indicator_view.cc
@@ -1,20 +1,17 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/chromeos/input_method/mode_indicator_delegate_view.h"
+#include "ash/ime/mode_indicator_view.h"
-#include "ash/shell.h"
-#include "ash/shell_window_ids.h"
-#include "ash/wm/window_animations.h"
-#include "ash/wm/window_util.h"
#include "base/logging.h"
#include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/controls/label.h"
+#include "ui/views/corewm/window_animations.h"
#include "ui/views/layout/fill_layout.h"
-namespace chromeos {
-namespace input_method {
+namespace ash {
+namespace ime {
namespace {
// Minimum size of inner contents in pixel.
@@ -26,28 +23,25 @@ const int kShowingDuration = 500;
} // namespace
-ModeIndicatorDelegateView::ModeIndicatorDelegateView(
- const gfx::Rect& cursor_bounds,
- const base::string16& label)
- : cursor_bounds_(cursor_bounds),
- label_view_(new views::Label(label)) {
+ModeIndicatorView::ModeIndicatorView(gfx::NativeView parent,
+ const gfx::Rect& cursor_bounds,
+ const base::string16& label)
+ : cursor_bounds_(cursor_bounds),
+ label_view_(new views::Label(label)) {
set_use_focusless(true);
set_accept_events(false);
- set_parent_window(
- ash::Shell::GetContainer(
- ash::wm::GetActiveWindow()->GetRootWindow(),
- ash::internal::kShellWindowId_InputMethodContainer));
+ set_parent_window(parent);
set_shadow(views::BubbleBorder::NO_SHADOW);
set_arrow(views::BubbleBorder::TOP_CENTER);
}
-ModeIndicatorDelegateView::~ModeIndicatorDelegateView() {}
+ModeIndicatorView::~ModeIndicatorView() {}
-void ModeIndicatorDelegateView::FadeOut() {
+void ModeIndicatorView::FadeOut() {
StartFade(false);
}
-void ModeIndicatorDelegateView::ShowAndFadeOut() {
+void ModeIndicatorView::ShowAndFadeOut() {
views::corewm::SetWindowVisibilityAnimationTransition(
GetWidget()->GetNativeView(),
views::corewm::ANIMATE_HIDE);
@@ -55,21 +49,21 @@ void ModeIndicatorDelegateView::ShowAndFadeOut() {
timer_.Start(FROM_HERE,
base::TimeDelta::FromMilliseconds(kShowingDuration),
this,
- &ModeIndicatorDelegateView::FadeOut);
+ &ModeIndicatorView::FadeOut);
}
-gfx::Size ModeIndicatorDelegateView::GetPreferredSize() {
+gfx::Size ModeIndicatorView::GetPreferredSize() {
gfx::Size size = label_view_->GetPreferredSize();
size.SetToMax(gfx::Size(kMinSize, kMinSize));
return size;
}
-void ModeIndicatorDelegateView::Init() {
+void ModeIndicatorView::Init() {
SetLayoutManager(new views::FillLayout());
AddChildView(label_view_);
SetAnchorRect(cursor_bounds_);
}
-} // namespace input_method
-} // namespace chromeos
+} // namespace ime
+} // namespace ash
diff --git a/chrome/browser/chromeos/input_method/mode_indicator_delegate_view.h b/ash/ime/mode_indicator_view.h
index bc4c9c2..2b3a8a8 100644
--- a/chrome/browser/chromeos/input_method/mode_indicator_delegate_view.h
+++ b/ash/ime/mode_indicator_view.h
@@ -1,12 +1,14 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MODE_INDICATOR_DELEGATE_VIEW_H_
-#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MODE_INDICATOR_DELEGATE_VIEW_H_
+#ifndef ASH_IME_MODE_INDICATOR_VIEW_H_
+#define ASH_IME_MODE_INDICATOR_VIEW_H_
+#include "ash/ash_export.h"
#include "base/strings/string16.h"
#include "base/timer/timer.h"
+#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/rect.h"
#include "ui/views/bubble/bubble_delegate.h"
@@ -14,14 +16,15 @@ namespace views {
class Label;
} // namespace views
-namespace chromeos {
-namespace input_method {
+namespace ash {
+namespace ime {
-class ModeIndicatorDelegateView : public views::BubbleDelegateView {
+class ASH_EXPORT ModeIndicatorView : public views::BubbleDelegateView {
public:
- ModeIndicatorDelegateView(const gfx::Rect& cursor_bounds,
- const base::string16& label);
- virtual ~ModeIndicatorDelegateView();
+ ModeIndicatorView(gfx::NativeView parent,
+ const gfx::Rect& cursor_bounds,
+ const base::string16& label);
+ virtual ~ModeIndicatorView();
// Show the mode indicator then hide with fading animation.
void ShowAndFadeOut();
@@ -40,10 +43,10 @@ class ModeIndicatorDelegateView : public views::BubbleDelegateView {
gfx::Rect cursor_bounds_;
views::Label* label_view_;
- base::OneShotTimer<ModeIndicatorDelegateView> timer_;
+ base::OneShotTimer<ModeIndicatorView> timer_;
};
-} // namespace input_method
-} // namespace chromeos
+} // namespace ime
+} // namespace ash
-#endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MODE_INDICATOR_DELEGATE_VIEW_H_
+#endif // ASH_IME_MODE_INDICATOR_VIEW_H_
diff --git a/chrome/app/chromeos_strings.grdp b/chrome/app/chromeos_strings.grdp
index 24faf6e..4752eeb 100644
--- a/chrome/app/chromeos_strings.grdp
+++ b/chrome/app/chromeos_strings.grdp
@@ -3488,9 +3488,6 @@ Battery full
<message name="IDS_STATUSBAR_LAYOUT_MONGOLIAN" desc="In the language menu button, this shows the input mode.">
Mongolian keyboard
</message>
- <message name="IDS_INPUT_METHOD_INFOLIST_WINDOW_TITLE" desc="The title of the infolist window where the meanings and the usages of words are displayed.">
- Information
- </message>
<message name="IDS_STATUSBAR_LAYOUT_USA_MYSTERY" desc="In the language menu button, this shows the input mode.">
US Mystery keyboard
diff --git a/chrome/browser/chromeos/input_method/candidate_window_controller_impl.cc b/chrome/browser/chromeos/input_method/candidate_window_controller_impl.cc
index f801f81..4cc9b2f 100644
--- a/chrome/browser/chromeos/input_method/candidate_window_controller_impl.cc
+++ b/chrome/browser/chromeos/input_method/candidate_window_controller_impl.cc
@@ -7,13 +7,11 @@
#include <string>
#include <vector>
+#include "ash/ime/infolist_window.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/window_util.h"
#include "base/logging.h"
-#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/chromeos/input_method/candidate_window_view.h"
-#include "chrome/browser/chromeos/input_method/infolist_window.h"
#include "chrome/browser/chromeos/input_method/mode_indicator_controller.h"
#include "ui/gfx/screen.h"
#include "ui/views/widget/widget.h"
@@ -47,10 +45,11 @@ void CandidateWindowControllerImpl::InitCandidateWindowView() {
return;
aura::Window* active_window = ash::wm::GetActiveWindow();
- candidate_window_view_ = new CandidateWindowView(ash::Shell::GetContainer(
- active_window ?
- active_window->GetRootWindow() : ash::Shell::GetTargetRootWindow(),
- ash::internal::kShellWindowId_InputMethodContainer));
+ candidate_window_view_ =
+ new ash::ime::CandidateWindowView(ash::Shell::GetContainer(
+ active_window ?
+ active_window->GetRootWindow() : ash::Shell::GetTargetRootWindow(),
+ ash::internal::kShellWindowId_InputMethodContainer));
candidate_window_view_->AddObserver(this);
candidate_window_view_->SetCursorBounds(cursor_bounds_, composition_head_);
views::Widget* widget = candidate_window_view_->InitWidget();
@@ -99,35 +98,6 @@ void CandidateWindowControllerImpl::FocusStateChanged(bool is_focused) {
mode_indicator_controller_->FocusStateChanged(is_focused);
}
-// static
-void CandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry(
- const ui::CandidateWindow& candidate_window,
- std::vector<InfolistEntry>* infolist_entries,
- bool* has_highlighted) {
- DCHECK(infolist_entries);
- DCHECK(has_highlighted);
- infolist_entries->clear();
- *has_highlighted = false;
-
- const size_t cursor_index_in_page =
- candidate_window.cursor_position() % candidate_window.page_size();
-
- for (size_t i = 0; i < candidate_window.candidates().size(); ++i) {
- const ui::CandidateWindow::Entry& ibus_entry =
- candidate_window.candidates()[i];
- if (ibus_entry.description_title.empty() &&
- ibus_entry.description_body.empty())
- continue;
- InfolistEntry entry(base::UTF8ToUTF16(ibus_entry.description_title),
- base::UTF8ToUTF16(ibus_entry.description_body));
- if (i == cursor_index_in_page) {
- entry.highlighted = true;
- *has_highlighted = true;
- }
- infolist_entries->push_back(entry);
- }
-}
-
void CandidateWindowControllerImpl::UpdateLookupTable(
const ui::CandidateWindow& candidate_window,
bool visible) {
@@ -148,9 +118,8 @@ void CandidateWindowControllerImpl::UpdateLookupTable(
candidate_window_view_->ShowLookupTable();
bool has_highlighted = false;
- std::vector<InfolistEntry> infolist_entries;
- ConvertLookupTableToInfolistEntry(candidate_window, &infolist_entries,
- &has_highlighted);
+ std::vector<ui::InfolistEntry> infolist_entries;
+ candidate_window.GetInfolistEntries(&infolist_entries, &has_highlighted);
// If there is no change, just return.
if (latest_infolist_entries_ == infolist_entries)
@@ -174,7 +143,7 @@ void CandidateWindowControllerImpl::UpdateLookupTable(
if (infolist_window_) {
infolist_window_->Relayout(infolist_entries);
} else {
- infolist_window_ = new InfolistWindow(
+ infolist_window_ = new ash::ime::InfolistWindow(
candidate_window_view_, infolist_entries);
infolist_window_->InitWidget();
infolist_window_->GetWidget()->AddObserver(this);
diff --git a/chrome/browser/chromeos/input_method/candidate_window_controller_impl.h b/chrome/browser/chromeos/input_method/candidate_window_controller_impl.h
index 9976555..a5eab24 100644
--- a/chrome/browser/chromeos/input_method/candidate_window_controller_impl.h
+++ b/chrome/browser/chromeos/input_method/candidate_window_controller_impl.h
@@ -7,21 +7,27 @@
#include "chrome/browser/chromeos/input_method/candidate_window_controller.h"
+#include "ash/ime/candidate_window_view.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
-#include "chrome/browser/chromeos/input_method/candidate_window_view.h"
-#include "chrome/browser/chromeos/input_method/infolist_window.h"
#include "ui/base/ime/chromeos/ibus_bridge.h"
+#include "ui/base/ime/infolist_entry.h"
#include "ui/views/widget/widget_observer.h"
-namespace views {
-class Widget;
-} // namespace views
+namespace ash {
+namespace ime {
+class InfolistWindow;
+} // namespace ime
+} // namespace ash
namespace ui {
class CandidateWindow;
} // namespace ui
+namespace views {
+class Widget;
+} // namespace views
+
namespace chromeos {
namespace input_method {
@@ -32,7 +38,7 @@ class ModeIndicatorController;
// CandidateWindowController controls the CandidateWindow.
class CandidateWindowControllerImpl
: public CandidateWindowController,
- public CandidateWindowView::Observer,
+ public ash::ime::CandidateWindowView::Observer,
public views::WidgetObserver,
public IBusPanelCandidateWindowHandlerInterface {
public:
@@ -47,16 +53,13 @@ class CandidateWindowControllerImpl
virtual void Hide() OVERRIDE;
protected:
- // Converts |candidate_window| to infolist entry models. Sets
- // |has_highlighted| to true if infolist_entries contains highlighted entry.
- // TODO(mukai): move this method (and tests) to the new InfolistEntry model.
static void ConvertLookupTableToInfolistEntry(
const ui::CandidateWindow& candidate_window,
- std::vector<InfolistEntry>* infolist_entries,
+ std::vector<ui::InfolistEntry>* infolist_entries,
bool* has_highlighted);
private:
- // CandidateWindowView::Observer implementation.
+ // ash::ime::CandidateWindowView::Observer implementation.
virtual void OnCandidateCommitted(int index) OVERRIDE;
// views::WidgetObserver implementation.
@@ -75,10 +78,10 @@ class CandidateWindowControllerImpl
void InitCandidateWindowView();
// The candidate window view.
- CandidateWindowView* candidate_window_view_;
+ ash::ime::CandidateWindowView* candidate_window_view_;
// This is the outer frame of the infolist window view. Owned by the widget.
- InfolistWindow* infolist_window_;
+ ash::ime::InfolistWindow* infolist_window_;
gfx::Rect cursor_bounds_;
gfx::Rect composition_head_;
@@ -88,7 +91,7 @@ class CandidateWindowControllerImpl
// The infolist entries and its focused index which currently shown in
// Infolist window.
- std::vector<InfolistEntry> latest_infolist_entries_;
+ std::vector<ui::InfolistEntry> latest_infolist_entries_;
ObserverList<CandidateWindowController::Observer> observers_;
diff --git a/chrome/browser/chromeos/input_method/candidate_window_controller_impl_unittest.cc b/chrome/browser/chromeos/input_method/candidate_window_controller_impl_unittest.cc
deleted file mode 100644
index a127346..0000000
--- a/chrome/browser/chromeos/input_method/candidate_window_controller_impl_unittest.cc
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/chromeos/input_method/candidate_window_controller_impl.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace chromeos {
-namespace input_method {
-
-namespace {
-
-const size_t kSampleCandidateSize = 3;
-const char* kSampleCandidate[] = {
- "Sample Candidate 1",
- "Sample Candidate 2",
- "Sample Candidate 3",
-};
-const char* kSampleDescriptionTitle[] = {
- "Sample Description Title 1",
- "Sample Description Title 2",
- "Sample Description Title 3",
-};
-const char* kSampleDescriptionBody[] = {
- "Sample Description Body 1",
- "Sample Description Body 2",
- "Sample Description Body 3",
-};
-
-class TestableCandidateWindowControllerImpl :
- public CandidateWindowControllerImpl {
- public:
- TestableCandidateWindowControllerImpl() {}
- virtual ~TestableCandidateWindowControllerImpl() {}
-
- // Changes access right for testing.
- using CandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TestableCandidateWindowControllerImpl);
-};
-
-} // namespace
-
-class CandidateWindowControllerImplTest : public testing::Test {
- public:
- CandidateWindowControllerImplTest()
- : kScreenRect(gfx::Rect(0, 0, 1000, 1000)) {
- }
-
- virtual ~CandidateWindowControllerImplTest() {
- }
-
- protected:
- const gfx::Rect kScreenRect;
-};
-
-TEST_F(CandidateWindowControllerImplTest,
- ConvertLookupTableToInfolistEntryTest_DenseCase) {
- ui::CandidateWindow candidate_window;
- candidate_window.set_page_size(10);
- for (size_t i = 0; i < kSampleCandidateSize; ++i) {
- ui::CandidateWindow::Entry entry;
- entry.value = kSampleCandidate[i];
- entry.description_title = kSampleDescriptionTitle[i];
- entry.description_body = kSampleDescriptionBody[i];
- candidate_window.mutable_candidates()->push_back(entry);
- }
- candidate_window.set_cursor_position(1);
-
- std::vector<InfolistEntry> infolist_entries;
- bool has_highlighted = false;
-
- TestableCandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry(
- candidate_window,
- &infolist_entries,
- &has_highlighted);
-
- EXPECT_EQ(kSampleCandidateSize, infolist_entries.size());
- EXPECT_TRUE(has_highlighted);
- EXPECT_TRUE(infolist_entries[1].highlighted);
-}
-
-TEST_F(CandidateWindowControllerImplTest,
- ConvertLookupTableToInfolistEntryTest_SparseCase) {
- ui::CandidateWindow candidate_window;
- candidate_window.set_page_size(10);
- for (size_t i = 0; i < kSampleCandidateSize; ++i) {
- ui::CandidateWindow::Entry entry;
- entry.value = kSampleCandidate[i];
- candidate_window.mutable_candidates()->push_back(entry);
- }
-
- std::vector<ui::CandidateWindow::Entry>* candidates =
- candidate_window.mutable_candidates();
- (*candidates)[2].description_title = kSampleDescriptionTitle[2];
- (*candidates)[2].description_body = kSampleDescriptionBody[2];
-
- candidate_window.set_cursor_position(2);
-
- std::vector<InfolistEntry> infolist_entries;
- bool has_highlighted = false;
-
- TestableCandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry(
- candidate_window,
- &infolist_entries,
- &has_highlighted);
-
- // Infolist entries skips empty descriptions, so expected entry size is 1.
- EXPECT_EQ(1UL, infolist_entries.size());
- EXPECT_TRUE(has_highlighted);
- EXPECT_TRUE(infolist_entries[0].highlighted);
-}
-
-TEST_F(CandidateWindowControllerImplTest,
- ConvertLookupTableToInfolistEntryTest_SparseNoSelectionCase) {
- ui::CandidateWindow candidate_window;
- candidate_window.set_page_size(10);
-
- for (size_t i = 0; i < kSampleCandidateSize; ++i) {
- ui::CandidateWindow::Entry entry;
- entry.value = kSampleCandidate[i];
- candidate_window.mutable_candidates()->push_back(entry);
- }
-
- std::vector<ui::CandidateWindow::Entry>* candidates =
- candidate_window.mutable_candidates();
- (*candidates)[2].description_title = kSampleDescriptionTitle[2];
- (*candidates)[2].description_body = kSampleDescriptionBody[2];
-
- candidate_window.set_cursor_position(0);
-
- std::vector<InfolistEntry> infolist_entries;
- bool has_highlighted;
-
- TestableCandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry(
- candidate_window,
- &infolist_entries,
- &has_highlighted);
-
- // Infolist entries skips empty descriptions, so expected entry size is 1 and
- // no highlighted entries.
- EXPECT_EQ(1UL, infolist_entries.size());
- EXPECT_FALSE(has_highlighted);
- EXPECT_FALSE(infolist_entries[0].highlighted);
-}
-
-TEST_F(CandidateWindowControllerImplTest,
- ConvertLookupTableToInfolistEntryTest_NoInfolistCase) {
- ui::CandidateWindow candidate_window;
- candidate_window.set_page_size(10);
-
- for (size_t i = 0; i < kSampleCandidateSize; ++i) {
- ui::CandidateWindow::Entry entry;
- entry.value = kSampleCandidate[i];
- candidate_window.mutable_candidates()->push_back(entry);
- }
- candidate_window.set_cursor_position(1);
-
- std::vector<InfolistEntry> infolist_entries;
- bool has_highlighted = false;
-
- TestableCandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry(
- candidate_window,
- &infolist_entries,
- &has_highlighted);
-
- EXPECT_TRUE(infolist_entries.empty());
- EXPECT_FALSE(has_highlighted);
-}
-
-} // namespace input_method
-} // namespace chromeos
diff --git a/chrome/browser/chromeos/input_method/mode_indicator_controller.cc b/chrome/browser/chromeos/input_method/mode_indicator_controller.cc
index 1bdc1b1..cd8241e 100644
--- a/chrome/browser/chromeos/input_method/mode_indicator_controller.cc
+++ b/chrome/browser/chromeos/input_method/mode_indicator_controller.cc
@@ -4,11 +4,14 @@
#include "chrome/browser/chromeos/input_method/mode_indicator_controller.h"
+#include "ash/ime/mode_indicator_view.h"
+#include "ash/shell.h"
+#include "ash/shell_window_ids.h"
+#include "ash/wm/window_util.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h"
-#include "chrome/browser/chromeos/input_method/mode_indicator_delegate_view.h"
#include "chromeos/chromeos_switches.h"
namespace chromeos {
@@ -115,16 +118,19 @@ void ModeIndicatorController::ShowModeIndicator() {
const base::string16 short_name =
imm_->GetInputMethodUtil()->GetInputMethodShortName(descriptor);
- ModeIndicatorDelegateView* mi_delegate_view =
- new ModeIndicatorDelegateView(cursor_bounds_, short_name);
- views::BubbleDelegateView::CreateBubble(mi_delegate_view);
+ aura::Window* parent = ash::Shell::GetContainer(
+ ash::wm::GetActiveWindow()->GetRootWindow(),
+ ash::internal::kShellWindowId_InputMethodContainer);
+ ash::ime::ModeIndicatorView* mi_view = new ash::ime::ModeIndicatorView(
+ parent, cursor_bounds_, short_name);
+ views::BubbleDelegateView::CreateBubble(mi_view);
- views::Widget* mi_widget = mi_delegate_view->GetWidget();
+ views::Widget* mi_widget = mi_view->GetWidget();
if (GetModeIndicatorObserverForTesting())
GetModeIndicatorObserverForTesting()->AddModeIndicatorWidget(mi_widget);
mi_observer_->AddModeIndicatorWidget(mi_widget);
- mi_delegate_view->ShowAndFadeOut();
+ mi_view->ShowAndFadeOut();
}
} // namespace input_method
diff --git a/chrome/chrome_browser_chromeos.gypi b/chrome/chrome_browser_chromeos.gypi
index 16e8cde..31e8aaf 100644
--- a/chrome/chrome_browser_chromeos.gypi
+++ b/chrome/chrome_browser_chromeos.gypi
@@ -402,16 +402,10 @@
'browser/chromeos/input_method/accessibility.h',
'browser/chromeos/input_method/browser_state_monitor.cc',
'browser/chromeos/input_method/browser_state_monitor.h',
- 'browser/chromeos/input_method/candidate_view.cc',
- 'browser/chromeos/input_method/candidate_view.h',
'browser/chromeos/input_method/candidate_window_controller.cc',
'browser/chromeos/input_method/candidate_window_controller.h',
'browser/chromeos/input_method/candidate_window_controller_impl.cc',
'browser/chromeos/input_method/candidate_window_controller_impl.h',
- 'browser/chromeos/input_method/candidate_window_view.cc',
- 'browser/chromeos/input_method/candidate_window_view.h',
- 'browser/chromeos/input_method/infolist_window.cc',
- 'browser/chromeos/input_method/infolist_window.h',
'browser/chromeos/input_method/input_method_engine.cc',
'browser/chromeos/input_method/input_method_engine.h',
'browser/chromeos/input_method/input_method_configuration.cc',
@@ -430,8 +424,6 @@
'browser/chromeos/input_method/component_extension_ime_manager_impl.h',
'browser/chromeos/input_method/mode_indicator_controller.cc',
'browser/chromeos/input_method/mode_indicator_controller.h',
- 'browser/chromeos/input_method/mode_indicator_delegate_view.cc',
- 'browser/chromeos/input_method/mode_indicator_delegate_view.h',
'browser/chromeos/keyboard_driven_event_rewriter.cc',
'browser/chromeos/keyboard_driven_event_rewriter.h',
'browser/chromeos/kiosk_mode/kiosk_mode_idle_logout.cc',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 0c72a92..e6844cc 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -688,8 +688,6 @@
'browser/chromeos/imageburner/burn_device_handler_unittest.cc',
'browser/chromeos/imageburner/burn_manager_unittest.cc',
'browser/chromeos/input_method/browser_state_monitor_unittest.cc',
- 'browser/chromeos/input_method/candidate_window_controller_impl_unittest.cc',
- 'browser/chromeos/input_method/candidate_window_view_unittest.cc',
'browser/chromeos/input_method/input_method_configuration_unittest.cc',
'browser/chromeos/input_method/input_method_manager_impl_unittest.cc',
'browser/chromeos/input_method/input_method_persistence_unittest.cc',
diff --git a/ui/base/ime/candidate_window.cc b/ui/base/ime/candidate_window.cc
index bf287ff..f49613b 100644
--- a/ui/base/ime/candidate_window.cc
+++ b/ui/base/ime/candidate_window.cc
@@ -6,6 +6,7 @@
#include <string>
#include "base/logging.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
namespace ui {
@@ -53,6 +54,32 @@ void CandidateWindow::CopyFrom(const CandidateWindow& cw) {
}
+void CandidateWindow::GetInfolistEntries(
+ std::vector<ui::InfolistEntry>* infolist_entries,
+ bool* has_highlighted) const {
+ DCHECK(infolist_entries);
+ DCHECK(has_highlighted);
+ infolist_entries->clear();
+ *has_highlighted = false;
+
+ const size_t cursor_index_in_page = cursor_position() % page_size();
+
+ for (size_t i = 0; i < candidates().size(); ++i) {
+ const CandidateWindow::Entry& candidate_entry = candidates()[i];
+ if (candidate_entry.description_title.empty() &&
+ candidate_entry.description_body.empty())
+ continue;
+
+ InfolistEntry entry(base::UTF8ToUTF16(candidate_entry.description_title),
+ base::UTF8ToUTF16(candidate_entry.description_body));
+ if (i == cursor_index_in_page) {
+ entry.highlighted = true;
+ *has_highlighted = true;
+ }
+ infolist_entries->push_back(entry);
+ }
+}
+
// When the default values are changed, please modify
// InputMethodEngineInterface::CandidateWindowProperty too.
CandidateWindow::CandidateWindowProperty::CandidateWindowProperty()
diff --git a/ui/base/ime/candidate_window.h b/ui/base/ime/candidate_window.h
index d7523e1..f4f3851 100644
--- a/ui/base/ime/candidate_window.h
+++ b/ui/base/ime/candidate_window.h
@@ -9,6 +9,7 @@
#include <vector>
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
+#include "ui/base/ime/infolist_entry.h"
#include "ui/base/ui_base_export.h"
namespace ui {
@@ -63,6 +64,11 @@ class UI_BASE_EXPORT CandidateWindow {
*property_ = property;
}
+ // Gets the infolist entry models. Sets |has_highlighted| to true if |entries|
+ // contains highlighted entry.
+ void GetInfolistEntries(std::vector<InfolistEntry>* entries,
+ bool* has_highlighted) const;
+
// Returns the number of candidates in one page.
uint32 page_size() const { return property_->page_size; }
void set_page_size(uint32 page_size) { property_->page_size = page_size; }
diff --git a/ui/base/ime/candidate_window_unittest.cc b/ui/base/ime/candidate_window_unittest.cc
index 8af1e99..c408f5f 100644
--- a/ui/base/ime/candidate_window_unittest.cc
+++ b/ui/base/ime/candidate_window_unittest.cc
@@ -14,6 +14,27 @@
namespace ui {
+namespace {
+
+const size_t kSampleCandidateSize = 3;
+const char* kSampleCandidate[] = {
+ "Sample Candidate 1",
+ "Sample Candidate 2",
+ "Sample Candidate 3",
+};
+const char* kSampleDescriptionTitle[] = {
+ "Sample Description Title 1",
+ "Sample Description Title 2",
+ "Sample Description Title 3",
+};
+const char* kSampleDescriptionBody[] = {
+ "Sample Description Body 1",
+ "Sample Description Body 2",
+ "Sample Description Body 3",
+};
+
+}
+
TEST(CandidateWindow, IsEqualTest) {
CandidateWindow cw1;
CandidateWindow cw2;
@@ -135,4 +156,102 @@ TEST(CandidateWindow, CopyFromTest) {
EXPECT_TRUE(cw1.IsEqual(cw2));
}
+TEST(CandidateWindow, GetInfolistEntries_DenseCase) {
+ CandidateWindow candidate_window;
+ candidate_window.set_page_size(10);
+ for (size_t i = 0; i < kSampleCandidateSize; ++i) {
+ CandidateWindow::Entry entry;
+ entry.value = kSampleCandidate[i];
+ entry.description_title = kSampleDescriptionTitle[i];
+ entry.description_body = kSampleDescriptionBody[i];
+ candidate_window.mutable_candidates()->push_back(entry);
+ }
+ candidate_window.set_cursor_position(1);
+
+ std::vector<InfolistEntry> infolist_entries;
+ bool has_highlighted = false;
+
+ candidate_window.GetInfolistEntries(&infolist_entries, &has_highlighted);
+
+ EXPECT_EQ(kSampleCandidateSize, infolist_entries.size());
+ EXPECT_TRUE(has_highlighted);
+ EXPECT_TRUE(infolist_entries[1].highlighted);
+}
+
+TEST(CandidateWindow, GetInfolistEntries_SparseCase) {
+ CandidateWindow candidate_window;
+ candidate_window.set_page_size(10);
+ for (size_t i = 0; i < kSampleCandidateSize; ++i) {
+ CandidateWindow::Entry entry;
+ entry.value = kSampleCandidate[i];
+ candidate_window.mutable_candidates()->push_back(entry);
+ }
+
+ std::vector<CandidateWindow::Entry>* candidates =
+ candidate_window.mutable_candidates();
+ (*candidates)[2].description_title = kSampleDescriptionTitle[2];
+ (*candidates)[2].description_body = kSampleDescriptionBody[2];
+
+ candidate_window.set_cursor_position(2);
+
+ std::vector<InfolistEntry> infolist_entries;
+ bool has_highlighted = false;
+
+ candidate_window.GetInfolistEntries(&infolist_entries, &has_highlighted);
+
+ // Infolist entries skips empty descriptions, so expected entry size is 1.
+ EXPECT_EQ(1UL, infolist_entries.size());
+ EXPECT_TRUE(has_highlighted);
+ EXPECT_TRUE(infolist_entries[0].highlighted);
+}
+
+TEST(CandidateWindow, GetInfolistEntries_SparseNoSelectionCase) {
+ CandidateWindow candidate_window;
+ candidate_window.set_page_size(10);
+
+ for (size_t i = 0; i < kSampleCandidateSize; ++i) {
+ CandidateWindow::Entry entry;
+ entry.value = kSampleCandidate[i];
+ candidate_window.mutable_candidates()->push_back(entry);
+ }
+
+ std::vector<CandidateWindow::Entry>* candidates =
+ candidate_window.mutable_candidates();
+ (*candidates)[2].description_title = kSampleDescriptionTitle[2];
+ (*candidates)[2].description_body = kSampleDescriptionBody[2];
+
+ candidate_window.set_cursor_position(0);
+
+ std::vector<InfolistEntry> infolist_entries;
+ bool has_highlighted;
+
+ candidate_window.GetInfolistEntries(&infolist_entries, &has_highlighted);
+
+ // Infolist entries skips empty descriptions, so expected entry size is 1 and
+ // no highlighted entries.
+ EXPECT_EQ(1UL, infolist_entries.size());
+ EXPECT_FALSE(has_highlighted);
+ EXPECT_FALSE(infolist_entries[0].highlighted);
+}
+
+TEST(CandidateWindow, GetInfolistEntries_NoInfolistCase) {
+ CandidateWindow candidate_window;
+ candidate_window.set_page_size(10);
+
+ for (size_t i = 0; i < kSampleCandidateSize; ++i) {
+ CandidateWindow::Entry entry;
+ entry.value = kSampleCandidate[i];
+ candidate_window.mutable_candidates()->push_back(entry);
+ }
+ candidate_window.set_cursor_position(1);
+
+ std::vector<InfolistEntry> infolist_entries;
+ bool has_highlighted = false;
+
+ candidate_window.GetInfolistEntries(&infolist_entries, &has_highlighted);
+
+ EXPECT_TRUE(infolist_entries.empty());
+ EXPECT_FALSE(has_highlighted);
+}
+
} // namespace ui
diff --git a/ui/base/ime/ime.gypi b/ui/base/ime/ime.gypi
index c3f57ae..a475d99 100644
--- a/ui/base/ime/ime.gypi
+++ b/ui/base/ime/ime.gypi
@@ -26,6 +26,8 @@
'composition_underline.h',
'dummy_input_method_delegate.cc',
'dummy_input_method_delegate.h',
+ 'infolist_entry.cc',
+ 'infolist_entry.h',
'input_method.h',
'input_method_base.cc',
'input_method_base.h',
diff --git a/ui/base/ime/infolist_entry.cc b/ui/base/ime/infolist_entry.cc
new file mode 100644
index 0000000..7423f73
--- /dev/null
+++ b/ui/base/ime/infolist_entry.cc
@@ -0,0 +1,22 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/base/ime/infolist_entry.h"
+
+namespace ui {
+
+InfolistEntry::InfolistEntry(const base::string16& title,
+ const base::string16& body)
+ : title(title), body(body), highlighted(false) {}
+
+bool InfolistEntry::operator==(const InfolistEntry& other) const {
+ return title == other.title && body == other.body &&
+ highlighted == other.highlighted;
+}
+
+bool InfolistEntry::operator!=(const InfolistEntry& other) const {
+ return !(*this == other);
+}
+
+} // namespace ui
diff --git a/ui/base/ime/infolist_entry.h b/ui/base/ime/infolist_entry.h
new file mode 100644
index 0000000..3cb7672
--- /dev/null
+++ b/ui/base/ime/infolist_entry.h
@@ -0,0 +1,26 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_BASE_IME_INFOLIST_ENTRY_H_
+#define UI_BASE_IME_INFOLIST_ENTRY_H_
+
+#include "base/strings/string16.h"
+#include "ui/base/ui_base_export.h"
+
+namespace ui {
+
+// The data model of infolist window.
+struct UI_BASE_EXPORT InfolistEntry {
+ base::string16 title;
+ base::string16 body;
+ bool highlighted;
+
+ InfolistEntry(const base::string16& title, const base::string16& body);
+ bool operator==(const InfolistEntry& entry) const;
+ bool operator!=(const InfolistEntry& entry) const;
+};
+
+} // namespace ui
+
+#endif // UI_BASE_IME_INFOLIST_ENTRY_H_