| 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/browser/infobars/infobar_extension_api.h" | 5 #include "chrome/browser/infobars/infobar_extension_api.h" |
| 6 | 6 |
| 7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/extensions/extension_host.h" | 10 #include "chrome/browser/extensions/extension_host.h" |
| 11 #include "chrome/browser/extensions/extension_infobar_delegate.h" | 11 #include "chrome/browser/extensions/extension_infobar_delegate.h" |
| 12 #include "chrome/browser/extensions/extension_tab_util.h" | 12 #include "chrome/browser/extensions/extension_tab_util.h" |
| 13 #include "chrome/browser/extensions/extension_tabs_module_constants.h" | 13 #include "chrome/browser/extensions/extension_tabs_module_constants.h" |
| 14 #include "chrome/browser/extensions/extension_window_controller.h" | 14 #include "chrome/browser/extensions/extension_window_controller.h" |
| 15 #include "chrome/browser/infobars/infobar_tab_helper.h" | 15 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 16 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 16 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
| 17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 19 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
| 20 #include "chrome/common/extensions/extension_error_utils.h" | 20 #include "chrome/common/extensions/extension_error_utils.h" |
| 21 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 23 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
| 24 | 24 |
| 25 using extensions::Extension; | 25 using extensions::Extension; |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 46 EXTENSION_FUNCTION_VALIDATE(args->GetString(kHtmlPath, &html_path)); | 46 EXTENSION_FUNCTION_VALIDATE(args->GetString(kHtmlPath, &html_path)); |
| 47 | 47 |
| 48 int height = 0; | 48 int height = 0; |
| 49 if (args->HasKey(kHeight)) | 49 if (args->HasKey(kHeight)) |
| 50 EXTENSION_FUNCTION_VALIDATE(args->GetInteger(kHeight, &height)); | 50 EXTENSION_FUNCTION_VALIDATE(args->GetInteger(kHeight, &height)); |
| 51 | 51 |
| 52 const Extension* extension = GetExtension(); | 52 const Extension* extension = GetExtension(); |
| 53 GURL url = extension->GetResourceURL(extension->url(), html_path); | 53 GURL url = extension->GetResourceURL(extension->url(), html_path); |
| 54 | 54 |
| 55 Browser* browser = NULL; | 55 Browser* browser = NULL; |
| 56 TabContentsWrapper* tab_contents = NULL; | 56 TabContents* tab_contents = NULL; |
| 57 if (!ExtensionTabUtil::GetTabById( | 57 if (!ExtensionTabUtil::GetTabById( |
| 58 tab_id, | 58 tab_id, |
| 59 profile(), | 59 profile(), |
| 60 include_incognito(), | 60 include_incognito(), |
| 61 &browser, | 61 &browser, |
| 62 NULL, | 62 NULL, |
| 63 &tab_contents, | 63 &tab_contents, |
| 64 NULL)) { | 64 NULL)) { |
| 65 error_ = ExtensionErrorUtils::FormatErrorMessage( | 65 error_ = ExtensionErrorUtils::FormatErrorMessage( |
| 66 extension_tabs_module_constants::kTabNotFoundError, | 66 extension_tabs_module_constants::kTabNotFoundError, |
| 67 base::IntToString(tab_id)); | 67 base::IntToString(tab_id)); |
| 68 return false; | 68 return false; |
| 69 } | 69 } |
| 70 | 70 |
| 71 tab_contents->infobar_tab_helper()->AddInfoBar( | 71 tab_contents->infobar_tab_helper()->AddInfoBar( |
| 72 new ExtensionInfoBarDelegate(browser, tab_contents->infobar_tab_helper(), | 72 new ExtensionInfoBarDelegate(browser, tab_contents->infobar_tab_helper(), |
| 73 GetExtension(), url, height)); | 73 GetExtension(), url, height)); |
| 74 | 74 |
| 75 // TODO(finnur): Return the actual DOMWindow object. Bug 26463. | 75 // TODO(finnur): Return the actual DOMWindow object. Bug 26463. |
| 76 DCHECK(browser->extension_window_controller()); | 76 DCHECK(browser->extension_window_controller()); |
| 77 result_.reset(browser->extension_window_controller()->CreateWindowValue()); | 77 result_.reset(browser->extension_window_controller()->CreateWindowValue()); |
| 78 | 78 |
| 79 return true; | 79 return true; |
| 80 } | 80 } |
| OLD | NEW |