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

Side by Side Diff: chrome/renderer/render_view.cc

Issue 545123: --issue=523108 (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: version to commit Created 10 years, 11 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/renderer/render_view.h" 5 #include "chrome/renderer/render_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #include "chrome/renderer/webplugin_delegate_proxy.h" 60 #include "chrome/renderer/webplugin_delegate_proxy.h"
61 #include "chrome/renderer/websharedworker_proxy.h" 61 #include "chrome/renderer/websharedworker_proxy.h"
62 #include "chrome/renderer/webworker_proxy.h" 62 #include "chrome/renderer/webworker_proxy.h"
63 #include "grit/generated_resources.h" 63 #include "grit/generated_resources.h"
64 #include "grit/renderer_resources.h" 64 #include "grit/renderer_resources.h"
65 #include "net/base/data_url.h" 65 #include "net/base/data_url.h"
66 #include "net/base/escape.h" 66 #include "net/base/escape.h"
67 #include "net/base/net_errors.h" 67 #include "net/base/net_errors.h"
68 #include "skia/ext/bitmap_platform_device.h" 68 #include "skia/ext/bitmap_platform_device.h"
69 #include "skia/ext/image_operations.h" 69 #include "skia/ext/image_operations.h"
70 #if defined(OS_WIN)
71 // TODO(port): The compact language detection library works only for Windows.
72 #include "third_party/cld/bar/toolbar/cld/i18n/encodings/compact_lang_det/win/cl d_unicodetext.h" 70 #include "third_party/cld/bar/toolbar/cld/i18n/encodings/compact_lang_det/win/cl d_unicodetext.h"
73 #endif
74 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityCache.h" 71 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityCache.h"
75 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityObject.h" 72 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityObject.h"
76 #include "third_party/WebKit/WebKit/chromium/public/WebCString.h" 73 #include "third_party/WebKit/WebKit/chromium/public/WebCString.h"
77 #include "third_party/WebKit/WebKit/chromium/public/WebDataSource.h" 74 #include "third_party/WebKit/WebKit/chromium/public/WebDataSource.h"
78 #include "third_party/WebKit/WebKit/chromium/public/WebDevToolsAgent.h" 75 #include "third_party/WebKit/WebKit/chromium/public/WebDevToolsAgent.h"
79 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" 76 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h"
80 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" 77 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h"
81 #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h" 78 #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h"
82 #include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h" 79 #include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h"
83 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" 80 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 213
217 // The maximum number of popups that can be spawned from one page. 214 // The maximum number of popups that can be spawned from one page.
218 static const int kMaximumNumberOfUnacknowledgedPopups = 25; 215 static const int kMaximumNumberOfUnacknowledgedPopups = 25;
219 216
220 static const char* const kUnreachableWebDataURL = 217 static const char* const kUnreachableWebDataURL =
221 "chrome://chromewebdata/"; 218 "chrome://chromewebdata/";
222 219
223 static const char* const kBackForwardNavigationScheme = "history"; 220 static const char* const kBackForwardNavigationScheme = "history";
224 221
225 // The string returned in DetectLanguage if we failed to detect the language. 222 // The string returned in DetectLanguage if we failed to detect the language.
226 static const char* const kUnknownLanguageCode = "unknown"; 223 static const char* const kUnknownLanguageCode = "und";
227 224
228 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { 225 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) {
229 WebVector<WebURL> urls; 226 WebVector<WebURL> urls;
230 ds->redirectChain(urls); 227 ds->redirectChain(urls);
231 result->reserve(urls.size()); 228 result->reserve(urls.size());
232 for (size_t i = 0; i < urls.size(); ++i) 229 for (size_t i = 0; i < urls.size(); ++i)
233 result->push_back(urls[i]); 230 result->push_back(urls[i]);
234 } 231 }
235 232
236 static bool UrlMatchesPermissions( 233 static bool UrlMatchesPermissions(
(...skipping 2838 matching lines...) Expand 10 before | Expand all | Expand 10 after
3075 return; 3072 return;
3076 } 3073 }
3077 3074
3078 Send(new ViewHostMsg_PageLanguageDetermined(routing_id_, DetectLanguage())); 3075 Send(new ViewHostMsg_PageLanguageDetermined(routing_id_, DetectLanguage()));
3079 } 3076 }
3080 3077
3081 std::string RenderView::DetectLanguage() { 3078 std::string RenderView::DetectLanguage() {
3082 if (!webview() || is_loading_) 3079 if (!webview() || is_loading_)
3083 return kUnknownLanguageCode; 3080 return kUnknownLanguageCode;
3084 3081
3085 std::string language = kUnknownLanguageCode;
3086 #if defined(OS_WIN) // CLD is only available on Windows at this time.
3087 WebFrame* main_frame = webview()->mainFrame(); 3082 WebFrame* main_frame = webview()->mainFrame();
3088 std::wstring contents; 3083 std::wstring contents;
3089 CaptureText(main_frame, &contents); 3084 CaptureText(main_frame, &contents);
3090 language = DetermineTextLanguage(contents); 3085 return DetermineTextLanguage(contents);
3091 #endif
3092
3093 return language;
3094 } 3086 }
3095 3087
3096 // static 3088 // static
3097 std::string RenderView::DetermineTextLanguage(const std::wstring& text) { 3089 std::string RenderView::DetermineTextLanguage(const std::wstring& text) {
3098 std::string language = kUnknownLanguageCode; 3090 std::string language = kUnknownLanguageCode;
3099 #if defined(OS_WIN) // CLD is only available on Windows at this time.
3100 int num_languages = 0; 3091 int num_languages = 0;
3101 bool is_reliable = false; 3092 bool is_reliable = false;
3093 string16 input = WideToUTF16(text);
3102 Language cld_language = 3094 Language cld_language =
3103 DetectLanguageOfUnicodeText(NULL, text.c_str(), true, &is_reliable, 3095 DetectLanguageOfUnicodeText(NULL, input.c_str(), true, &is_reliable,
3104 &num_languages, NULL); 3096 &num_languages, NULL);
3105 if (cld_language != NUM_LANGUAGES && cld_language != UNKNOWN_LANGUAGE && 3097 if (cld_language != NUM_LANGUAGES && cld_language != UNKNOWN_LANGUAGE &&
3106 cld_language != TG_UNKNOWN_LANGUAGE) { 3098 cld_language != TG_UNKNOWN_LANGUAGE) {
3107 language = LanguageCodeISO639_1(cld_language); 3099 // We should not use LanguageCode_ISO_639_1 because it does not cover all th e
3100 // languages CLD can detect. As a result, it'll return the invalid language
3101 // code for tradtional Chinese among others. |LanguageCode| will go through
3102 // ISO 639-1, ISO-639-2 and 'other' tables to do the 'right' thing.
3103 language = LanguageCode(cld_language);
3108 } 3104 }
3109 #endif
3110 return language; 3105 return language;
3111 } 3106 }
3112 3107
3113 void RenderView::DnsPrefetch(const std::vector<std::string>& host_names) { 3108 void RenderView::DnsPrefetch(const std::vector<std::string>& host_names) {
3114 Send(new ViewHostMsg_DnsPrefetch(host_names)); 3109 Send(new ViewHostMsg_DnsPrefetch(host_names));
3115 } 3110 }
3116 3111
3117 void RenderView::OnZoom(PageZoom::Function function) { 3112 void RenderView::OnZoom(PageZoom::Function function) {
3118 if (!webview()) // Not sure if this can happen, but no harm in being safe. 3113 if (!webview()) // Not sure if this can happen, but no harm in being safe.
3119 return; 3114 return;
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
4049 new PluginMsg_SignalModalDialogEvent(host_window_)); 4044 new PluginMsg_SignalModalDialogEvent(host_window_));
4050 4045
4051 message->EnableMessagePumping(); // Runs a nested message loop. 4046 message->EnableMessagePumping(); // Runs a nested message loop.
4052 bool rv = Send(message); 4047 bool rv = Send(message);
4053 4048
4054 PluginChannelHost::Broadcast( 4049 PluginChannelHost::Broadcast(
4055 new PluginMsg_ResetModalDialogEvent(host_window_)); 4050 new PluginMsg_ResetModalDialogEvent(host_window_));
4056 4051
4057 return rv; 4052 return rv;
4058 } 4053 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698