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/ui/panels/panel.h" | 5 #include "chrome/browser/ui/panels/panel.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 std::string PanelExtensionWindowController::GetWindowTypeText() const { | 90 std::string PanelExtensionWindowController::GetWindowTypeText() const { |
91 return extensions::tabs_constants::kWindowTypeValuePanel; | 91 return extensions::tabs_constants::kWindowTypeValuePanel; |
92 } | 92 } |
93 | 93 |
94 base::DictionaryValue* | 94 base::DictionaryValue* |
95 PanelExtensionWindowController::CreateWindowValueWithTabs( | 95 PanelExtensionWindowController::CreateWindowValueWithTabs( |
96 const extensions::Extension* extension) const { | 96 const extensions::Extension* extension) const { |
97 base::DictionaryValue* result = CreateWindowValue(); | 97 base::DictionaryValue* result = CreateWindowValue(); |
98 | 98 |
99 DCHECK(IsVisibleToExtension(extension)); | |
100 base::DictionaryValue* tab_value = CreateTabValue(extension, 0); | 99 base::DictionaryValue* tab_value = CreateTabValue(extension, 0); |
101 if (tab_value) { | 100 if (tab_value) { |
102 base::ListValue* tab_list = new base::ListValue(); | 101 base::ListValue* tab_list = new base::ListValue(); |
103 tab_list->Append(tab_value); | 102 tab_list->Append(tab_value); |
104 result->Set(extensions::tabs_constants::kTabsKey, tab_list); | 103 result->Set(extensions::tabs_constants::kTabsKey, tab_list); |
105 } | 104 } |
106 return result; | 105 return result; |
107 } | 106 } |
108 | 107 |
109 base::DictionaryValue* PanelExtensionWindowController::CreateTabValue( | 108 base::DictionaryValue* PanelExtensionWindowController::CreateTabValue( |
110 const extensions::Extension* extension, int tab_index) const { | 109 const extensions::Extension* extension, int tab_index) const { |
111 if (tab_index > 0) | 110 if (tab_index > 0) |
112 return NULL; | 111 return NULL; |
113 | 112 |
114 content::WebContents* web_contents = panel_->GetWebContents(); | 113 content::WebContents* web_contents = panel_->GetWebContents(); |
115 if (!web_contents) | 114 if (!web_contents) |
116 return NULL; | 115 return NULL; |
117 | 116 |
118 DCHECK(IsVisibleToExtension(extension)); | |
119 base::DictionaryValue* tab_value = new base::DictionaryValue(); | 117 base::DictionaryValue* tab_value = new base::DictionaryValue(); |
120 tab_value->SetInteger(extensions::tabs_constants::kIdKey, | 118 tab_value->SetInteger(extensions::tabs_constants::kIdKey, |
121 SessionTabHelper::IdForTab(web_contents)); | 119 SessionTabHelper::IdForTab(web_contents)); |
122 tab_value->SetInteger(extensions::tabs_constants::kIndexKey, 0); | 120 tab_value->SetInteger(extensions::tabs_constants::kIndexKey, 0); |
123 tab_value->SetInteger( | 121 tab_value->SetInteger( |
124 extensions::tabs_constants::kWindowIdKey, | 122 extensions::tabs_constants::kWindowIdKey, |
125 SessionTabHelper::IdForWindowContainingTab(web_contents)); | 123 SessionTabHelper::IdForWindowContainingTab(web_contents)); |
126 tab_value->SetString( | 124 tab_value->SetString( |
127 extensions::tabs_constants::kUrlKey, web_contents->GetURL().spec()); | 125 extensions::tabs_constants::kUrlKey, web_contents->GetURL().spec()); |
128 tab_value->SetString(extensions::tabs_constants::kStatusKey, | 126 tab_value->SetString(extensions::tabs_constants::kStatusKey, |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 // static | 893 // static |
896 void Panel::FormatTitleForDisplay(base::string16* title) { | 894 void Panel::FormatTitleForDisplay(base::string16* title) { |
897 size_t current_index = 0; | 895 size_t current_index = 0; |
898 size_t match_index; | 896 size_t match_index; |
899 while ((match_index = title->find(L'\n', current_index)) != | 897 while ((match_index = title->find(L'\n', current_index)) != |
900 base::string16::npos) { | 898 base::string16::npos) { |
901 title->replace(match_index, 1, base::string16()); | 899 title->replace(match_index, 1, base::string16()); |
902 current_index = match_index; | 900 current_index = match_index; |
903 } | 901 } |
904 } | 902 } |
OLD | NEW |