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

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

Issue 10544021: Disable the new window context menu option in the bookmarks extension for Windows 8 metro mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 months 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) 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/extensions/extension_tabs_module.h" 5 #include "chrome/browser/extensions/extension_tabs_module.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 #include "ui/base/ui_base_types.h" 70 #include "ui/base/ui_base_types.h"
71 #include "ui/gfx/codec/jpeg_codec.h" 71 #include "ui/gfx/codec/jpeg_codec.h"
72 #include "ui/gfx/codec/png_codec.h" 72 #include "ui/gfx/codec/png_codec.h"
73 73
74 #if defined(USE_ASH) 74 #if defined(USE_ASH)
75 #include "ash/ash_switches.h" 75 #include "ash/ash_switches.h"
76 #include "base/command_line.h" 76 #include "base/command_line.h"
77 #include "chrome/browser/ui/views/ash/panel_view_aura.h" 77 #include "chrome/browser/ui/views/ash/panel_view_aura.h"
78 #endif 78 #endif
79 79
80 #if defined(OS_WIN)
81 #include "base/win/metro.h"
82 #endif // OS_WIN
83
80 namespace Get = extensions::api::windows::Get; 84 namespace Get = extensions::api::windows::Get;
81 namespace GetAll = extensions::api::windows::GetAll; 85 namespace GetAll = extensions::api::windows::GetAll;
82 namespace GetCurrent = extensions::api::windows::GetCurrent; 86 namespace GetCurrent = extensions::api::windows::GetCurrent;
83 namespace GetLastFocused = extensions::api::windows::GetLastFocused; 87 namespace GetLastFocused = extensions::api::windows::GetLastFocused;
84 namespace errors = extension_manifest_errors; 88 namespace errors = extension_manifest_errors;
85 namespace keys = extension_tabs_module_constants; 89 namespace keys = extension_tabs_module_constants;
86 90
87 using content::NavigationController; 91 using content::NavigationController;
88 using content::NavigationEntry; 92 using content::NavigationEntry;
89 using content::OpenURLParams; 93 using content::OpenURLParams;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 212
209 QueryArg ParseBoolQueryArg(base::DictionaryValue* query, const char* key) { 213 QueryArg ParseBoolQueryArg(base::DictionaryValue* query, const char* key) {
210 if (query->HasKey(key)) { 214 if (query->HasKey(key)) {
211 bool value = false; 215 bool value = false;
212 CHECK(query->GetBoolean(key, &value)); 216 CHECK(query->GetBoolean(key, &value));
213 return value ? MATCH_TRUE : MATCH_FALSE; 217 return value ? MATCH_TRUE : MATCH_FALSE;
214 } 218 }
215 return NOT_SET; 219 return NOT_SET;
216 } 220 }
217 221
222 Browser* CreateBrowserWindow(const Browser::CreateParams& params,
223 Profile* profile,
224 const std::string& extension_id) {
225 bool use_existing_browser_window = false;
226
227 #if defined(OS_WIN)
228 // In Windows 8 metro mode we only allow new windows to be created if the
229 // extension id is valid in which case it is created as an application window
230 if (extension_id.empty() && base::win::GetMetroModule())
231 use_existing_browser_window = true;
232 #endif // OS_WIN
233
234 Browser* new_window = NULL;
235 if (use_existing_browser_window)
236 // The false parameter passed below is to ensure that we find a browser
237 // object matching the profile passed in, instead of the original profile
238 new_window = browser::FindTabbedBrowser(profile, false);
239
240 if (!new_window)
241 new_window = Browser::CreateWithParams(params);
242 return new_window;
243 }
244
218 } // namespace 245 } // namespace
219 246
220 // Windows --------------------------------------------------------------------- 247 // Windows ---------------------------------------------------------------------
221 248
222 bool GetWindowFunction::RunImpl() { 249 bool GetWindowFunction::RunImpl() {
223 scoped_ptr<Get::Params> params(Get::Params::Create(*args_)); 250 scoped_ptr<Get::Params> params(Get::Params::Create(*args_));
224 EXTENSION_FUNCTION_VALIDATE(params.get()); 251 EXTENSION_FUNCTION_VALIDATE(params.get());
225 252
226 bool populate_tabs = false; 253 bool populate_tabs = false;
227 if (params->get_info.get() && params->get_info->populate.get()) 254 if (params->get_info.get() && params->get_info->populate.get())
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 create_params = Browser::CreateParams(window_type, window_profile); 605 create_params = Browser::CreateParams(window_type, window_profile);
579 create_params.initial_bounds = window_bounds; 606 create_params.initial_bounds = window_bounds;
580 } else { 607 } else {
581 create_params = Browser::CreateParams::CreateForApp( 608 create_params = Browser::CreateParams::CreateForApp(
582 window_type, 609 window_type,
583 web_app::GenerateApplicationNameFromExtensionId(extension_id), 610 web_app::GenerateApplicationNameFromExtensionId(extension_id),
584 (window_type == Browser::TYPE_PANEL ? panel_bounds : popup_bounds), 611 (window_type == Browser::TYPE_PANEL ? panel_bounds : popup_bounds),
585 window_profile); 612 window_profile);
586 } 613 }
587 create_params.initial_show_state = ui::SHOW_STATE_NORMAL; 614 create_params.initial_show_state = ui::SHOW_STATE_NORMAL;
588 Browser* new_window = Browser::CreateWithParams(create_params); 615
616 Browser* new_window = CreateBrowserWindow(create_params, window_profile,
617 extension_id);
589 618
590 for (std::vector<GURL>::iterator i = urls.begin(); i != urls.end(); ++i) { 619 for (std::vector<GURL>::iterator i = urls.begin(); i != urls.end(); ++i) {
591 TabContentsWrapper* tab = new_window->AddSelectedTabWithURL( 620 TabContentsWrapper* tab = new_window->AddSelectedTabWithURL(
592 *i, content::PAGE_TRANSITION_LINK); 621 *i, content::PAGE_TRANSITION_LINK);
593 if (window_type == Browser::TYPE_PANEL) 622 if (window_type == Browser::TYPE_PANEL)
594 tab->extension_tab_helper()->SetExtensionAppIconById(extension_id); 623 tab->extension_tab_helper()->SetExtensionAppIconById(extension_id);
595 } 624 }
596 if (contents) { 625 if (contents) {
597 TabStripModel* target_tab_strip = new_window->tab_strip_model(); 626 TabStripModel* target_tab_strip = new_window->tab_strip_model();
598 target_tab_strip->InsertTabContentsAt(urls.size(), contents, 627 target_tab_strip->InsertTabContentsAt(urls.size(), contents,
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 // called for every API call the extension made. 1813 // called for every API call the extension made.
1785 GotLanguage(language); 1814 GotLanguage(language);
1786 } 1815 }
1787 1816
1788 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { 1817 void DetectTabLanguageFunction::GotLanguage(const std::string& language) {
1789 result_.reset(Value::CreateStringValue(language.c_str())); 1818 result_.reset(Value::CreateStringValue(language.c_str()));
1790 SendResponse(true); 1819 SendResponse(true);
1791 1820
1792 Release(); // Balanced in Run() 1821 Release(); // Balanced in Run()
1793 } 1822 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_function_registry.cc ('k') | chrome/browser/resources/bookmark_manager/js/main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698