| OLD | NEW |
| 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_frame/chrome_frame_npapi.h" | 5 #include "chrome_frame/chrome_frame_npapi.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 if (chrome_extra_arguments_arg) | 239 if (chrome_extra_arguments_arg) |
| 240 extra_arguments = UTF8ToWide(chrome_extra_arguments_arg); | 240 extra_arguments = UTF8ToWide(chrome_extra_arguments_arg); |
| 241 | 241 |
| 242 if (chrome_profile_name_arg) | 242 if (chrome_profile_name_arg) |
| 243 profile_name = UTF8ToWide(chrome_profile_name_arg); | 243 profile_name = UTF8ToWide(chrome_profile_name_arg); |
| 244 | 244 |
| 245 if (chrome_network_arg_set) | 245 if (chrome_network_arg_set) |
| 246 automation_client_->set_use_chrome_network(chrome_network_arg); | 246 automation_client_->set_use_chrome_network(chrome_network_arg); |
| 247 } | 247 } |
| 248 | 248 |
| 249 static const wchar_t kHandleTopLevelRequests[] = L"HandleTopLevelRequests"; |
| 250 bool top_level_requests = GetConfigBool(true, kHandleTopLevelRequests); |
| 251 automation_client_->set_handle_top_level_requests(top_level_requests); |
| 252 automation_client_->set_route_all_top_level_navigations(true); |
| 253 |
| 249 // Setup Url fetcher. | 254 // Setup Url fetcher. |
| 250 url_fetcher_.set_NPPInstance(instance_); | 255 url_fetcher_.set_NPPInstance(instance_); |
| 251 url_fetcher_.set_frame_busting(!is_privileged_); | 256 url_fetcher_.set_frame_busting(!is_privileged_); |
| 252 automation_client_->SetUrlFetcher(&url_fetcher_); | 257 automation_client_->SetUrlFetcher(&url_fetcher_); |
| 253 | 258 |
| 254 // TODO(joshia): Initialize navigation here and send proxy config as | 259 // TODO(joshia): Initialize navigation here and send proxy config as |
| 255 // part of LaunchSettings | 260 // part of LaunchSettings |
| 256 /* | 261 /* |
| 257 if (!src_.empty()) | 262 if (!src_.empty()) |
| 258 automation_client_->InitiateNavigation(src_, is_privileged_); | 263 automation_client_->InitiateNavigation(src_, is_privileged_); |
| 259 | 264 |
| 260 std::string proxy_settings; | 265 std::string proxy_settings; |
| 261 bool has_prefs = pref_service_->Initialize(instance_, | 266 bool has_prefs = pref_service_->Initialize(instance_, |
| 262 automation_client_.get()); | 267 automation_client_.get()); |
| 263 if (has_prefs && pref_service_->GetProxyValueJSONString(&proxy_settings)) { | 268 if (has_prefs && pref_service_->GetProxyValueJSONString(&proxy_settings)) { |
| 264 automation_client_->SetProxySettings(proxy_settings); | 269 automation_client_->SetProxySettings(proxy_settings); |
| 265 } | 270 } |
| 266 */ | 271 */ |
| 267 | 272 |
| 268 // We can't call SubscribeToFocusEvents here since | 273 // We can't call SubscribeToFocusEvents here since |
| 269 // when Initialize gets called, Opera is in a state where | 274 // when Initialize gets called, Opera is in a state where |
| 270 // it can't handle calls back and the thread will hang. | 275 // it can't handle calls back and the thread will hang. |
| 271 // Instead, we call SubscribeToFocusEvents when we initialize | 276 // Instead, we call SubscribeToFocusEvents when we initialize |
| 272 // our plugin window. | 277 // our plugin window. |
| 273 | 278 |
| 274 // TODO(stoyan): Ask host for specific interface whether to honor | 279 // TODO(stoyan): Ask host for specific interface whether to honor |
| 275 // host's in-private mode. | 280 // host's in-private mode. |
| 276 return InitializeAutomation(profile_name, extra_arguments, | 281 return InitializeAutomation(profile_name, extra_arguments, |
| 277 GetBrowserIncognitoMode(), true, | 282 GetBrowserIncognitoMode(), true, |
| 278 GURL(src_), GURL()); | 283 GURL(src_), GURL(), true); |
| 279 } | 284 } |
| 280 | 285 |
| 281 void ChromeFrameNPAPI::Uninitialize() { | 286 void ChromeFrameNPAPI::Uninitialize() { |
| 282 // Don't call SetReadyState as it will end up calling FireEvent. | 287 // Don't call SetReadyState as it will end up calling FireEvent. |
| 283 // We are in the context of NPP_DESTROY. | 288 // We are in the context of NPP_DESTROY. |
| 284 ready_state_ = READYSTATE_UNINITIALIZED; | 289 ready_state_ = READYSTATE_UNINITIALIZED; |
| 285 | 290 |
| 286 UnsubscribeFromFocusEvents(); | 291 UnsubscribeFromFocusEvents(); |
| 287 | 292 |
| 288 if (pref_service_) { | 293 if (pref_service_) { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 input.type = INPUT_KEYBOARD; | 464 input.type = INPUT_KEYBOARD; |
| 460 input.ki.wVk = VK_TAB; | 465 input.ki.wVk = VK_TAB; |
| 461 SendInput(1, &input, sizeof(input)); | 466 SendInput(1, &input, sizeof(input)); |
| 462 input.ki.dwFlags = KEYEVENTF_KEYUP; | 467 input.ki.dwFlags = KEYEVENTF_KEYUP; |
| 463 SendInput(1, &input, sizeof(input)); | 468 SendInput(1, &input, sizeof(input)); |
| 464 | 469 |
| 465 ignore_setfocus_ = false; | 470 ignore_setfocus_ = false; |
| 466 } | 471 } |
| 467 | 472 |
| 468 void ChromeFrameNPAPI::OnOpenURL(int tab_handle, | 473 void ChromeFrameNPAPI::OnOpenURL(int tab_handle, |
| 469 const GURL& url, int open_disposition) { | 474 const GURL& url, |
| 475 const GURL& referrer, |
| 476 int open_disposition) { |
| 470 std::string target; | 477 std::string target; |
| 471 switch (open_disposition) { | 478 switch (open_disposition) { |
| 472 case NEW_FOREGROUND_TAB: | 479 case NEW_FOREGROUND_TAB: |
| 473 target = "_blank"; | 480 target = "_blank"; |
| 474 break; | 481 break; |
| 475 case NEW_BACKGROUND_TAB: | 482 case NEW_BACKGROUND_TAB: |
| 476 target = "_blank"; | 483 target = "_blank"; |
| 477 break; | 484 break; |
| 478 case NEW_WINDOW: | 485 case NEW_WINDOW: |
| 479 case NEW_POPUP: | 486 case NEW_POPUP: |
| (...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1450 } | 1457 } |
| 1451 | 1458 |
| 1452 int32 ChromeFrameNPAPI::Write(NPStream* stream, int32 offset, int32 len, | 1459 int32 ChromeFrameNPAPI::Write(NPStream* stream, int32 offset, int32 len, |
| 1453 void* buffer) { | 1460 void* buffer) { |
| 1454 return url_fetcher_.Write(stream, offset, len, buffer); | 1461 return url_fetcher_.Write(stream, offset, len, buffer); |
| 1455 } | 1462 } |
| 1456 | 1463 |
| 1457 NPError ChromeFrameNPAPI::DestroyStream(NPStream* stream, NPReason reason) { | 1464 NPError ChromeFrameNPAPI::DestroyStream(NPStream* stream, NPReason reason) { |
| 1458 return url_fetcher_.DestroyStream(stream, reason); | 1465 return url_fetcher_.DestroyStream(stream, reason); |
| 1459 } | 1466 } |
| OLD | NEW |