OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/extension_helper.h" | 5 #include "chrome/renderer/extensions/extension_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 // some alternative way to transmit the icon data to the browser process. | 502 // some alternative way to transmit the icon data to the browser process. |
503 // | 503 // |
504 // See also: bug 63729. | 504 // See also: bug 63729. |
505 const size_t kMaxIconSize = 1024 * 128; | 505 const size_t kMaxIconSize = 1024 * 128; |
506 size_t actual_icon_size = 0; | 506 size_t actual_icon_size = 0; |
507 for (size_t i = 0; i < pending_app_info_->icons.size(); ++i) { | 507 for (size_t i = 0; i < pending_app_info_->icons.size(); ++i) { |
508 size_t current_size = pending_app_info_->icons[i].data.getSize(); | 508 size_t current_size = pending_app_info_->icons[i].data.getSize(); |
509 if (current_size > kMaxIconSize - actual_icon_size) { | 509 if (current_size > kMaxIconSize - actual_icon_size) { |
510 AddMessageToRootConsole( | 510 AddMessageToRootConsole( |
511 content::CONSOLE_MESSAGE_LEVEL_ERROR, | 511 content::CONSOLE_MESSAGE_LEVEL_ERROR, |
512 ASCIIToUTF16("Icons are too large. " | 512 "Icons are too large. Maximum total size for app icons is 128 KB."); |
513 "Maximum total size for app icons is 128 KB.")); | |
514 return; | 513 return; |
515 } | 514 } |
516 actual_icon_size += current_size; | 515 actual_icon_size += current_size; |
517 } | 516 } |
518 | 517 |
519 Send(new ExtensionHostMsg_InstallApplication( | 518 Send(new ExtensionHostMsg_InstallApplication( |
520 routing_id(), *pending_app_info_)); | 519 routing_id(), *pending_app_info_)); |
521 pending_app_info_.reset(NULL); | 520 pending_app_info_.reset(NULL); |
522 } | 521 } |
523 | 522 |
524 void ExtensionHelper::AddMessageToRootConsole(ConsoleMessageLevel level, | 523 void ExtensionHelper::AddMessageToRootConsole(ConsoleMessageLevel level, |
| 524 const std::string& message) { |
| 525 AddMessageToRootConsole(level, ASCIIToUTF16(message)); |
| 526 } |
| 527 |
| 528 void ExtensionHelper::AddMessageToRootConsole(ConsoleMessageLevel level, |
525 const string16& message) { | 529 const string16& message) { |
526 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { | 530 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
527 WebConsoleMessage::Level target_level = WebConsoleMessage::LevelLog; | 531 WebConsoleMessage::Level target_level = WebConsoleMessage::LevelLog; |
528 switch (level) { | 532 switch (level) { |
529 case content::CONSOLE_MESSAGE_LEVEL_DEBUG: | 533 case content::CONSOLE_MESSAGE_LEVEL_DEBUG: |
530 target_level = WebConsoleMessage::LevelDebug; | 534 target_level = WebConsoleMessage::LevelDebug; |
531 break; | 535 break; |
532 case content::CONSOLE_MESSAGE_LEVEL_LOG: | 536 case content::CONSOLE_MESSAGE_LEVEL_LOG: |
533 target_level = WebConsoleMessage::LevelLog; | 537 target_level = WebConsoleMessage::LevelLog; |
534 break; | 538 break; |
535 case content::CONSOLE_MESSAGE_LEVEL_WARNING: | 539 case content::CONSOLE_MESSAGE_LEVEL_WARNING: |
536 target_level = WebConsoleMessage::LevelWarning; | 540 target_level = WebConsoleMessage::LevelWarning; |
537 break; | 541 break; |
538 case content::CONSOLE_MESSAGE_LEVEL_ERROR: | 542 case content::CONSOLE_MESSAGE_LEVEL_ERROR: |
539 target_level = WebConsoleMessage::LevelError; | 543 target_level = WebConsoleMessage::LevelError; |
540 break; | 544 break; |
541 } | 545 } |
542 render_view()->GetWebView()->mainFrame()->addMessageToConsole( | 546 render_view()->GetWebView()->mainFrame()->addMessageToConsole( |
543 WebConsoleMessage(target_level, message)); | 547 WebConsoleMessage(target_level, message)); |
544 } | 548 } |
545 } | 549 } |
546 | 550 |
547 } // namespace extensions | 551 } // namespace extensions |
OLD | NEW |