OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ash_panel_contents.h" | 5 #include "chrome/browser/extensions/api/tabs/ash_panel_contents.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 8 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
9 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" | 9 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" |
10 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" | 10 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 71 } |
72 | 72 |
73 std::string AshPanelWindowController::GetWindowTypeText() const { | 73 std::string AshPanelWindowController::GetWindowTypeText() const { |
74 return extensions::tabs_constants::kWindowTypeValuePanel; | 74 return extensions::tabs_constants::kWindowTypeValuePanel; |
75 } | 75 } |
76 | 76 |
77 base::DictionaryValue* AshPanelWindowController::CreateWindowValueWithTabs( | 77 base::DictionaryValue* AshPanelWindowController::CreateWindowValueWithTabs( |
78 const extensions::Extension* extension) const { | 78 const extensions::Extension* extension) const { |
79 DCHECK(IsVisibleToExtension(extension)); | 79 DCHECK(IsVisibleToExtension(extension)); |
80 base::DictionaryValue* result = CreateWindowValue(); | 80 base::DictionaryValue* result = CreateWindowValue(); |
81 DictionaryValue* tab_value = CreateTabValue(extension, 0); | 81 base::DictionaryValue* tab_value = CreateTabValue(extension, 0); |
82 if (tab_value) { | 82 if (tab_value) { |
83 base::ListValue* tab_list = new ListValue(); | 83 base::ListValue* tab_list = new base::ListValue(); |
84 tab_list->Append(tab_value); | 84 tab_list->Append(tab_value); |
85 result->Set(extensions::tabs_constants::kTabsKey, tab_list); | 85 result->Set(extensions::tabs_constants::kTabsKey, tab_list); |
86 } | 86 } |
87 return result; | 87 return result; |
88 } | 88 } |
89 | 89 |
90 base::DictionaryValue* AshPanelWindowController::CreateTabValue( | 90 base::DictionaryValue* AshPanelWindowController::CreateTabValue( |
91 const extensions::Extension* extension, int tab_index) const { | 91 const extensions::Extension* extension, int tab_index) const { |
92 if ((extension && !IsVisibleToExtension(extension)) || | 92 if ((extension && !IsVisibleToExtension(extension)) || |
93 (tab_index > 0)) { | 93 (tab_index > 0)) { |
94 return NULL; | 94 return NULL; |
95 } | 95 } |
96 content::WebContents* web_contents = shell_window_->web_contents(); | 96 content::WebContents* web_contents = shell_window_->web_contents(); |
97 if (!web_contents) | 97 if (!web_contents) |
98 return NULL; | 98 return NULL; |
99 | 99 |
100 DictionaryValue* tab_value = new DictionaryValue(); | 100 base::DictionaryValue* tab_value = new base::DictionaryValue(); |
101 tab_value->SetInteger(extensions::tabs_constants::kIdKey, | 101 tab_value->SetInteger(extensions::tabs_constants::kIdKey, |
102 SessionID::IdForTab(web_contents)); | 102 SessionID::IdForTab(web_contents)); |
103 tab_value->SetInteger(extensions::tabs_constants::kIndexKey, 0); | 103 tab_value->SetInteger(extensions::tabs_constants::kIndexKey, 0); |
104 const int window_id = GetWindowId(); | 104 const int window_id = GetWindowId(); |
105 tab_value->SetInteger(extensions::tabs_constants::kWindowIdKey, window_id); | 105 tab_value->SetInteger(extensions::tabs_constants::kWindowIdKey, window_id); |
106 tab_value->SetString( | 106 tab_value->SetString( |
107 extensions::tabs_constants::kUrlKey, web_contents->GetURL().spec()); | 107 extensions::tabs_constants::kUrlKey, web_contents->GetURL().spec()); |
108 tab_value->SetString( | 108 tab_value->SetString( |
109 extensions::tabs_constants::kStatusKey, | 109 extensions::tabs_constants::kStatusKey, |
110 ExtensionTabUtil::GetTabStatusText(web_contents->IsLoading())); | 110 ExtensionTabUtil::GetTabStatusText(web_contents->IsLoading())); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 234 |
235 content::WebContents* AshPanelContents::GetAssociatedWebContents() const { | 235 content::WebContents* AshPanelContents::GetAssociatedWebContents() const { |
236 return web_contents_.get(); | 236 return web_contents_.get(); |
237 } | 237 } |
238 | 238 |
239 void AshPanelContents::OnRequest( | 239 void AshPanelContents::OnRequest( |
240 const ExtensionHostMsg_Request_Params& params) { | 240 const ExtensionHostMsg_Request_Params& params) { |
241 extension_function_dispatcher_->Dispatch( | 241 extension_function_dispatcher_->Dispatch( |
242 params, web_contents_->GetRenderViewHost()); | 242 params, web_contents_->GetRenderViewHost()); |
243 } | 243 } |
OLD | NEW |