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 <windows.h> | 5 #include <windows.h> |
6 | 6 |
7 #include "chrome/browser/platform_util.h" | 7 #include "chrome/browser/platform_util.h" |
8 #include "chrome/browser/ui/browser_dialogs.h" | 8 #include "chrome/browser/ui/browser_dialogs.h" |
9 #include "chrome/browser/ui/host_desktop.h" | 9 #include "chrome/browser/ui/host_desktop.h" |
10 #include "chrome/browser/ui/views/color_chooser_aura.h" | 10 #include "chrome/browser/ui/views/color_chooser_aura.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 : web_contents_(web_contents) { | 59 : web_contents_(web_contents) { |
60 gfx::NativeWindow owning_window = platform_util::GetTopLevel( | 60 gfx::NativeWindow owning_window = platform_util::GetTopLevel( |
61 web_contents->GetRenderViewHost()->GetView()->GetNativeView()); | 61 web_contents->GetRenderViewHost()->GetView()->GetNativeView()); |
62 color_chooser_dialog_ = new ColorChooserDialog(this, | 62 color_chooser_dialog_ = new ColorChooserDialog(this, |
63 initial_color, | 63 initial_color, |
64 owning_window); | 64 owning_window); |
65 } | 65 } |
66 | 66 |
67 ColorChooserWin::~ColorChooserWin() { | 67 ColorChooserWin::~ColorChooserWin() { |
68 // Always call End() before destroying. | 68 // Always call End() before destroying. |
69 DCHECK(!color_chooser_dialog_); | 69 DCHECK(!color_chooser_dialog_.get()); |
70 } | 70 } |
71 | 71 |
72 void ColorChooserWin::End() { | 72 void ColorChooserWin::End() { |
73 // The ColorChooserDialog's listener is going away. Ideally we'd | 73 // The ColorChooserDialog's listener is going away. Ideally we'd |
74 // programmatically close the dialog at this point. Since that's impossible, | 74 // programmatically close the dialog at this point. Since that's impossible, |
75 // we instead tell the dialog its listener is going away, so that the dialog | 75 // we instead tell the dialog its listener is going away, so that the dialog |
76 // doesn't try to communicate with a destroyed listener later. (We also tell | 76 // doesn't try to communicate with a destroyed listener later. (We also tell |
77 // the renderer the dialog is closed, since from the renderer's perspective | 77 // the renderer the dialog is closed, since from the renderer's perspective |
78 // it effectively is.) | 78 // it effectively is.) |
79 OnColorChooserDialogClosed(); | 79 OnColorChooserDialogClosed(); |
(...skipping 20 matching lines...) Expand all Loading... |
100 content::ColorChooser* ShowColorChooser(content::WebContents* web_contents, | 100 content::ColorChooser* ShowColorChooser(content::WebContents* web_contents, |
101 SkColor initial_color) { | 101 SkColor initial_color) { |
102 gfx::NativeView native_view = web_contents->GetNativeView(); | 102 gfx::NativeView native_view = web_contents->GetNativeView(); |
103 if (GetHostDesktopTypeForNativeView(native_view) == HOST_DESKTOP_TYPE_ASH) | 103 if (GetHostDesktopTypeForNativeView(native_view) == HOST_DESKTOP_TYPE_ASH) |
104 return ColorChooserAura::Open(web_contents, initial_color); | 104 return ColorChooserAura::Open(web_contents, initial_color); |
105 | 105 |
106 return ColorChooserWin::Open(web_contents, initial_color); | 106 return ColorChooserWin::Open(web_contents, initial_color); |
107 } | 107 } |
108 | 108 |
109 } // namespace chrome | 109 } // namespace chrome |
OLD | NEW |