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

Unified Diff: chrome/browser/extensions/extension_input_ui_api.cc

Issue 10399046: Remove virtual keyboard support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: final rebase Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_input_ui_api.cc
diff --git a/chrome/browser/extensions/extension_input_ui_api.cc b/chrome/browser/extensions/extension_input_ui_api.cc
deleted file mode 100644
index ac151ea807cef60b280932658aa3a23ba3e6978b..0000000000000000000000000000000000000000
--- a/chrome/browser/extensions/extension_input_ui_api.cc
+++ /dev/null
@@ -1,239 +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/extensions/extension_input_ui_api.h"
-
-#include <algorithm>
-#include <string>
-
-#include "base/json/json_writer.h"
-#include "base/logging.h"
-#include "base/string_util.h"
-#include "base/values.h"
-#include "chrome/browser/chromeos/cros/cros_library.h"
-#include "chrome/browser/extensions/extension_event_router.h"
-#include "chrome/browser/profiles/profile.h"
-#include "third_party/cros/chromeos_cros_api.h"
-
-namespace events {
-
-const char kOnUpdateAuxiliaryText[] =
- "experimental.input.ui.onUpdateAuxiliaryText";
-const char kOnUpdateLookupTable[] = "experimental.input.ui.onUpdateLookupTable";
-const char kOnSetCursorLocation[] = "experimental.input.ui.onSetCursorLocation";
-
-} // namespace events
-
-ExtensionInputUiEventRouter*
-ExtensionInputUiEventRouter::GetInstance() {
- return Singleton<ExtensionInputUiEventRouter>::get();
-}
-
-ExtensionInputUiEventRouter::ExtensionInputUiEventRouter()
- : profile_(NULL),
- ibus_ui_controller_(NULL) {
-}
-
-ExtensionInputUiEventRouter::~ExtensionInputUiEventRouter() {
-}
-
-void ExtensionInputUiEventRouter::Init() {
- if (ibus_ui_controller_.get() == NULL) {
- ibus_ui_controller_.reset(
- chromeos::input_method::IBusUiController::Create());
- // The observer should be added before Connect() so we can capture the
- // initial connection change.
- ibus_ui_controller_->AddObserver(this);
- ibus_ui_controller_->Connect();
- }
-}
-
-void ExtensionInputUiEventRouter::Register(
- Profile* profile, const std::string& extension_id) {
- profile_ = profile;
- extension_id_ = extension_id;
-}
-
-void ExtensionInputUiEventRouter::CandidateClicked(Profile* profile,
- const std::string& extension_id, int index, int button) {
- if (profile_ != profile || extension_id_ != extension_id) {
- DLOG(WARNING) << "called from unregistered extension";
- }
- ibus_ui_controller_->NotifyCandidateClicked(index, button, 0);
-}
-
-void ExtensionInputUiEventRouter::CursorUp(Profile* profile,
- const std::string& extension_id) {
- if (profile_ != profile || extension_id_ != extension_id) {
- DLOG(WARNING) << "called from unregistered extension";
- }
- ibus_ui_controller_->NotifyCursorUp();
-}
-
-void ExtensionInputUiEventRouter::CursorDown(Profile* profile,
- const std::string& extension_id) {
- if (profile_ != profile || extension_id_ != extension_id) {
- DLOG(WARNING) << "called from unregistered extension";
- }
- ibus_ui_controller_->NotifyCursorDown();
-}
-
-void ExtensionInputUiEventRouter::PageUp(Profile* profile,
- const std::string& extension_id) {
- if (profile_ != profile || extension_id_ != extension_id) {
- DLOG(WARNING) << "called from unregistered extension";
- }
- ibus_ui_controller_->NotifyPageUp();
-}
-
-void ExtensionInputUiEventRouter::PageDown(Profile* profile,
- const std::string& extension_id) {
- if (profile_ != profile || extension_id_ != extension_id) {
- DLOG(WARNING) << "called from unregistered extension";
- }
- ibus_ui_controller_->NotifyPageDown();
-}
-
-void ExtensionInputUiEventRouter::OnHideAuxiliaryText() {
- OnUpdateAuxiliaryText("", false);
-}
-
-void ExtensionInputUiEventRouter::OnHideLookupTable() {
- if (profile_ == NULL || extension_id_.empty())
- return;
-
- DictionaryValue* dict = new DictionaryValue();
- dict->SetBoolean("visible", false);
-
- ListValue *candidates = new ListValue();
- dict->Set("candidates", candidates);
-
- ListValue args;
- args.Append(dict);
-
- std::string json_args;
- base::JSONWriter::Write(&args, &json_args);
- profile_->GetExtensionEventRouter()->DispatchEventToExtension(
- extension_id_, events::kOnUpdateLookupTable, json_args, profile_, GURL());
-}
-
-void ExtensionInputUiEventRouter::OnHidePreeditText() {
-}
-
-void ExtensionInputUiEventRouter::OnSetCursorLocation(
- int x, int y, int width, int height) {
-
- if (profile_ == NULL || extension_id_.empty())
- return;
-
- ListValue args;
- args.Append(Value::CreateIntegerValue(x));
- args.Append(Value::CreateIntegerValue(y));
- args.Append(Value::CreateIntegerValue(width));
- args.Append(Value::CreateIntegerValue(height));
-
- std::string json_args;
- base::JSONWriter::Write(&args, &json_args);
- profile_->GetExtensionEventRouter()->DispatchEventToExtension(
- extension_id_, events::kOnSetCursorLocation, json_args, profile_, GURL());
-}
-
-void ExtensionInputUiEventRouter::OnUpdateAuxiliaryText(
- const std::string& utf8_text,
- bool visible) {
- if (profile_ == NULL || extension_id_.empty())
- return;
-
- ListValue args;
- args.Append(Value::CreateStringValue(visible ? utf8_text : ""));
-
- std::string json_args;
- base::JSONWriter::Write(&args, &json_args);
- profile_->GetExtensionEventRouter()->DispatchEventToExtension(
- extension_id_, events::kOnUpdateAuxiliaryText, json_args, profile_, GURL());
-}
-
-void ExtensionInputUiEventRouter::OnUpdateLookupTable(
- const chromeos::input_method::InputMethodLookupTable& lookup_table) {
- if (profile_ == NULL || extension_id_.empty())
- return;
-
- DictionaryValue* dict = new DictionaryValue();
- dict->SetBoolean("visible", lookup_table.visible);
-
- if (lookup_table.visible) {
- }
-
- ListValue *candidates = new ListValue();
-
- size_t page = lookup_table.cursor_absolute_index / lookup_table.page_size;
- size_t begin = page * lookup_table.page_size;
- size_t end = std::min(begin + lookup_table.page_size,
- lookup_table.candidates.size());
-
- for (size_t i = begin; i < end; i++) {
- candidates->Append(Value::CreateStringValue(lookup_table.candidates[i]));
- }
-
- dict->Set("candidates", candidates);
-
- ListValue args;
- args.Append(dict);
-
- std::string json_args;
- base::JSONWriter::Write(&args, &json_args);
- profile_->GetExtensionEventRouter()->DispatchEventToExtension(
- extension_id_, events::kOnUpdateLookupTable, json_args, profile_, GURL());
-}
-
-void ExtensionInputUiEventRouter::OnUpdatePreeditText(
- const std::string& utf8_text,
- unsigned int cursor,
- bool visible) {
-}
-
-void ExtensionInputUiEventRouter::OnConnectionChange(bool connected) {
-}
-
-bool RegisterInputUiFunction::RunImpl() {
- ExtensionInputUiEventRouter::GetInstance()->Register(
- profile(), extension_id());
- return true;
-}
-
-bool CandidateClickedInputUiFunction::RunImpl() {
- int index = 0;
- int button = 0;
- EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &index));
- EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &button));
-
- ExtensionInputUiEventRouter::GetInstance()->CandidateClicked(
- profile(), extension_id(), index, button);
-
- return true;
-}
-
-bool CursorUpInputUiFunction::RunImpl() {
- ExtensionInputUiEventRouter::GetInstance()->CursorUp(
- profile(), extension_id());
- return true;
-}
-
-bool CursorDownInputUiFunction::RunImpl() {
- ExtensionInputUiEventRouter::GetInstance()->CursorDown(
- profile(), extension_id());
- return true;
-}
-
-bool PageUpInputUiFunction::RunImpl() {
- ExtensionInputUiEventRouter::GetInstance()->PageUp(
- profile(), extension_id());
- return true;
-}
-
-bool PageDownInputUiFunction::RunImpl() {
- ExtensionInputUiEventRouter::GetInstance()->PageDown(
- profile(), extension_id());
- return true;
-}
« no previous file with comments | « chrome/browser/extensions/extension_input_ui_api.h ('k') | chrome/browser/extensions/extension_input_ui_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698