diff --git a/brightray/.gitmodules b/brightray/.gitmodules index 1e27bc6b5a2..17120b4cdf6 100644 --- a/brightray/.gitmodules +++ b/brightray/.gitmodules @@ -4,3 +4,6 @@ [submodule "vendor/gyp"] path = vendor/gyp url = https://github.com/svn2github/gyp +[submodule "vendor/google-styleguide"] + path = vendor/google-styleguide + url = https://github.com/svn2github/sgss-mirror-google-styleguide diff --git a/brightray/browser/browser_client.cc b/brightray/browser/browser_client.cc index 1c19f622ef0..c407989af49 100644 --- a/brightray/browser/browser_client.cc +++ b/brightray/browser/browser_client.cc @@ -42,18 +42,23 @@ NotificationPresenter* BrowserClient::notification_presenter() { return notification_presenter_.get(); } -BrowserMainParts* BrowserClient::OverrideCreateBrowserMainParts(const content::MainFunctionParams&) { +BrowserMainParts* BrowserClient::OverrideCreateBrowserMainParts( + const content::MainFunctionParams&) { return new BrowserMainParts; } -content::BrowserMainParts* BrowserClient::CreateBrowserMainParts(const content::MainFunctionParams& parameters) { +content::BrowserMainParts* BrowserClient::CreateBrowserMainParts( + const content::MainFunctionParams& parameters) { DCHECK(!browser_main_parts_); browser_main_parts_ = OverrideCreateBrowserMainParts(parameters); return browser_main_parts_; } -net::URLRequestContextGetter* BrowserClient::CreateRequestContext(content::BrowserContext* browser_context, content::ProtocolHandlerMap* protocol_handlers) { - return static_cast(browser_context)->CreateRequestContext(protocol_handlers); +net::URLRequestContextGetter* BrowserClient::CreateRequestContext( + content::BrowserContext* browser_context, + content::ProtocolHandlerMap* protocol_handlers) { + auto context = static_cast(browser_context); + return context->CreateRequestContext(protocol_handlers); } void BrowserClient::ShowDesktopNotification( @@ -74,11 +79,12 @@ void BrowserClient::CancelDesktopNotification( auto presenter = notification_presenter(); if (!presenter) return; - presenter->CancelNotification(render_process_id, render_view_id, notification_id); + presenter->CancelNotification( + render_process_id, render_view_id, notification_id); } content::MediaObserver* BrowserClient::GetMediaObserver() { return MediaCaptureDevicesDispatcher::GetInstance(); } -} +} // namespace brightray diff --git a/brightray/browser/browser_client.h b/brightray/browser/browser_client.h index f5bc9d618fe..41a3861f61f 100644 --- a/brightray/browser/browser_client.h +++ b/brightray/browser/browser_client.h @@ -14,7 +14,7 @@ class BrowserMainParts; class NotificationPresenter; class BrowserClient : public content::ContentBrowserClient { -public: + public: static BrowserClient* Get(); BrowserClient(); @@ -24,17 +24,21 @@ public: BrowserMainParts* browser_main_parts() { return browser_main_parts_; } NotificationPresenter* notification_presenter(); -protected: - // Subclasses should override this to provide their own BrowserMainParts implementation. The - // lifetime of the returned instance is managed by the caller. - virtual BrowserMainParts* OverrideCreateBrowserMainParts(const content::MainFunctionParams&); + protected: + // Subclasses should override this to provide their own BrowserMainParts + // implementation. The lifetime of the returned instance is managed by the + // caller. + virtual BrowserMainParts* OverrideCreateBrowserMainParts( + const content::MainFunctionParams&); - // Subclasses that override this (e.g., to provide their own protocol handlers) should call this - // implementation after doing their own work. - virtual net::URLRequestContextGetter* CreateRequestContext(content::BrowserContext*, content::ProtocolHandlerMap*) OVERRIDE; + // Subclasses that override this (e.g., to provide their own protocol + // handlers) should call this implementation after doing their own work. + virtual net::URLRequestContextGetter* CreateRequestContext( + content::BrowserContext*, content::ProtocolHandlerMap*) OVERRIDE; -private: - virtual content::BrowserMainParts* CreateBrowserMainParts(const content::MainFunctionParams&) OVERRIDE; + private: + virtual content::BrowserMainParts* CreateBrowserMainParts( + const content::MainFunctionParams&) OVERRIDE; virtual void ShowDesktopNotification( const content::ShowDesktopNotificationHostMsgParams&, int render_process_id, @@ -52,6 +56,6 @@ private: DISALLOW_COPY_AND_ASSIGN(BrowserClient); }; -} +} // namespace brightray #endif diff --git a/brightray/browser/browser_context.cc b/brightray/browser/browser_context.cc index e43607a196c..20b70470552 100644 --- a/brightray/browser/browser_context.cc +++ b/brightray/browser/browser_context.cc @@ -2,11 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE-CHROMIUM file. -#include "browser_context.h" +#include "browser/browser_context.h" #include "browser/download_manager_delegate.h" #include "browser/inspectable_web_contents_impl.h" #include "browser/network_delegate.h" +#include "browser/url_request_context_getter.h" #include "common/application_info.h" #include "base/environment.h" @@ -19,7 +20,6 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/resource_context.h" #include "content/public/browser/storage_partition.h" -#include "url_request_context_getter.h" #if defined(OS_LINUX) #include "base/nix/xdg_util.h" @@ -28,28 +28,30 @@ namespace brightray { class BrowserContext::ResourceContext : public content::ResourceContext { -public: + public: ResourceContext() : getter_(nullptr) {} void set_url_request_context_getter(URLRequestContextGetter* getter) { getter_ = getter; } -private: + private: virtual net::HostResolver* GetHostResolver() OVERRIDE { return getter_->host_resolver(); } - + virtual net::URLRequestContext* GetRequestContext() OVERRIDE { return getter_->GetURLRequestContext(); } - // FIXME: We should probably allow clients to override this to implement more restrictive policies. + // FIXME: We should probably allow clients to override this to implement more + // restrictive policies. virtual bool AllowMicAccess(const GURL& origin) OVERRIDE { return true; } - - // FIXME: We should probably allow clients to override this to implement more restrictive policies. + + // FIXME: We should probably allow clients to override this to implement more + // restrictive policies. virtual bool AllowCameraAccess(const GURL& origin) OVERRIDE { return true; } @@ -76,7 +78,8 @@ void BrowserContext::Initialize() { auto prefs_path = GetPath().Append(FILE_PATH_LITERAL("Preferences")); PrefServiceBuilder builder; builder.WithUserFilePrefs(prefs_path, - JsonPrefStore::GetTaskRunnerForFile(prefs_path, content::BrowserThread::GetBlockingPool())); + JsonPrefStore::GetTaskRunnerForFile( + prefs_path, content::BrowserThread::GetBlockingPool())); auto registry = make_scoped_refptr(new PrefRegistrySimple); RegisterInternalPrefs(registry); @@ -92,12 +95,17 @@ void BrowserContext::RegisterInternalPrefs(PrefRegistrySimple* registry) { InspectableWebContentsImpl::RegisterPrefs(registry); } -net::URLRequestContextGetter* BrowserContext::CreateRequestContext(content::ProtocolHandlerMap* protocol_handlers) { +net::URLRequestContextGetter* BrowserContext::CreateRequestContext( + content::ProtocolHandlerMap* protocol_handlers) { DCHECK(!url_request_getter_); + auto io_loop = content::BrowserThread::UnsafeGetMessageLoopForThread( + content::BrowserThread::IO); + auto file_loop = content::BrowserThread::UnsafeGetMessageLoopForThread( + content::BrowserThread::FILE); url_request_getter_ = new URLRequestContextGetter( GetPath(), - content::BrowserThread::UnsafeGetMessageLoopForThread(content::BrowserThread::IO), - content::BrowserThread::UnsafeGetMessageLoopForThread(content::BrowserThread::FILE), + io_loop, + file_loop, CreateNetworkDelegate().Pass(), protocol_handlers); resource_context_->set_url_request_context_getter(url_request_getter_.get()); @@ -120,7 +128,8 @@ net::URLRequestContextGetter* BrowserContext::GetRequestContext() { return GetDefaultStoragePartition(this)->GetURLRequestContext(); } -net::URLRequestContextGetter* BrowserContext::GetRequestContextForRenderProcess(int renderer_child_id) { +net::URLRequestContextGetter* BrowserContext::GetRequestContextForRenderProcess( + int renderer_child_id) { return GetRequestContext(); } @@ -128,15 +137,24 @@ net::URLRequestContextGetter* BrowserContext::GetMediaRequestContext() { return GetRequestContext(); } -net::URLRequestContextGetter* BrowserContext::GetMediaRequestContextForRenderProcess(int renderer_child_id) { +net::URLRequestContextGetter* + BrowserContext::GetMediaRequestContextForRenderProcess( + int renderer_child_id) { return GetRequestContext(); } -net::URLRequestContextGetter* BrowserContext::GetMediaRequestContextForStoragePartition(const base::FilePath& partition_path, bool in_memory) { +net::URLRequestContextGetter* + BrowserContext::GetMediaRequestContextForStoragePartition( + const base::FilePath& partition_path, + bool in_memory) { return GetRequestContext(); } -void BrowserContext::RequestMIDISysExPermission(int render_process_id, int render_view_id, const GURL& requesting_frame, const MIDISysExPermissionCallback& callback) { +void BrowserContext::RequestMIDISysExPermission( + int render_process_id, + int render_view_id, + const GURL& requesting_frame, + const MIDISysExPermissionCallback& callback) { callback.Run(false); } @@ -150,7 +168,8 @@ content::DownloadManagerDelegate* BrowserContext::GetDownloadManagerDelegate() { return download_manager_delegate_.get(); } -content::GeolocationPermissionContext* BrowserContext::GetGeolocationPermissionContext() { +content::GeolocationPermissionContext* + BrowserContext::GetGeolocationPermissionContext() { return nullptr; } @@ -158,4 +177,4 @@ quota::SpecialStoragePolicy* BrowserContext::GetSpecialStoragePolicy() { return nullptr; } -} +} // namespace brightray diff --git a/brightray/browser/browser_context.h b/brightray/browser/browser_context.h index f18cfdadced..6356277942e 100644 --- a/brightray/browser/browser_context.h +++ b/brightray/browser/browser_context.h @@ -18,41 +18,54 @@ class NetworkDelegate; class URLRequestContextGetter; class BrowserContext : public content::BrowserContext { -public: + public: BrowserContext(); ~BrowserContext(); void Initialize(); - net::URLRequestContextGetter* CreateRequestContext(content::ProtocolHandlerMap*); + net::URLRequestContextGetter* CreateRequestContext( + content::ProtocolHandlerMap*); PrefService* prefs() { return prefs_.get(); } -protected: + protected: // Subclasses should override this to register custom preferences. - virtual void RegisterPrefs(PrefRegistrySimple*) {} + virtual void RegisterPrefs(PrefRegistrySimple* pref_registry) {} - // Subclasses should override this to provide a custom NetworkDelegate implementation. + // Subclasses should override this to provide a custom NetworkDelegate + // implementation. virtual scoped_ptr CreateNetworkDelegate(); virtual base::FilePath GetPath() const OVERRIDE; -private: + private: class ResourceContext; - void RegisterInternalPrefs(PrefRegistrySimple*); + void RegisterInternalPrefs(PrefRegistrySimple* pref_registry); virtual bool IsOffTheRecord() const OVERRIDE; virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; - virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(int renderer_child_id); + virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess( + int renderer_child_id); virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE; - virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(int renderer_child_id) OVERRIDE; - virtual net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition(const base::FilePath& partition_path, bool in_memory); - virtual void RequestMIDISysExPermission(int render_process_id, int render_view_id, const GURL& requesting_frame, const MIDISysExPermissionCallback&) OVERRIDE; + virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( + int renderer_child_id) OVERRIDE; + virtual net::URLRequestContextGetter* + GetMediaRequestContextForStoragePartition( + const base::FilePath& partition_path, bool in_memory); + virtual void RequestMIDISysExPermission( + int render_process_id, + int render_view_id, + const GURL& requesting_frame, + const MIDISysExPermissionCallback&) OVERRIDE; virtual content::ResourceContext* GetResourceContext() OVERRIDE; - virtual content::DownloadManagerDelegate* GetDownloadManagerDelegate() OVERRIDE; - virtual content::GeolocationPermissionContext* GetGeolocationPermissionContext() OVERRIDE; - virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; + virtual content::DownloadManagerDelegate* + GetDownloadManagerDelegate() OVERRIDE; + virtual content::GeolocationPermissionContext* + GetGeolocationPermissionContext() OVERRIDE; + virtual quota::SpecialStoragePolicy* + GetSpecialStoragePolicy() OVERRIDE; base::FilePath path_; scoped_ptr resource_context_; @@ -63,6 +76,6 @@ private: DISALLOW_COPY_AND_ASSIGN(BrowserContext); }; -} +} // namespace brightray #endif diff --git a/brightray/browser/browser_main_parts.cc b/brightray/browser/browser_main_parts.cc index c41a6a3a6f3..60057034f6e 100644 --- a/brightray/browser/browser_main_parts.cc +++ b/brightray/browser/browser_main_parts.cc @@ -19,8 +19,10 @@ void BrowserMainParts::PreMainMessageLoopRun() { browser_context_.reset(CreateBrowserContext()); browser_context_->Initialize(); - web_ui_controller_factory_.reset(new WebUIControllerFactory(browser_context_.get())); - content::WebUIControllerFactory::RegisterFactory(web_ui_controller_factory_.get()); + web_ui_controller_factory_.reset( + new WebUIControllerFactory(browser_context_.get())); + content::WebUIControllerFactory::RegisterFactory( + web_ui_controller_factory_.get()); } void BrowserMainParts::PostMainMessageLoopRun() { @@ -31,4 +33,4 @@ BrowserContext* BrowserMainParts::CreateBrowserContext() { return new BrowserContext; } -} +} // namespace brightray diff --git a/brightray/browser/browser_main_parts.h b/brightray/browser/browser_main_parts.h index 210ff7e31ba..f0aeb427796 100644 --- a/brightray/browser/browser_main_parts.h +++ b/brightray/browser/browser_main_parts.h @@ -15,15 +15,15 @@ class BrowserContext; class WebUIControllerFactory; class BrowserMainParts : public content::BrowserMainParts { -public: + public: BrowserMainParts(); ~BrowserMainParts(); BrowserContext* browser_context() { return browser_context_.get(); } -protected: - // Subclasses should override this to provide their own BrowserContxt implementation. The caller - // takes ownership of the returned object. + protected: + // Subclasses should override this to provide their own BrowserContxt + // implementation. The caller takes ownership of the returned object. virtual BrowserContext* CreateBrowserContext(); #if defined(OS_MACOSX) @@ -33,13 +33,13 @@ protected: virtual void PreMainMessageLoopRun() OVERRIDE; virtual void PostMainMessageLoopRun() OVERRIDE; -private: + private: scoped_ptr browser_context_; scoped_ptr web_ui_controller_factory_; DISALLOW_COPY_AND_ASSIGN(BrowserMainParts); }; -} +} // namespace brightray #endif diff --git a/brightray/browser/default_web_contents_delegate.cc b/brightray/browser/default_web_contents_delegate.cc index f4e08b84098..05bdac399ad 100644 --- a/brightray/browser/default_web_contents_delegate.cc +++ b/brightray/browser/default_web_contents_delegate.cc @@ -18,4 +18,4 @@ void DefaultWebContentsDelegate::RequestMediaAccessPermission( controller.TakeAction(); } -} +} // namespace brightray diff --git a/brightray/browser/default_web_contents_delegate.h b/brightray/browser/default_web_contents_delegate.h index b4dabdd03b8..5b16b10f653 100644 --- a/brightray/browser/default_web_contents_delegate.h +++ b/brightray/browser/default_web_contents_delegate.h @@ -5,22 +5,24 @@ namespace brightray { -// This class provides some sane default behaviors to any content::WebContents instance (e.g., -// keyboard shortcut handling on Mac). +// This class provides some sane default behaviors to any content::WebContents +// instance (e.g., keyboard shortcut handling on Mac). class DefaultWebContentsDelegate : public content::WebContentsDelegate { -public: + public: DefaultWebContentsDelegate(); ~DefaultWebContentsDelegate(); -protected: - virtual void RequestMediaAccessPermission(content::WebContents*, - const content::MediaStreamRequest&, - const content::MediaResponseCallback&) OVERRIDE; + protected: + virtual void RequestMediaAccessPermission( + content::WebContents*, + const content::MediaStreamRequest&, + const content::MediaResponseCallback&) OVERRIDE; #if defined(OS_MACOSX) - virtual void HandleKeyboardEvent(content::WebContents*, const content::NativeWebKeyboardEvent&) OVERRIDE; + virtual void HandleKeyboardEvent( + content::WebContents*, const content::NativeWebKeyboardEvent&) OVERRIDE; #endif }; -} +} // namespace brightray #endif diff --git a/brightray/browser/devtools_ui.cc b/brightray/browser/devtools_ui.cc index 94e581728ab..def3ecb4694 100644 --- a/brightray/browser/devtools_ui.cc +++ b/brightray/browser/devtools_ui.cc @@ -90,12 +90,12 @@ class BundledDataSource : public content::URLDataSource { DISALLOW_COPY_AND_ASSIGN(BundledDataSource); }; -} +} // namespace DevToolsUI::DevToolsUI(BrowserContext* browser_context, content::WebUI* web_ui) - : WebUIController(web_ui) { + : WebUIController(web_ui) { web_ui->SetBindings(0); content::URLDataSource::Add(browser_context, new BundledDataSource()); } -} +} // namespace brightray diff --git a/brightray/browser/devtools_ui.h b/brightray/browser/devtools_ui.h index 70ab0f2686d..1f5ff4f7217 100644 --- a/brightray/browser/devtools_ui.h +++ b/brightray/browser/devtools_ui.h @@ -20,6 +20,6 @@ class DevToolsUI : public content::WebUIController { DISALLOW_COPY_AND_ASSIGN(DevToolsUI); }; -} +} // namespace brightray #endif diff --git a/brightray/browser/download_manager_delegate.h b/brightray/browser/download_manager_delegate.h index c25d2e7a16a..95ac7d5a817 100644 --- a/brightray/browser/download_manager_delegate.h +++ b/brightray/browser/download_manager_delegate.h @@ -14,6 +14,6 @@ class DownloadManagerDelegate : public content::DownloadManagerDelegate { DISALLOW_COPY_AND_ASSIGN(DownloadManagerDelegate); }; -} +} // namespace brightray #endif diff --git a/brightray/browser/inspectable_web_contents.cc b/brightray/browser/inspectable_web_contents.cc index 5e3af6013de..5090011a203 100644 --- a/brightray/browser/inspectable_web_contents.cc +++ b/brightray/browser/inspectable_web_contents.cc @@ -6,7 +6,8 @@ namespace brightray { -InspectableWebContents* InspectableWebContents::Create(const content::WebContents::CreateParams& create_params) { +InspectableWebContents* InspectableWebContents::Create( + const content::WebContents::CreateParams& create_params) { auto contents = content::WebContents::Create(create_params); #if defined(OS_MACOSX) // Work around http://crbug.com/279472. @@ -16,8 +17,9 @@ InspectableWebContents* InspectableWebContents::Create(const content::WebContent return Create(contents); } -InspectableWebContents* InspectableWebContents::Create(content::WebContents* web_contents) { +InspectableWebContents* InspectableWebContents::Create( + content::WebContents* web_contents) { return new InspectableWebContentsImpl(web_contents); } -} +} // namespace brightray diff --git a/brightray/browser/inspectable_web_contents.h b/brightray/browser/inspectable_web_contents.h index 0a585146866..9c381ae7403 100644 --- a/brightray/browser/inspectable_web_contents.h +++ b/brightray/browser/inspectable_web_contents.h @@ -8,10 +8,12 @@ namespace brightray { class InspectableWebContentsView; class InspectableWebContents { -public: - static InspectableWebContents* Create(const content::WebContents::CreateParams&); + public: + static InspectableWebContents* Create( + const content::WebContents::CreateParams&); - // The returned InspectableWebContents takes ownership of the passed-in WebContents. + // The returned InspectableWebContents takes ownership of the passed-in + // WebContents. static InspectableWebContents* Create(content::WebContents*); virtual ~InspectableWebContents() {} @@ -22,6 +24,6 @@ public: virtual void ShowDevTools() = 0; }; -} +} // namespace brightray #endif diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 08d820d4631..5f561953218 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -31,15 +31,18 @@ const char kDockSidePref[] = "brightray.devtools.dockside"; } // Implemented separately on each platform. -InspectableWebContentsView* CreateInspectableContentsView(InspectableWebContentsImpl*); +InspectableWebContentsView* CreateInspectableContentsView( + InspectableWebContentsImpl* inspectable_web_contents_impl); void InspectableWebContentsImpl::RegisterPrefs(PrefRegistrySimple* registry) { registry->RegisterStringPref(kDockSidePref, "bottom"); } -InspectableWebContentsImpl::InspectableWebContentsImpl(content::WebContents* web_contents) +InspectableWebContentsImpl::InspectableWebContentsImpl( + content::WebContents* web_contents) : web_contents_(web_contents) { - auto context = static_cast(web_contents_->GetBrowserContext()); + auto context = static_cast( + web_contents_->GetBrowserContext()); dock_side_ = context->prefs()->GetString(kDockSidePref); view_.reset(CreateInspectableContentsView(this)); @@ -58,7 +61,9 @@ content::WebContents* InspectableWebContentsImpl::GetWebContents() const { void InspectableWebContentsImpl::ShowDevTools() { if (!devtools_web_contents_) { - devtools_web_contents_.reset(content::WebContents::Create(content::WebContents::CreateParams(web_contents_->GetBrowserContext()))); + auto create_params = content::WebContents::CreateParams( + web_contents_->GetBrowserContext()); + devtools_web_contents_.reset(content::WebContents::Create(create_params)); #if defined(OS_MACOSX) // Work around http://crbug.com/279472. @@ -68,12 +73,20 @@ void InspectableWebContentsImpl::ShowDevTools() { Observe(devtools_web_contents_.get()); devtools_web_contents_->SetDelegate(this); - agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents_->GetRenderViewHost()); - frontend_host_.reset(content::DevToolsClientHost::CreateDevToolsFrontendHost(devtools_web_contents_.get(), this)); - content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(agent_host_, frontend_host_.get()); + agent_host_ = content::DevToolsAgentHost::GetOrCreateFor( + web_contents_->GetRenderViewHost()); + frontend_host_.reset( + content::DevToolsClientHost::CreateDevToolsFrontendHost( + devtools_web_contents_.get(), this)); + content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( + agent_host_, frontend_host_.get()); GURL devtools_url(kChromeUIDevToolsURL); - devtools_web_contents_->GetController().LoadURL(devtools_url, content::Referrer(), content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); + devtools_web_contents_->GetController().LoadURL( + devtools_url, + content::Referrer(), + content::PAGE_TRANSITION_AUTO_TOPLEVEL, + std::string()); } view_->SetDockSide(dock_side_); @@ -81,8 +94,10 @@ void InspectableWebContentsImpl::ShowDevTools() { } void InspectableWebContentsImpl::UpdateFrontendDockSide() { - auto javascript = base::StringPrintf("InspectorFrontendAPI.setDockSide(\"%s\")", dock_side_.c_str()); - devtools_web_contents_->GetRenderViewHost()->ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(javascript)); + auto javascript = base::StringPrintf( + "InspectorFrontendAPI.setDockSide(\"%s\")", dock_side_.c_str()); + devtools_web_contents_->GetRenderViewHost()->ExecuteJavascriptInWebFrame( + string16(), ASCIIToUTF16(javascript)); } void InspectableWebContentsImpl::ActivateWindow() { @@ -106,7 +121,8 @@ void InspectableWebContentsImpl::SetDockSide(const std::string& side) { dock_side_ = side; - auto context = static_cast(web_contents_->GetBrowserContext()); + auto context = static_cast( + web_contents_->GetBrowserContext()); context->prefs()->SetString(kDockSidePref, side); UpdateFrontendDockSide(); @@ -115,10 +131,12 @@ void InspectableWebContentsImpl::SetDockSide(const std::string& side) { void InspectableWebContentsImpl::OpenInNewTab(const std::string& url) { } -void InspectableWebContentsImpl::SaveToFile(const std::string& url, const std::string& content, bool save_as) { +void InspectableWebContentsImpl::SaveToFile( + const std::string& url, const std::string& content, bool save_as) { } -void InspectableWebContentsImpl::AppendToFile(const std::string& url, const std::string& content) { +void InspectableWebContentsImpl::AppendToFile( + const std::string& url, const std::string& content) { } void InspectableWebContentsImpl::RequestFileSystems() { @@ -127,26 +145,36 @@ void InspectableWebContentsImpl::RequestFileSystems() { void InspectableWebContentsImpl::AddFileSystem() { } -void InspectableWebContentsImpl::RemoveFileSystem(const std::string& file_system_path) { +void InspectableWebContentsImpl::RemoveFileSystem( + const std::string& file_system_path) { } -void InspectableWebContentsImpl::IndexPath(int request_id, const std::string& file_system_path) { +void InspectableWebContentsImpl::IndexPath( + int request_id, const std::string& file_system_path) { } void InspectableWebContentsImpl::StopIndexing(int request_id) { } -void InspectableWebContentsImpl::SearchInPath(int request_id, const std::string& file_system_path, const std::string& query) { +void InspectableWebContentsImpl::SearchInPath( + int request_id, + const std::string& file_system_path, + const std::string& query) { } void InspectableWebContentsImpl::InspectedContentsClosing() { } -void InspectableWebContentsImpl::AboutToNavigateRenderView(content::RenderViewHost* render_view_host) { - content::DevToolsClientHost::SetupDevToolsFrontendClient(web_contents()->GetRenderViewHost()); +void InspectableWebContentsImpl::AboutToNavigateRenderView( + content::RenderViewHost* render_view_host) { + content::DevToolsClientHost::SetupDevToolsFrontendClient( + web_contents()->GetRenderViewHost()); } -void InspectableWebContentsImpl::DidFinishLoad(int64, const GURL&, bool is_main_frame, content::RenderViewHost*) { +void InspectableWebContentsImpl::DidFinishLoad(int64 frame_id, + const GURL& validated_url, + bool is_main_frame, + content::RenderViewHost*) { if (!is_main_frame) return; @@ -154,16 +182,19 @@ void InspectableWebContentsImpl::DidFinishLoad(int64, const GURL&, bool is_main_ } void InspectableWebContentsImpl::WebContentsDestroyed(content::WebContents*) { - content::DevToolsManager::GetInstance()->ClientHostClosing(frontend_host_.get()); + content::DevToolsManager::GetInstance()->ClientHostClosing( + frontend_host_.get()); Observe(nullptr); agent_host_ = nullptr; frontend_host_.reset(); } -void InspectableWebContentsImpl::HandleKeyboardEvent(content::WebContents* source, const content::NativeWebKeyboardEvent& event) { +void InspectableWebContentsImpl::HandleKeyboardEvent( + content::WebContents* source, + const content::NativeWebKeyboardEvent& event) { auto delegate = web_contents_->GetDelegate(); if (delegate) delegate->HandleKeyboardEvent(source, event); } -} +} // namespace brightray diff --git a/brightray/browser/inspectable_web_contents_impl.h b/brightray/browser/inspectable_web_contents_impl.h index f81ccc0185a..50592fd3fc5 100644 --- a/brightray/browser/inspectable_web_contents_impl.h +++ b/brightray/browser/inspectable_web_contents_impl.h @@ -28,10 +28,10 @@ class InspectableWebContentsImpl : content::DevToolsFrontendHostDelegate, content::WebContentsObserver, content::WebContentsDelegate { -public: - static void RegisterPrefs(PrefRegistrySimple*); + public: + static void RegisterPrefs(PrefRegistrySimple* pref_registry); - InspectableWebContentsImpl(content::WebContents*); + explicit InspectableWebContentsImpl(content::WebContents*); virtual ~InspectableWebContentsImpl(); virtual InspectableWebContentsView* GetView() const OVERRIDE; @@ -39,13 +39,15 @@ public: virtual void ShowDevTools() OVERRIDE; - content::WebContents* devtools_web_contents() { return devtools_web_contents_.get(); } + content::WebContents* devtools_web_contents() { + return devtools_web_contents_.get(); + } -private: + private: void UpdateFrontendDockSide(); // content::DevToolsFrontendHostDelegate - + virtual void ActivateWindow() OVERRIDE; virtual void ChangeAttachedWindowHeight(unsigned height) OVERRIDE; virtual void CloseWindow() OVERRIDE; @@ -60,16 +62,18 @@ private: virtual void RequestFileSystems() OVERRIDE; virtual void AddFileSystem() OVERRIDE; virtual void RemoveFileSystem(const std::string& file_system_path) OVERRIDE; - virtual void IndexPath(int request_id, const std::string& file_system_path) OVERRIDE; + virtual void IndexPath(int request_id, + const std::string& file_system_path) OVERRIDE; virtual void StopIndexing(int request_id) OVERRIDE; virtual void SearchInPath(int request_id, const std::string& file_system_path, const std::string& query) OVERRIDE; virtual void InspectedContentsClosing() OVERRIDE; - + // content::WebContentsObserver - - virtual void AboutToNavigateRenderView(content::RenderViewHost* render_view_host) OVERRIDE; + + virtual void AboutToNavigateRenderView( + content::RenderViewHost* render_view_host) OVERRIDE; virtual void DidFinishLoad(int64 frame_id, const GURL& validated_url, bool is_main_frame, @@ -77,9 +81,10 @@ private: virtual void WebContentsDestroyed(content::WebContents*) OVERRIDE; // content::WebContentsDelegate - - virtual void HandleKeyboardEvent(content::WebContents*, const content::NativeWebKeyboardEvent&) OVERRIDE; - + + virtual void HandleKeyboardEvent( + content::WebContents*, const content::NativeWebKeyboardEvent&) OVERRIDE; + scoped_ptr web_contents_; scoped_ptr frontend_host_; scoped_ptr devtools_web_contents_; @@ -90,6 +95,6 @@ private: DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsImpl); }; -} +} // namespace brightray #endif diff --git a/brightray/browser/inspectable_web_contents_view.h b/brightray/browser/inspectable_web_contents_view.h index 3964cc682c0..eed32f34919 100644 --- a/brightray/browser/inspectable_web_contents_view.h +++ b/brightray/browser/inspectable_web_contents_view.h @@ -6,7 +6,7 @@ namespace brightray { class InspectableWebContentsView { -public: + public: virtual ~InspectableWebContentsView() {} virtual gfx::NativeView GetNativeView() const = 0; @@ -16,6 +16,6 @@ public: virtual bool SetDockSide(const std::string& side) = 0; }; -} +} // namespace brightray #endif diff --git a/brightray/browser/inspectable_web_contents_view_mac.h b/brightray/browser/inspectable_web_contents_view_mac.h index 1b5a6e43322..f31149f570b 100644 --- a/brightray/browser/inspectable_web_contents_view_mac.h +++ b/brightray/browser/inspectable_web_contents_view_mac.h @@ -1,9 +1,9 @@ #ifndef BRIGHTRAY_BROWSER_INSPECTABLE_WEB_CONTENTS_VIEW_MAC_H_ #define BRIGHTRAY_BROWSER_INSPECTABLE_WEB_CONTENTS_VIEW_MAC_H_ -#import "browser/inspectable_web_contents_view.h" +#include "browser/inspectable_web_contents_view.h" -#import "base/mac/scoped_nsobject.h" +#include "base/mac/scoped_nsobject.h" @class BRYInspectableWebContentsView; @@ -12,25 +12,28 @@ namespace brightray { class InspectableWebContentsImpl; class InspectableWebContentsViewMac : public InspectableWebContentsView { -public: - InspectableWebContentsViewMac(InspectableWebContentsImpl*); - + public: + explicit InspectableWebContentsViewMac( + InspectableWebContentsImpl* inspectable_web_contents_impl); + virtual gfx::NativeView GetNativeView() const OVERRIDE; virtual void ShowDevTools() OVERRIDE; virtual void CloseDevTools() OVERRIDE; virtual bool SetDockSide(const std::string& side) OVERRIDE; - InspectableWebContentsImpl* inspectable_web_contents() { return inspectable_web_contents_; } + InspectableWebContentsImpl* inspectable_web_contents() { + return inspectable_web_contents_; + } -private: + private: // Owns us. InspectableWebContentsImpl* inspectable_web_contents_; - + base::scoped_nsobject view_; DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewMac); }; -} +} // namespace brightray #endif diff --git a/brightray/browser/linux/inspectable_web_contents_view_linux.cc b/brightray/browser/linux/inspectable_web_contents_view_linux.cc index eb792aa69d8..cbe8e4e9c34 100644 --- a/brightray/browser/linux/inspectable_web_contents_view_linux.cc +++ b/brightray/browser/linux/inspectable_web_contents_view_linux.cc @@ -1,4 +1,4 @@ -#include "inspectable_web_contents_view_linux.h" +#include "browser/linux/inspectable_web_contents_view_linux.h" #include #include @@ -10,12 +10,15 @@ namespace brightray { -InspectableWebContentsView* CreateInspectableContentsView(InspectableWebContentsImpl* inspectable_web_contents) { +InspectableWebContentsView* CreateInspectableContentsView( + InspectableWebContentsImpl* inspectable_web_contents) { return new InspectableWebContentsViewLinux(inspectable_web_contents); } -InspectableWebContentsViewLinux::InspectableWebContentsViewLinux(InspectableWebContentsImpl* inspectable_web_contents) - : inspectable_web_contents_(inspectable_web_contents), devtools_window_(NULL) { +InspectableWebContentsViewLinux::InspectableWebContentsViewLinux( + InspectableWebContentsImpl* inspectable_web_contents) + : inspectable_web_contents_(inspectable_web_contents), + devtools_window_(NULL) { } InspectableWebContentsViewLinux::~InspectableWebContentsViewLinux() { @@ -26,11 +29,13 @@ InspectableWebContentsViewLinux::~InspectableWebContentsViewLinux() { static void dump_one(GtkWidget *wat, int indent) { GtkAllocation alloc; gtk_widget_get_allocation(wat, &alloc); - fprintf(stderr, "%*s[%p] %s @%d,%d %dx%d", + fprintf(stderr, "%*s[%p] %s @%d,%d %dx%d", indent, "", wat, - g_type_name_from_instance((GTypeInstance*)wat), + g_type_name_from_instance(reinterpret_cast(wat)), alloc.x, alloc.y, alloc.width, alloc.height); - if (GTK_IS_WINDOW(wat)) fprintf(stderr, " - \"%s\"", gtk_window_get_title(GTK_WINDOW(wat))); + if (GTK_IS_WINDOW(wat)) { + fprintf(stderr, " - \"%s\"", gtk_window_get_title(GTK_WINDOW(wat))); + } fputc('\n', stderr); } @@ -41,21 +46,24 @@ static void dump_the_whole_tree(GtkWidget *wat, int indent) { } dump_one(wat, indent); GList *kids = gtk_container_get_children(GTK_CONTAINER(wat)); - for (GList *p=kids; p; p=p->next) { + for (GList *p = kids; p; p = p->next) { dump_the_whole_tree(GTK_WIDGET(p->data), indent+2); } } static void dump_parents(GtkWidget *wat) { fprintf(stderr, "Parents:\n"); - for (GtkWidget *p=gtk_widget_get_parent(wat); p; p=gtk_widget_get_parent(p)) { + for (GtkWidget *p = gtk_widget_get_parent(wat); + p; + p = gtk_widget_get_parent(p)) { dump_one(p, 2); } } #endif gfx::NativeView InspectableWebContentsViewLinux::GetNativeView() const { - return inspectable_web_contents_->GetWebContents()->GetView()->GetNativeView(); + auto web_contents = inspectable_web_contents_->GetWebContents(); + return web_contents->GetView()->GetNativeView(); } @@ -90,18 +98,24 @@ gfx::NativeView InspectableWebContentsViewLinux::GetNativeView() const { */ void InspectableWebContentsViewLinux::ShowDevTools() { - GtkWidget *devtools = inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(); + auto devtools_web_contents = + inspectable_web_contents()->devtools_web_contents(); + GtkWidget *devtools = devtools_web_contents->GetView()->GetNativeView(); GtkWidget *parent = gtk_widget_get_parent(devtools); - DLOG(INFO) << base::StringPrintf("InspectableWebContentsViewLinux::ShowDevTools - parent=%s@%p window=%p dockside=\"%s\"", - g_type_name_from_instance((GTypeInstance*)parent), parent, devtools_window_, dockside_.c_str()); + DLOG(INFO) << base::StringPrintf( + "InspectableWebContentsViewLinux::ShowDevTools - " \ + "parent=%s@%p window=%p dockside=\"%s\"", + g_type_name_from_instance(reinterpret_cast(parent)), + parent, + devtools_window_, + dockside_.c_str()); if (!parent || GTK_IS_PANED(parent)) { if (dockside_ == "undocked") ShowDevToolsInWindow(); else if (dockside_ == "bottom") ShowDevToolsInPane(true); else if (dockside_ == "right") ShowDevToolsInPane(false); - } - else { + } else { DCHECK(parent == devtools_window_); if (dockside_ == "undocked") gtk_widget_show_all(parent); else if (dockside_ == "bottom") ShowDevToolsInPane(true); @@ -110,16 +124,22 @@ void InspectableWebContentsViewLinux::ShowDevTools() { } void InspectableWebContentsViewLinux::CloseDevTools() { - GtkWidget *devtools = inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(); + auto devtools_web_contents = + inspectable_web_contents()->devtools_web_contents(); + GtkWidget *devtools = devtools_web_contents->GetView()->GetNativeView(); GtkWidget *parent = gtk_widget_get_parent(devtools); - DLOG(INFO) << base::StringPrintf("InspectableWebContentsViewLinux::CloseDevTools - parent=%s@%p window=%p dockside=\"%s\"", - g_type_name_from_instance((GTypeInstance*)parent), parent, devtools_window_, dockside_.c_str()); + DLOG(INFO) << base::StringPrintf( + "InspectableWebContentsViewLinux::CloseDevTools - " \ + "parent=%s@%p window=%p dockside=\"%s\"", + g_type_name_from_instance(reinterpret_cast(parent)), + parent, + devtools_window_, + dockside_.c_str()); if (!parent) { return; // Not visible -> nothing to do - } - else if (GTK_IS_PANED(parent)) { + } else if (GTK_IS_PANED(parent)) { GtkWidget *browser = GetBrowserWindow(); GtkWidget *view = GetNativeView(); @@ -129,22 +149,26 @@ void InspectableWebContentsViewLinux::CloseDevTools() { gtk_container_remove(GTK_CONTAINER(browser), parent); gtk_widget_reparent(view, browser); g_object_unref(parent); - } - else { + } else { DCHECK(parent == devtools_window_); gtk_widget_hide(parent); } } bool InspectableWebContentsViewLinux::SetDockSide(const std::string& side) { - DLOG(INFO) << "InspectableWebContentsViewLinux::SetDockSide: \"" << side << "\""; - if (side != "undocked" && side != "bottom" && side != "right") return false; // unsupported display location - if (dockside_ == side) return true; // no change from current location + DLOG(INFO) << + "InspectableWebContentsViewLinux::SetDockSide: \"" << side << "\""; + if (side != "undocked" && side != "bottom" && side != "right") + return false; // unsupported display location + if (dockside_ == side) + return true; // no change from current location dockside_ = side; // If devtools already has a parent, then we're being asked to move it. - GtkWidget *devtools = inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(); + auto devtools_web_contents = + inspectable_web_contents()->devtools_web_contents(); + GtkWidget *devtools = devtools_web_contents->GetView()->GetNativeView(); if (gtk_widget_get_parent(devtools)) { ShowDevTools(); } @@ -153,14 +177,16 @@ bool InspectableWebContentsViewLinux::SetDockSide(const std::string& side) { } void InspectableWebContentsViewLinux::ShowDevToolsInWindow() { - GtkWidget *devtools = inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(); + auto devtools_web_contents = + inspectable_web_contents()->devtools_web_contents(); + GtkWidget *devtools = devtools_web_contents->GetView()->GetNativeView(); GtkWidget *parent = gtk_widget_get_parent(devtools); - if (!devtools_window_) MakeDevToolsWindow(); + if (!devtools_window_) + MakeDevToolsWindow(); if (!parent) { gtk_container_add(GTK_CONTAINER(devtools_window_), devtools); - } - else if (parent != devtools_window_) { + } else if (parent != devtools_window_) { DCHECK(GTK_IS_PANED(parent)); gtk_widget_reparent(devtools, devtools_window_); @@ -181,11 +207,16 @@ void InspectableWebContentsViewLinux::MakeDevToolsWindow() { devtools_window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(devtools_window_), "Developer Tools"); gtk_window_set_default_size(GTK_WINDOW(devtools_window_), 800, 600); - g_signal_connect(GTK_OBJECT(devtools_window_), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), this); + g_signal_connect(GTK_OBJECT(devtools_window_), + "delete-event", + G_CALLBACK(gtk_widget_hide_on_delete), + this); } void InspectableWebContentsViewLinux::ShowDevToolsInPane(bool on_bottom) { - GtkWidget *devtools = inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(); + auto devtools_web_contents = + inspectable_web_contents()->devtools_web_contents(); + GtkWidget *devtools = devtools_web_contents->GetView()->GetNativeView(); GtkWidget *parent = gtk_widget_get_parent(devtools); GtkWidget *pane = on_bottom ? gtk_vpaned_new() : gtk_hpaned_new(); GtkWidget *view = GetNativeView(); @@ -193,15 +224,15 @@ void InspectableWebContentsViewLinux::ShowDevToolsInPane(bool on_bottom) { GtkAllocation alloc; gtk_widget_get_allocation(browser, &alloc); - gtk_paned_set_position(GTK_PANED(pane), on_bottom ? alloc.height*2/3 : alloc.width/2); + gtk_paned_set_position(GTK_PANED(pane), + on_bottom ? alloc.height * 2 / 3 : alloc.width / 2); if (!parent) { g_object_ref(view); gtk_container_remove(GTK_CONTAINER(browser), view); gtk_paned_add1(GTK_PANED(pane), view); gtk_paned_add2(GTK_PANED(pane), devtools); g_object_unref(view); - } - else if (GTK_IS_PANED(parent)) { + } else if (GTK_IS_PANED(parent)) { g_object_ref(view); g_object_ref(devtools); gtk_container_remove(GTK_CONTAINER(parent), view); @@ -211,8 +242,7 @@ void InspectableWebContentsViewLinux::ShowDevToolsInPane(bool on_bottom) { g_object_unref(view); g_object_unref(devtools); gtk_container_remove(GTK_CONTAINER(browser), parent); - } - else { + } else { DCHECK(parent == devtools_window_); g_object_ref(view); gtk_container_remove(GTK_CONTAINER(devtools_window_), devtools); @@ -229,9 +259,10 @@ void InspectableWebContentsViewLinux::ShowDevToolsInPane(bool on_bottom) { GtkWidget *InspectableWebContentsViewLinux::GetBrowserWindow() { GtkWidget *view = GetNativeView(); GtkWidget *parent = gtk_widget_get_parent(view); - GtkWidget *browser = GTK_IS_PANED(parent) ? gtk_widget_get_parent(parent) : parent; + GtkWidget *browser = + GTK_IS_PANED(parent) ? gtk_widget_get_parent(parent) : parent; DCHECK(GTK_IS_WINDOW(browser)); return browser; } -} +} // namespace brightray diff --git a/brightray/browser/linux/inspectable_web_contents_view_linux.h b/brightray/browser/linux/inspectable_web_contents_view_linux.h index f82de0a54cd..c6605b3939f 100644 --- a/brightray/browser/linux/inspectable_web_contents_view_linux.h +++ b/brightray/browser/linux/inspectable_web_contents_view_linux.h @@ -10,8 +10,9 @@ namespace brightray { class InspectableWebContentsImpl; class InspectableWebContentsViewLinux : public InspectableWebContentsView { -public: - InspectableWebContentsViewLinux(InspectableWebContentsImpl*); + public: + explicit InspectableWebContentsViewLinux( + InspectableWebContentsImpl* inspectable_web_contents_impl); ~InspectableWebContentsViewLinux(); virtual gfx::NativeView GetNativeView() const OVERRIDE; @@ -19,9 +20,11 @@ public: virtual void CloseDevTools() OVERRIDE; virtual bool SetDockSide(const std::string& side) OVERRIDE; - InspectableWebContentsImpl* inspectable_web_contents() { return inspectable_web_contents_; } + InspectableWebContentsImpl* inspectable_web_contents() { + return inspectable_web_contents_; + } -private: + private: // Show the dev tools in their own window. If they're already shown // somewhere else, remove them cleanly and take any GtkPaned out of the // window. @@ -49,6 +52,6 @@ private: DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewLinux); }; -} +} // namespace brightray #endif diff --git a/brightray/browser/mac/bry_application.h b/brightray/browser/mac/bry_application.h index f64d5db4e36..98594861496 100644 --- a/brightray/browser/mac/bry_application.h +++ b/brightray/browser/mac/bry_application.h @@ -1,6 +1,6 @@ #import "base/mac/scoped_sending_event.h" -@interface BRYApplication : NSApplication { +@interface BRYApplication : NSApplication { BOOL _handlingSendEvent; } diff --git a/brightray/browser/media/media_capture_devices_dispatcher.cc b/brightray/browser/media/media_capture_devices_dispatcher.cc index 1c3f9430050..eb3e6731a27 100644 --- a/brightray/browser/media/media_capture_devices_dispatcher.cc +++ b/brightray/browser/media/media_capture_devices_dispatcher.cc @@ -28,7 +28,7 @@ const content::MediaStreamDevice* FindDeviceWithId( } } return NULL; -}; +} } // namespace @@ -153,7 +153,6 @@ void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged( const content::MediaStreamDevice& device, content::MediaRequestState state) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - } void MediaCaptureDevicesDispatcher::OnAudioStreamPlayingChanged( @@ -175,10 +174,10 @@ void MediaCaptureDevicesDispatcher::UpdateAudioDevicesOnUIThread( } void MediaCaptureDevicesDispatcher::UpdateVideoDevicesOnUIThread( - const content::MediaStreamDevices& devices){ + const content::MediaStreamDevices& devices) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); devices_enumerated_ = true; video_devices_ = devices; } -} // namespace brightray +} // namespace brightray diff --git a/brightray/browser/media/media_capture_devices_dispatcher.h b/brightray/browser/media/media_capture_devices_dispatcher.h index 680455e2321..d10c27df1bc 100644 --- a/brightray/browser/media/media_capture_devices_dispatcher.h +++ b/brightray/browser/media/media_capture_devices_dispatcher.h @@ -97,6 +97,6 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver { DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher); }; -} // namespace brightray +} // namespace brightray #endif // BRIGHTRAY_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ diff --git a/brightray/browser/media/media_stream_devices_controller.cc b/brightray/browser/media/media_stream_devices_controller.cc index e6f0af89b73..a85c1c928d4 100644 --- a/brightray/browser/media/media_stream_devices_controller.cc +++ b/brightray/browser/media/media_stream_devices_controller.cc @@ -159,4 +159,4 @@ void MediaStreamDevicesController::Deny() { cb.Run(content::MediaStreamDevices(), scoped_ptr()); } -} // namespace brightray +} // namespace brightray diff --git a/brightray/browser/media/media_stream_devices_controller.h b/brightray/browser/media/media_stream_devices_controller.h index 820c8721365..9100fa4e27e 100644 --- a/brightray/browser/media/media_stream_devices_controller.h +++ b/brightray/browser/media/media_stream_devices_controller.h @@ -39,6 +39,6 @@ class MediaStreamDevicesController { DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController); }; -} // namespace brightray +} // namespace brightray #endif // BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ diff --git a/brightray/browser/network_delegate.cc b/brightray/browser/network_delegate.cc index 8213a744edb..6467dc3e3d6 100644 --- a/brightray/browser/network_delegate.cc +++ b/brightray/browser/network_delegate.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE-CHROMIUM file. -#include "network_delegate.h" +#include "browser/network_delegate.h" #include "net/base/net_errors.h" @@ -102,4 +102,4 @@ void NetworkDelegate::OnRequestWaitStateChange( RequestWaitState waiting) { } -} +} // namespace brightray diff --git a/brightray/browser/network_delegate.h b/brightray/browser/network_delegate.h index aff8e228856..0d4f2d3600c 100644 --- a/brightray/browser/network_delegate.h +++ b/brightray/browser/network_delegate.h @@ -15,28 +15,53 @@ class NetworkDelegate : public net::NetworkDelegate { virtual ~NetworkDelegate(); protected: - virtual int OnBeforeURLRequest(net::URLRequest* request, const net::CompletionCallback& callback, GURL* new_url) OVERRIDE; - virtual int OnBeforeSendHeaders(net::URLRequest* request, const net::CompletionCallback& callback, net::HttpRequestHeaders* headers) OVERRIDE; - virtual void OnSendHeaders(net::URLRequest* request, const net::HttpRequestHeaders& headers) OVERRIDE; - virtual int OnHeadersReceived(net::URLRequest* request, const net::CompletionCallback& callback, const net::HttpResponseHeaders* original_response_headers, scoped_refptr* override_response_headers) OVERRIDE; - virtual void OnBeforeRedirect(net::URLRequest* request, const GURL& new_location) OVERRIDE; + virtual int OnBeforeURLRequest(net::URLRequest* request, + const net::CompletionCallback& callback, + GURL* new_url) OVERRIDE; + virtual int OnBeforeSendHeaders(net::URLRequest* request, + const net::CompletionCallback& callback, + net::HttpRequestHeaders* headers) OVERRIDE; + virtual void OnSendHeaders(net::URLRequest* request, + const net::HttpRequestHeaders& headers) OVERRIDE; + virtual int OnHeadersReceived( + net::URLRequest* request, + const net::CompletionCallback& callback, + const net::HttpResponseHeaders* original_response_headers, + scoped_refptr* + override_response_headers) OVERRIDE; + virtual void OnBeforeRedirect(net::URLRequest* request, + const GURL& new_location) OVERRIDE; virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE; - virtual void OnRawBytesRead(const net::URLRequest& request, int bytes_read) OVERRIDE; + virtual void OnRawBytesRead(const net::URLRequest& request, + int bytes_read) OVERRIDE; virtual void OnCompleted(net::URLRequest* request, bool started) OVERRIDE; virtual void OnURLRequestDestroyed(net::URLRequest* request) OVERRIDE; - virtual void OnPACScriptError(int line_number, const string16& error) OVERRIDE; - virtual AuthRequiredResponse OnAuthRequired(net::URLRequest* request, const net::AuthChallengeInfo& auth_info, const AuthCallback& callback, net::AuthCredentials* credentials) OVERRIDE; - virtual bool OnCanGetCookies(const net::URLRequest& request, const net::CookieList& cookie_list) OVERRIDE; - virtual bool OnCanSetCookie(const net::URLRequest& request, const std::string& cookie_line, net::CookieOptions* options) OVERRIDE; - virtual bool OnCanAccessFile(const net::URLRequest& request, const base::FilePath& path) const OVERRIDE; - virtual bool OnCanThrottleRequest(const net::URLRequest& request) const OVERRIDE; - virtual int OnBeforeSocketStreamConnect(net::SocketStream* stream, const net::CompletionCallback& callback) OVERRIDE; - virtual void OnRequestWaitStateChange(const net::URLRequest& request, RequestWaitState state) OVERRIDE; + virtual void OnPACScriptError(int line_number, + const string16& error) OVERRIDE; + virtual AuthRequiredResponse OnAuthRequired( + net::URLRequest* request, + const net::AuthChallengeInfo& auth_info, + const AuthCallback& callback, + net::AuthCredentials* credentials) OVERRIDE; + virtual bool OnCanGetCookies(const net::URLRequest& request, + const net::CookieList& cookie_list) OVERRIDE; + virtual bool OnCanSetCookie(const net::URLRequest& request, + const std::string& cookie_line, + net::CookieOptions* options) OVERRIDE; + virtual bool OnCanAccessFile(const net::URLRequest& request, + const base::FilePath& path) const OVERRIDE; + virtual bool OnCanThrottleRequest( + const net::URLRequest& request) const OVERRIDE; + virtual int OnBeforeSocketStreamConnect( + net::SocketStream* stream, + const net::CompletionCallback& callback) OVERRIDE; + virtual void OnRequestWaitStateChange(const net::URLRequest& request, + RequestWaitState state) OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(NetworkDelegate); }; -} +} // namespace brightray #endif diff --git a/brightray/browser/notification_presenter.h b/brightray/browser/notification_presenter.h index a106edab208..db925f5e927 100644 --- a/brightray/browser/notification_presenter.h +++ b/brightray/browser/notification_presenter.h @@ -9,7 +9,7 @@ namespace brightray { class NotificationPresenter { public: - virtual ~NotificationPresenter() {}; + virtual ~NotificationPresenter() {} static NotificationPresenter* Create(); @@ -23,6 +23,6 @@ class NotificationPresenter { int notification_id) = 0; }; -} +} // namespace brightray #endif diff --git a/brightray/browser/notification_presenter_mac.h b/brightray/browser/notification_presenter_mac.h index b3757bf56ea..e4656b98f02 100644 --- a/brightray/browser/notification_presenter_mac.h +++ b/brightray/browser/notification_presenter_mac.h @@ -30,10 +30,12 @@ class NotificationPresenterMac : public NotificationPresenter { int notification_id) OVERRIDE; private: - std::map> notification_map_; + typedef std::map> + NotificationMap; + NotificationMap notification_map_; base::scoped_nsobject delegate_; }; -} +} // namespace brightray #endif diff --git a/brightray/browser/url_request_context_getter.cc b/brightray/browser/url_request_context_getter.cc index 4fe6d3f1b94..ecba106e96b 100644 --- a/brightray/browser/url_request_context_getter.cc +++ b/brightray/browser/url_request_context_getter.cc @@ -4,7 +4,10 @@ #include "browser/url_request_context_getter.h" -#include "network_delegate.h" +#include + +#include "browser/network_delegate.h" + #include "base/strings/string_util.h" #include "base/threading/worker_pool.h" #include "content/public/browser/browser_thread.h" @@ -43,7 +46,8 @@ URLRequestContextGetter::URLRequestContextGetter( std::swap(protocol_handlers_, *protocol_handlers); - proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService(io_loop_->message_loop_proxy(), file_loop_)); + proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService( + io_loop_->message_loop_proxy(), file_loop_)); } URLRequestContextGetter::~URLRequestContextGetter() { @@ -53,8 +57,7 @@ net::HostResolver* URLRequestContextGetter::host_resolver() { return url_request_context_->host_resolver(); } -net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() -{ +net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); if (!url_request_context_.get()) { @@ -87,7 +90,8 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults); storage_->set_http_auth_handler_factory( net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get())); - scoped_ptr server_properties(new net::HttpServerPropertiesImpl); + scoped_ptr server_properties( + new net::HttpServerPropertiesImpl); storage_->set_http_server_properties(server_properties.Pass()); base::FilePath cache_path = base_path_.Append(FILE_PATH_LITERAL("Cache")); @@ -130,21 +134,25 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() new net::URLRequestJobFactoryImpl()); for (auto it = protocol_handlers_.begin(), end = protocol_handlers_.end(); it != end; ++it) { - bool set_protocol = job_factory->SetProtocolHandler(it->first, it->second.release()); + bool set_protocol = job_factory->SetProtocolHandler( + it->first, it->second.release()); DCHECK(set_protocol); } protocol_handlers_.clear(); - job_factory->SetProtocolHandler(chrome::kDataScheme, new net::DataProtocolHandler); - job_factory->SetProtocolHandler(chrome::kFileScheme, new net::FileProtocolHandler); + job_factory->SetProtocolHandler( + chrome::kDataScheme, new net::DataProtocolHandler); + job_factory->SetProtocolHandler( + chrome::kFileScheme, new net::FileProtocolHandler); storage_->set_job_factory(job_factory.release()); } return url_request_context_.get(); } -scoped_refptr URLRequestContextGetter::GetNetworkTaskRunner() const -{ - return content::BrowserThread::GetMessageLoopProxyForThread(content::BrowserThread::IO); +scoped_refptr + URLRequestContextGetter::GetNetworkTaskRunner() const { + return content::BrowserThread::GetMessageLoopProxyForThread( + content::BrowserThread::IO); } -} +} // namespace brightray diff --git a/brightray/browser/url_request_context_getter.h b/brightray/browser/url_request_context_getter.h index 7d4efb6c00d..c9700250aad 100644 --- a/brightray/browser/url_request_context_getter.h +++ b/brightray/browser/url_request_context_getter.h @@ -25,7 +25,7 @@ namespace brightray { class NetworkDelegate; class URLRequestContextGetter : public net::URLRequestContextGetter { -public: + public: URLRequestContextGetter( const base::FilePath& base_path, base::MessageLoop* io_loop, @@ -37,8 +37,9 @@ public: net::HostResolver* host_resolver(); virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; -private: - virtual scoped_refptr GetNetworkTaskRunner() const OVERRIDE; + private: + virtual scoped_refptr + GetNetworkTaskRunner() const OVERRIDE; base::FilePath base_path_; base::MessageLoop* io_loop_; @@ -53,6 +54,6 @@ private: DISALLOW_COPY_AND_ASSIGN(URLRequestContextGetter); }; -} +} // namespace brightray #endif diff --git a/brightray/browser/web_ui_controller_factory.cc b/brightray/browser/web_ui_controller_factory.cc index 61f6bf993c5..9a9694de083 100644 --- a/brightray/browser/web_ui_controller_factory.cc +++ b/brightray/browser/web_ui_controller_factory.cc @@ -56,4 +56,4 @@ content::WebUIController* WebUIControllerFactory::CreateWebUIControllerForURL( return NULL; } -} +} // namespace brightray diff --git a/brightray/browser/web_ui_controller_factory.h b/brightray/browser/web_ui_controller_factory.h index 1ee3f9b2dfd..74db390746d 100644 --- a/brightray/browser/web_ui_controller_factory.h +++ b/brightray/browser/web_ui_controller_factory.h @@ -15,11 +15,11 @@ class BrowserContext; class WebUIControllerFactory : public content::WebUIControllerFactory { public: - WebUIControllerFactory(BrowserContext* browser_context); + explicit WebUIControllerFactory(BrowserContext* browser_context); virtual ~WebUIControllerFactory(); - virtual content::WebUI::TypeID GetWebUIType(content::BrowserContext* browser_context, - const GURL& url) const OVERRIDE; + virtual content::WebUI::TypeID GetWebUIType( + content::BrowserContext* browser_context, const GURL& url) const OVERRIDE; virtual bool UseWebUIForURL(content::BrowserContext* browser_context, const GURL& url) const OVERRIDE; virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context, @@ -37,6 +37,6 @@ class WebUIControllerFactory : public content::WebUIControllerFactory { DISALLOW_COPY_AND_ASSIGN(WebUIControllerFactory); }; -} +} // namespace brightray #endif diff --git a/brightray/browser/win/devtools_window.cc b/brightray/browser/win/devtools_window.cc index 8bed3e89f7d..9fc4b5dba88 100644 --- a/brightray/browser/win/devtools_window.cc +++ b/brightray/browser/win/devtools_window.cc @@ -8,7 +8,8 @@ namespace brightray { -DevToolsWindow* DevToolsWindow::Create(InspectableWebContentsViewWin* controller) { +DevToolsWindow* DevToolsWindow::Create( + InspectableWebContentsViewWin* controller) { return new DevToolsWindow(controller); } @@ -20,13 +21,18 @@ DevToolsWindow::~DevToolsWindow() { } LRESULT DevToolsWindow::OnCreate(UINT, WPARAM, LPARAM, BOOL&) { - SetParent(controller_->inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(), hwnd()); + auto devtools_web_contents = + controller_->inspectable_web_contents()->devtools_web_contents(); + SetParent(devtools_web_contents->GetView()->GetNativeView(), hwnd()); SetWindowText(hwnd(), L"Developer Tools"); return 0; } LRESULT DevToolsWindow::OnDestroy(UINT, WPARAM, LPARAM, BOOL&) { - SetParent(controller_->inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(), ui::GetHiddenWindow()); + auto devtools_web_contents = + controller_->inspectable_web_contents()->devtools_web_contents(); + SetParent( + devtools_web_contents->GetView()->GetNativeView(), ui::GetHiddenWindow()); delete this; return 0; } @@ -35,7 +41,9 @@ LRESULT DevToolsWindow::OnSize(UINT, WPARAM, LPARAM, BOOL&) { RECT rect; GetClientRect(hwnd(), &rect); - SetWindowPos(controller_->inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(), + auto devtools_web_contents = + controller_->inspectable_web_contents()->devtools_web_contents(); + SetWindowPos(devtools_web_contents->GetView()->GetNativeView(), nullptr, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, @@ -44,4 +52,4 @@ LRESULT DevToolsWindow::OnSize(UINT, WPARAM, LPARAM, BOOL&) { return 0; } -} +} // namespace brightray diff --git a/brightray/browser/win/devtools_window.h b/brightray/browser/win/devtools_window.h index 7181ab8e4d3..738af0a427c 100644 --- a/brightray/browser/win/devtools_window.h +++ b/brightray/browser/win/devtools_window.h @@ -8,9 +8,11 @@ namespace brightray { class InspectableWebContentsViewWin; -class DevToolsWindow : public ui::WindowImpl, public base::SupportsWeakPtr { +class DevToolsWindow : public ui::WindowImpl, + public base::SupportsWeakPtr { public: - static DevToolsWindow* Create(InspectableWebContentsViewWin*); + static DevToolsWindow* Create( + InspectableWebContentsViewWin* inspectable_web_contents_view_win); BEGIN_MSG_MAP_EX(DevToolsWindow) MESSAGE_HANDLER(WM_CREATE, OnCreate) @@ -19,7 +21,8 @@ class DevToolsWindow : public ui::WindowImpl, public base::SupportsWeakPtrGetWebContents()->GetView()->GetNativeView(); + auto web_contents = inspectable_web_contents_->GetWebContents(); + return web_contents->GetView()->GetNativeView(); } void InspectableWebContentsViewWin::ShowDevTools() { @@ -41,7 +44,9 @@ void InspectableWebContentsViewWin::ShowDevTools() { auto contents_view = inspectable_web_contents_->GetWebContents()->GetView(); auto size = contents_view->GetContainerSize(); size.Enlarge(-kWindowInset, -kWindowInset); - ui::CenterAndSizeWindow(contents_view->GetNativeView(), devtools_window_->hwnd(), size); + ui::CenterAndSizeWindow(contents_view->GetNativeView(), + devtools_window_->hwnd(), + size); ShowWindow(devtools_window_->hwnd(), SW_SHOWNORMAL); } @@ -56,4 +61,4 @@ bool InspectableWebContentsViewWin::SetDockSide(const std::string& side) { return false; } -} +} // namespace brightray diff --git a/brightray/browser/win/inspectable_web_contents_view_win.h b/brightray/browser/win/inspectable_web_contents_view_win.h index 8f5816fb4e7..534f4997284 100644 --- a/brightray/browser/win/inspectable_web_contents_view_win.h +++ b/brightray/browser/win/inspectable_web_contents_view_win.h @@ -12,8 +12,9 @@ class DevToolsWindow; class InspectableWebContentsImpl; class InspectableWebContentsViewWin : public InspectableWebContentsView { -public: - InspectableWebContentsViewWin(InspectableWebContentsImpl*); + public: + explicit InspectableWebContentsViewWin( + InspectableWebContentsImpl* inspectable_web_contents_impl); ~InspectableWebContentsViewWin(); virtual gfx::NativeView GetNativeView() const OVERRIDE; @@ -21,9 +22,11 @@ public: virtual void CloseDevTools() OVERRIDE; virtual bool SetDockSide(const std::string& side) OVERRIDE; - InspectableWebContentsImpl* inspectable_web_contents() { return inspectable_web_contents_; } + InspectableWebContentsImpl* inspectable_web_contents() { + return inspectable_web_contents_; + } -private: + private: // Owns us. InspectableWebContentsImpl* inspectable_web_contents_; @@ -32,6 +35,6 @@ private: DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewWin); }; -} +} // namespace brightray #endif diff --git a/brightray/common/application_info_win.cc b/brightray/common/application_info_win.cc index 49c53796358..696d8b36b5e 100644 --- a/brightray/common/application_info_win.cc +++ b/brightray/common/application_info_win.cc @@ -7,13 +7,17 @@ namespace brightray { std::string GetApplicationName() { - auto info = make_scoped_ptr(FileVersionInfo::CreateFileVersionInfoForModule(GetModuleHandle(nullptr))); + auto module = GetModuleHandle(nullptr); + auto info = make_scoped_ptr( + FileVersionInfo::CreateFileVersionInfoForModule(module)); return UTF16ToUTF8(info->product_name()); } std::string GetApplicationVersion() { - auto info = make_scoped_ptr(FileVersionInfo::CreateFileVersionInfoForModule(GetModuleHandle(nullptr))); + auto module = GetModuleHandle(nullptr); + auto info = make_scoped_ptr( + FileVersionInfo::CreateFileVersionInfoForModule(module)); return UTF16ToUTF8(info->product_version()); } -} +} // namespace brightray diff --git a/brightray/common/content_client.cc b/brightray/common/content_client.cc index a518cc026ca..dd6ce530690 100644 --- a/brightray/common/content_client.cc +++ b/brightray/common/content_client.cc @@ -22,19 +22,23 @@ ContentClient::~ContentClient() { std::string ContentClient::GetProduct() const { auto name = GetApplicationName(); RemoveChars(name, kWhitespaceASCII, &name); - return base::StringPrintf("%s/%s", name.c_str(), GetApplicationVersion().c_str()); + return base::StringPrintf("%s/%s", + name.c_str(), GetApplicationVersion().c_str()); } std::string ContentClient::GetUserAgent() const { return webkit_glue::BuildUserAgentFromProduct(GetProduct()); } -base::StringPiece ContentClient::GetDataResource(int resource_id, ui::ScaleFactor scale_factor) const { - return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(resource_id, scale_factor); +base::StringPiece ContentClient::GetDataResource( + int resource_id, ui::ScaleFactor scale_factor) const { + return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( + resource_id, scale_factor); } gfx::Image& ContentClient::GetNativeImageNamed(int resource_id) const { - return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); + return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( + resource_id); } -} +} // namespace brightray diff --git a/brightray/common/content_client.h b/brightray/common/content_client.h index 8a93771018e..11ad7e0aea2 100644 --- a/brightray/common/content_client.h +++ b/brightray/common/content_client.h @@ -11,19 +11,20 @@ namespace brightray { class ContentClient : public content::ContentClient { -public: + public: ContentClient(); ~ContentClient(); -private: + private: virtual std::string GetProduct() const OVERRIDE; virtual std::string GetUserAgent() const OVERRIDE; - virtual base::StringPiece GetDataResource(int resource_id, ui::ScaleFactor) const OVERRIDE; + virtual base::StringPiece GetDataResource(int resource_id, + ui::ScaleFactor) const OVERRIDE; virtual gfx::Image& GetNativeImageNamed(int resource_id) const OVERRIDE; DISALLOW_COPY_AND_ASSIGN(ContentClient); }; -} +} // namespace brightray #endif diff --git a/brightray/common/mac/foundation_util.h b/brightray/common/mac/foundation_util.h index 509c635b04f..3b7e6a66a95 100644 --- a/brightray/common/mac/foundation_util.h +++ b/brightray/common/mac/foundation_util.h @@ -6,8 +6,8 @@ #import -// base/mac/foundation_util.h contains an incompatible declaration of NSSearchPathDirectory, -// so here we #define it to be something else. +// base/mac/foundation_util.h contains an incompatible declaration of +// NSSearchPathDirectory, so here we #define it to be something else. #define NSSearchPathDirectory NSSearchPathDirectory___PRE_10_8 #import "base/mac/foundation_util.h" #undef NSSearchPathDirectory diff --git a/brightray/common/mac/main_application_bundle.h b/brightray/common/mac/main_application_bundle.h index 61f19adadd7..78e6bc200b4 100644 --- a/brightray/common/mac/main_application_bundle.h +++ b/brightray/common/mac/main_application_bundle.h @@ -9,12 +9,13 @@ class FilePath; namespace brightray { -// The "main" application bundle is the outermost bundle for this logical application. E.g., if you -// have MyApp.app and MyApp.app/Contents/Frameworks/MyApp Helper.app, the main application bundle is -// MyApp.app, no matter which executable is currently running. +// The "main" application bundle is the outermost bundle for this logical +// application. E.g., if you have MyApp.app and +// MyApp.app/Contents/Frameworks/MyApp Helper.app, the main application bundle +// is MyApp.app, no matter which executable is currently running. NSBundle* MainApplicationBundle(); base::FilePath MainApplicationBundlePath(); -} +} // namespace brightray #endif diff --git a/brightray/common/main_delegate.cc b/brightray/common/main_delegate.cc index b58b2e9d72f..4c903149d09 100644 --- a/brightray/common/main_delegate.cc +++ b/brightray/common/main_delegate.cc @@ -53,8 +53,10 @@ void MainDelegate::InitializeResourceBundle() { std::vector pak_paths; AddPakPaths(&pak_paths); - for (auto it = pak_paths.begin(), end = pak_paths.end(); it != end; ++it) - ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(*it, ui::SCALE_FACTOR_NONE); + for (auto it = pak_paths.begin(), end = pak_paths.end(); it != end; ++it) { + ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( + *it, ui::SCALE_FACTOR_NONE); + } } -} +} // namespace brightray diff --git a/brightray/common/main_delegate.h b/brightray/common/main_delegate.h index ba99f5155f0..e1d033312c9 100644 --- a/brightray/common/main_delegate.h +++ b/brightray/common/main_delegate.h @@ -5,10 +5,11 @@ #ifndef BRIGHTRAY_COMMON_MAIN_DELEGATE_H_ #define BRIGHTRAY_COMMON_MAIN_DELEGATE_H_ +#include + #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" #include "content/public/app/content_main_delegate.h" -#include namespace base { class FilePath; @@ -19,21 +20,23 @@ namespace brightray { class ContentClient; class MainDelegate : public content::ContentMainDelegate { -public: + public: MainDelegate(); ~MainDelegate(); -protected: - // Subclasses can override this to provide their own ContentClient implementation. + protected: + // Subclasses can override this to provide their own ContentClient + // implementation. virtual scoped_ptr CreateContentClient(); - // Subclasses can override this to provide additional .pak files to be included in the ui::ResourceBundle. + // Subclasses can override this to provide additional .pak files to be + // included in the ui::ResourceBundle. virtual void AddPakPaths(std::vector* pak_paths) {} virtual bool BasicStartupComplete(int* exit_code) OVERRIDE; virtual void PreSandboxStartup() OVERRIDE; -private: + private: void InitializeResourceBundle(); #if defined(OS_MACOSX) static base::FilePath GetResourcesPakFilePath(); @@ -47,5 +50,5 @@ private: DISALLOW_COPY_AND_ASSIGN(MainDelegate); }; -} +} // namespace brightray #endif diff --git a/brightray/script/cibuild b/brightray/script/cibuild index 318331ffb3b..bfe1ec92b80 100755 --- a/brightray/script/cibuild +++ b/brightray/script/cibuild @@ -18,7 +18,8 @@ def main(): url = 'https://{0}.s3.amazonaws.com/libchromiumcontent'.format(os.environ['JANKY_ARTIFACTS_S3_BUCKET']) return (run_script('bootstrap', url) or - run_script('build')) + run_script('build') or + run_script('cpplint')) def copy_to_environment(credentials_file): diff --git a/brightray/script/cpplint b/brightray/script/cpplint new file mode 100755 index 00000000000..69b7aaff9a0 --- /dev/null +++ b/brightray/script/cpplint @@ -0,0 +1,47 @@ +#!/usr/bin/env python + +import fnmatch +import os +import subprocess +import sys + + +SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) +CPPLINT = os.path.join(SOURCE_ROOT, 'vendor', 'google-styleguide', 'trunk', 'cpplint', 'cpplint.py') + +IGNORED_FILES = [ + os.path.join('browser', 'mac', 'bry_inspectable_web_contents_view_private.h'), +] + +FILTERS = [ + '-build/header_guard', + '-build/include_what_you_use', + '-legal/copyright', + # cpplint doesn't like the BOOL& parameters that ui::WindowImpl uses. + '-runtime/references', +] + + +def main(): + os.chdir(SOURCE_ROOT) + files = list_files(['browser', 'common'], + ['*.cc', '*.h']) + return cpplint(set(files) - set(IGNORED_FILES)) + + +def list_files(directories, filters): + matches = [] + for directory in directories: + for root, _, filenames, in os.walk(directory): + for f in filters: + for filename in fnmatch.filter(filenames, f): + matches.append(os.path.join(root, filename)) + return matches + + +def cpplint(files): + return subprocess.call([sys.executable, CPPLINT, '--filter=' + ','.join(FILTERS)] + list(files)) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/brightray/vendor/google-styleguide b/brightray/vendor/google-styleguide new file mode 160000 index 00000000000..8025f5495c0 --- /dev/null +++ b/brightray/vendor/google-styleguide @@ -0,0 +1 @@ +Subproject commit 8025f5495c04f1cf9e0d65a0aaa97b58c304faf7