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

Side by Side Diff: chrome/browser/ui/input_method/input_method_engine.cc

Issue 1756853002: Correctly sets the security origin for the IME window. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed tests. Created 4 years, 9 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 unified diff | Download patch
OLDNEW
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/input_method/input_method_engine.h" 5 #include "chrome/browser/ui/input_method/input_method_engine.h"
6 6
7 #include "content/public/browser/render_frame_host.h"
7 #include "ui/base/ime/composition_text.h" 8 #include "ui/base/ime/composition_text.h"
8 #include "ui/base/ime/ime_bridge.h" 9 #include "ui/base/ime/ime_bridge.h"
9 #include "ui/base/ime/ime_input_context_handler_interface.h" 10 #include "ui/base/ime/ime_input_context_handler_interface.h"
10 11
11 namespace { 12 namespace {
12 13
13 const char kErrorFollowCursorWindowExists[] = 14 const char kErrorFollowCursorWindowExists[] =
14 "A follow cursor IME window exists."; 15 "A follow cursor IME window exists.";
15 const char kErrorNoInputFocus[] = 16 const char kErrorNoInputFocus[] =
16 "The follow cursor IME window cannot be created without an input focus."; 17 "The follow cursor IME window cannot be created without an input focus.";
(...skipping 20 matching lines...) Expand all
37 } 38 }
38 39
39 bool InputMethodEngine::IsActive() const { 40 bool InputMethodEngine::IsActive() const {
40 return true; 41 return true;
41 } 42 }
42 43
43 std::string InputMethodEngine::GetExtensionId() const { 44 std::string InputMethodEngine::GetExtensionId() const {
44 return extension_id_; 45 return extension_id_;
45 } 46 }
46 47
47 int InputMethodEngine::CreateImeWindow(const extensions::Extension* extension, 48 int InputMethodEngine::CreateImeWindow(
48 const std::string& url, 49 const extensions::Extension* extension,
49 ui::ImeWindow::Mode mode, 50 content::RenderFrameHost* render_frame_host,
50 const gfx::Rect& bounds, 51 const std::string& url,
51 std::string* error) { 52 ui::ImeWindow::Mode mode,
53 const gfx::Rect& bounds,
54 std::string* error) {
52 if (mode == ui::ImeWindow::FOLLOW_CURSOR) { 55 if (mode == ui::ImeWindow::FOLLOW_CURSOR) {
53 if (follow_cursor_window_) { 56 if (follow_cursor_window_) {
54 *error = kErrorFollowCursorWindowExists; 57 *error = kErrorFollowCursorWindowExists;
55 return 0; 58 return 0;
56 } 59 }
57 if (current_input_type_ == ui::TEXT_INPUT_TYPE_NONE) { 60 if (current_input_type_ == ui::TEXT_INPUT_TYPE_NONE) {
58 *error = kErrorNoInputFocus; 61 *error = kErrorNoInputFocus;
59 return 0; 62 return 0;
60 } 63 }
61 } 64 }
62 65
63 if (mode == ui::ImeWindow::NORMAL && 66 if (mode == ui::ImeWindow::NORMAL &&
64 normal_windows_.size() >= kMaxNormalWindowCount) { 67 normal_windows_.size() >= kMaxNormalWindowCount) {
65 *error = kErrorReachMaxWindowCount; 68 *error = kErrorReachMaxWindowCount;
66 return 0; 69 return 0;
67 } 70 }
68 71
69 // ui::ImeWindow manages its own lifetime. 72 // ui::ImeWindow manages its own lifetime.
70 ui::ImeWindow* ime_window = 73 ui::ImeWindow* ime_window = new ui::ImeWindow(
71 new ui::ImeWindow(profile_, extension, url, mode, bounds); 74 profile_, extension, render_frame_host, url, mode, bounds);
72 ime_window->AddObserver(this); 75 ime_window->AddObserver(this);
73 ime_window->Show(); 76 ime_window->Show();
74 if (mode == ui::ImeWindow::FOLLOW_CURSOR) { 77 if (mode == ui::ImeWindow::FOLLOW_CURSOR) {
75 follow_cursor_window_ = ime_window; 78 follow_cursor_window_ = ime_window;
76 ime_window->FollowCursor(current_cursor_bounds_); 79 ime_window->FollowCursor(current_cursor_bounds_);
77 } else { 80 } else {
78 normal_windows_.push_back(ime_window); 81 normal_windows_.push_back(ime_window);
79 } 82 }
80 83
81 return ime_window->GetFrameId(); 84 return ime_window->GetFrameId();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 follow_cursor_window_ = nullptr; 160 follow_cursor_window_ = nullptr;
158 } else { 161 } else {
159 auto it = std::find( 162 auto it = std::find(
160 normal_windows_.begin(), normal_windows_.end(), ime_window); 163 normal_windows_.begin(), normal_windows_.end(), ime_window);
161 if (it != normal_windows_.end()) 164 if (it != normal_windows_.end())
162 normal_windows_.erase(it); 165 normal_windows_.erase(it);
163 } 166 }
164 } 167 }
165 168
166 } // namespace input_method 169 } // namespace input_method
OLDNEW
« no previous file with comments | « chrome/browser/ui/input_method/input_method_engine.h ('k') | chrome/browser/ui/views/ime/ime_window_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698