| 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/chromeos/input_method/input_method_engine.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_engine.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 | 341 |
| 342 bool InputMethodEngineImpl::SetMenuItems(const std::vector<MenuItem>& items) { | 342 bool InputMethodEngineImpl::SetMenuItems(const std::vector<MenuItem>& items) { |
| 343 std::vector<input_method::IBusEngineController::EngineProperty*> properties; | 343 std::vector<input_method::IBusEngineController::EngineProperty*> properties; |
| 344 | 344 |
| 345 for (std::vector<MenuItem>::const_iterator item = items.begin(); | 345 for (std::vector<MenuItem>::const_iterator item = items.begin(); |
| 346 item != items.end(); ++item) { | 346 item != items.end(); ++item) { |
| 347 input_method::IBusEngineController::EngineProperty* property = | 347 input_method::IBusEngineController::EngineProperty* property = |
| 348 new input_method::IBusEngineController::EngineProperty; | 348 new input_method::IBusEngineController::EngineProperty; |
| 349 if (!MenuItemToProperty(*item, property)) { | 349 if (!MenuItemToProperty(*item, property)) { |
| 350 delete property; | 350 delete property; |
| 351 LOG(ERROR) << "Bad menu item"; | 351 DVLOG(1) << "Bad menu item"; |
| 352 return false; | 352 return false; |
| 353 } | 353 } |
| 354 properties.push_back(property); | 354 properties.push_back(property); |
| 355 } | 355 } |
| 356 return connection_->RegisterProperties(properties); | 356 return connection_->RegisterProperties(properties); |
| 357 } | 357 } |
| 358 | 358 |
| 359 bool InputMethodEngineImpl::MenuItemToProperty( | 359 bool InputMethodEngineImpl::MenuItemToProperty( |
| 360 const MenuItem& item, | 360 const MenuItem& item, |
| 361 input_method::IBusEngineController::EngineProperty* property) { | 361 input_method::IBusEngineController::EngineProperty* property) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 property->modified |= | 409 property->modified |= |
| 410 input_method::IBusEngineController::PROPERTY_MODIFIED_CHECKED; | 410 input_method::IBusEngineController::PROPERTY_MODIFIED_CHECKED; |
| 411 } | 411 } |
| 412 | 412 |
| 413 for (std::vector<MenuItem>::const_iterator child = item.children.begin(); | 413 for (std::vector<MenuItem>::const_iterator child = item.children.begin(); |
| 414 child != item.children.end(); ++child) { | 414 child != item.children.end(); ++child) { |
| 415 input_method::IBusEngineController::EngineProperty* new_property = | 415 input_method::IBusEngineController::EngineProperty* new_property = |
| 416 new input_method::IBusEngineController::EngineProperty; | 416 new input_method::IBusEngineController::EngineProperty; |
| 417 if (!MenuItemToProperty(*child, new_property)) { | 417 if (!MenuItemToProperty(*child, new_property)) { |
| 418 delete new_property; | 418 delete new_property; |
| 419 LOG(ERROR) << "Bad menu item child"; | 419 DVLOG(1) << "Bad menu item child"; |
| 420 return false; | 420 return false; |
| 421 } | 421 } |
| 422 property->children.push_back(new_property); | 422 property->children.push_back(new_property); |
| 423 } | 423 } |
| 424 | 424 |
| 425 return true; | 425 return true; |
| 426 } | 426 } |
| 427 | 427 |
| 428 bool InputMethodEngineImpl::UpdateMenuItems( | 428 bool InputMethodEngineImpl::UpdateMenuItems( |
| 429 const std::vector<MenuItem>& items) { | 429 const std::vector<MenuItem>& items) { |
| 430 std::vector<input_method::IBusEngineController::EngineProperty*> properties; | 430 std::vector<input_method::IBusEngineController::EngineProperty*> properties; |
| 431 | 431 |
| 432 for (std::vector<MenuItem>::const_iterator item = items.begin(); | 432 for (std::vector<MenuItem>::const_iterator item = items.begin(); |
| 433 item != items.end(); ++item) { | 433 item != items.end(); ++item) { |
| 434 input_method::IBusEngineController::EngineProperty* new_property = | 434 input_method::IBusEngineController::EngineProperty* new_property = |
| 435 new input_method::IBusEngineController::EngineProperty(); | 435 new input_method::IBusEngineController::EngineProperty(); |
| 436 if (!MenuItemToProperty(*item, new_property)) { | 436 if (!MenuItemToProperty(*item, new_property)) { |
| 437 LOG(ERROR) << "Bad menu item"; | 437 DVLOG(1) << "Bad menu item"; |
| 438 delete new_property; | 438 delete new_property; |
| 439 return false; | 439 return false; |
| 440 } | 440 } |
| 441 properties.push_back(new_property); | 441 properties.push_back(new_property); |
| 442 } | 442 } |
| 443 return connection_->UpdateProperties(properties); | 443 return connection_->UpdateProperties(properties); |
| 444 } | 444 } |
| 445 | 445 |
| 446 void InputMethodEngineImpl::KeyEventDone(input_method::KeyEventHandle* key_data, | 446 void InputMethodEngineImpl::KeyEventDone(input_method::KeyEventHandle* key_data, |
| 447 bool handled) { | 447 bool handled) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 } | 506 } |
| 507 | 507 |
| 508 MouseButtonEvent pressed_button; | 508 MouseButtonEvent pressed_button; |
| 509 if (button & input_method::IBusEngineController::MOUSE_BUTTON_1_MASK) { | 509 if (button & input_method::IBusEngineController::MOUSE_BUTTON_1_MASK) { |
| 510 pressed_button = MOUSE_BUTTON_LEFT; | 510 pressed_button = MOUSE_BUTTON_LEFT; |
| 511 } else if (button & input_method::IBusEngineController::MOUSE_BUTTON_2_MASK) { | 511 } else if (button & input_method::IBusEngineController::MOUSE_BUTTON_2_MASK) { |
| 512 pressed_button = MOUSE_BUTTON_MIDDLE; | 512 pressed_button = MOUSE_BUTTON_MIDDLE; |
| 513 } else if (button & input_method::IBusEngineController::MOUSE_BUTTON_3_MASK) { | 513 } else if (button & input_method::IBusEngineController::MOUSE_BUTTON_3_MASK) { |
| 514 pressed_button = MOUSE_BUTTON_RIGHT; | 514 pressed_button = MOUSE_BUTTON_RIGHT; |
| 515 } else { | 515 } else { |
| 516 LOG(ERROR) << "Unknown button: " << button; | 516 DVLOG(1) << "Unknown button: " << button; |
| 517 pressed_button = MOUSE_BUTTON_LEFT; | 517 pressed_button = MOUSE_BUTTON_LEFT; |
| 518 } | 518 } |
| 519 | 519 |
| 520 observer_->OnCandidateClicked( | 520 observer_->OnCandidateClicked( |
| 521 engine_id_, candidate_ids_.at(index), pressed_button); | 521 engine_id_, candidate_ids_.at(index), pressed_button); |
| 522 } | 522 } |
| 523 | 523 |
| 524 class InputMethodEngineStub : public InputMethodEngine { | 524 class InputMethodEngineStub : public InputMethodEngine { |
| 525 public: | 525 public: |
| 526 InputMethodEngineStub() | 526 InputMethodEngineStub() |
| 527 : observer_(NULL), active_(false), next_context_id_(1), | 527 : observer_(NULL), active_(false), next_context_id_(1), |
| 528 context_id_(-1) {} | 528 context_id_(-1) {} |
| 529 | 529 |
| 530 ~InputMethodEngineStub() { | 530 ~InputMethodEngineStub() { |
| 531 } | 531 } |
| 532 | 532 |
| 533 bool Init(InputMethodEngine::Observer* observer, | 533 bool Init(InputMethodEngine::Observer* observer, |
| 534 const char* engine_name, | 534 const char* engine_name, |
| 535 const char* extension_id, | 535 const char* extension_id, |
| 536 const char* engine_id, | 536 const char* engine_id, |
| 537 const char* description, | 537 const char* description, |
| 538 const char* language, | 538 const char* language, |
| 539 const std::vector<std::string>& layouts, | 539 const std::vector<std::string>& layouts, |
| 540 std::string* error) { | 540 std::string* error) { |
| 541 VLOG(0) << "Init"; | 541 DVLOG(1) << "Init"; |
| 542 return true; | 542 return true; |
| 543 } | 543 } |
| 544 | 544 |
| 545 virtual bool SetComposition(int context_id, | 545 virtual bool SetComposition(int context_id, |
| 546 const char* text, int selection_start, | 546 const char* text, int selection_start, |
| 547 int selection_end, int cursor, | 547 int selection_end, int cursor, |
| 548 const std::vector<SegmentInfo>& segments, | 548 const std::vector<SegmentInfo>& segments, |
| 549 std::string* error) { | 549 std::string* error) { |
| 550 VLOG(0) << "SetComposition"; | 550 DVLOG(1) << "SetComposition"; |
| 551 return true; | 551 return true; |
| 552 } | 552 } |
| 553 | 553 |
| 554 virtual bool ClearComposition(int context_id, std::string* error) { | 554 virtual bool ClearComposition(int context_id, std::string* error) { |
| 555 VLOG(0) << "ClearComposition"; | 555 DVLOG(1) << "ClearComposition"; |
| 556 return true; | 556 return true; |
| 557 } | 557 } |
| 558 | 558 |
| 559 virtual bool CommitText(int context_id, | 559 virtual bool CommitText(int context_id, |
| 560 const char* text, std::string* error) { | 560 const char* text, std::string* error) { |
| 561 VLOG(0) << "CommitText"; | 561 DVLOG(1) << "CommitText"; |
| 562 return true; | 562 return true; |
| 563 } | 563 } |
| 564 | 564 |
| 565 virtual bool SetCandidateWindowVisible(bool visible, std::string* error) { | 565 virtual bool SetCandidateWindowVisible(bool visible, std::string* error) { |
| 566 VLOG(0) << "SetCandidateWindowVisible"; | 566 DVLOG(1) << "SetCandidateWindowVisible"; |
| 567 return true; | 567 return true; |
| 568 } | 568 } |
| 569 | 569 |
| 570 virtual void SetCandidateWindowCursorVisible(bool visible) { | 570 virtual void SetCandidateWindowCursorVisible(bool visible) { |
| 571 VLOG(0) << "SetCandidateWindowCursorVisible"; | 571 DVLOG(1) << "SetCandidateWindowCursorVisible"; |
| 572 } | 572 } |
| 573 | 573 |
| 574 virtual void SetCandidateWindowVertical(bool vertical) { | 574 virtual void SetCandidateWindowVertical(bool vertical) { |
| 575 VLOG(0) << "SetCandidateWindowVertical"; | 575 DVLOG(1) << "SetCandidateWindowVertical"; |
| 576 } | 576 } |
| 577 | 577 |
| 578 virtual void SetCandidateWindowPageSize(int size) { | 578 virtual void SetCandidateWindowPageSize(int size) { |
| 579 VLOG(0) << "SetCandidateWindowPageSize"; | 579 DVLOG(1) << "SetCandidateWindowPageSize"; |
| 580 } | 580 } |
| 581 | 581 |
| 582 virtual void SetCandidateWindowAuxText(const char* text) { | 582 virtual void SetCandidateWindowAuxText(const char* text) { |
| 583 VLOG(0) << "SetCandidateWindowAuxText"; | 583 DVLOG(1) << "SetCandidateWindowAuxText"; |
| 584 } | 584 } |
| 585 | 585 |
| 586 virtual void SetCandidateWindowAuxTextVisible(bool visible) { | 586 virtual void SetCandidateWindowAuxTextVisible(bool visible) { |
| 587 VLOG(0) << "SetCandidateWindowAuxTextVisible"; | 587 DVLOG(1) << "SetCandidateWindowAuxTextVisible"; |
| 588 } | 588 } |
| 589 | 589 |
| 590 virtual bool SetCandidates(int context_id, | 590 virtual bool SetCandidates(int context_id, |
| 591 const std::vector<Candidate>& candidates, | 591 const std::vector<Candidate>& candidates, |
| 592 std::string* error) { | 592 std::string* error) { |
| 593 VLOG(0) << "SetCandidates"; | 593 DVLOG(1) << "SetCandidates"; |
| 594 return true; | 594 return true; |
| 595 } | 595 } |
| 596 | 596 |
| 597 virtual bool SetCursorPosition(int context_id, int candidate_id, | 597 virtual bool SetCursorPosition(int context_id, int candidate_id, |
| 598 std::string* error) { | 598 std::string* error) { |
| 599 VLOG(0) << "SetCursorPosition"; | 599 DVLOG(1) << "SetCursorPosition"; |
| 600 return true; | 600 return true; |
| 601 } | 601 } |
| 602 | 602 |
| 603 virtual bool SetMenuItems(const std::vector<MenuItem>& items) { | 603 virtual bool SetMenuItems(const std::vector<MenuItem>& items) { |
| 604 VLOG(0) << "SetMenuItems"; | 604 DVLOG(1) << "SetMenuItems"; |
| 605 return true; | 605 return true; |
| 606 } | 606 } |
| 607 | 607 |
| 608 virtual bool UpdateMenuItems(const std::vector<MenuItem>& items) { | 608 virtual bool UpdateMenuItems(const std::vector<MenuItem>& items) { |
| 609 VLOG(0) << "UpdateMenuItems"; | 609 DVLOG(1) << "UpdateMenuItems"; |
| 610 return true; | 610 return true; |
| 611 } | 611 } |
| 612 | 612 |
| 613 virtual bool IsActive() const { | 613 virtual bool IsActive() const { |
| 614 VLOG(0) << "IsActive"; | 614 DVLOG(1) << "IsActive"; |
| 615 return active_; | 615 return active_; |
| 616 } | 616 } |
| 617 | 617 |
| 618 virtual void KeyEventDone(input_method::KeyEventHandle* key_data, | 618 virtual void KeyEventDone(input_method::KeyEventHandle* key_data, |
| 619 bool handled) { | 619 bool handled) { |
| 620 } | 620 } |
| 621 | 621 |
| 622 private: | 622 private: |
| 623 // Pointer to the object recieving events for this IME. | 623 // Pointer to the object recieving events for this IME. |
| 624 InputMethodEngine::Observer* observer_; | 624 InputMethodEngine::Observer* observer_; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 647 std::string* error) { | 647 std::string* error) { |
| 648 | 648 |
| 649 #if defined(HAVE_IBUS) | 649 #if defined(HAVE_IBUS) |
| 650 InputMethodEngineImpl* new_engine = new InputMethodEngineImpl(); | 650 InputMethodEngineImpl* new_engine = new InputMethodEngineImpl(); |
| 651 #else | 651 #else |
| 652 InputMethodEngineStub* new_engine = new InputMethodEngineStub(); | 652 InputMethodEngineStub* new_engine = new InputMethodEngineStub(); |
| 653 #endif | 653 #endif |
| 654 | 654 |
| 655 if (!new_engine->Init(observer, engine_name, extension_id, engine_id, | 655 if (!new_engine->Init(observer, engine_name, extension_id, engine_id, |
| 656 description, language, layouts, error)) { | 656 description, language, layouts, error)) { |
| 657 LOG(ERROR) << "Init() failed."; | 657 DVLOG(1) << "Init() failed."; |
| 658 delete new_engine; | 658 delete new_engine; |
| 659 new_engine = NULL; | 659 new_engine = NULL; |
| 660 } | 660 } |
| 661 | 661 |
| 662 return new_engine; | 662 return new_engine; |
| 663 } | 663 } |
| 664 | 664 |
| 665 } // namespace chromeos | 665 } // namespace chromeos |
| OLD | NEW |