Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: chrome/browser/extensions/extension_sidebar_api.cc

Issue 4694008: Make pink's TabContentsWrapper change compile on Windows.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/extension_sidebar_api.h" 5 #include "chrome/browser/extensions/extension_sidebar_api.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/extensions/extension_event_router.h" 12 #include "chrome/browser/extensions/extension_event_router.h"
13 #include "chrome/browser/extensions/extensions_service.h" 13 #include "chrome/browser/extensions/extensions_service.h"
14 #include "chrome/browser/extensions/extension_tabs_module.h" 14 #include "chrome/browser/extensions/extension_tabs_module.h"
15 #include "chrome/browser/profile.h" 15 #include "chrome/browser/profile.h"
16 #include "chrome/browser/sidebar/sidebar_container.h" 16 #include "chrome/browser/sidebar/sidebar_container.h"
17 #include "chrome/browser/sidebar/sidebar_manager.h" 17 #include "chrome/browser/sidebar/sidebar_manager.h"
18 #include "chrome/browser/tab_contents/tab_contents.h" 18 #include "chrome/browser/tab_contents/tab_contents.h"
19 #include "chrome/browser/tab_contents_wrapper.h"
19 #include "chrome/common/extensions/extension.h" 20 #include "chrome/common/extensions/extension.h"
20 #include "chrome/common/extensions/extension_constants.h" 21 #include "chrome/common/extensions/extension_constants.h"
21 #include "chrome/common/extensions/extension_error_utils.h" 22 #include "chrome/common/extensions/extension_error_utils.h"
22 #include "chrome/common/render_messages.h" 23 #include "chrome/common/render_messages.h"
23 #include "chrome/common/url_constants.h" 24 #include "chrome/common/url_constants.h"
24 #include "ipc/ipc_message_utils.h" 25 #include "ipc/ipc_message_utils.h"
25 #include "third_party/skia/include/core/SkBitmap.h" 26 #include "third_party/skia/include/core/SkBitmap.h"
26 27
27 namespace { 28 namespace {
28 // Errors. 29 // Errors.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 116
116 DictionaryValue* details = NULL; 117 DictionaryValue* details = NULL;
117 DictionaryValue default_details; 118 DictionaryValue default_details;
118 if (IsArgumentListEmpty(args_.get())) { 119 if (IsArgumentListEmpty(args_.get())) {
119 details = &default_details; 120 details = &default_details;
120 } else { 121 } else {
121 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details)); 122 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details));
122 } 123 }
123 124
124 int tab_id; 125 int tab_id;
125 TabContents* tab_contents = NULL; 126 TabContentsWrapper* tab_contents = NULL;
126 if (details->HasKey(kTabIdKey)) { 127 if (details->HasKey(kTabIdKey)) {
127 EXTENSION_FUNCTION_VALIDATE(details->GetInteger(kTabIdKey, &tab_id)); 128 EXTENSION_FUNCTION_VALIDATE(details->GetInteger(kTabIdKey, &tab_id));
128 if (!ExtensionTabUtil::GetTabById(tab_id, profile(), include_incognito(), 129 if (!ExtensionTabUtil::GetTabById(tab_id, profile(), include_incognito(),
129 NULL, NULL, &tab_contents, NULL)) { 130 NULL, NULL, &tab_contents, NULL)) {
130 error_ = ExtensionErrorUtils::FormatErrorMessage( 131 error_ = ExtensionErrorUtils::FormatErrorMessage(
131 kNoTabError, base::IntToString(tab_id)); 132 kNoTabError, base::IntToString(tab_id));
132 return false; 133 return false;
133 } 134 }
134 } else { 135 } else {
135 Browser* browser = GetCurrentBrowser(); 136 Browser* browser = GetCurrentBrowser();
136 if (!browser) { 137 if (!browser) {
137 error_ = kNoCurrentWindowError; 138 error_ = kNoCurrentWindowError;
138 return false; 139 return false;
139 } 140 }
140 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) { 141 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) {
141 error_ = kNoDefaultTabError; 142 error_ = kNoDefaultTabError;
142 return false; 143 return false;
143 } 144 }
144 } 145 }
145 if (!tab_contents) 146 if (!tab_contents)
146 return false; 147 return false;
147 148
148 std::string content_id(GetExtension()->id()); 149 std::string content_id(GetExtension()->id());
149 return RunImpl(tab_contents, content_id, *details); 150 return RunImpl(tab_contents->tab_contents(), content_id, *details);
150 } 151 }
151 152
152 153
153 bool CollapseSidebarFunction::RunImpl(TabContents* tab, 154 bool CollapseSidebarFunction::RunImpl(TabContents* tab,
154 const std::string& content_id, 155 const std::string& content_id,
155 const DictionaryValue& details) { 156 const DictionaryValue& details) {
156 SidebarManager::GetInstance()->CollapseSidebar(tab, content_id); 157 SidebarManager::GetInstance()->CollapseSidebar(tab, content_id);
157 return true; 158 return true;
158 } 159 }
159 160
(...skipping 26 matching lines...) Expand all
186 // is displayed on it. 187 // is displayed on it.
187 if (active_sidebar && active_sidebar->content_id() == content_id) { 188 if (active_sidebar && active_sidebar->content_id() == content_id) {
188 if (!details.HasKey(kTabIdKey)) { 189 if (!details.HasKey(kTabIdKey)) {
189 is_active = NULL != GetCurrentBrowser(); 190 is_active = NULL != GetCurrentBrowser();
190 } else { 191 } else {
191 int tab_id; 192 int tab_id;
192 EXTENSION_FUNCTION_VALIDATE(details.GetInteger(kTabIdKey, &tab_id)); 193 EXTENSION_FUNCTION_VALIDATE(details.GetInteger(kTabIdKey, &tab_id));
193 194
194 // Check if this tab is selected. 195 // Check if this tab is selected.
195 Browser* browser = GetCurrentBrowser(); 196 Browser* browser = GetCurrentBrowser();
196 TabContents* contents = NULL; 197 TabContentsWrapper* contents = NULL;
197 int default_tab_id = -1; 198 int default_tab_id = -1;
198 if (browser && 199 if (browser &&
199 ExtensionTabUtil::GetDefaultTab(browser, &contents, 200 ExtensionTabUtil::GetDefaultTab(browser, &contents,
200 &default_tab_id)) { 201 &default_tab_id)) {
201 is_active = default_tab_id == tab_id; 202 is_active = default_tab_id == tab_id;
202 } 203 }
203 } 204 }
204 } 205 }
205 206
206 result = is_active ? extension_sidebar_constants::kActiveState : 207 result = is_active ? extension_sidebar_constants::kActiveState :
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 SidebarManager::GetInstance()->SetSidebarTitle(tab, content_id, title); 277 SidebarManager::GetInstance()->SetSidebarTitle(tab, content_id, title);
277 return true; 278 return true;
278 } 279 }
279 280
280 bool ShowSidebarFunction::RunImpl(TabContents* tab, 281 bool ShowSidebarFunction::RunImpl(TabContents* tab,
281 const std::string& content_id, 282 const std::string& content_id,
282 const DictionaryValue& details) { 283 const DictionaryValue& details) {
283 SidebarManager::GetInstance()->ShowSidebar(tab, content_id); 284 SidebarManager::GetInstance()->ShowSidebar(tab, content_id);
284 return true; 285 return true;
285 } 286 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698