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

Side by Side Diff: content/shell/shell_aura.cc

Issue 10913237: Allow the Views Delegate to provide the native widget. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « content/content_shell.gypi ('k') | ui/views/examples/examples_window_with_content.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/shell/shell.h" 5 #include "content/shell/shell.h"
6 6
7 #include "base/command_line.h"
7 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
8 #include "ui/aura/desktop/desktop_screen.h" 9 #include "ui/aura/desktop/desktop_screen.h"
9 #include "ui/aura/desktop/desktop_stacking_client.h" 10 #include "ui/aura/desktop/desktop_stacking_client.h"
10 #include "ui/aura/display_manager.h" 11 #include "ui/aura/display_manager.h"
11 #include "ui/aura/env.h" 12 #include "ui/aura/env.h"
12 #include "ui/aura/root_window.h" 13 #include "ui/aura/root_window.h"
13 #include "ui/aura/single_display_manager.h" 14 #include "ui/aura/single_display_manager.h"
14 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
15 #include "ui/base/accessibility/accessibility_types.h" 16 #include "ui/base/accessibility/accessibility_types.h"
16 #include "ui/base/clipboard/clipboard.h" 17 #include "ui/base/clipboard/clipboard.h"
17 #include "ui/base/events/event.h" 18 #include "ui/base/events/event.h"
18 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/screen.h" 20 #include "ui/gfx/screen.h"
20 #include "ui/views/controls/button/text_button.h" 21 #include "ui/views/controls/button/text_button.h"
21 #include "ui/views/controls/textfield/textfield.h" 22 #include "ui/views/controls/textfield/textfield.h"
22 #include "ui/views/controls/textfield/textfield_controller.h" 23 #include "ui/views/controls/textfield/textfield_controller.h"
23 #include "ui/views/controls/webview/webview.h" 24 #include "ui/views/controls/webview/webview.h"
24 #include "ui/views/layout/fill_layout.h" 25 #include "ui/views/layout/fill_layout.h"
25 #include "ui/views/layout/grid_layout.h" 26 #include "ui/views/layout/grid_layout.h"
26 #include "ui/views/view.h" 27 #include "ui/views/view.h"
27 #include "ui/views/views_delegate.h" 28 #include "ui/views/test/test_views_delegate.h"
29 #include "ui/views/views_switches.h"
30 #include "ui/views/widget/desktop_native_widget_aura.h"
28 #include "ui/views/widget/desktop_native_widget_helper_aura.h" 31 #include "ui/views/widget/desktop_native_widget_helper_aura.h"
29 #include "ui/views/widget/widget.h" 32 #include "ui/views/widget/widget.h"
30 #include "ui/views/widget/widget_delegate.h" 33 #include "ui/views/widget/widget_delegate.h"
31 34
32 #if defined(OS_CHROMEOS) 35 #if defined(OS_CHROMEOS)
33 #include "chromeos/dbus/dbus_thread_manager.h" 36 #include "chromeos/dbus/dbus_thread_manager.h"
34 #endif 37 #endif
35 38
36 namespace views {
37 // ViewDelegate implementation for aura content shell 39 // ViewDelegate implementation for aura content shell
38 class ShellViewsDelegateAura : public ViewsDelegate { 40 class ShellViewsDelegateAura : public views::TestViewsDelegate {
39 public: 41 public:
40 ShellViewsDelegateAura() 42 ShellViewsDelegateAura() : use_transparent_windows_(false) {
41 : use_transparent_windows_(false) {
42 DCHECK(!ViewsDelegate::views_delegate);
43 ViewsDelegate::views_delegate = this;
44 } 43 }
45 44
46 virtual ~ShellViewsDelegateAura() { 45 virtual ~ShellViewsDelegateAura() {
47 ViewsDelegate::views_delegate = NULL; 46 ViewsDelegate::views_delegate = NULL;
48 } 47 }
49 48
50 void SetUseTransparentWindows(bool transparent) { 49 void SetUseTransparentWindows(bool transparent) {
51 use_transparent_windows_ = transparent; 50 use_transparent_windows_ = transparent;
52 } 51 }
53 52
54 // Overridden from ViewsDelegate: 53 // Overridden from views::TestViewsDelegate:
55 virtual void SaveWindowPlacement(const Widget* window,
56 const std::string& window_name,
57 const gfx::Rect& bounds,
58 ui::WindowShowState show_state) OVERRIDE {
59 }
60
61 virtual bool GetSavedWindowPlacement(
62 const std::string& window_name,
63 gfx::Rect* bounds,
64 ui::WindowShowState* show_state) const OVERRIDE {
65 return false;
66 }
67
68 virtual void NotifyAccessibilityEvent(
69 View* view, ui::AccessibilityTypes::Event event_type) OVERRIDE {}
70
71 virtual void NotifyMenuItemFocused(const string16& menu_name,
72 const string16& menu_item_name,
73 int item_index,
74 int item_count,
75 bool has_submenu) OVERRIDE {}
76 #if defined(OS_WIN)
77 virtual HICON GetDefaultWindowIcon() const OVERRIDE {
78 return NULL;
79 }
80 #endif
81 virtual NonClientFrameView* CreateDefaultNonClientFrameView(
82 Widget* widget) OVERRIDE {
83 return NULL;
84 }
85 virtual bool UseTransparentWindows() const OVERRIDE { 54 virtual bool UseTransparentWindows() const OVERRIDE {
86 return use_transparent_windows_; 55 return use_transparent_windows_;
87 } 56 }
88 virtual void AddRef() OVERRIDE {}
89 virtual void ReleaseRef() OVERRIDE {}
90
91 virtual int GetDispositionForEvent(int event_flags) OVERRIDE {
92 return 0;
93 }
94
95 virtual views::NativeWidgetHelperAura* CreateNativeWidgetHelper( 57 virtual views::NativeWidgetHelperAura* CreateNativeWidgetHelper(
96 views::NativeWidgetAura* native_widget) OVERRIDE { 58 views::NativeWidgetAura* native_widget) OVERRIDE {
97 return new views::DesktopNativeWidgetHelperAura(native_widget); 59 return new views::DesktopNativeWidgetHelperAura(native_widget);
98 } 60 }
99 61
100 virtual content::WebContents* CreateWebContents(
101 content::BrowserContext* browser_context,
102 content::SiteInstance* site_instance) OVERRIDE {
103 return NULL;
104 }
105
106 private: 62 private:
107 bool use_transparent_windows_; 63 bool use_transparent_windows_;
108 64
109 DISALLOW_COPY_AND_ASSIGN(ShellViewsDelegateAura); 65 DISALLOW_COPY_AND_ASSIGN(ShellViewsDelegateAura);
110 }; 66 };
111 67
68 // TODO(beng): This stuff should NOT be in the views namespace!
69 namespace views {
70
112 // Maintain the UI controls and web view for content shell 71 // Maintain the UI controls and web view for content shell
113 class ShellWindowDelegateView : public WidgetDelegateView, 72 class ShellWindowDelegateView : public WidgetDelegateView,
114 public TextfieldController, 73 public TextfieldController,
115 public ButtonListener { 74 public ButtonListener {
116 public: 75 public:
117 enum UIControl { 76 enum UIControl {
118 BACK_BUTTON, 77 BACK_BUTTON,
119 FORWARD_BUTTON, 78 FORWARD_BUTTON,
120 STOP_BUTTON 79 STOP_BUTTON
121 }; 80 };
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 265
307 // Contents view contains the web contents view 266 // Contents view contains the web contents view
308 View* contents_view_; 267 View* contents_view_;
309 WebView* web_view_; 268 WebView* web_view_;
310 269
311 DISALLOW_COPY_AND_ASSIGN(ShellWindowDelegateView); 270 DISALLOW_COPY_AND_ASSIGN(ShellWindowDelegateView);
312 }; 271 };
313 272
314 } // namespace views 273 } // namespace views
315 274
275 using views::ShellWindowDelegateView;
276
316 namespace content { 277 namespace content {
317 278
318 using views::ShellWindowDelegateView;
319 using views::ShellViewsDelegateAura;
320
321 aura::client::StackingClient* Shell::stacking_client_ = NULL; 279 aura::client::StackingClient* Shell::stacking_client_ = NULL;
322 views::ViewsDelegate* Shell::views_delegate_ = NULL; 280 views::ViewsDelegate* Shell::views_delegate_ = NULL;
323 281
324 // static 282 // static
325 void Shell::PlatformInitialize() { 283 void Shell::PlatformInitialize() {
326 #if defined(OS_CHROMEOS) 284 #if defined(OS_CHROMEOS)
327 chromeos::DBusThreadManager::Initialize(); 285 chromeos::DBusThreadManager::Initialize();
328 #endif 286 #endif
329 aura::Env::GetInstance()->SetDisplayManager(new aura::SingleDisplayManager); 287 aura::Env::GetInstance()->SetDisplayManager(new aura::SingleDisplayManager);
330 stacking_client_ = new aura::DesktopStackingClient(); 288 stacking_client_ = new aura::DesktopStackingClient();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 } 350 }
393 351
394 void Shell::PlatformSetTitle(const string16& title) { 352 void Shell::PlatformSetTitle(const string16& title) {
395 ShellWindowDelegateView* delegate_view = 353 ShellWindowDelegateView* delegate_view =
396 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); 354 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate());
397 delegate_view->SetWindowTitle(title); 355 delegate_view->SetWindowTitle(title);
398 window_widget_->UpdateWindowTitle(); 356 window_widget_->UpdateWindowTitle();
399 } 357 }
400 358
401 } // namespace content 359 } // namespace content
OLDNEW
« no previous file with comments | « content/content_shell.gypi ('k') | ui/views/examples/examples_window_with_content.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698