| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "ChromiumBridge.h" | 6 #include "ChromiumBridge.h" |
| 7 | 7 |
| 8 #include "BitmapImage.h" | 8 #include "BitmapImage.h" |
| 9 #include "Cursor.h" | 9 #include "Cursor.h" |
| 10 #include "Frame.h" | 10 #include "Frame.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #include "webkit/glue/webplugin_impl.h" | 40 #include "webkit/glue/webplugin_impl.h" |
| 41 #include "webkit/glue/webview_impl.h" | 41 #include "webkit/glue/webview_impl.h" |
| 42 | 42 |
| 43 #if defined(OS_WIN) | 43 #if defined(OS_WIN) |
| 44 #include <windows.h> | 44 #include <windows.h> |
| 45 #include <vssym32.h> | 45 #include <vssym32.h> |
| 46 #include "base/gfx/native_theme.h" | 46 #include "base/gfx/native_theme.h" |
| 47 #endif | 47 #endif |
| 48 | 48 |
| 49 using WebKit::WebCursorInfo; | 49 using WebKit::WebCursorInfo; |
| 50 using WebKit::WebWidgetClient; |
| 50 | 51 |
| 51 namespace { | 52 namespace { |
| 52 | 53 |
| 53 gfx::NativeViewId ToNativeId(WebCore::Widget* widget) { | 54 gfx::NativeViewId ToNativeId(WebCore::Widget* widget) { |
| 54 if (!widget) | 55 if (!widget) |
| 55 return 0; | 56 return 0; |
| 56 return widget->root()->hostWindow()->platformWindow(); | 57 return widget->root()->hostWindow()->platformWindow(); |
| 57 } | 58 } |
| 58 | 59 |
| 59 ChromeClientImpl* ToChromeClient(WebCore::Widget* widget) { | 60 ChromeClientImpl* ToChromeClient(WebCore::Widget* widget) { |
| 60 WebCore::FrameView* view; | 61 WebCore::FrameView* view; |
| 61 if (widget->isFrameView()) { | 62 if (widget->isFrameView()) { |
| 62 view = static_cast<WebCore::FrameView*>(widget); | 63 view = static_cast<WebCore::FrameView*>(widget); |
| 63 } else if (widget->parent() && widget->parent()->isFrameView()) { | 64 } else if (widget->parent() && widget->parent()->isFrameView()) { |
| 64 view = static_cast<WebCore::FrameView*>(widget->parent()); | 65 view = static_cast<WebCore::FrameView*>(widget->parent()); |
| 65 } else { | 66 } else { |
| 66 return NULL; | 67 return NULL; |
| 67 } | 68 } |
| 68 | 69 |
| 69 WebCore::Page* page = view->frame() ? view->frame()->page() : NULL; | 70 WebCore::Page* page = view->frame() ? view->frame()->page() : NULL; |
| 70 if (!page) | 71 if (!page) |
| 71 return NULL; | 72 return NULL; |
| 72 | 73 |
| 73 return static_cast<ChromeClientImpl*>(page->chrome()->client()); | 74 return static_cast<ChromeClientImpl*>(page->chrome()->client()); |
| 74 } | 75 } |
| 75 | 76 |
| 76 WebViewImpl* ToWebView(WebCore::Widget* widget) { | 77 WebWidgetClient* ToWebWidgetClient(WebCore::Widget* widget) { |
| 77 ChromeClientImpl* chrome_client = ToChromeClient(widget); | 78 ChromeClientImpl* chrome_client = ToChromeClient(widget); |
| 78 if (!chrome_client) | 79 if (!chrome_client || !chrome_client->webview()) |
| 79 return NULL; | 80 return NULL; |
| 80 return chrome_client->webview(); | 81 return chrome_client->webview()->delegate(); |
| 81 } | 82 } |
| 82 | 83 |
| 83 WebCore::IntRect ToIntRect(const WebKit::WebRect& input) { | 84 WebCore::IntRect ToIntRect(const WebKit::WebRect& input) { |
| 84 return WebCore::IntRect(input.x, input.y, input.width, input.height); | 85 return WebCore::IntRect(input.x, input.y, input.width, input.height); |
| 85 } | 86 } |
| 86 | 87 |
| 87 } // namespace | 88 } // namespace |
| 88 | 89 |
| 89 namespace WebCore { | 90 namespace WebCore { |
| 90 | 91 |
| 91 // JavaScript ----------------------------------------------------------------- | 92 // JavaScript ----------------------------------------------------------------- |
| 92 | 93 |
| 93 void ChromiumBridge::notifyJSOutOfMemory(Frame* frame) { | 94 void ChromiumBridge::notifyJSOutOfMemory(Frame* frame) { |
| 94 if (!frame) | 95 if (!frame) |
| 95 return; | 96 return; |
| 96 | 97 |
| 97 // Dispatch to the delegate of the view that owns the frame. | 98 // Dispatch to the delegate of the view that owns the frame. |
| 98 WebFrame* webframe = WebFrameImpl::FromFrame(frame); | 99 WebViewImpl* webview = WebFrameImpl::FromFrame(frame)->GetWebViewImpl(); |
| 99 WebView* webview = webframe->GetView(); | 100 if (!webview || !webview->delegate()) |
| 100 if (!webview) | |
| 101 return; | 101 return; |
| 102 WebViewDelegate* delegate = webview->GetDelegate(); | 102 webview->delegate()->JSOutOfMemory(); |
| 103 if (!delegate) | |
| 104 return; | |
| 105 delegate->JSOutOfMemory(); | |
| 106 } | 103 } |
| 107 | 104 |
| 108 // Plugin --------------------------------------------------------------------- | 105 // Plugin --------------------------------------------------------------------- |
| 109 | 106 |
| 110 NPObject* ChromiumBridge::pluginScriptableObject(Widget* widget) { | 107 NPObject* ChromiumBridge::pluginScriptableObject(Widget* widget) { |
| 111 if (!widget) | 108 if (!widget) |
| 112 return NULL; | 109 return NULL; |
| 113 | 110 |
| 114 // NOTE: We have to trust that the widget passed to us here is a | 111 // NOTE: We have to trust that the widget passed to us here is a |
| 115 // WebPluginImpl. There isn't a way to dynamically verify it, since the | 112 // WebPluginImpl. There isn't a way to dynamically verify it, since the |
| (...skipping 15 matching lines...) Expand all Loading... |
| 131 // Protocol ------------------------------------------------------------------- | 128 // Protocol ------------------------------------------------------------------- |
| 132 | 129 |
| 133 String ChromiumBridge::uiResourceProtocol() { | 130 String ChromiumBridge::uiResourceProtocol() { |
| 134 return webkit_glue::StdStringToString(webkit_glue::GetUIResourceProtocol()); | 131 return webkit_glue::StdStringToString(webkit_glue::GetUIResourceProtocol()); |
| 135 } | 132 } |
| 136 | 133 |
| 137 | 134 |
| 138 // Screen --------------------------------------------------------------------- | 135 // Screen --------------------------------------------------------------------- |
| 139 | 136 |
| 140 int ChromiumBridge::screenDepth(Widget* widget) { | 137 int ChromiumBridge::screenDepth(Widget* widget) { |
| 141 WebViewImpl* view = ToWebView(widget); | 138 WebWidgetClient* client = ToWebWidgetClient(widget); |
| 142 if (!view || !view->delegate()) | 139 if (!client) |
| 143 return NULL; | 140 return 0; |
| 144 return view->delegate()->GetScreenInfo(view).depth; | 141 return client->screenInfo().depth; |
| 145 } | 142 } |
| 146 | 143 |
| 147 int ChromiumBridge::screenDepthPerComponent(Widget* widget) { | 144 int ChromiumBridge::screenDepthPerComponent(Widget* widget) { |
| 148 WebViewImpl* view = ToWebView(widget); | 145 WebWidgetClient* client = ToWebWidgetClient(widget); |
| 149 if (!view || !view->delegate()) | 146 if (!client) |
| 150 return NULL; | 147 return 0; |
| 151 return view->delegate()->GetScreenInfo(view).depthPerComponent; | 148 return client->screenInfo().depthPerComponent; |
| 152 } | 149 } |
| 153 | 150 |
| 154 bool ChromiumBridge::screenIsMonochrome(Widget* widget) { | 151 bool ChromiumBridge::screenIsMonochrome(Widget* widget) { |
| 155 WebViewImpl* view = ToWebView(widget); | 152 WebWidgetClient* client = ToWebWidgetClient(widget); |
| 156 if (!view || !view->delegate()) | 153 if (!client) |
| 157 return NULL; | 154 return false; |
| 158 return view->delegate()->GetScreenInfo(view).isMonochrome; | 155 return client->screenInfo().isMonochrome; |
| 159 } | 156 } |
| 160 | 157 |
| 161 IntRect ChromiumBridge::screenRect(Widget* widget) { | 158 IntRect ChromiumBridge::screenRect(Widget* widget) { |
| 162 WebViewImpl* view = ToWebView(widget); | 159 WebWidgetClient* client = ToWebWidgetClient(widget); |
| 163 if (!view || !view->delegate()) | 160 if (!client) |
| 164 return IntRect(); | 161 return IntRect(); |
| 165 return ToIntRect(view->delegate()->GetScreenInfo(view).rect); | 162 return ToIntRect(client->screenInfo().rect); |
| 166 } | 163 } |
| 167 | 164 |
| 168 IntRect ChromiumBridge::screenAvailableRect(Widget* widget) { | 165 IntRect ChromiumBridge::screenAvailableRect(Widget* widget) { |
| 169 WebViewImpl* view = ToWebView(widget); | 166 WebWidgetClient* client = ToWebWidgetClient(widget); |
| 170 if (!view || !view->delegate()) | 167 if (!client) |
| 171 return IntRect(); | 168 return IntRect(); |
| 172 return ToIntRect(view->delegate()->GetScreenInfo(view).availableRect); | 169 return ToIntRect(client->screenInfo().availableRect); |
| 173 } | 170 } |
| 174 | 171 |
| 175 // Widget --------------------------------------------------------------------- | 172 // Widget --------------------------------------------------------------------- |
| 176 | 173 |
| 177 void ChromiumBridge::widgetSetCursor(Widget* widget, const Cursor& cursor) { | 174 void ChromiumBridge::widgetSetCursor(Widget* widget, const Cursor& cursor) { |
| 178 ChromeClientImpl* chrome_client = ToChromeClient(widget); | 175 ChromeClientImpl* chrome_client = ToChromeClient(widget); |
| 179 if (chrome_client) | 176 if (chrome_client) |
| 180 chrome_client->SetCursor(webkit_glue::CursorToWebCursorInfo(cursor)); | 177 chrome_client->SetCursor(webkit_glue::CursorToWebCursorInfo(cursor)); |
| 181 } | 178 } |
| 182 | 179 |
| 183 void ChromiumBridge::widgetSetFocus(Widget* widget) { | 180 void ChromiumBridge::widgetSetFocus(Widget* widget) { |
| 184 ChromeClientImpl* chrome_client = ToChromeClient(widget); | 181 ChromeClientImpl* chrome_client = ToChromeClient(widget); |
| 185 if (chrome_client) | 182 if (chrome_client) |
| 186 chrome_client->focus(); | 183 chrome_client->focus(); |
| 187 } | 184 } |
| 188 | 185 |
| 189 } // namespace WebCore | 186 } // namespace WebCore |
| OLD | NEW |