| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/extensions/api/tabs/app_window_controller.h" | 5 #include "chrome/browser/extensions/api/tabs/app_window_controller.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 if (app_window_->window_type_is_panel()) | 44 if (app_window_->window_type_is_panel()) |
| 45 return tabs_constants::kWindowTypeValuePanel; | 45 return tabs_constants::kWindowTypeValuePanel; |
| 46 return tabs_constants::kWindowTypeValueApp; | 46 return tabs_constants::kWindowTypeValueApp; |
| 47 } | 47 } |
| 48 | 48 |
| 49 std::unique_ptr<base::DictionaryValue> | 49 std::unique_ptr<base::DictionaryValue> |
| 50 AppWindowController::CreateWindowValueWithTabs( | 50 AppWindowController::CreateWindowValueWithTabs( |
| 51 const Extension* extension) const { | 51 const Extension* extension) const { |
| 52 std::unique_ptr<base::DictionaryValue> result = CreateWindowValue(); | 52 std::unique_ptr<base::DictionaryValue> result = CreateWindowValue(); |
| 53 | 53 |
| 54 base::DictionaryValue* tab_value = CreateTabValue(extension, 0); | 54 std::unique_ptr<base::DictionaryValue> tab_value = |
| 55 CreateTabObject(extension, 0)->ToValue(); |
| 55 if (!tab_value) | 56 if (!tab_value) |
| 56 return result; | 57 return result; |
| 57 | 58 |
| 58 base::ListValue* tab_list = new base::ListValue(); | 59 base::ListValue* tab_list = new base::ListValue(); |
| 59 tab_list->Append(tab_value); | 60 tab_list->Append(std::move(tab_value)); |
| 60 result->Set(tabs_constants::kTabsKey, tab_list); | 61 result->Set(tabs_constants::kTabsKey, tab_list); |
| 61 | 62 |
| 62 return result; | 63 return result; |
| 63 } | 64 } |
| 64 | 65 |
| 65 base::DictionaryValue* AppWindowController::CreateTabValue( | |
| 66 const Extension* extension, | |
| 67 int tab_index) const { | |
| 68 return CreateTabObject(extension, tab_index)->ToValue().release(); | |
| 69 } | |
| 70 | |
| 71 std::unique_ptr<api::tabs::Tab> AppWindowController::CreateTabObject( | 66 std::unique_ptr<api::tabs::Tab> AppWindowController::CreateTabObject( |
| 72 const extensions::Extension* extension, | 67 const extensions::Extension* extension, |
| 73 int tab_index) const { | 68 int tab_index) const { |
| 74 if (tab_index > 0) | 69 if (tab_index > 0) |
| 75 return nullptr; | 70 return nullptr; |
| 76 | 71 |
| 77 content::WebContents* web_contents = app_window_->web_contents(); | 72 content::WebContents* web_contents = app_window_->web_contents(); |
| 78 if (!web_contents) | 73 if (!web_contents) |
| 79 return nullptr; | 74 return nullptr; |
| 80 | 75 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 return nullptr; | 121 return nullptr; |
| 127 } | 122 } |
| 128 | 123 |
| 129 bool AppWindowController::IsVisibleToExtension( | 124 bool AppWindowController::IsVisibleToExtension( |
| 130 const Extension* extension) const { | 125 const Extension* extension) const { |
| 131 DCHECK(extension); | 126 DCHECK(extension); |
| 132 return extension->id() == app_window_->extension_id(); | 127 return extension->id() == app_window_->extension_id(); |
| 133 } | 128 } |
| 134 | 129 |
| 135 } // namespace extensions | 130 } // namespace extensions |
| OLD | NEW |