OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "public/platform/WebColor.h" | 31 #include "public/platform/WebColor.h" |
32 #include "public/web/WebColorChooser.h" | 32 #include "public/web/WebColorChooser.h" |
33 #include "public/web/WebColorSuggestion.h" | 33 #include "public/web/WebColorSuggestion.h" |
34 #include "public/web/WebFrameClient.h" | 34 #include "public/web/WebFrameClient.h" |
35 #include "web/WebLocalFrameImpl.h" | 35 #include "web/WebLocalFrameImpl.h" |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 | 39 |
40 ColorChooserUIController::ColorChooserUIController(LocalFrame* frame, ColorChoos
erClient* client) | 40 ColorChooserUIController::ColorChooserUIController(LocalFrame* frame, ColorChoos
erClient* client) |
41 : m_frame(frame) | 41 : m_client(client) |
42 , m_client(client) | 42 , m_frame(frame) |
43 { | 43 { |
44 } | 44 } |
45 | 45 |
46 ColorChooserUIController::~ColorChooserUIController() | 46 ColorChooserUIController::~ColorChooserUIController() |
47 { | 47 { |
| 48 // The client cannot be accessed when finalizing. |
| 49 m_client = nullptr; |
| 50 endChooser(); |
| 51 } |
| 52 |
| 53 void ColorChooserUIController::trace(Visitor* visitor) |
| 54 { |
| 55 visitor->trace(m_frame); |
| 56 visitor->trace(m_client); |
| 57 ColorChooser::trace(visitor); |
48 } | 58 } |
49 | 59 |
50 void ColorChooserUIController::openUI() | 60 void ColorChooserUIController::openUI() |
51 { | 61 { |
52 openColorChooser(); | 62 openColorChooser(); |
53 } | 63 } |
54 | 64 |
55 void ColorChooserUIController::setSelectedColor(const Color& color) | 65 void ColorChooserUIController::setSelectedColor(const Color& color) |
56 { | 66 { |
57 ASSERT(m_chooser); | 67 ASSERT(m_chooser); |
(...skipping 12 matching lines...) Expand all Loading... |
70 } | 80 } |
71 | 81 |
72 void ColorChooserUIController::didChooseColor(const WebColor& color) | 82 void ColorChooserUIController::didChooseColor(const WebColor& color) |
73 { | 83 { |
74 ASSERT(m_client); | 84 ASSERT(m_client); |
75 m_client->didChooseColor(Color(static_cast<RGBA32>(color))); | 85 m_client->didChooseColor(Color(static_cast<RGBA32>(color))); |
76 } | 86 } |
77 | 87 |
78 void ColorChooserUIController::didEndChooser() | 88 void ColorChooserUIController::didEndChooser() |
79 { | 89 { |
80 ASSERT(m_client); | |
81 m_chooser = nullptr; | 90 m_chooser = nullptr; |
82 m_client->didEndChooser(); | 91 if (m_client) |
| 92 m_client->didEndChooser(); |
83 } | 93 } |
84 | 94 |
85 void ColorChooserUIController::openColorChooser() | 95 void ColorChooserUIController::openColorChooser() |
86 { | 96 { |
87 ASSERT(!m_chooser); | 97 ASSERT(!m_chooser); |
88 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(m_frame); | 98 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(m_frame); |
89 WebFrameClient* webFrameClient = frame->client(); | 99 WebFrameClient* webFrameClient = frame->client(); |
90 if (!webFrameClient) | 100 if (!webFrameClient) |
91 return; | 101 return; |
92 m_chooser = adoptPtr(webFrameClient->createColorChooser( | 102 m_chooser = adoptPtr(webFrameClient->createColorChooser( |
93 this, static_cast<WebColor>(m_client->currentColor().rgb()), m_client->s
uggestions())); | 103 this, static_cast<WebColor>(m_client->currentColor().rgb()), m_client->s
uggestions())); |
94 } | 104 } |
95 | 105 |
96 } // namespace blink | 106 } // namespace blink |
OLD | NEW |