OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/shell/browser/shell.h" | 5 #include "content/shell/browser/shell.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "content/public/browser/render_widget_host_view.h" | 9 #include "content/public/browser/render_widget_host_view.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
11 #include "content/public/browser/web_contents_view.h" | 11 #include "content/public/browser/web_contents_view.h" |
12 #include "content/public/common/context_menu_params.h" | 12 #include "content/public/common/context_menu_params.h" |
13 #include "content/shell/browser/shell_platform_data_aura.h" | 13 #include "content/shell/browser/shell_platform_data_aura.h" |
14 #include "ui/aura/client/screen_position_client.h" | 14 #include "ui/aura/client/screen_position_client.h" |
15 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
17 #include "ui/aura/window_event_dispatcher.h" | 17 #include "ui/aura/window_event_dispatcher.h" |
18 #include "ui/base/clipboard/clipboard.h" | 18 #include "ui/base/clipboard/clipboard.h" |
19 #include "ui/base/models/simple_menu_model.h" | 19 #include "ui/base/models/simple_menu_model.h" |
20 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
21 #include "ui/events/event.h" | 21 #include "ui/events/event.h" |
22 #include "ui/gfx/screen.h" | 22 #include "ui/gfx/screen.h" |
23 #include "ui/views/background.h" | 23 #include "ui/views/background.h" |
24 #include "ui/views/controls/button/label_button.h" | 24 #include "ui/views/controls/button/label_button.h" |
25 #include "ui/views/controls/button/menu_button.h" | 25 #include "ui/views/controls/button/menu_button.h" |
26 #include "ui/views/controls/button/menu_button_listener.h" | 26 #include "ui/views/controls/button/menu_button_listener.h" |
27 #include "ui/views/controls/menu/menu_item_view.h" | |
28 #include "ui/views/controls/menu/menu_runner.h" | 27 #include "ui/views/controls/menu/menu_runner.h" |
29 #include "ui/views/controls/textfield/textfield.h" | 28 #include "ui/views/controls/textfield/textfield.h" |
30 #include "ui/views/controls/textfield/textfield_controller.h" | 29 #include "ui/views/controls/textfield/textfield_controller.h" |
31 #include "ui/views/controls/webview/webview.h" | 30 #include "ui/views/controls/webview/webview.h" |
32 #include "ui/views/layout/fill_layout.h" | 31 #include "ui/views/layout/fill_layout.h" |
33 #include "ui/views/layout/grid_layout.h" | 32 #include "ui/views/layout/grid_layout.h" |
34 #include "ui/views/test/desktop_test_views_delegate.h" | 33 #include "ui/views/test/desktop_test_views_delegate.h" |
35 #include "ui/views/view.h" | 34 #include "ui/views/view.h" |
36 #include "ui/views/widget/widget.h" | 35 #include "ui/views/widget/widget.h" |
37 #include "ui/views/widget/widget_delegate.h" | 36 #include "ui/views/widget/widget_delegate.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 if (screen_position_client) { | 181 if (screen_position_client) { |
183 screen_position_client->ConvertPointToScreen(web_contents_window, | 182 screen_position_client->ConvertPointToScreen(web_contents_window, |
184 &screen_point); | 183 &screen_point); |
185 } | 184 } |
186 | 185 |
187 context_menu_model_.reset(new ContextMenuModel(shell_, params)); | 186 context_menu_model_.reset(new ContextMenuModel(shell_, params)); |
188 context_menu_runner_.reset( | 187 context_menu_runner_.reset( |
189 new views::MenuRunner(context_menu_model_.get())); | 188 new views::MenuRunner(context_menu_model_.get())); |
190 | 189 |
191 if (context_menu_runner_->RunMenuAt(web_view_->GetWidget(), | 190 if (context_menu_runner_->RunMenuAt(web_view_->GetWidget(), |
192 NULL, gfx::Rect(screen_point, gfx::Size()), | 191 NULL, |
193 views::MenuItemView::TOPRIGHT, ui::MENU_SOURCE_NONE, | 192 gfx::Rect(screen_point, gfx::Size()), |
194 views::MenuRunner::CONTEXT_MENU) == | 193 views::MENU_ANCHOR_TOPRIGHT, |
195 views::MenuRunner::MENU_DELETED) | 194 ui::MENU_SOURCE_NONE, |
196 return; | 195 views::MenuRunner::CONTEXT_MENU) == |
| 196 views::MenuRunner::MENU_DELETED) { |
| 197 return; |
| 198 } |
197 } | 199 } |
198 | 200 |
199 void OnWebContentsFocused(content::WebContents* web_contents) { | 201 void OnWebContentsFocused(content::WebContents* web_contents) { |
200 if (web_view_->GetWebContents() == web_contents) | 202 if (web_view_->GetWebContents() == web_contents) |
201 web_view_->OnWebContentsFocused(web_contents); | 203 web_view_->OnWebContentsFocused(web_contents); |
202 } | 204 } |
203 | 205 |
204 private: | 206 private: |
205 // Initialize the UI control contained in shell window | 207 // Initialize the UI control contained in shell window |
206 void InitShellWindow() { | 208 void InitShellWindow() { |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 | 563 |
562 void Shell::PlatformWebContentsFocused(WebContents* contents) { | 564 void Shell::PlatformWebContentsFocused(WebContents* contents) { |
563 if (headless_) | 565 if (headless_) |
564 return; | 566 return; |
565 ShellWindowDelegateView* delegate_view = | 567 ShellWindowDelegateView* delegate_view = |
566 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); | 568 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); |
567 delegate_view->OnWebContentsFocused(contents); | 569 delegate_view->OnWebContentsFocused(contents); |
568 } | 570 } |
569 | 571 |
570 } // namespace content | 572 } // namespace content |
OLD | NEW |