| 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 16 matching lines...) Expand all Loading... |
| 27 #include "web/ColorChooserPopupUIController.h" | 27 #include "web/ColorChooserPopupUIController.h" |
| 28 | 28 |
| 29 #include "core/frame/FrameView.h" | 29 #include "core/frame/FrameView.h" |
| 30 #include "platform/ColorChooserClient.h" | 30 #include "platform/ColorChooserClient.h" |
| 31 #include "platform/geometry/IntRect.h" | 31 #include "platform/geometry/IntRect.h" |
| 32 #include "public/platform/Platform.h" | 32 #include "public/platform/Platform.h" |
| 33 #include "public/web/WebColorChooser.h" | 33 #include "public/web/WebColorChooser.h" |
| 34 #include "web/ChromeClientImpl.h" | 34 #include "web/ChromeClientImpl.h" |
| 35 #include "web/WebViewImpl.h" | 35 #include "web/WebViewImpl.h" |
| 36 | 36 |
| 37 using namespace blink; | |
| 38 | |
| 39 namespace blink { | 37 namespace blink { |
| 40 | 38 |
| 41 // Keep in sync with Actions in colorSuggestionPicker.js. | 39 // Keep in sync with Actions in colorSuggestionPicker.js. |
| 42 enum ColorPickerPopupAction { | 40 enum ColorPickerPopupAction { |
| 43 ColorPickerPopupActionChooseOtherColor = -2, | 41 ColorPickerPopupActionChooseOtherColor = -2, |
| 44 ColorPickerPopupActionCancel = -1, | 42 ColorPickerPopupActionCancel = -1, |
| 45 ColorPickerPopupActionSetValue = 0 | 43 ColorPickerPopupActionSetValue = 0 |
| 46 }; | 44 }; |
| 47 | 45 |
| 48 ColorChooserPopupUIController::ColorChooserPopupUIController(blink::LocalFrame*
frame, ChromeClientImpl* chromeClient, ColorChooserClient* client) | 46 ColorChooserPopupUIController::ColorChooserPopupUIController(LocalFrame* frame,
ChromeClientImpl* chromeClient, ColorChooserClient* client) |
| 49 : ColorChooserUIController(frame, client) | 47 : ColorChooserUIController(frame, client) |
| 50 , m_chromeClient(chromeClient) | 48 , m_chromeClient(chromeClient) |
| 51 , m_client(client) | 49 , m_client(client) |
| 52 , m_popup(0) | 50 , m_popup(0) |
| 53 , m_locale(Locale::defaultLocale()) | 51 , m_locale(Locale::defaultLocale()) |
| 54 { | 52 { |
| 55 } | 53 } |
| 56 | 54 |
| 57 ColorChooserPopupUIController::~ColorChooserPopupUIController() | 55 ColorChooserPopupUIController::~ColorChooserPopupUIController() |
| 58 { | 56 { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 81 | 79 |
| 82 void ColorChooserPopupUIController::writeDocument(SharedBuffer* data) | 80 void ColorChooserPopupUIController::writeDocument(SharedBuffer* data) |
| 83 { | 81 { |
| 84 Vector<ColorSuggestion> suggestions = m_client->suggestions(); | 82 Vector<ColorSuggestion> suggestions = m_client->suggestions(); |
| 85 Vector<String> suggestionValues; | 83 Vector<String> suggestionValues; |
| 86 for (unsigned i = 0; i < suggestions.size(); i++) | 84 for (unsigned i = 0; i < suggestions.size(); i++) |
| 87 suggestionValues.append(suggestions[i].color.serialized()); | 85 suggestionValues.append(suggestions[i].color.serialized()); |
| 88 IntRect anchorRectInScreen = m_chromeClient->rootViewToScreen(m_client->elem
entRectRelativeToRootView()); | 86 IntRect anchorRectInScreen = m_chromeClient->rootViewToScreen(m_client->elem
entRectRelativeToRootView()); |
| 89 | 87 |
| 90 PagePopupClient::addString("<!DOCTYPE html><head><meta charset='UTF-8'><styl
e>\n", data); | 88 PagePopupClient::addString("<!DOCTYPE html><head><meta charset='UTF-8'><styl
e>\n", data); |
| 91 data->append(blink::Platform::current()->loadResource("pickerCommon.css")); | 89 data->append(Platform::current()->loadResource("pickerCommon.css")); |
| 92 data->append(blink::Platform::current()->loadResource("colorSuggestionPicker
.css")); | 90 data->append(Platform::current()->loadResource("colorSuggestionPicker.css"))
; |
| 93 PagePopupClient::addString("</style></head><body><div id=main>Loading...</di
v><script>\n" | 91 PagePopupClient::addString("</style></head><body><div id=main>Loading...</di
v><script>\n" |
| 94 "window.dialogArguments = {\n", data); | 92 "window.dialogArguments = {\n", data); |
| 95 PagePopupClient::addProperty("values", suggestionValues, data); | 93 PagePopupClient::addProperty("values", suggestionValues, data); |
| 96 PagePopupClient::addProperty("otherColorLabel", locale().queryString(WebLoca
lizedString::OtherColorLabel), data); | 94 PagePopupClient::addProperty("otherColorLabel", locale().queryString(WebLoca
lizedString::OtherColorLabel), data); |
| 97 addProperty("anchorRectInScreen", anchorRectInScreen, data); | 95 addProperty("anchorRectInScreen", anchorRectInScreen, data); |
| 98 PagePopupClient::addString("};\n", data); | 96 PagePopupClient::addString("};\n", data); |
| 99 data->append(blink::Platform::current()->loadResource("pickerCommon.js")); | 97 data->append(Platform::current()->loadResource("pickerCommon.js")); |
| 100 data->append(blink::Platform::current()->loadResource("colorSuggestionPicker
.js")); | 98 data->append(Platform::current()->loadResource("colorSuggestionPicker.js")); |
| 101 PagePopupClient::addString("</script></body>\n", data); | 99 PagePopupClient::addString("</script></body>\n", data); |
| 102 } | 100 } |
| 103 | 101 |
| 104 Locale& ColorChooserPopupUIController::locale() | 102 Locale& ColorChooserPopupUIController::locale() |
| 105 { | 103 { |
| 106 return m_locale; | 104 return m_locale; |
| 107 } | 105 } |
| 108 | 106 |
| 109 void ColorChooserPopupUIController::setValueAndClosePopup(int numValue, const St
ring& stringValue) | 107 void ColorChooserPopupUIController::setValueAndClosePopup(int numValue, const St
ring& stringValue) |
| 110 { | 108 { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 141 m_popup = m_chromeClient->openPagePopup(this, m_client->elementRectRelativeT
oRootView()); | 139 m_popup = m_chromeClient->openPagePopup(this, m_client->elementRectRelativeT
oRootView()); |
| 142 } | 140 } |
| 143 | 141 |
| 144 void ColorChooserPopupUIController::closePopup() | 142 void ColorChooserPopupUIController::closePopup() |
| 145 { | 143 { |
| 146 if (!m_popup) | 144 if (!m_popup) |
| 147 return; | 145 return; |
| 148 m_chromeClient->closePagePopup(m_popup); | 146 m_chromeClient->closePagePopup(m_popup); |
| 149 } | 147 } |
| 150 | 148 |
| 151 } | 149 } // namespace blink |
| OLD | NEW |